Add hmac_drbg_{write,update}_seed_file()
This commit is contained in:
parent
fef0f8f55a
commit
48bc3e81da
7 changed files with 157 additions and 0 deletions
1
tests/.gitignore
vendored
1
tests/.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
/test_suite*
|
||||
data_files/mpi_write
|
||||
data_files/hmac_drbg_seed
|
||||
|
|
|
@ -63,6 +63,7 @@ add_test_suite(gcm gcm.aes128_de)
|
|||
add_test_suite(gcm gcm.aes192_de)
|
||||
add_test_suite(gcm gcm.aes256_de)
|
||||
add_test_suite(gcm gcm.camellia)
|
||||
add_test_suite(hmac_drbg hmac_drbg.misc)
|
||||
add_test_suite(hmac_drbg hmac_drbg.no_reseed)
|
||||
add_test_suite(hmac_shax)
|
||||
add_test_suite(md)
|
||||
|
|
|
@ -44,6 +44,7 @@ APPS = test_suite_aes.ecb test_suite_aes.cbc \
|
|||
test_suite_gcm.aes192_en \
|
||||
test_suite_gcm.aes256_en \
|
||||
test_suite_gcm.camellia test_suite_hmac_shax \
|
||||
test_suite_hmac_drbg.misc \
|
||||
test_suite_hmac_drbg.no_reseed \
|
||||
test_suite_md test_suite_mdx \
|
||||
test_suite_mpi test_suite_pbkdf2 \
|
||||
|
@ -134,6 +135,10 @@ test_suite_gcm.camellia.c : suites/test_suite_gcm.function suites/test_suite_gcm
|
|||
echo " Generate $@"
|
||||
scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.camellia
|
||||
|
||||
test_suite_hmac_drbg.misc.c : suites/test_suite_hmac_drbg.function suites/test_suite_hmac_drbg.misc.data scripts/generate_code.pl suites/helpers.function suites/main_test.function
|
||||
echo " Generate $@"
|
||||
scripts/generate_code.pl suites test_suite_hmac_drbg test_suite_hmac_drbg.misc
|
||||
|
||||
test_suite_hmac_drbg.no_reseed.c : suites/test_suite_hmac_drbg.function suites/test_suite_hmac_drbg.no_reseed.data scripts/generate_code.pl suites/helpers.function suites/main_test.function
|
||||
echo " Generate $@"
|
||||
scripts/generate_code.pl suites test_suite_hmac_drbg test_suite_hmac_drbg.no_reseed
|
||||
|
@ -262,6 +267,10 @@ test_suite_gcm.camellia: test_suite_gcm.camellia.c ../library/libpolarssl.a
|
|||
echo " CC $@.c"
|
||||
$(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
|
||||
|
||||
test_suite_hmac_drbg.misc: test_suite_hmac_drbg.misc.c ../library/libpolarssl.a
|
||||
echo " CC $@.c"
|
||||
$(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
|
||||
|
||||
test_suite_hmac_drbg.no_reseed: test_suite_hmac_drbg.no_reseed.c ../library/libpolarssl.a
|
||||
echo " CC $@.c"
|
||||
$(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
|
||||
|
|
|
@ -28,6 +28,23 @@ int entropy_func( void *data, unsigned char *buf, size_t len )
|
|||
* END_DEPENDENCIES
|
||||
*/
|
||||
|
||||
/* BEGIN_CASE depends_on:POLARSSL_FS_IO */
|
||||
void hmac_drbg_seed_file( int md_alg, char *path, int ret )
|
||||
{
|
||||
const md_info_t *md_info;
|
||||
hmac_drbg_context ctx;
|
||||
|
||||
TEST_ASSERT( ( md_info = md_info_from_type( md_alg ) ) != NULL );
|
||||
TEST_ASSERT( hmac_drbg_init( &ctx, md_info, rnd_std_rand, NULL,
|
||||
NULL, 0 ) == 0 );
|
||||
|
||||
TEST_ASSERT( hmac_drbg_write_seed_file( &ctx, path ) == ret );
|
||||
TEST_ASSERT( hmac_drbg_update_seed_file( &ctx, path ) == ret );
|
||||
|
||||
hmac_drbg_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void hmac_drbg_no_reseed( int md_alg,
|
||||
char *entropy_hex, char *custom_hex,
|
||||
|
|
40
tests/suites/test_suite_hmac_drbg.misc.data
Normal file
40
tests/suites/test_suite_hmac_drbg.misc.data
Normal file
|
@ -0,0 +1,40 @@
|
|||
HMAC_DRBG write/update seed file SHA-1
|
||||
depends_on:POLARSSL_SHA1_C
|
||||
hmac_drbg_seed_file:POLARSSL_MD_SHA1:"data_files/hmac_drbg_seed":0
|
||||
|
||||
HMAC_DRBG write/update seed file SHA-1
|
||||
depends_on:POLARSSL_SHA1_C
|
||||
hmac_drbg_seed_file:POLARSSL_MD_SHA1:"no_such_dir/file":POLARSSL_ERR_HMAC_DRBG_FILE_IO_ERROR
|
||||
|
||||
HMAC_DRBG write/update seed file SHA-224
|
||||
depends_on:POLARSSL_SHA256_C
|
||||
hmac_drbg_seed_file:POLARSSL_MD_SHA224:"data_files/hmac_drbg_seed":0
|
||||
|
||||
HMAC_DRBG write/update seed file SHA-224
|
||||
depends_on:POLARSSL_SHA256_C
|
||||
hmac_drbg_seed_file:POLARSSL_MD_SHA224:"no_such_dir/file":POLARSSL_ERR_HMAC_DRBG_FILE_IO_ERROR
|
||||
|
||||
HMAC_DRBG write/update seed file SHA-256
|
||||
depends_on:POLARSSL_SHA256_C
|
||||
hmac_drbg_seed_file:POLARSSL_MD_SHA256:"data_files/hmac_drbg_seed":0
|
||||
|
||||
HMAC_DRBG write/update seed file SHA-256
|
||||
depends_on:POLARSSL_SHA256_C
|
||||
hmac_drbg_seed_file:POLARSSL_MD_SHA256:"no_such_dir/file":POLARSSL_ERR_HMAC_DRBG_FILE_IO_ERROR
|
||||
|
||||
HMAC_DRBG write/update seed file SHA-384
|
||||
depends_on:POLARSSL_SHA512_C
|
||||
hmac_drbg_seed_file:POLARSSL_MD_SHA384:"data_files/hmac_drbg_seed":0
|
||||
|
||||
HMAC_DRBG write/update seed file SHA-384
|
||||
depends_on:POLARSSL_SHA512_C
|
||||
hmac_drbg_seed_file:POLARSSL_MD_SHA384:"no_such_dir/file":POLARSSL_ERR_HMAC_DRBG_FILE_IO_ERROR
|
||||
|
||||
HMAC_DRBG write/update seed file SHA-512
|
||||
depends_on:POLARSSL_SHA512_C
|
||||
hmac_drbg_seed_file:POLARSSL_MD_SHA512:"data_files/hmac_drbg_seed":0
|
||||
|
||||
HMAC_DRBG write/update seed file SHA-512
|
||||
depends_on:POLARSSL_SHA512_C
|
||||
hmac_drbg_seed_file:POLARSSL_MD_SHA512:"no_such_dir/file":POLARSSL_ERR_HMAC_DRBG_FILE_IO_ERROR
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue