According the discussion on http://forums.macrumors.com/showthread.php?t=551476 the code seen below would do for RSA encryption. The datatype of the key ("public") is SecKeyRef. I will not be using the keychain, though, as I'm only interested in encryption where the key is public and is no secret. Is it even possible to use the crypto API then? My current idea is to construct a SecKeyRef struct from my public key only and use the API. I don't know how the struct is declared, though. Does anyone know? Do you think my approach will work?
uint8_t *pPlainText = (uint8_t*) "This is a test";
uint8_t aCipherText[1024];
size_t iCipherLength = 1024;
status = SecKeyEncrypt(public,
kSecPaddingNone,
pPlainText,
strlen((char*) pPlainText ) + 1,
aCipherText,
&iCipherLength);