1.1 --- a/MYKeychainItem.m Sat Apr 04 22:56:13 2009 -0700
1.2 +++ b/MYKeychainItem.m Tue Apr 07 10:56:58 2009 -0700
1.3 @@ -37,6 +37,12 @@
1.4 [super dealloc];
1.5 }
1.6
1.7 +- (void) finalize
1.8 +{
1.9 + if (_itemRef) CFRelease(_itemRef);
1.10 + [super finalize];
1.11 +}
1.12 +
1.13 - (id) copyWithZone: (NSZone*)zone {
1.14 // As keys are immutable, it's not necessary to make copies of them. This makes it more efficient
1.15 // to use instances as NSDictionary keys or store them in NSSets.
1.16 @@ -63,7 +69,7 @@
1.17 return $array((id)_itemRef);
1.18 }
1.19
1.20 -#if USE_IPHONE_API
1.21 +#if MYCRYPTO_USE_IPHONE_API
1.22 - (CFDictionaryRef) asQuery {
1.23 return (CFDictionaryRef) $dict( {(id)kSecClass, (id)kSecClassKey},//FIX
1.24 {(id)kSecMatchItemList, self._itemList} );
1.25 @@ -72,7 +78,7 @@
1.26
1.27
1.28 - (MYKeychain*) keychain {
1.29 -#if USE_IPHONE_API
1.30 +#if MYCRYPTO_USE_IPHONE_API
1.31 return [MYKeychain defaultKeychain];
1.32 #else
1.33 MYKeychain *keychain = nil;
1.34 @@ -88,7 +94,7 @@
1.35 }
1.36
1.37 - (BOOL) removeFromKeychain {
1.38 -#if USE_IPHONE_API
1.39 +#if MYCRYPTO_USE_IPHONE_API
1.40 return check(SecItemDelete(self.asQuery), @"SecItemDelete");
1.41 #else
1.42 return check(SecKeychainItemDelete((SecKeychainItemRef)_itemRef), @"SecKeychainItemDelete");
1.43 @@ -102,7 +108,7 @@
1.44
1.45 - (NSData*) _getContents: (OSStatus*)outError {
1.46 NSData *contents = nil;
1.47 -#if USE_IPHONE_API
1.48 +#if MYCRYPTO_USE_IPHONE_API
1.49 #else
1.50 UInt32 length = 0;
1.51 void *bytes = NULL;
1.52 @@ -117,7 +123,7 @@
1.53
1.54 + (NSData*) _getAttribute: (SecKeychainAttrType)attr ofItem: (MYKeychainItemRef)item {
1.55 NSData *value = nil;
1.56 -#if USE_IPHONE_API
1.57 +#if MYCRYPTO_USE_IPHONE_API
1.58 NSDictionary *info = $dict( {(id)kSecClass, (id)kSecClassKey},
1.59 {(id)kSecMatchItemList, $array((id)item)},
1.60 {(id)kSecReturnAttributes, $true} );
1.61 @@ -171,7 +177,7 @@
1.62 + (BOOL) _setAttribute: (SecKeychainAttrType)attr ofItem: (MYKeychainItemRef)item
1.63 stringValue: (NSString*)stringValue
1.64 {
1.65 -#if USE_IPHONE_API
1.66 +#if MYCRYPTO_USE_IPHONE_API
1.67 id value = stringValue ?(id)stringValue :(id)[NSNull null];
1.68 NSDictionary *query = $dict({(id)kSecClass, (id)kSecClassKey},
1.69 {(id)kSecAttrKeyType, (id)attr},
1.70 @@ -200,7 +206,7 @@
1.71
1.72 BOOL check(OSStatus err, NSString *what) {
1.73 if (err) {
1.74 -#if !USE_IPHONE_API
1.75 +#if !MYCRYPTO_USE_IPHONE_API
1.76 if (err < -2000000000)
1.77 return checkcssm(err,what);
1.78 #endif
1.79 @@ -210,7 +216,7 @@
1.80 return YES;
1.81 }
1.82
1.83 -#if !USE_IPHONE_API
1.84 +#if !MYCRYPTO_USE_IPHONE_API
1.85 BOOL checkcssm(CSSM_RETURN err, NSString *what) {
1.86 if (err != CSSM_OK) {
1.87 Warn(@"MYCrypto error, %@: %@", what, MYErrorName(MYCSSMErrorDomain,err));