Using SecKeyEncrypt/SecKeyDecrypt
Was anybody successfull in using those methods of the security framework for iphone?
Im getting a status error code -9809 and I have no clue of what it means as it is not defined in the list of OSStatus
+ (NSString *) encrypt:(NSString *)data
{
uint8_t *plainText = (unsigned char *)[data UTF8String];
size_t BLOCKSIZE = sizeof(plainText);
uint8_t cipherText[BLOCKSIZE];
size_t *cipherTextLen = &BLOCKSIZE;
OSStatus status = SecKeyEncrypt(publickey, kSecPaddingNone, plainText, BLOCKSIZE, cipherText, cipherTextLen);
if(status != errSecSuccess)
{
NSAssert1(0, @"Error: failed to encrypt data '%d'.", status);
}
return [[NSString alloc] initWithUTF8String:(char *)cipherText];
}
Im getting a status error code -9809 and I have no clue of what it means as it is not defined in the list of OSStatus
+ (NSString *) encrypt:(NSString *)data
{
uint8_t *plainText = (unsigned char *)[data UTF8String];
size_t BLOCKSIZE = sizeof(plainText);
uint8_t cipherText[BLOCKSIZE];
size_t *cipherTextLen = &BLOCKSIZE;
OSStatus status = SecKeyEncrypt(publickey, kSecPaddingNone, plainText, BLOCKSIZE, cipherText, cipherTextLen);
if(status != errSecSuccess)
{
NSAssert1(0, @"Error: failed to encrypt data '%d'.", status);
}
return [[NSString alloc] initWithUTF8String:(char *)cipherText];
}
Mac OS X (10.5.3)