]> git.codecow.com Git - Monocypher.git/commitdiff
Make custom hash length requirements more explicit
authorFabio Scotoni <34964387+fscoto@users.noreply.github.com>
Tue, 10 Dec 2019 10:21:39 +0000 (11:21 +0100)
committerFabio Scotoni <34964387+fscoto@users.noreply.github.com>
Tue, 10 Dec 2019 10:21:39 +0000 (11:21 +0100)
Related to 0074dfab1.

Also note that vtable->final must actually write the hash,
not only finalize the context.

doc/man/man3/crypto_sign_init_first_pass_custom_hash.3monocypher
src/monocypher.h

index 438930cb10f14fab99844a3f7bcc4177a8106418..431696c7b46dcbdeedd37d65446993e8a481bcc4 100644 (file)
@@ -62,7 +62,7 @@ typedef struct {
     void (*init  )(void *ctx);
     void (*update)(void *ctx, const uint8_t *message,
                    size_t message_size);
-    void (*final )(void *ctx, uint8_t *hash);
+    void (*final )(void *ctx, uint8_t hash[64]);
     size_t ctx_size;
 } crypto_sign_vtable;
 .Ed
@@ -99,7 +99,9 @@ The fields of
 are:
 .Bl -tag -width Ds
 .It Fa hash
-Function that generates a 64-byte hash for a given message.
+Function that computes a 64-byte hash for a given message
+and writes the computed hash to
+.Fa hash .
 The output length
 .Em must
 be exactly 64 bytes.
@@ -115,7 +117,12 @@ Function that initialises the hash context of an outer signing context.
 Function that updates the hash context of an outer signing context.
 It must be able to handle message sizes of at least 32 bytes.
 .It Fa final
-Function that finalises the hash context of an outer signing context.
+Function that finalises the hash context of an outer signing context
+and writes the computed hash to
+.Fa hash .
+The output length
+.Em must
+be exactly 64 bytes.
 This function should wipe the hash context with
 .Xr crypto_wipe 3monocypher
 if it contains pointers to objects outside the outer signing context.
index e7a690c1fbd9688fb49348b55c05aa71de455437..54fd6f0951e86e00fae8fcf0281e87a863cdd89b 100644 (file)
@@ -17,7 +17,7 @@ typedef struct {
     void (*hash)(uint8_t hash[64], const uint8_t *message, size_t message_size);
     void (*init  )(void *ctx);
     void (*update)(void *ctx, const uint8_t *message, size_t message_size);
-    void (*final )(void *ctx, uint8_t *hash);
+    void (*final )(void *ctx, uint8_t hash[64]);
     size_t ctx_size;
 } crypto_sign_vtable;