Quote:
Originally Posted by manojb
seems you have to write some other method that accepts this key as input and then return the encrypted code... I don't think we have any pre-compiled code for this purpose!
|
thanks for the reply manoj, i will try i am using this method for encryption here can u tell me where i can explictily add the key
my code is as follow:
this is the encryption method where the parameters are plaintext and cipther text
OSStatus status = noErr;
size_t plainBufferSize = strle(char *plainBuffer);
size_t cipherBufferSize = CIPHER_BUFFER_SIZE;
// Error handling
// Encrypt using the public.
status = SecKeyEncrypt([self getPublicKeyRef],
PADDING,
plainBuffer,
plainBufferSize,
&cipherBuffer[0],
&cipherBufferSize
);
}
- (SecKeyRef)getPublicKeyRef {
OSStatus resultCode = noErr;
SecKeyRef publicKeyReference = NULL;
if(publicKey == NULL) {
NSMutableDictionary * queryPublicKey = [[NSMutableDictionary alloc] init];
// Set the public key query dictionary.
[queryPublicKey setObject (id)kSecClassKey forKey

id)kSecClass];
[queryPublicKey setObject publicTag forKey

id)kSecAttrApplicationTag];
[queryPublicKey setObject (id)kSecAttrKeyTypeRSA forKey

id)kSecAttrKeyType];
[queryPublicKey setObject [NSNumber numberWithBool:YES] forKey

id)kSecReturnRef];
// Get the key.
resultCode = SecItemCopyMatching((CFDictionaryRef)queryPublicKe y, (CFTypeRef *)&publicKeyReference);
if(resultCode != noErr)
{
publicKeyReference = NULL;
}
[queryPublicKey release];
} else {
publicKeyReference = publicKey;
}
return publicKeyReference;
}