¡@

Home 

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

iphone Programming Glossary: publickey

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

is as follows #import UIKit UIKit.h #import Security Security.h @interface ViewController UIViewController SecKeyRef publicKey SecKeyRef privateKey NSData publicTag NSData privateTag void encryptWithPublicKey uint8_t plainBuffer cipherBuffer uint8_t.. size_t BUFFER_SIZE 64 const size_t CIPHER_BUFFER_SIZE 1024 const uint32_t PADDING kSecPaddingNone static const UInt8 publicKeyIdentifier com.apple.sample.publickey static const UInt8 privateKeyIdentifier com.apple.sample.privatekey @implementation.. @implementation ViewController SecKeyRef getPublicKeyRef OSStatus sanityCheck noErr SecKeyRef publicKeyReference NULL if publicKeyReference NULL self generateKeyPair 512 NSMutableDictionary queryPublicKey NSMutableDictionary..

RSA implementations in Objective C

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

is as follows #import UIKit UIKit.h #import Security Security.h @interface ViewController UIViewController SecKeyRef publicKey SecKeyRef privateKey NSData publicTag NSData privateTag void encryptWithPublicKey uint8_t plainBuffer cipherBuffer uint8_t.. size_t BUFFER_SIZE 64 const size_t CIPHER_BUFFER_SIZE 1024 const uint32_t PADDING kSecPaddingNone static const UInt8 publicKeyIdentifier com.apple.sample.publickey static const UInt8 privateKeyIdentifier com.apple.sample.privatekey @implementation.. @implementation ViewController SecKeyRef getPublicKeyRef OSStatus sanityCheck noErr SecKeyRef publicKeyReference NULL if publicKeyReference NULL self generateKeyPair 512 NSMutableDictionary queryPublicKey NSMutableDictionary..

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... OSStatus status noErr NSMutableDictionary privateKeyAttr NSMutableDictionary alloc init NSMutableDictionary publicKeyAttr NSMutableDictionary alloc init NSMutableDictionary keyPairAttr NSMutableDictionary alloc init NSData publicTag publicIdentifier.. NSUTF8StringEncoding NSData privateTag privateIdentifier dataUsingEncoding NSUTF8StringEncoding SecKeyRef publicKey NULL SecKeyRef privateKey NULL keyPairAttr setObject __bridge id kSecAttrKeyTypeRSA forKey __bridge id kSecAttrKeyType keyPairAttr.. forKey __bridge id kSecAttrIsPermanent privateKeyAttr setObject privateTag forKey __bridge id kSecAttrApplicationTag publicKeyAttr setObject NSNumber numberWithBool YES forKey __bridge id kSecAttrIsPermanent publicKeyAttr setObject publicTag forKey..

send RSA public key to iphone and use it to encrypt

http://stackoverflow.com/questions/4211484/send-rsa-public-key-to-iphone-and-use-it-to-encrypt

cert policy trust SecTrustResultType trustResult if status noErr status SecTrustEvaluate trust trustResult SecKeyRef publicKey SecTrustCopyPublicKey trust const char plain_text plainText UTF8String size_t blockSize SecKeyGetBlockSize publicKey NSMutableData.. publicKey SecTrustCopyPublicKey trust const char plain_text plainText UTF8String size_t blockSize SecKeyGetBlockSize publicKey NSMutableData collectedCipherData NSMutableData data BOOL success YES size_t cipherBufferSize blockSize uint8_t cipherBuffer.. int j for j 0 j blockSize 11 plain_text i j ' 0' j cipherBuffer j plain_text i j int result if result SecKeyEncrypt publicKey kSecPaddingPKCS1 cipherBuffer j cipherBuffer cipherBufferSize errSecSuccess collectedCipherData appendBytes cipherBuffer..