hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 91771bc19c3d9321798a7a69e5bd67917bcb15de
parent aa4f4639ed06a02574aae5ebe6a116db9ee0fb94
Author: Armin Preiml <apreiml@strohwolke.at>
Date:   Tue, 11 Jan 2022 15:42:39 +0100

crytpo::poly1305: pass key by reference

Signed-off-by: Armin Preiml <apreiml@strohwolke.at>

Diffstat:
Mcrypto/poly1305/+test.ha | 8++++----
Mcrypto/poly1305/poly1305.ha | 4++--
2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/crypto/poly1305/+test.ha b/crypto/poly1305/+test.ha @@ -21,7 +21,7 @@ use encoding::hex; let result: [16]u8 = [0...]; let p = poly1305(); - init(&p, key); + init(&p, &key); mac::write(&p, message); mac::sum(&p, result); mac::finish(&p); @@ -46,7 +46,7 @@ use encoding::hex; let result: [16]u8 = [0...]; let p = poly1305(); - init(&p, key); + init(&p, &key); mac::sum(&p, result); mac::finish(&p); @@ -77,7 +77,7 @@ use encoding::hex; let result: [16]u8 = [0...]; let p = poly1305(); - init(&p, key); + init(&p, &key); mac::write(&p, message); mac::sum(&p, result); mac::finish(&p); @@ -112,7 +112,7 @@ use encoding::hex; let result: [16]u8 = [0...]; let p = poly1305(); - init(&p, key); + init(&p, &key); mac::write(&p, message); mac::sum(&p, result); mac::finish(&p); diff --git a/crypto/poly1305/poly1305.ha b/crypto/poly1305/poly1305.ha @@ -3,7 +3,6 @@ use bytes; use crypto::mac; use endian; -use encoding::hex; use io; // Internal block size in bytes. @@ -12,6 +11,7 @@ export def BLOCKSIZE: size = 16; // Length of the resulting MAC in bytes. export def SIZE: size = 16; +// Poly1305 key. export type key = [32]u8; export type state = struct { @@ -38,7 +38,7 @@ export fn poly1305() state = { }; // Initialises the MAC with given one time key. -export fn init(p: *state, key: key) void = { +export fn init(p: *state, key: *key) void = { leputu32slice(p.r, key); leputu32slice(p.pad, key[16..]);