根据http://forums.macrumors.com/showthread.php?t=551476上的讨论,下面看到的代码将用于 RSA 加密。密钥(“public”)的数据类型是 SecKeyRef。不过,我不会使用钥匙串,因为我只对密钥公开且不是秘密的加密感兴趣。那么甚至可以使用加密API吗?我目前的想法是仅从我的公钥构造一个 SecKeyRef 结构并使用 API。不过,我不知道该结构是如何声明的。有人知道吗?你认为我的方法会奏效吗?
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);