mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-09-11 04:39:56 +00:00
pk: test buffer too small for RSA-opaque + RSA-alt
A previous commit added tests "normal" PK RSA contexts, but missed opaque RSA keys and RSA_ALT keys. Signed-off-by: Manuel Pégourié-Gonnard <[email protected]>
This commit is contained in:
@@ -1624,6 +1624,12 @@ void pk_wrap_rsa_decrypt_test_vec(data_t *cipher, int mod,
|
||||
if (ret == 0) {
|
||||
TEST_EQUAL(olen, clear->len);
|
||||
TEST_EQUAL(memcmp(output, clear->x, olen), 0);
|
||||
|
||||
/* Try again with an output buffer that's too small */
|
||||
TEST_EQUAL(mbedtls_pk_decrypt(&pk, cipher->x, cipher->len,
|
||||
output, &olen, clear->len - 1,
|
||||
mbedtls_test_rnd_pseudo_rand, &rnd_info),
|
||||
MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE);
|
||||
}
|
||||
|
||||
TEST_EQUAL(PSA_SUCCESS, psa_destroy_key(key_id));
|
||||
@@ -1795,6 +1801,13 @@ void pk_rsa_alt()
|
||||
TEST_ASSERT(test_len == sizeof(msg));
|
||||
TEST_ASSERT(memcmp(test, msg, test_len) == 0);
|
||||
|
||||
|
||||
/* Try again with an output buffer that's too small */
|
||||
TEST_EQUAL(mbedtls_pk_decrypt(&alt, ciph, ciph_len,
|
||||
test, &test_len, sizeof(msg) - 1,
|
||||
mbedtls_test_rnd_std_rand, NULL),
|
||||
MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE);
|
||||
|
||||
/* Test forbidden operations */
|
||||
TEST_ASSERT(mbedtls_pk_encrypt(&alt, msg, sizeof(msg),
|
||||
ciph, &ciph_len, sizeof(ciph),
|
||||
|
||||
Reference in New Issue
Block a user