mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2026-01-06 14:38:57 +01:00
Add PK test for forbidden operations
This commit is contained in:
parent
67d4583835
commit
75c7882de3
2 changed files with 46 additions and 0 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue