Add PK test for forbidden operations
This commit is contained in:
parent
67d4583835
commit
75c7882de3
@ -46,6 +46,10 @@ EC(DSA) sign-verify
|
||||
depends_on:POLARSSL_ECDSA_C:POLARSSL_ECP_DP_SECP192R1_ENABLED
|
||||
pk_sign_verify:POLARSSL_PK_ECKEY:0:0
|
||||
|
||||
EC_DH (no) sign-verify
|
||||
depends_on:POLARSSL_ECP_C:POLARSSL_ECP_DP_SECP192R1_ENABLED
|
||||
pk_sign_verify:POLARSSL_PK_ECKEY_DH:POLARSSL_ERR_PK_TYPE_MISMATCH:POLARSSL_ERR_PK_TYPE_MISMATCH
|
||||
|
||||
RSA sign-verify
|
||||
depends_on:POLARSSL_RSA_C
|
||||
pk_sign_verify:POLARSSL_PK_RSA:0:0
|
||||
@ -58,3 +62,15 @@ pk_rsa_decrypt_test_vec:"a42eda41e56235e666e7faaa77100197f657288a1bf183e4820f0c3
|
||||
|
||||
RSA decrypt test vector #2
|
||||
pk_rsa_decrypt_test_vec:"a42eda41e56235e666e7faaa77100197f657288a1bf183e4820f0c37ce2c456b960278d6003e0bbcd4be4a969f8e8fd9231e1f492414f00ed09844994c86ec32db7cde3bec7f0c3dbf6ae55baeb2712fa609f5fc3207a824eb3dace31849cd6a6084318523912bccb84cf42e3c6d6d1685131d69bb545acec827d2b0dfdd5568b7dcc4f5a11d6916583fefa689d367f8c9e1d95dcd2240895a9470b0c1730f97cd6e8546860bd254801769f54be96e16362ddcbf34d56035028890199e0f48db38642cb66a4181e028a6443a404feb284ce02b4614b683367d40874e505611d23142d49f06feea831d52d347b13610b413c4efc43a6de9f0b08d2a951dc503b6":2048:16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"4E636AF98E40F3ADCFCCB698F4E80B9F":POLARSSL_ERR_RSA_INVALID_PADDING
|
||||
|
||||
EC nocrypt
|
||||
depends_on:POLARSSL_ECP_C
|
||||
pk_ec_nocrypt:POLARSSL_PK_ECKEY
|
||||
|
||||
EC-DH nocrypt
|
||||
depends_on:POLARSSL_ECP_C
|
||||
pk_ec_nocrypt:POLARSSL_PK_ECKEY_DH
|
||||
|
||||
ECDSA nocrypt
|
||||
depends_on:POLARSSL_ECDSA_C
|
||||
pk_ec_nocrypt:POLARSSL_PK_ECDSA
|
||||
|
@ -250,3 +250,33 @@ void pk_rsa_decrypt_test_vec( char *cipher_hex, int mod,
|
||||
pk_free( &pk );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void pk_ec_nocrypt( int type )
|
||||
{
|
||||
pk_context pk;
|
||||
unsigned char output[100];
|
||||
unsigned char input[100];
|
||||
rnd_pseudo_info rnd_info;
|
||||
size_t olen = 0;
|
||||
int ret = POLARSSL_ERR_PK_TYPE_MISMATCH;
|
||||
|
||||
pk_init( &pk );
|
||||
|
||||
memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) );
|
||||
memset( output, 0, sizeof( output ) );
|
||||
memset( input, 0, sizeof( input ) );
|
||||
|
||||
TEST_ASSERT( pk_init_ctx( &pk, pk_info_from_type( type ) ) == 0 );
|
||||
|
||||
TEST_ASSERT( pk_encrypt( &pk, input, sizeof( input ),
|
||||
output, &olen, sizeof( output ),
|
||||
rnd_pseudo_rand, &rnd_info ) == ret );
|
||||
|
||||
TEST_ASSERT( pk_decrypt( &pk, input, sizeof( input ),
|
||||
output, &olen, sizeof( output ),
|
||||
rnd_pseudo_rand, &rnd_info ) == ret );
|
||||
|
||||
pk_free( &pk );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
Loading…
Reference in New Issue
Block a user