[Cryptech-Commits] [sw/libhal] branch master updated: New release -> new compiler -> new error
git at cryptech.is
git at cryptech.is
Sun Jan 2 16:35:11 UTC 2022
This is an automated email from the git hooks/post-receive script.
sra at hactrn.net pushed a commit to branch master
in repository sw/libhal.
The following commit(s) were added to refs/heads/master by this push:
new f8c3655 New release -> new compiler -> new error
f8c3655 is described below
commit f8c3655b7af461555b89f7394c396b7ed7a267ee
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Sun Jan 2 11:32:32 2022 -0500
New release -> new compiler -> new error
gcc 10 whines about forward references to enums.
gcc 10 correctly dings zero length array variables as illegal.
---
hal.h | 44 ++++++++++++++++++++++++--------------------
tests/test-rpc_hash.c | 26 +++++++++++++-------------
2 files changed, 37 insertions(+), 33 deletions(-)
diff --git a/hal.h b/hal.h
index 7adfd39..84d9c0c 100644
--- a/hal.h
+++ b/hal.h
@@ -703,6 +703,30 @@ extern hal_error_t hal_ecdsa_verify(hal_core_t *core,
const uint8_t * const hash, const size_t hash_len,
const uint8_t * const signature, const size_t signature_len);
+/*
+ * Enums for hash-based signatures, to avoid forward reference problem.
+ * Rest of hash-based signature declarations should be here too, but
+ * at the moment we're trying for minimal change needed to deal with
+ * a new pedantic warning.
+ */
+
+typedef enum hal_lmots_algorithm_type {
+ HAL_LMOTS_RESERVED = 0,
+ HAL_LMOTS_SHA256_N32_W1 = 1,
+ HAL_LMOTS_SHA256_N32_W2 = 2,
+ HAL_LMOTS_SHA256_N32_W4 = 3,
+ HAL_LMOTS_SHA256_N32_W8 = 4
+} hal_lmots_algorithm_t;
+
+typedef enum hal_lms_algorithm_type {
+ HAL_LMS_RESERVED = 0,
+ HAL_LMS_SHA256_N32_H5 = 5,
+ HAL_LMS_SHA256_N32_H10 = 6,
+ HAL_LMS_SHA256_N32_H15 = 7,
+ HAL_LMS_SHA256_N32_H20 = 8,
+ HAL_LMS_SHA256_N32_H25 = 9
+} hal_lms_algorithm_t;
+
/*
* UUID stuff. All UUIDs we use (or are likely to use) are type 4 "random" UUIDs
*/
@@ -899,9 +923,6 @@ extern hal_error_t hal_rpc_pkey_generate_ec(const hal_client_handle_t client,
const hal_curve_name_t curve,
const hal_key_flags_t flags);
-typedef enum hal_lmots_algorithm_type hal_lmots_algorithm_t;
-typedef enum hal_lms_algorithm_type hal_lms_algorithm_t;
-
extern hal_error_t hal_rpc_pkey_generate_hashsig(const hal_client_handle_t client,
const hal_session_handle_t session,
hal_pkey_handle_t *pkey,
@@ -995,23 +1016,6 @@ extern hal_error_t hal_rpc_server_dispatch(const uint8_t * const ibuf, const siz
* references to hal_key_flags_t and hal_uuid_t.
*/
-enum hal_lmots_algorithm_type {
- HAL_LMOTS_RESERVED = 0,
- HAL_LMOTS_SHA256_N32_W1 = 1,
- HAL_LMOTS_SHA256_N32_W2 = 2,
- HAL_LMOTS_SHA256_N32_W4 = 3,
- HAL_LMOTS_SHA256_N32_W8 = 4
-};
-
-enum hal_lms_algorithm_type {
- HAL_LMS_RESERVED = 0,
- HAL_LMS_SHA256_N32_H5 = 5,
- HAL_LMS_SHA256_N32_H10 = 6,
- HAL_LMS_SHA256_N32_H15 = 7,
- HAL_LMS_SHA256_N32_H20 = 8,
- HAL_LMS_SHA256_N32_H25 = 9
-};
-
typedef struct hal_hashsig_key hal_hashsig_key_t;
extern const size_t hal_hashsig_key_t_size;
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");
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Commits
mailing list