1.1 --- a/MYSymmetricKey-iPhone.m Sun Apr 19 21:19:35 2009 -0700
1.2 +++ b/MYSymmetricKey-iPhone.m Tue Jun 09 23:58:03 2009 -0700
1.3 @@ -43,27 +43,27 @@
1.4 Assert(algorithm <= kCCAlgorithmRC4);
1.5 Assert(keyData);
1.6 NSNumber *keySizeInBits = [NSNumber numberWithUnsignedInt: keyData.length * 8];
1.7 - NSDictionary *keyAttrs = $dict( {(id)kSecClass, (id)kSecClassKey},
1.8 - //{(id)kSecAttrKeyClass, (id)kSecAttrKeyClassSymmetric},
1.9 - {(id)kSecAttrKeyType, [NSNumber numberWithUnsignedInt: kCSSMAlgorithms[algorithm]]},
1.10 - {(id)kSecAttrKeySizeInBits, keySizeInBits},
1.11 - {(id)kSecAttrEffectiveKeySize, keySizeInBits},
1.12 - {(id)kSecAttrIsPermanent, keychain ?$true :$false},
1.13 - {(id)kSecAttrCanEncrypt, $true},
1.14 - {(id)kSecAttrCanDecrypt, $true},
1.15 - {(id)kSecAttrCanWrap, $false},
1.16 - {(id)kSecAttrCanUnwrap, $false},
1.17 - {(id)kSecAttrCanDerive, $false},
1.18 - {(id)kSecAttrCanSign, $false},
1.19 - {(id)kSecAttrCanVerify, $false},
1.20 - {(id)kSecValueData, keyData},
1.21 - {(id)kSecReturnPersistentRef, $true});
1.22 - SecKeyRef keyRef = NULL;
1.23 - if (!check(SecItemAdd((CFDictionaryRef)keyAttrs, (CFTypeRef*)&keyRef), @"SecItemAdd")) {
1.24 + NSNumber *keyType = [NSNumber numberWithUnsignedInt: kCSSMAlgorithms[algorithm]];
1.25 + NSMutableDictionary *keyAttrs = $mdict( {(id)kSecClass, (id)kSecClassKey},
1.26 + {(id)kSecAttrKeyClass, (id)kSecAttrKeyClassSymmetric},
1.27 + {(id)kSecAttrKeyType, keyType},
1.28 + {(id)kSecValueData, keyData},
1.29 + {(id)kSecAttrKeySizeInBits, keySizeInBits},
1.30 + {(id)kSecAttrEffectiveKeySize, keySizeInBits},
1.31 + {(id)kSecAttrIsPermanent, keychain ?$true :$false},
1.32 + {(id)kSecAttrCanEncrypt, $true},
1.33 + {(id)kSecAttrCanDecrypt, $true},
1.34 + {(id)kSecAttrCanWrap, $false},
1.35 + {(id)kSecAttrCanUnwrap, $false},
1.36 + {(id)kSecAttrCanDerive, $false},
1.37 + {(id)kSecAttrCanSign, $false},
1.38 + {(id)kSecAttrCanVerify, $false},
1.39 + {(id)kSecReturnPersistentRef, $true});
1.40 + SecKeyRef keyRef = [[self class] _addKeyWithInfo: keyAttrs];
1.41 + if (!keyRef) {
1.42 [self release];
1.43 return nil;
1.44 }
1.45 - Assert(keyRef, @"SecItemAdd didn't return anything");
1.46 self = [self initWithKeyRef: keyRef];
1.47 CFRelease(keyRef);
1.48 return self;
1.49 @@ -93,7 +93,7 @@
1.50 }
1.51
1.52
1.53 -- (SecExternalItemType) keyType {
1.54 +- (SecExternalItemType) keyClass {
1.55 return kSecAttrKeyClassSymmetric;
1.56 }
1.57