unsigned int ciphertxt_len;
unsigned char *ciphertxt = NULL;
const unsigned char plaintxt[16] = {0};
- unsigned char decoded[256];
+ unsigned char *decoded = NULL;
unsigned int decoded_len;
unsigned int plaintxt_len = (unsigned int)sizeof(plaintxt_len);
int padding = RSA_PKCS1_PADDING;
OSSL_SELF_TEST_DESC_PCT_RSA_PKCS1);
ciphertxt_len = RSA_size(rsa);
- ciphertxt = OPENSSL_zalloc(ciphertxt_len);
+ /*
+ * RSA_private_encrypt() and RSA_private_decrypt() requires the 'to'
+ * parameter to be a maximum of RSA_size() - allocate space for both.
+ */
+ ciphertxt = OPENSSL_zalloc(ciphertxt_len * 2);
if (ciphertxt == NULL)
goto err;
+ decoded = ciphertxt + ciphertxt_len;
ciphertxt_len = RSA_public_encrypt(plaintxt_len, plaintxt, ciphertxt, rsa,
padding);
my $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0);
plan tests =>
- ($no_fips ? 0 : 1) # Extra FIPS related test
+ ($no_fips ? 0 : 2) # Extra FIPS related test
+ 13;
# We want to know that an absurdly small number of bits isn't support
'-pkeyopt', 'bits:2080',
'-out', 'genrsatest2080.pem'])),
"Generating RSA key with > 2048 bits and < 3072 bits");
+ ok(run(app(['openssl', 'genpkey',
+ @prov,
+ '-algorithm', 'RSA',
+ '-pkeyopt', 'bits:3072',
+ '-out', 'genrsatest3072.pem'])),
+ "Generating RSA key with 3072 bits");
}