let RSA_public_encrypt() do the PKCS1 padding

noteworthy is that it will do pkcs1 type 2 padding
This commit is contained in:
Klas Lindfors
2015-05-19 15:11:30 +02:00
parent 3d0ff7b969
commit 18e057e58c
+2 -3
View File
@@ -1542,8 +1542,7 @@ static bool test_decipher(ykpiv_state *state, enum enum_slot slot,
goto decipher_out; goto decipher_out;
} }
RSA_padding_add_PKCS1_type_1(data, RSA_size(rsa), secret, sizeof(secret)); len = RSA_public_encrypt(sizeof(secret), secret, data, rsa, RSA_PKCS1_PADDING);
len = RSA_public_encrypt(RSA_size(rsa), data, data, rsa, RSA_NO_PADDING);
if(len < 0) { if(len < 0) {
fprintf(stderr, "Failed performing RSA encryption!\n"); fprintf(stderr, "Failed performing RSA encryption!\n");
goto decipher_out; goto decipher_out;
@@ -1553,7 +1552,7 @@ static bool test_decipher(ykpiv_state *state, enum enum_slot slot,
goto decipher_out; goto decipher_out;
} }
/* for some reason we have to give the padding check function data + 1 */ /* for some reason we have to give the padding check function data + 1 */
len = RSA_padding_check_PKCS1_type_1(secret2, sizeof(secret2), data + 1, len2 - 1, RSA_size(rsa)); len = RSA_padding_check_PKCS1_type_2(secret2, sizeof(secret2), data + 1, len2 - 1, RSA_size(rsa));
if(len == sizeof(secret)) { if(len == sizeof(secret)) {
if(verbose) { if(verbose) {
fprintf(stderr, "Generated nonce: "); fprintf(stderr, "Generated nonce: ");