Re: Naming for names in struct nettle_hash

2024-03-28 Thread Niels Möller
Niels Möller  writes:

> Hi, I've got a bug report that sha512_224 and sha512_256 are missing in
> the list returned by nettle_get_hashes, and I'm about to add them.
>
> But then there's a question of naming convention. Currently, the 
>
>   extern const struct nettle_hash nettle_sha512_256;
>
> includes a name field set to the string "sha512-256", which is somewhat
> inconsistent with, e.g., the struct nettle_sha3_256 which includes the
> name "sha3_256".
>
> Should I just change this (patch below)?

I've decided to changing those names to use underscore.

Regards,
/Niels

-- 
Niels Möller. PGP key CB4962D070D77D7FCB8BA36271D8F1FF368C6677.
Internet email is subject to wholesale government surveillance.
___
nettle-bugs mailing list -- nettle-bugs@lists.lysator.liu.se
To unsubscribe send an email to nettle-bugs-le...@lists.lysator.liu.se


Naming for names in struct nettle_hash

2024-03-13 Thread Niels Möller
Hi, I've got a bug report that sha512_224 and sha512_256 are missing in
the list returned by nettle_get_hashes, and I'm about to add them.

But then there's a question of naming convention. Currently, the 

  extern const struct nettle_hash nettle_sha512_256;

includes a name field set to the string "sha512-256", which is somewhat
inconsistent with, e.g., the struct nettle_sha3_256 which includes the
name "sha3_256".

Should I just change this (patch below)? Honestly, I haven't given much
thought to the conventions used here, but perhaps it makes the most
sense that naming match the names of corresponding C symbols (with
underscore rather than dash)?

Regards,
/Niels

diff --git a/nettle-meta-hashes.c b/nettle-meta-hashes.c
index 4d421182..2245dfb7 100644
--- a/nettle-meta-hashes.c
+++ b/nettle-meta-hashes.c
@@ -49,6 +49,8 @@ const struct nettle_hash * const _nettle_hashes[] = {
   &nettle_sha256,
   &nettle_sha384,
   &nettle_sha512,
+  &nettle_sha512_224,
+  &nettle_sha512_256,
   &nettle_sha3_224,
   &nettle_sha3_256,
   &nettle_sha3_384,
diff --git a/sha512-224-meta.c b/sha512-224-meta.c
index 24c42bfc..f3751e14 100644
--- a/sha512-224-meta.c
+++ b/sha512-224-meta.c
@@ -39,7 +39,7 @@
 
 const struct nettle_hash nettle_sha512_224 =
   {
-"sha512-224", sizeof(struct sha512_ctx),
+"sha512_224", sizeof(struct sha512_ctx),
 SHA512_224_DIGEST_SIZE,
 SHA512_224_BLOCK_SIZE,
 (nettle_hash_init_func *) sha512_224_init,
diff --git a/sha512-256-meta.c b/sha512-256-meta.c
index 37d17c35..181f2874 100644
--- a/sha512-256-meta.c
+++ b/sha512-256-meta.c
@@ -39,7 +39,7 @@
 
 const struct nettle_hash nettle_sha512_256 =
   {
-"sha512-256", sizeof(struct sha512_ctx),
+"sha512_256", sizeof(struct sha512_ctx),
 SHA512_256_DIGEST_SIZE,
 SHA512_256_BLOCK_SIZE,
 (nettle_hash_init_func *) sha512_256_init,
diff --git a/testsuite/meta-hash-test.c b/testsuite/meta-hash-test.c
index 6a15e7db..ec4e0d1e 100644
--- a/testsuite/meta-hash-test.c
+++ b/testsuite/meta-hash-test.c
@@ -16,6 +16,8 @@ const char* hashes[] = {
   "sha256",
   "sha384",
   "sha512",
+  "sha512_224",
+  "sha512_256",
   "sha3_224",
   "sha3_256",
   "sha3_384",


-- 
Niels Möller. PGP key CB4962D070D77D7FCB8BA36271D8F1FF368C6677.
Internet email is subject to wholesale government surveillance.

___
nettle-bugs mailing list -- nettle-bugs@lists.lysator.liu.se
To unsubscribe send an email to nettle-bugs-le...@lists.lysator.liu.se