]> git.codecow.com Git - Monocypher.git/commitdiff
Fixed crypto_sha512 (and HMAC) prototypes
authorLoup Vaillant <loup@loup-vaillant.fr>
Wed, 4 Dec 2019 18:18:06 +0000 (19:18 +0100)
committerLoup Vaillant <loup@loup-vaillant.fr>
Wed, 4 Dec 2019 18:19:48 +0000 (19:19 +0100)
The output hash (and MAC) has a fixed size: 64 bytes.

src/optional/ed25519.c
src/optional/ed25519.h

index dd9a5cdae554f5f725e7b2f70c69920cd839a3b9..78ef5f38e9c0053a506df64645b705efa57f3dfe 100644 (file)
@@ -209,7 +209,7 @@ void crypto_sha512_final(crypto_sha512_ctx *ctx, u8 hash[64])
     WIPE_CTX(ctx);
 }
 
-void crypto_sha512(u8 *hash, const u8 *message, size_t message_size)
+void crypto_sha512(u8 hash[64], const u8 *message, size_t message_size)
 {
     crypto_sha512_ctx ctx;
     crypto_sha512_init  (&ctx);
@@ -281,7 +281,7 @@ void crypto_hmac_final(crypto_hmac_ctx *ctx, u8 hmac[64])
     WIPE_CTX(ctx);
 }
 
-void crypto_hmac(u8 *hmac, const u8 *key, size_t key_size,
+void crypto_hmac(u8 hmac[64], const u8 *key, size_t key_size,
                  const u8 *message, size_t message_size)
 {
     crypto_hmac_ctx ctx;
index 32cb5c4e3f8621c3ccaaa9cbd128b437712680f0..259b7e929e9f3c4c87cac5741b651862951e67c3 100644 (file)
@@ -35,7 +35,7 @@ void crypto_sha512_init  (crypto_sha512_ctx *ctx);
 void crypto_sha512_update(crypto_sha512_ctx *ctx,
                           const uint8_t *message, size_t  message_size);
 void crypto_sha512_final (crypto_sha512_ctx *ctx, uint8_t hash[64]);
-void crypto_sha512(uint8_t *hash, const uint8_t *message, size_t message_size);
+void crypto_sha512(uint8_t hash[64], const uint8_t *message, size_t message_size);
 
 // vtable for signatures
 extern const crypto_sign_vtable crypto_sha512_vtable;
@@ -48,7 +48,7 @@ void crypto_hmac_init(crypto_hmac_ctx *ctx,
 void crypto_hmac_update(crypto_hmac_ctx *ctx,
                         const uint8_t *message, size_t  message_size);
 void crypto_hmac_final(crypto_hmac_ctx *ctx, uint8_t hmac[64]);
-void crypto_hmac(uint8_t *hmac,
+void crypto_hmac(uint8_t hmac[64],
                  const uint8_t *key    , size_t key_size,
                  const uint8_t *message, size_t message_size);