diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-08-17 09:37:27 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-08-17 09:37:27 +0200 |
commit | 00d7406fe26bbcbad2945a0b4e3666dd991daac4 (patch) | |
tree | d25d86d49d7b1ed4de036865630ebb8123085b0c /src/sha256.c | |
parent | f12681b09b381e6a61926c3af2b81842b6f0396d (diff) | |
download | fastd-00d7406fe26bbcbad2945a0b4e3666dd991daac4.tar fastd-00d7406fe26bbcbad2945a0b4e3666dd991daac4.zip |
Slightly improve the SHA256 API
Diffstat (limited to 'src/sha256.c')
-rw-r--r-- | src/sha256.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/sha256.c b/src/sha256.c index 4722272..61faae7 100644 --- a/src/sha256.c +++ b/src/sha256.c @@ -133,7 +133,7 @@ static void sha256_blocks_va(uint32_t out[FASTD_SHA256_HASH_WORDS], const uint32 out[i] = htonl(h[i]); } -static void hmacsha256_blocks_va(uint32_t out[FASTD_SHA256_HASH_WORDS], const uint32_t key[FASTD_HMACSHA256_KEY_WORDS], va_list ap) { +static void hmacsha256_blocks_va(fastd_sha256_t *out, const uint32_t key[FASTD_HMACSHA256_KEY_WORDS], va_list ap) { static const uint32_t ipad2[8] = { 0x36363636, 0x36363636, @@ -170,17 +170,17 @@ static void hmacsha256_blocks_va(uint32_t out[FASTD_SHA256_HASH_WORDS], const ui } -void fastd_sha256_blocks(uint32_t out[FASTD_SHA256_HASH_WORDS], ...) { +void fastd_sha256_blocks(fastd_sha256_t *out, ...) { va_list ap; va_start(ap, out); const uint32_t *in1 = va_arg(ap, const uint32_t*); const uint32_t *in2 = in1 ? va_arg(ap, const uint32_t*) : NULL; - sha256_blocks_va(out, in1, in2, ap); + sha256_blocks_va(out->w, in1, in2, ap); va_end(ap); } -void fastd_hmacsha256_blocks(uint32_t out[FASTD_SHA256_HASH_WORDS], const uint32_t key[FASTD_HMACSHA256_KEY_WORDS], ...) { +void fastd_hmacsha256_blocks(fastd_sha256_t *out, const uint32_t key[FASTD_HMACSHA256_KEY_WORDS], ...) { va_list ap; va_start(ap, key); @@ -190,11 +190,11 @@ void fastd_hmacsha256_blocks(uint32_t out[FASTD_SHA256_HASH_WORDS], const uint32 bool fastd_hmacsha256_blocks_verify(const uint8_t mac[FASTD_SHA256_HASH_BYTES], const uint32_t key[FASTD_HMACSHA256_KEY_WORDS], ...) { va_list ap; - uint32_t out[8]; + fastd_sha256_t out; va_start(ap, key); - hmacsha256_blocks_va(out, key, ap); + hmacsha256_blocks_va(&out, key, ap); va_end(ap); - return !memcmp(out, mac, sizeof(out)); + return !memcmp(out.b, mac, FASTD_SHA256_HASH_BYTES); } |