Header comments in QCCRSASmallCryptor(T) are incorrect.

Originator:armadsen
Number:rdar://23063476 Date Originated:11-Oct-2015 11:58 AM
Status:Open Resolved:
Product:Sample Code Product Version:CryptoCompatibility Version 1.0
Classification:Other Bug Reproducible:Always
 
In the headers for QCCRSASmallCryptor and QCCRSASmallCryptorT, there are comments on the init methods as follows:

- (id)initToEncryptSmallInputData:(NSData *)smallInputData key:(SecKeyRef)key;      // must be the *private* key
- (id)initToDecryptSmallInputData:(NSData *)smallInputData key:(SecKeyRef)key;      // must be the *public*  key

Best I can tell, these comments are reversed. In fact, initToEncrypt: requires the *public* key and initToDecrypt: requires the *private* key. At least, an encryption operation fails when trying to use a private key for encryption with CSSMERR_CSP_INVALID_KEY_CLASS.

Incidentally, I’m trying to use a public key for decryption, which OpenSSL supports using its RSA_public_decrypt() function. Filed rdar://23063471 for that.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!