Thank you Martin. I have tried using the function, however using the
code I have pasted below I get the error "Error = oaep decoding error"
when trying to unpadd to retrieve the original data.
For simplicity the code I have added here does not encrypt/decrypt, but
only attempts to pad and unpadd.
What could be the cause of this problem here?
------------------------------------------------------
ERR_load_RSA_strings();
int status;
const int RSA_LENGTH = 256;
const int LABEL_LENGTH = 10;
const int PADDED_DATA_LENGTH = 256;
const int ORIGINAL_DATA_LENGTH = 16;
unsigned char paddedData[PADDED_DATA_LENGTH];
unsigned char unPaddedData[ORIGINAL_DATA_LENGTH];
unsigned char originalData[ORIGINAL_DATA_LENGTH] =
{ 0x4C, 0x2E, 0x20, 0x4C, 0x65, 0x74, 0x27, 0x73,
0x20, 0x68, 0x6F, 0x70, 0x65, 0x0D, 0x0A, 0x00 };
unsigned char label[LABEL_LENGTH] =
{ 0xB8, 0x37, 0xA4, 0x26, 0xA8,
0xBF, 0x8A, 0xA0, 0xBE, 0xEB };
status = RSA_padding_add_PKCS1_OAEP
( paddedData, PADDED_DATA_LENGTH,
originalData, ORIGINAL_DATA_LENGTH,
label, LABEL_LENGTH );
status = RSA_padding_check_PKCS1_OAEP
( unPaddedData, ORIGINAL_DATA_LENGTH,
paddedData, PADDED_DATA_LENGTH,
RSA_LENGTH, label, LABEL_LENGTH );
if ( status == -1 ) {
std::cout << "Unpadding failed! ";
printf("Error = %s\n",ERR_reason_error_string(ERR_get_error()));
}
else {
std::cout << "Unpadding was OK! Lenght of the recovered data: "
<< status << std::endl;
}
------------------------------------------------------
Thank for all help so far :)
- Einar
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [email protected]
Automated List Manager [email protected]