From: Loup Vaillant Date: Sat, 28 Mar 2020 11:29:03 +0000 (+0100) Subject: More accurate code examples for Blake2b MAC X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=a33e2c31bf5c0e2dabb6756885cb2c7fb0c3a6bf;p=Monocypher.git More accurate code examples for Blake2b MAC --- diff --git a/doc/man/man3/crypto_blake2b.3monocypher b/doc/man/man3/crypto_blake2b.3monocypher index 78ae03c..5ff809f 100644 --- a/doc/man/man3/crypto_blake2b.3monocypher +++ b/doc/man/man3/crypto_blake2b.3monocypher @@ -232,11 +232,11 @@ crypto_blake2b(hash, message, 12); .Pp Computing a message authentication code all at once: .Bd -literal -offset indent -uint8_t hash [64]; /* Output hash (between 1 and 64 bytes) */ -uint8_t key [32]; /* Key (between 0 and 64 bytes) */ +uint8_t hash [16]; +uint8_t key [32]; uint8_t message[11] = "Lorem ipsu"; /* Message to authenticate */ arc4random_buf(key, 32); -crypto_blake2b_general(hash, 64, key, 32, message, 11); +crypto_blake2b_general(hash, 16, key, 32, message, 11); /* Wipe secrets if they are no longer needed */ crypto_wipe(message, 11); crypto_wipe(key, 32); @@ -256,12 +256,12 @@ crypto_blake2b_final(&ctx, hash); .Pp Computing a message authentication code incrementally: .Bd -literal -offset indent -uint8_t hash [ 64]; /* Output hash (between 1 and 64 bytes) */ -uint8_t key [ 32]; /* Key (between 0 and 64 bytes) */ +uint8_t hash [ 16]; +uint8_t key [ 32]; uint8_t message[500] = {1}; /* Message to authenticate */ crypto_blake2b_ctx ctx; arc4random_buf(key, 32); -crypto_blake2b_general_init(&ctx, 64, key, 32); +crypto_blake2b_general_init(&ctx, 16, key, 32); /* Wipe the key */ crypto_wipe(key, 32); for (size_t i = 0; i < 500; i += 100) {