Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have a library that lets you create the binary data to import RSA keys in modulus and exponent now:</p> <p><a href="https://github.com/StCredZero/SCZ-BasicEncodingRules-iOS" rel="nofollow">https://github.com/StCredZero/SCZ-BasicEncodingRules-iOS</a></p> <h1>SCZ-BasicEncodingRules-iOS</h1> <p>Implementation of Basic Encoding Rules to enable import of RSA keys to iOS KeyChain using exponent. Code targets iOS 5 with ARC. </p> <p>Let's say you already have a modulus and exponent from an RSA public key as an NSData in variables named pubKeyModData and pubKeyExpData. Then the following code will create an NSData containing that RSA public key, which you can then insert into the iOS or OS X Keychain.</p> <pre><code>NSMutableArray *testArray = [[NSMutableArray alloc] init]; [testArray addObject:pubKeyModData]; [testArray addObject:pubKeyExpData]; NSData *testPubKey = [testArray berData]; </code></pre> <p>This would allow you to store the key using the addPeerPublicKey:keyBits: method from SecKeyWrapper in the Apple CryptoExercise example. Or, from the perspective of the low-level API, you can use SecItemAdd().</p> <pre><code>NSString * peerName = @"Test Public Key"; NSData * peerTag = [[NSData alloc] initWithBytes:(const void *)[peerName UTF8String] length:[peerName length]]; NSMutableDictionary * peerPublicKeyAttr = [[NSMutableDictionary alloc] init]; [peerPublicKeyAttr setObject:(__bridge id)kSecClassKey forKey:(__bridge id)kSecClass]; [peerPublicKeyAttr setObject:(__bridge id)kSecAttrKeyTypeRSA forKey:(__bridge id)kSecAttrKeyType]; [peerPublicKeyAttr setObject:peerTag forKey:(__bridge id)kSecAttrApplicationTag]; [peerPublicKeyAttr setObject:testPubKey forKey:(__bridge id)kSecValueData]; [peerPublicKeyAttr setObject:[NSNumber numberWithBool:YES] forKey:(__bridge id)kSecReturnPersistentRef]; sanityCheck = SecItemAdd((__bridge CFDictionaryRef) peerPublicKeyAttr, (CFTypeRef *)&amp;persistPeer); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload