mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 16:45:41 +01:00
Test SHA-512 parameter validation
This commit is contained in:
parent
b5c99f5c72
commit
686c9a0e8d
@ -95,6 +95,12 @@ SHA-256 Test Vector NIST CAVS #7
|
||||
depends_on:MBEDTLS_SHA256_C
|
||||
mbedtls_sha256:"8390cf0be07661cc7669aac54ce09a37733a629d45f5d983ef201f9b2d13800e555d9b1097fec3b783d7a50dcb5e2b644b96a1e9463f177cf34906bf388f366db5c2deee04a30e283f764a97c3b377a034fefc22c259214faa99babaff160ab0aaa7e2ccb0ce09c6b32fe08cbc474694375aba703fadbfa31cf685b30a11c57f3cf4edd321e57d3ae6ebb1133c8260e75b9224fa47a2bb205249add2e2e62f817491482ae152322be0900355cdcc8d42a98f82e961a0dc6f537b7b410eff105f59673bfb787bf042aa071f7af68d944d27371c64160fe9382772372516c230c1f45c0d6b6cca7f274b394da9402d3eafdf733994ec58ab22d71829a98399574d4b5908a447a5a681cb0dd50a31145311d92c22a16de1ead66a5499f2dceb4cae694772ce90762ef8336afec653aa9b1a1c4820b221136dfce80dce2ba920d88a530c9410d0a4e0358a3a11052e58dd73b0b179ef8f56fe3b5a2d117a73a0c38a1392b6938e9782e0d86456ee4884e3c39d4d75813f13633bc79baa07c0d2d555afbf207f52b7dca126d015aa2b9873b3eb065e90b9b065a5373fe1fb1b20d594327d19fba56cb81e7b6696605ffa56eba3c27a438697cc21b201fd7e09f18deea1b3ea2f0d1edc02df0e20396a145412cd6b13c32d2e605641c948b714aec30c0649dc44143511f35ab0fd5dd64c34d06fe86f3836dfe9edeb7f08cfc3bd40956826356242191f99f53473f32b0cc0cf9321d6c92a112e8db90b86ee9e87cc32d0343db01e32ce9eb782cb24efbbbeb440fe929e8f2bf8dfb1550a3a2e742e8b455a3e5730e9e6a7a9824d17acc0f72a7f67eae0f0970f8bde46dcdefaed3047cf807e7f00a42e5fd11d40f5e98533d7574425b7d2bc3b3845c443008b58980e768e464e17cc6f6b3939eee52f713963d07d8c4abf02448ef0b889c9671e2f8a436ddeeffcca7176e9bf9d1005ecd377f2fa67c23ed1f137e60bf46018a8bd613d038e883704fc26e798969df35ec7bbc6a4fe46d8910bd82fa3cded265d0a3b6d399e4251e4d8233daa21b5812fded6536198ff13aa5a1cd46a5b9a17a4ddc1d9f85544d1d1cc16f3df858038c8e071a11a7e157a85a6a8dc47e88d75e7009a8b26fdb73f33a2a70f1e0c259f8f9533b9b8f9af9288b7274f21baeec78d396f8bacdcc22471207d9b4efccd3fedc5c5a2214ff5e51c553f35e21ae696fe51e8df733a8e06f50f419e599e9f9e4b37ce643fc810faaa47989771509d69a110ac916261427026369a21263ac4460fb4f708f8ae28599856db7cb6a43ac8e03d64a9609807e76c5f312b9d1863bfa304e8953647648b4f4ab0ed995e":"4109cdbec3240ad74cc6c37f39300f70fede16e21efc77f7865998714aad0b5e"
|
||||
|
||||
SHA-512 Invalid parameters
|
||||
sha512_invalid_param:
|
||||
|
||||
SHA-512 Valid parameters
|
||||
sha512_valid_param:
|
||||
|
||||
SHA-384 Test Vector NIST CAVS #1
|
||||
depends_on:MBEDTLS_SHA512_C
|
||||
sha384:"":"38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b"
|
||||
|
@ -46,6 +46,62 @@ void mbedtls_sha256( data_t * src_str, data_t * hex_hash_string )
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_SHA256_C */
|
||||
void sha512_valid_param( )
|
||||
{
|
||||
TEST_VALID_PARAM( mbedtls_sha512_free( NULL ) );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_SHA512_C:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
|
||||
void sha512_invalid_param( )
|
||||
{
|
||||
mbedtls_sha512_context ctx;
|
||||
unsigned char buf[64] = { 0 };
|
||||
size_t const buflen = sizeof( buf );
|
||||
int valid_type = 0;
|
||||
int invalid_type = 42;
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_sha512_init( NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_sha512_clone( NULL, &ctx ) );
|
||||
TEST_INVALID_PARAM( mbedtls_sha512_clone( &ctx, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
|
||||
mbedtls_sha512_starts_ret( NULL, valid_type ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
|
||||
mbedtls_sha512_starts_ret( &ctx, invalid_type ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
|
||||
mbedtls_sha512_update_ret( NULL, buf, buflen ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
|
||||
mbedtls_sha512_update_ret( &ctx, NULL, buflen ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
|
||||
mbedtls_sha512_finish_ret( NULL, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
|
||||
mbedtls_sha512_finish_ret( &ctx, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
|
||||
mbedtls_internal_sha512_process( NULL, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
|
||||
mbedtls_internal_sha512_process( &ctx, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
|
||||
mbedtls_sha512_ret( NULL, buflen,
|
||||
buf, valid_type ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
|
||||
mbedtls_sha512_ret( buf, buflen,
|
||||
NULL, valid_type ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
|
||||
mbedtls_sha512_ret( buf, buflen,
|
||||
buf, invalid_type ) );
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_SHA512_C */
|
||||
void sha384( data_t * src_str, data_t * hex_hash_string )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user