diff options
author | Rob Austein <sra@hactrn.net> | 2022-01-02 11:32:32 -0500 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2022-01-02 11:32:32 -0500 |
commit | f8c3655b7af461555b89f7394c396b7ed7a267ee (patch) | |
tree | bacfaa3cc995eb42751750f07a896e37020a3b69 /tests | |
parent | 12f20b6cc82c45943880e35e9ac2a3709271f189 (diff) |
New release -> new compiler -> new error
gcc 10 whines about forward references to enums.
gcc 10 correctly dings zero length array variables as illegal.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-rpc_hash.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/tests/test-rpc_hash.c b/tests/test-rpc_hash.c index 51fa2be..047d8c3 100644 --- a/tests/test-rpc_hash.c +++ b/tests/test-rpc_hash.c @@ -45,7 +45,8 @@ /* Usual NIST sample messages. */ /* "" */ -static const uint8_t nist_512_empty[] = { /* 0 bytes */ +static const uint8_t nist_empty[] = { /* 0 bytes */ + 0x00 /* except that's not allowed in ISO C */ }; static const uint8_t sha1_empty_digest[] = { /* 20 bytes */ @@ -95,10 +96,6 @@ static const uint8_t sha256_double_digest[] = { /* 32 bytes */ 0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1 }; -/* "" */ -static const uint8_t nist_1024_empty[] = { /* 0 bytes */ -}; - static const uint8_t sha384_empty_digest[] = { /* 48 bytes */ 0x38, 0xb0, 0x60, 0xa7, 0x51, 0xac, 0x96, 0x38, 0x4c, 0xd9, 0x32, 0x7e, 0xb1, 0xb1, 0xe3, 0x6a, 0x21, 0xfd, 0xb7, 0x11, 0x14, 0xbe, 0x07, 0x43, @@ -770,17 +767,20 @@ static int _test_hmac(const hal_digest_algorithm_t alg, #define test_hmac(_alg_, _key_, _data_, _result_, _label_) \ _test_hmac(_alg_, _key_, sizeof(_key_), _data_, sizeof(_data_), _result_, sizeof(_result_), _label_) +#define test_hash_empty(_alg_, _result_, _label_) \ + _test_hash(_alg_, nist_empty, 0, _result_, sizeof(_result_), _label_) + int main (int argc, char *argv[]) { int ok = 1; ok &= hal_rpc_client_init(); - ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA1, nist_512_empty, sha1_empty_digest, "SHA-1 empty block"); + ok &= test_hash_empty(HAL_DIGEST_ALGORITHM_SHA1, sha1_empty_digest, "SHA-1 empty block"); ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA1, nist_512_single, sha1_single_digest, "SHA-1 single block"); ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA1, nist_512_double, sha1_double_digest, "SHA-1 double block"); - ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA256, nist_512_empty, sha256_empty_digest, "SHA-256 empty block"); + ok &= test_hash_empty(HAL_DIGEST_ALGORITHM_SHA256, sha256_empty_digest, "SHA-256 empty block"); ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA256, nist_512_single, sha256_single_digest, "SHA-256 single block"); ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA256, nist_512_double, sha256_double_digest, "SHA-256 double block"); @@ -790,27 +790,27 @@ int main (int argc, char *argv[]) ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA512_256, nist_1024_single, sha512_256_single_digest, "SHA-512/256 single block"); ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA512_256, nist_1024_double, sha512_256_double_digest, "SHA-512/256 double block"); - ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA384, nist_1024_empty, sha384_empty_digest, "SHA-384 empty block"); + ok &= test_hash_empty(HAL_DIGEST_ALGORITHM_SHA384, sha384_empty_digest, "SHA-384 empty block"); ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA384, nist_1024_single, sha384_single_digest, "SHA-384 single block"); ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA384, nist_1024_double, sha384_double_digest, "SHA-384 double block"); - ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA512, nist_1024_empty, sha512_empty_digest, "SHA-512 empty block"); + ok &= test_hash_empty(HAL_DIGEST_ALGORITHM_SHA512, sha512_empty_digest, "SHA-512 empty block"); ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA512, nist_1024_single, sha512_single_digest, "SHA-512 single block"); ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA512, nist_1024_double, sha512_double_digest, "SHA-512 double block"); - ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA3_224, nist_1024_empty, sha3_224_empty_digest, "SHA3-224 empty block"); + ok &= test_hash_empty(HAL_DIGEST_ALGORITHM_SHA3_224, sha3_224_empty_digest, "SHA3-224 empty block"); ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA3_224, nist_1024_single, sha3_224_single_digest, "SHA3-224 single block"); ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA3_224, nist_1024_double, sha3_224_double_digest, "SHA3-224 double block"); - ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA3_256, nist_1024_empty, sha3_256_empty_digest, "SHA3-256 empty block"); + ok &= test_hash_empty(HAL_DIGEST_ALGORITHM_SHA3_256, sha3_256_empty_digest, "SHA3-256 empty block"); ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA3_256, nist_1024_single, sha3_256_single_digest, "SHA3-256 single block"); ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA3_256, nist_1024_double, sha3_256_double_digest, "SHA3-256 double block"); - ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA3_384, nist_1024_empty, sha3_384_empty_digest, "SHA3-384 empty block"); + ok &= test_hash_empty(HAL_DIGEST_ALGORITHM_SHA3_384, sha3_384_empty_digest, "SHA3-384 empty block"); ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA3_384, nist_1024_single, sha3_384_single_digest, "SHA3-384 single block"); ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA3_384, nist_1024_double, sha3_384_double_digest, "SHA3-384 double block"); - ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA3_512, nist_1024_empty, sha3_512_empty_digest, "SHA3-512 empty block"); + ok &= test_hash_empty(HAL_DIGEST_ALGORITHM_SHA3_512, sha3_512_empty_digest, "SHA3-512 empty block"); ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA3_512, nist_1024_single, sha3_512_single_digest, "SHA3-512 single block"); ok &= test_hash(HAL_DIGEST_ALGORITHM_SHA3_512, nist_1024_double, sha3_512_double_digest, "SHA3-512 double block"); |