The following code results in status = 0
in the iOS4.3 SDK on iOS4.3:
size_t mySize, cypherSize; mySize = (secKeyGetBlockSize() - 11); // Code that reads in mySize bytes into buffer and // sets cipherSize to secKeyGetBlockSize(). // [...] status = SecKeyEncrypt(myPublicKey, kSecPaddingPKCS1, myBuffer, mySize, myBuffer, &cipherSize);
It turns out that setKeyGetBlockSize()
is 256
and therefore mySize = 245
. cypherSize
always 256
after returning from SecKeyEncrypt
.
In the iOS5 SDK running on iOS5, the same code is higher in status = -50
! After some experimentation, I found that mySize = 244
(one lower than before!) Works again. I checked the SecKeyEncrypt
documentation on iOS5.0 and it didn't change - so the size didn't change either.
What is the reason for this difference?
source share