Cleaned up IosRSAKeyPairGenerator native code to improve readability.
Change on 2017/07/11 by tball
@@ -38,24 +38,25 @@ public class IosRSAKeyPairGenerator extends KeyPairGeneratorSpi {
@Override
public native KeyPair generateKeyPair() /*-[
// Requested keypair attributes.
+ NSMutableDictionary * keyPairAttr = [[NSMutableDictionary alloc] init];
+ NSMutableDictionary *publicKeyAttr = [[NSMutableDictionary alloc] init];
NSMutableDictionary * privateKeyAttr = [[NSMutableDictionary alloc] init];
- [privateKeyAttr setObject:[NSNumber numberWithBool:true] forKey:(id)kSecAttrIsPermanent];
- NSData *privateTag = [ComGoogleJ2objcSecurityIosRSAKey_get_PRIVATE_KEY_TAG()
- dataUsingEncoding:NSUTF8StringEncoding];
- [privateKeyAttr setObject:privateTag forKey:(id)kSecAttrApplicationTag];
- NSMutableDictionary * publicKeyAttr = [[NSMutableDictionary alloc] init];
- [publicKeyAttr setObject:[NSNumber numberWithBool:true] forKey:(id)kSecAttrIsPermanent];
NSData *publicTag = [ComGoogleJ2objcSecurityIosRSAKey_get_PUBLIC_KEY_TAG()
dataUsingEncoding:NSUTF8StringEncoding];
[publicKeyAttr setObject:publicTag forKey:(id)kSecAttrApplicationTag];
+ [publicKeyAttr setObject:@YES forKey:(id)kSecAttrIsPermanent];
+
+ NSData *privateTag = [ComGoogleJ2objcSecurityIosRSAKey_get_PRIVATE_KEY_TAG()
+ dataUsingEncoding:NSUTF8StringEncoding];
+ [privateKeyAttr setObject:privateTag forKey:(id)kSecAttrApplicationTag];
+ [privateKeyAttr setObject:@YES forKey:(id)kSecAttrIsPermanent];
- NSMutableDictionary * keyPairAttr = [[NSMutableDictionary alloc] init];
[keyPairAttr setObject:(id)kSecAttrKeyTypeRSA forKey:(id)kSecAttrKeyType];
[keyPairAttr setObject:[NSNumber numberWithUnsignedInteger:keySize_]
forKey:(id)kSecAttrKeySizeInBits];
- [keyPairAttr setObject:privateKeyAttr forKey:@"private"];
- [keyPairAttr setObject:publicKeyAttr forKey:@"public"];
+ [keyPairAttr setObject:privateKeyAttr forKey:(id)kSecPrivateKeyAttrs];
+ [keyPairAttr setObject:publicKeyAttr forKey:(id)kSecPublicKeyAttrs];
SecKeyRef publicKeyRef = NULL;
SecKeyRef privateKeyRef = NULL;
