From 9fa62b38a4434139b9937f0be930698b565db383 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 10 Apr 2014 21:14:04 -0700 Subject: [PATCH] Move crypto_hash_sha256_state to the crypto_hash_sha256.h header file --- .../crypto_auth/hmacsha256/cp/hmac_hmacsha256.c | 6 ------ .../crypto_hash/sha256/cp/hash_sha256.c | 6 ------ .../scryptxsalsa208sha256/sha256.h | 17 +++++++---------- .../include/sodium/crypto_hash_sha256.h | 9 +++++++++ 4 files changed, 16 insertions(+), 22 deletions(-) diff --git a/src/libsodium/crypto_auth/hmacsha256/cp/hmac_hmacsha256.c b/src/libsodium/crypto_auth/hmacsha256/cp/hmac_hmacsha256.c index b0ce9275..ffe29850 100644 --- a/src/libsodium/crypto_auth/hmacsha256/cp/hmac_hmacsha256.c +++ b/src/libsodium/crypto_auth/hmacsha256/cp/hmac_hmacsha256.c @@ -38,12 +38,6 @@ #include #include -typedef struct crypto_hash_sha256_state { - uint32_t state[8]; - uint32_t count[2]; - unsigned char buf[64]; -} crypto_hash_sha256_state; - typedef struct crypto_hmac_sha256_state { crypto_hash_sha256_state ictx; crypto_hash_sha256_state octx; diff --git a/src/libsodium/crypto_hash/sha256/cp/hash_sha256.c b/src/libsodium/crypto_hash/sha256/cp/hash_sha256.c index d484605b..9deabcf5 100644 --- a/src/libsodium/crypto_hash/sha256/cp/hash_sha256.c +++ b/src/libsodium/crypto_hash/sha256/cp/hash_sha256.c @@ -37,12 +37,6 @@ #include #include -typedef struct crypto_hash_sha256_state { - uint32_t state[8]; - uint32_t count[2]; - unsigned char buf[64]; -} crypto_hash_sha256_state; - void _SHA256_Init(crypto_hash_sha256_state *); void _SHA256_Update(crypto_hash_sha256_state *, const void *, size_t); void _SHA256_Final(unsigned char [32], crypto_hash_sha256_state *); diff --git a/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/sha256.h b/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/sha256.h index 37da7e20..57b9fd33 100644 --- a/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/sha256.h +++ b/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/sha256.h @@ -33,20 +33,17 @@ #include -typedef struct SHA256Context { - uint32_t state[8]; - uint32_t count[2]; - unsigned char buf[64]; -} SHA256_CTX; +#include "crypto_hash_sha256.h" typedef struct HMAC_SHA256Context { - SHA256_CTX ictx; - SHA256_CTX octx; + crypto_hash_sha256_state ictx; + crypto_hash_sha256_state octx; } HMAC_SHA256_CTX; -void _SHA256_Init(SHA256_CTX *); -void _SHA256_Update(SHA256_CTX *, const void *, size_t); -void _SHA256_Final(unsigned char [32], SHA256_CTX *); +void _SHA256_Init(crypto_hash_sha256_state *); +void _SHA256_Update(crypto_hash_sha256_state *, const void *, size_t); +void _SHA256_Final(unsigned char [32], crypto_hash_sha256_state *); + void HMAC__SHA256_Init(HMAC_SHA256_CTX *, const void *, size_t); void HMAC__SHA256_Update(HMAC_SHA256_CTX *, const void *, size_t); void HMAC__SHA256_Final(unsigned char [32], HMAC_SHA256_CTX *); diff --git a/src/libsodium/include/sodium/crypto_hash_sha256.h b/src/libsodium/include/sodium/crypto_hash_sha256.h index 0594a097..04669f95 100644 --- a/src/libsodium/include/sodium/crypto_hash_sha256.h +++ b/src/libsodium/include/sodium/crypto_hash_sha256.h @@ -2,6 +2,9 @@ #define crypto_hash_sha256_H #include +#include +#include + #include "export.h" #define crypto_hash_sha256_BYTES 32U @@ -14,6 +17,12 @@ extern "C" { #endif +typedef struct crypto_hash_sha256_state { + uint32_t state[8]; + uint32_t count[2]; + unsigned char buf[64]; +} crypto_hash_sha256_state; + SODIUM_EXPORT size_t crypto_hash_sha256_bytes(void);