diff options
Diffstat (limited to 'src/lib/hash/sha2_32')
-rw-r--r-- | src/lib/hash/sha2_32/sha2_32.cpp | 50 | ||||
-rw-r--r-- | src/lib/hash/sha2_32/sha2_32.h | 12 |
2 files changed, 31 insertions, 31 deletions
diff --git a/src/lib/hash/sha2_32/sha2_32.cpp b/src/lib/hash/sha2_32/sha2_32.cpp index 46551431c..2a748a6aa 100644 --- a/src/lib/hash/sha2_32/sha2_32.cpp +++ b/src/lib/hash/sha2_32/sha2_32.cpp @@ -17,7 +17,7 @@ namespace SHA2_32 { /* * SHA-256 Rho Function */ -inline u32bit rho(u32bit X, u32bit rot1, u32bit rot2, u32bit rot3) +inline uint32_t rho(uint32_t X, uint32_t rot1, uint32_t rot2, uint32_t rot3) { return (rotate_right(X, rot1) ^ rotate_right(X, rot2) ^ rotate_right(X, rot3)); @@ -26,7 +26,7 @@ inline u32bit rho(u32bit X, u32bit rot1, u32bit rot2, u32bit rot3) /* * SHA-256 Sigma Function */ -inline u32bit sigma(u32bit X, u32bit rot1, u32bit rot2, u32bit shift) +inline uint32_t sigma(uint32_t X, uint32_t rot1, uint32_t rot2, uint32_t shift) { return (rotate_right(X, rot1) ^ rotate_right(X, rot2) ^ (X >> shift)); } @@ -48,31 +48,31 @@ inline u32bit sigma(u32bit X, u32bit rot1, u32bit rot2, u32bit shift) /* * SHA-224 / SHA-256 compression function */ -void compress(secure_vector<u32bit>& digest, - const byte input[], size_t blocks) +void compress(secure_vector<uint32_t>& digest, + const uint8_t input[], size_t blocks) { - u32bit A = digest[0], B = digest[1], C = digest[2], + uint32_t A = digest[0], B = digest[1], C = digest[2], D = digest[3], E = digest[4], F = digest[5], G = digest[6], H = digest[7]; for(size_t i = 0; i != blocks; ++i) { - u32bit W00 = load_be<u32bit>(input, 0); - u32bit W01 = load_be<u32bit>(input, 1); - u32bit W02 = load_be<u32bit>(input, 2); - u32bit W03 = load_be<u32bit>(input, 3); - u32bit W04 = load_be<u32bit>(input, 4); - u32bit W05 = load_be<u32bit>(input, 5); - u32bit W06 = load_be<u32bit>(input, 6); - u32bit W07 = load_be<u32bit>(input, 7); - u32bit W08 = load_be<u32bit>(input, 8); - u32bit W09 = load_be<u32bit>(input, 9); - u32bit W10 = load_be<u32bit>(input, 10); - u32bit W11 = load_be<u32bit>(input, 11); - u32bit W12 = load_be<u32bit>(input, 12); - u32bit W13 = load_be<u32bit>(input, 13); - u32bit W14 = load_be<u32bit>(input, 14); - u32bit W15 = load_be<u32bit>(input, 15); + uint32_t W00 = load_be<uint32_t>(input, 0); + uint32_t W01 = load_be<uint32_t>(input, 1); + uint32_t W02 = load_be<uint32_t>(input, 2); + uint32_t W03 = load_be<uint32_t>(input, 3); + uint32_t W04 = load_be<uint32_t>(input, 4); + uint32_t W05 = load_be<uint32_t>(input, 5); + uint32_t W06 = load_be<uint32_t>(input, 6); + uint32_t W07 = load_be<uint32_t>(input, 7); + uint32_t W08 = load_be<uint32_t>(input, 8); + uint32_t W09 = load_be<uint32_t>(input, 9); + uint32_t W10 = load_be<uint32_t>(input, 10); + uint32_t W11 = load_be<uint32_t>(input, 11); + uint32_t W12 = load_be<uint32_t>(input, 12); + uint32_t W13 = load_be<uint32_t>(input, 13); + uint32_t W14 = load_be<uint32_t>(input, 14); + uint32_t W15 = load_be<uint32_t>(input, 15); SHA2_32_F(A, B, C, D, E, F, G, H, W00, W14, W09, W01, 0x428A2F98); SHA2_32_F(H, A, B, C, D, E, F, G, W01, W15, W10, W02, 0x71374491); @@ -159,7 +159,7 @@ void compress(secure_vector<u32bit>& digest, /* * SHA-224 compression function */ -void SHA_224::compress_n(const byte input[], size_t blocks) +void SHA_224::compress_n(const uint8_t input[], size_t blocks) { SHA2_32::compress(m_digest, input, blocks); } @@ -167,7 +167,7 @@ void SHA_224::compress_n(const byte input[], size_t blocks) /* * Copy out the digest */ -void SHA_224::copy_out(byte output[]) +void SHA_224::copy_out(uint8_t output[]) { copy_out_vec_be(output, output_length(), m_digest); } @@ -191,7 +191,7 @@ void SHA_224::clear() /* * SHA-256 compression function */ -void SHA_256::compress_n(const byte input[], size_t blocks) +void SHA_256::compress_n(const uint8_t input[], size_t blocks) { SHA2_32::compress(m_digest, input, blocks); } @@ -199,7 +199,7 @@ void SHA_256::compress_n(const byte input[], size_t blocks) /* * Copy out the digest */ -void SHA_256::copy_out(byte output[]) +void SHA_256::copy_out(uint8_t output[]) { copy_out_vec_be(output, output_length(), m_digest); } diff --git a/src/lib/hash/sha2_32/sha2_32.h b/src/lib/hash/sha2_32/sha2_32.h index 528fe9cfd..78e08c97a 100644 --- a/src/lib/hash/sha2_32/sha2_32.h +++ b/src/lib/hash/sha2_32/sha2_32.h @@ -28,10 +28,10 @@ class BOTAN_DLL SHA_224 final : public MDx_HashFunction SHA_224() : MDx_HashFunction(64, true, true), m_digest(8) { clear(); } private: - void compress_n(const byte[], size_t blocks) override; - void copy_out(byte[]) override; + void compress_n(const uint8_t[], size_t blocks) override; + void copy_out(uint8_t[]) override; - secure_vector<u32bit> m_digest; + secure_vector<uint32_t> m_digest; }; /** @@ -49,10 +49,10 @@ class BOTAN_DLL SHA_256 final : public MDx_HashFunction SHA_256() : MDx_HashFunction(64, true, true), m_digest(8) { clear(); } private: - void compress_n(const byte[], size_t blocks) override; - void copy_out(byte[]) override; + void compress_n(const uint8_t[], size_t blocks) override; + void copy_out(uint8_t[]) override; - secure_vector<u32bit> m_digest; + secure_vector<uint32_t> m_digest; }; } |