Fixed iPhone build.
authorsnej@snej.local
Thu Apr 09 22:27:51 2009 -0700 (2009-04-09)
changeset 5b2e360b78189
parent 4 f4709533c816
child 6 2d7692f9b6b4
Fixed iPhone build.
Updated README.
MYCrypto-iPhone.xcodeproj/project.pbxproj
MYCryptoTest.m
MYIdentity.h
MYIdentity.m
MYKeychain-iPhone.m
MYKeychain.h
MYPrivateKey.m
README.textile
     1.1 --- a/MYCrypto-iPhone.xcodeproj/project.pbxproj	Thu Apr 09 21:36:21 2009 -0700
     1.2 +++ b/MYCrypto-iPhone.xcodeproj/project.pbxproj	Thu Apr 09 22:27:51 2009 -0700
     1.3 @@ -11,6 +11,7 @@
     1.4  		1D60589B0D05DD56006BFB54 /* MYCrypto_iPhone_main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* MYCrypto_iPhone_main.m */; };
     1.5  		1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
     1.6  		1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
     1.7 +		27059CF30F8F0F9200A8422F /* MYIdentity.m in Sources */ = {isa = PBXBuildFile; fileRef = 27059CF20F8F0F9200A8422F /* MYIdentity.m */; };
     1.8  		273391CD0F81EC70009414D9 /* MYCertificate-iPhone.m in Sources */ = {isa = PBXBuildFile; fileRef = 273391CC0F81EC70009414D9 /* MYCertificate-iPhone.m */; };
     1.9  		273392120F8283B8009414D9 /* MYKeychain-iPhone.m in Sources */ = {isa = PBXBuildFile; fileRef = 273392110F8283B8009414D9 /* MYKeychain-iPhone.m */; };
    1.10  		2748607F0F8D5E0600FE617B /* MYPrivateKey.m in Sources */ = {isa = PBXBuildFile; fileRef = 2748607E0F8D5E0600FE617B /* MYPrivateKey.m */; };
    1.11 @@ -43,6 +44,8 @@
    1.12  		1D3623250D0F684500981E51 /* MYCrypto_iPhoneAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MYCrypto_iPhoneAppDelegate.m; sourceTree = "<group>"; };
    1.13  		1D6058910D05DD3D006BFB54 /* MYCrypto-iPhone.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "MYCrypto-iPhone.app"; sourceTree = BUILT_PRODUCTS_DIR; };
    1.14  		1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
    1.15 +		27059CF10F8F0F8E00A8422F /* MYIdentity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MYIdentity.h; sourceTree = "<group>"; };
    1.16 +		27059CF20F8F0F9200A8422F /* MYIdentity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MYIdentity.m; sourceTree = "<group>"; };
    1.17  		273391CC0F81EC70009414D9 /* MYCertificate-iPhone.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MYCertificate-iPhone.m"; sourceTree = "<group>"; };
    1.18  		273392110F8283B8009414D9 /* MYKeychain-iPhone.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MYKeychain-iPhone.m"; sourceTree = "<group>"; };
    1.19  		2748607D0F8D5DF200FE617B /* MYPrivateKey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MYPrivateKey.h; sourceTree = "<group>"; };
    1.20 @@ -131,6 +134,8 @@
    1.21  				273391CC0F81EC70009414D9 /* MYCertificate-iPhone.m */,
    1.22  				27E8230E0F81D56E0019BE60 /* MYCryptor.h */,
    1.23  				27E8230F0F81D56E0019BE60 /* MYCryptor.m */,
    1.24 +				27059CF10F8F0F8E00A8422F /* MYIdentity.h */,
    1.25 +				27059CF20F8F0F9200A8422F /* MYIdentity.m */,
    1.26  				27E823100F81D56E0019BE60 /* MYKey.h */,
    1.27  				27E823110F81D56E0019BE60 /* MYKey.m */,
    1.28  				27FE453E0F87CC8500A86D63 /* MYKey-iPhone.m */,
    1.29 @@ -272,6 +277,7 @@
    1.30  				27A430140F87C6D50063D362 /* MYSymmetricKey.m in Sources */,
    1.31  				27FE453F0F87CC8500A86D63 /* MYKey-iPhone.m in Sources */,
    1.32  				2748607F0F8D5E0600FE617B /* MYPrivateKey.m in Sources */,
    1.33 +				27059CF30F8F0F9200A8422F /* MYIdentity.m in Sources */,
    1.34  			);
    1.35  			runOnlyForDeploymentPostprocessing = 0;
    1.36  		};
     2.1 --- a/MYCryptoTest.m	Thu Apr 09 21:36:21 2009 -0700
     2.2 +++ b/MYCryptoTest.m	Thu Apr 09 22:27:51 2009 -0700
     2.3 @@ -80,7 +80,11 @@
     2.4      for (MYIdentity *ident in e) {
     2.5          Log(@"Found %@ -- name=%@, emails=(%@), key=%@",
     2.6              ident, ident.commonName, 
     2.7 +#if TARGET_OS_IPHONE
     2.8 +            nil,
     2.9 +#else
    2.10              [ident.emailAddresses componentsJoinedByString: @", "],
    2.11 +#endif
    2.12              ident.privateKey);
    2.13      }
    2.14  }
     3.1 --- a/MYIdentity.h	Thu Apr 09 21:36:21 2009 -0700
     3.2 +++ b/MYIdentity.h	Thu Apr 09 22:27:51 2009 -0700
     3.3 @@ -23,6 +23,8 @@
     3.4  /** The identity's associated private key. */
     3.5  @property (readonly) MYPrivateKey *privateKey;
     3.6  
     3.7 +#if !TARGET_OS_IPHONE
     3.8 +
     3.9  /** Returns the identity that's been set as the preferred one for the given name, or nil. */
    3.10  + (MYIdentity*) preferredIdentityForName: (NSString*)name;
    3.11  
    3.12 @@ -30,4 +32,6 @@
    3.13      for later lookup using +preferredIdentityForName:. */
    3.14  - (BOOL) makePreferredIdentityForName: (NSString*)name;
    3.15  
    3.16 +#endif
    3.17 +
    3.18  @end
     4.1 --- a/MYIdentity.m	Thu Apr 09 21:36:21 2009 -0700
     4.2 +++ b/MYIdentity.m	Thu Apr 09 22:27:51 2009 -0700
     4.3 @@ -30,6 +30,7 @@
     4.4  }
     4.5  
     4.6  
     4.7 +#if !TARGET_OS_IPHONE
     4.8  - (id) initWithCertificateRef: (SecCertificateRef)certificateRef {
     4.9      self = [super initWithCertificateRef: certificateRef];
    4.10      if (self) {
    4.11 @@ -41,6 +42,7 @@
    4.12      }
    4.13      return self;
    4.14  }
    4.15 +#endif
    4.16  
    4.17  - (void) dealloc
    4.18  {
    4.19 @@ -66,6 +68,8 @@
    4.20  }
    4.21  
    4.22  
    4.23 +#if !TARGET_OS_IPHONE
    4.24 +
    4.25  + (MYIdentity*) preferredIdentityForName: (NSString*)name
    4.26  {
    4.27      Assert(name);
    4.28 @@ -82,4 +86,6 @@
    4.29                   @"SecIdentitySetPreference");
    4.30  }
    4.31  
    4.32 +#endif !TARGET_OS_IPHONE
    4.33 +
    4.34  @end
     5.1 --- a/MYKeychain-iPhone.m	Thu Apr 09 21:36:21 2009 -0700
     5.2 +++ b/MYKeychain-iPhone.m	Thu Apr 09 22:27:51 2009 -0700
     5.3 @@ -8,6 +8,8 @@
     5.4  
     5.5  #import "MYCrypto_Private.h"
     5.6  #import "MYDigest.h"
     5.7 +#import "MYIdentity.h"
     5.8 +
     5.9  
    5.10  #if MYCRYPTO_USE_IPHONE_API
    5.11  
    5.12 @@ -104,6 +106,13 @@
    5.13      return [[[MYKeyEnumerator alloc] initWithQuery: query] autorelease];
    5.14  }
    5.15  
    5.16 +- (NSEnumerator*) enumerateIdentities {
    5.17 +    NSMutableDictionary *query = $mdict({(id)kSecClass, (id)kSecClassIdentity},
    5.18 +                                        {(id)kSecMatchLimit, (id)kSecMatchLimitAll},
    5.19 +                                        {(id)kSecReturnRef, $true});
    5.20 +    return [[[MYKeyEnumerator alloc] initWithQuery: query] autorelease];
    5.21 +}
    5.22 +
    5.23  - (NSEnumerator*) enumerateSymmetricKeys {
    5.24      NSMutableDictionary *query = $mdict({(id)kSecClass, (id)kSecClassKey},
    5.25                                  {(id)kSecAttrKeyClass, (id)kSecAttrKeyClassSymmetric},
    5.26 @@ -161,7 +170,6 @@
    5.27  }
    5.28  
    5.29  
    5.30 -
    5.31  @end
    5.32  
    5.33  
    5.34 @@ -218,6 +226,8 @@
    5.35              next = [[[MYSymmetricKey alloc] initWithKeyRef: (SecKeyRef)found] autorelease];
    5.36          } else if (_itemClass == kSecClassCertificate) {
    5.37              next = [[[MYCertificate alloc] initWithCertificateRef: (SecCertificateRef)found] autorelease];
    5.38 +        } else if (_itemClass == kSecClassIdentity) {
    5.39 +            next = [[[MYIdentity alloc] initWithIdentityRef: (SecIdentityRef)found] autorelease];
    5.40          }
    5.41          CFRelease(found);
    5.42      }
     6.1 --- a/MYKeychain.h	Thu Apr 09 21:36:21 2009 -0700
     6.2 +++ b/MYKeychain.h	Thu Apr 09 22:27:51 2009 -0700
     6.3 @@ -56,9 +56,6 @@
     6.4  
     6.5  #pragma mark CERTIFICATES:
     6.6  
     6.7 -/** Adds a certificate to this keychain. (It must not already belong to a keychain.) */
     6.8 -- (BOOL) addCertificate: (MYCertificate*)certificate;
     6.9 -
    6.10  /** Imports a certificate into the keychain, given its external representation. */
    6.11  - (MYCertificate*) importCertificate: (NSData*)data;
    6.12  
    6.13 @@ -127,6 +124,9 @@
    6.14                         alertTitle: (NSString*)title
    6.15                        alertPrompt: (NSString*)prompt;
    6.16  
    6.17 +/** Adds a certificate to this keychain. (It must not already belong to a keychain.) */
    6.18 +- (BOOL) addCertificate: (MYCertificate*)certificate;
    6.19 +
    6.20  /** Imports a certificate into the keychain, given its external representation. */
    6.21  - (MYCertificate*) importCertificate: (NSData*)data
    6.22                                  type: (CSSM_CERT_TYPE) type
     7.1 --- a/MYPrivateKey.m	Thu Apr 09 21:36:21 2009 -0700
     7.2 +++ b/MYPrivateKey.m	Thu Apr 09 22:27:51 2009 -0700
     7.3 @@ -9,9 +9,11 @@
     7.4  #import "MYPrivateKey.h"
     7.5  #import "MYCrypto_Private.h"
     7.6  #import "MYDigest.h"
     7.7 -#import "MYCertGen.h"
     7.8  #import <CommonCrypto/CommonDigest.h>
     7.9  
    7.10 +#if !TARGET_OS_IPHONE
    7.11 +#import "MYCertGen.h"
    7.12 +#endif
    7.13  
    7.14  @implementation MYPrivateKey
    7.15  
     8.1 --- a/README.textile	Thu Apr 09 21:36:21 2009 -0700
     8.2 +++ b/README.textile	Thu Apr 09 22:27:51 2009 -0700
     8.3 @@ -1,6 +1,6 @@
     8.4  h1=. MYCrypto
     8.5  
     8.6 -p=. Version 0.1 -- 6 April 2009
     8.7 +p=. Version 0.1 -- 9 April 2009
     8.8  
     8.9  p=. By "Jens Alfke":mailto:jens@mooseyard.com <br>
    8.10  Based in part on code by Wade Tregaskis, <br>
    8.11 @@ -16,6 +16,7 @@
    8.12  
    8.13  * Symmmetric cryptography (session keys and password-based encryption)
    8.14  * Asymmetric cryptography (public and private keys; digital signatures)
    8.15 +* Identity certificates (for use with SSL and CMS)
    8.16  * Cryptographic digests/hashes (effectively-unique IDs for data)
    8.17  * The Keychain (a secure, encrypted storage system for keys and passwords)
    8.18  
    8.19 @@ -43,7 +44,6 @@
    8.20  
    8.21  * No API for accessing passwords; fortunately there are several other utility libraries that provide this. And if your code is doing cryptographic operations, it probably needs to store the keys themselves, not passwords.
    8.22  * No bulk data encryption/decryption using public/private keys. MYKeyPair only does raw RSA crypto, which is slow and limited to small chunks of data.
    8.23 -* No creating or signing certificate-requests, or creating self-signed certificates.
    8.24  * No evaluation of trust in certificates (i.e. SecTrust and related APIs.)
    8.25  * Error reporting is too limited. Most methods indicate an error by returning nil, NULL or NO, but don't provide the standard "out" NSError parameter to provide more information. Expect the API to be refactored in the near future to remedy this.
    8.26  
    8.27 @@ -51,18 +51,20 @@
    8.28  
    8.29  The class hierarchy of MYCrypto looks like this:
    8.30  
    8.31 -* "MYKeychainItem":Documentation/html/interfaceMYKeychainItem.html
    8.32 -** "MYKey":Documentation/html/interfaceMYKey.html
    8.33 -*** "*MYSymmetricKey*":Documentation/html/interfaceMYSymmetricKey.html
    8.34 -*** "*MYPublicKey*":Documentation/html/interfaceMYPublicKey.html
    8.35 -*** "*MYPrivateKey*":Documentation/html/interfaceMYPrivateKey.html
    8.36 -*** "*MYCertificate*":Documentation/html/interfaceMYCertificate.html
    8.37 -* "MYDigest":Documentation/html/interfaceMYDigest.html
    8.38 -** "*MYSHA1Digest*":Documentation/html/interfaceMYSHA1Digest.html
    8.39 -** "*MYSHA256Digest*":Documentation/html/interfaceMYSHA256Digest.html
    8.40 +* "_MYKeychain_":Documentation/html/interfaceMYKeychain.html
    8.41 +* "_MYKeychainItem_":Documentation/html/interfaceMYKeychainItem.html
    8.42 +** "_MYKey_":Documentation/html/interfaceMYKey.html
    8.43 +*** "MYSymmetricKey":Documentation/html/interfaceMYSymmetricKey.html
    8.44 +*** "MYPublicKey":Documentation/html/interfaceMYPublicKey.html
    8.45 +*** "MYPrivateKey":Documentation/html/interfaceMYPrivateKey.html
    8.46 +*** "MYCertificate":Documentation/html/interfaceMYCertificate.html
    8.47 +**** "MYIdentity":Documentation/html/interfaceMYIdentity.html
    8.48 +* "_MYDigest_":Documentation/html/interfaceMYDigest.html
    8.49 +** "MYSHA1Digest":Documentation/html/interfaceMYSHA1Digest.html
    8.50 +** "MYSHA256Digest":Documentation/html/interfaceMYSHA256Digest.html
    8.51  * "MYCryptor":Documentation/html/interfaceMYCryptor.html
    8.52  
    8.53 -(*Boldface* classes are concrete, others are abstract.)
    8.54 +(_Italicized_ classes are abstract.)
    8.55  
    8.56  h2. References
    8.57  
    8.58 @@ -72,5 +74,5 @@
    8.59  * "??Common Security: CDSA and CSSM, Version 2??":http://www.opengroup.org/publications/catalog/c914.htm (The Open Group)
    8.60  
    8.61  * "??Practical Cryptography??":http://www.schneier.com/book-practical.html (Ferguson and Schneier)
    8.62 -* "??Handbook of Applied Cryptography":http://www.cacr.math.uwaterloo.ca/hac/ (Menezes, van Oorschot, Vanstone) -- free download!
    8.63 +* "??Handbook of Applied Cryptography??":http://www.cacr.math.uwaterloo.ca/hac/ (Menezes, van Oorschot, Vanstone) -- free download!
    8.64  * "??The Devil's InfoSec Dictionary??":http://www.csoonline.com/article/220527/The_Devil_s_Infosec_Dictionary (CSO Online)
    8.65 \ No newline at end of file