¡@

Home 

2014/10/15 ¤U¤È 10:13:38

iphone Programming Glossary: sanitycheck

Iphone - How to encrypt NSData with public key and decrypt with private key?

http://stackoverflow.com/questions/10072124/iphone-how-to-encrypt-nsdata-with-public-key-and-decrypt-with-private-key

privateKeyIdentifier com.apple.sample.privatekey @implementation ViewController SecKeyRef getPublicKeyRef OSStatus sanityCheck noErr SecKeyRef publicKeyReference NULL if publicKeyReference NULL self generateKeyPair 512 NSMutableDictionary queryPublicKey.. id kSecAttrKeyType queryPublicKey setObject NSNumber numberWithBool YES forKey __bridge id kSecReturnRef Get the key. sanityCheck SecItemCopyMatching __bridge CFDictionaryRef queryPublicKey CFTypeRef publicKeyReference if sanityCheck noErr publicKeyReference.. Get the key. sanityCheck SecItemCopyMatching __bridge CFDictionaryRef queryPublicKey CFTypeRef publicKeyReference if sanityCheck noErr publicKeyReference NULL queryPublicKey release else publicKeyReference publicKey return publicKeyReference void..

RSA implementations in Objective C

http://stackoverflow.com/questions/10222524/rsa-implementations-in-objective-c

privateKeyIdentifier com.apple.sample.privatekey @implementation ViewController SecKeyRef getPublicKeyRef OSStatus sanityCheck noErr SecKeyRef publicKeyReference NULL if publicKeyReference NULL self generateKeyPair 512 NSMutableDictionary queryPublicKey.. id kSecAttrKeyType queryPublicKey setObject NSNumber numberWithBool YES forKey __bridge id kSecReturnRef Get the key. sanityCheck SecItemCopyMatching __bridge CFDictionaryRef queryPublicKey CFTypeRef publicKeyReference if sanityCheck noErr publicKeyReference.. Get the key. sanityCheck SecItemCopyMatching __bridge CFDictionaryRef queryPublicKey CFTypeRef publicKeyReference if sanityCheck noErr publicKeyReference NULL queryPublicKey release else publicKeyReference publicKey return publicKeyReference void..

Extracting a public key from key pair in key chain

http://stackoverflow.com/questions/11467215/extracting-a-public-key-from-key-pair-in-key-chain

key @ privateKey self getPublicKeyBits publicIdentifier NSData getPublicKeyBits NSString publicKeyIdentifier OSStatus sanityCheck noErr NSData publicKeyBits nil CFTypeRef pk NSMutableDictionary queryPublicKey NSMutableDictionary alloc init NSData publicTag.. queryPublicKey setObject NSNumber numberWithBool YES forKey __bridge_transfer id kSecReturnData Get the key bits. sanityCheck SecItemCopyMatching __bridge_retained CFDictionaryRef queryPublicKey pk if sanityCheck noErr publicKeyBits nil publicKeyBits.. Get the key bits. sanityCheck SecItemCopyMatching __bridge_retained CFDictionaryRef queryPublicKey pk if sanityCheck noErr publicKeyBits nil publicKeyBits __bridge_transfer NSData pk NSLog @ public bits @ publicKeyBits return publicKeyBits..

Creating a JSON Store For iPhone

http://stackoverflow.com/questions/5237943/creating-a-json-store-for-iphone

Saving SecKeyRef device generated public/private key pair on disk

http://stackoverflow.com/questions/5988735/saving-seckeyref-device-generated-public-private-key-pair-on-disk

the answer myself you can get the bytes for a public key using SecItemCopyMatching . NSData getPublicKeyBits OSStatus sanityCheck noErr NSData publicKeyBits nil NSMutableDictionary queryPublicKey NSMutableDictionary alloc init Set the public key query.. id kSecAttrKeyType queryPublicKey setObject NSNumber numberWithBool YES forKey id kSecReturnData Get the key bits. sanityCheck SecItemCopyMatching CFDictionaryRef queryPublicKey CFTypeRef publicKeyBits if sanityCheck noErr publicKeyBits nil queryPublicKey.. Get the key bits. sanityCheck SecItemCopyMatching CFDictionaryRef queryPublicKey CFTypeRef publicKeyBits if sanityCheck noErr publicKeyBits nil queryPublicKey release return publicKeyBits The above is from Apple's CryptoExercise. Not sure..