1.1 --- a/MYKey.m Sat Apr 04 20:42:03 2009 -0700
1.2 +++ b/MYKey.m Sat Apr 04 22:56:13 2009 -0700
1.3 @@ -19,11 +19,7 @@
1.4
1.5
1.6 - (id) initWithKeyRef: (SecKeyRef)key {
1.7 - self = [super initWithKeychainItemRef: (SecKeychainItemRef)key];
1.8 - if (self) {
1.9 - _key = key; // superclass has already CFRetained it
1.10 - }
1.11 - return self;
1.12 + return [super initWithKeychainItemRef: (SecKeychainItemRef)key];
1.13 }
1.14
1.15 - (id) _initWithKeyData: (NSData*)data
1.16 @@ -34,10 +30,7 @@
1.17 [self release];
1.18 return nil;
1.19 }
1.20 - self = [super initWithKeychainItemRef: (SecKeychainItemRef)key];
1.21 - if (self) {
1.22 - _key = key;
1.23 - }
1.24 + self = [self initWithKeyRef: key];
1.25 CFRelease(key);
1.26 return self;
1.27 }
1.28 @@ -47,32 +40,24 @@
1.29 }
1.30
1.31
1.32 -- (NSString*) description {
1.33 - return $sprintf(@"%@[%p]", [self class], _key); //FIX: Can we do anything better?
1.34 -}
1.35 -
1.36 -
1.37 - (SecExternalItemType) keyType {
1.38 AssertAbstractMethod();
1.39 }
1.40
1.41
1.42 -@synthesize keyRef=_key;
1.43 -
1.44 -
1.45 -- (MYKey*) asKey {
1.46 - return self;
1.47 +- (SecKeyRef) keyRef {
1.48 + return (SecKeyRef) self.keychainItemRef;
1.49 }
1.50
1.51 - (const CSSM_KEY*) cssmKey {
1.52 const CSSM_KEY *cssmKey = NULL;
1.53 - Assert(check(SecKeyGetCSSMKey(_key, &cssmKey), @"SecKeyGetCSSMKey"), @"Failed to get CSSM_KEY");
1.54 + Assert(check(SecKeyGetCSSMKey(self.keyRef, &cssmKey), @"SecKeyGetCSSMKey"), @"Failed to get CSSM_KEY");
1.55 return cssmKey;
1.56 }
1.57
1.58 - (NSData*) exportKeyInFormat: (SecExternalFormat)format withPEM: (BOOL)withPEM {
1.59 CFDataRef data = NULL;
1.60 - if (check(SecKeychainItemExport(_key, format, (withPEM ?kSecItemPemArmour :0), NULL, &data),
1.61 + if (check(SecKeychainItemExport(self.keyRef, format, (withPEM ?kSecItemPemArmour :0), NULL, &data),
1.62 @"SecKeychainItemExport"))
1.63 return [(id)CFMakeCollectable(data) autorelease];
1.64 else