aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/hash/sha2_64
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-12-11 15:28:38 -0500
committerJack Lloyd <[email protected]>2016-12-18 16:48:24 -0500
commitf3cb3edb512bdcab498d825886c3366c341b3f78 (patch)
tree645c73ec295a5a34f25d99903b6d9fa9751e86d3 /src/lib/hash/sha2_64
parentc1dd21253c1f3188ff45d3ad47698efd08235ae8 (diff)
Convert to using standard uintN_t integer types
Renames a couple of functions for somewhat better name consistency, eg make_u32bit becomes make_uint32. The old typedefs remain for now since probably lots of application code uses them.
Diffstat (limited to 'src/lib/hash/sha2_64')
-rw-r--r--src/lib/hash/sha2_64/sha2_64.cpp54
-rw-r--r--src/lib/hash/sha2_64/sha2_64.h18
2 files changed, 36 insertions, 36 deletions
diff --git a/src/lib/hash/sha2_64/sha2_64.cpp b/src/lib/hash/sha2_64/sha2_64.cpp
index d7c3f1325..59242ee9c 100644
--- a/src/lib/hash/sha2_64/sha2_64.cpp
+++ b/src/lib/hash/sha2_64/sha2_64.cpp
@@ -16,7 +16,7 @@ namespace SHA2_64 {
/*
* SHA-{384,512} Rho Function
*/
-inline u64bit rho(u64bit X, u32bit rot1, u32bit rot2, u32bit rot3)
+inline uint64_t rho(uint64_t X, uint32_t rot1, uint32_t rot2, uint32_t rot3)
{
return (rotate_right(X, rot1) ^ rotate_right(X, rot2) ^
rotate_right(X, rot3));
@@ -25,7 +25,7 @@ inline u64bit rho(u64bit X, u32bit rot1, u32bit rot2, u32bit rot3)
/*
* SHA-{384,512} Sigma Function
*/
-inline u64bit sigma(u64bit X, u32bit rot1, u32bit rot2, u32bit shift)
+inline uint64_t sigma(uint64_t X, uint32_t rot1, uint32_t rot2, uint32_t shift)
{
return (rotate_right(X, rot1) ^ rotate_right(X, rot2) ^ (X >> shift));
}
@@ -47,31 +47,31 @@ inline u64bit sigma(u64bit X, u32bit rot1, u32bit rot2, u32bit shift)
/*
* SHA-{384,512} Compression Function
*/
-void compress(secure_vector<u64bit>& digest,
- const byte input[], size_t blocks)
+void compress(secure_vector<uint64_t>& digest,
+ const uint8_t input[], size_t blocks)
{
- u64bit A = digest[0], B = digest[1], C = digest[2],
+ uint64_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)
{
- u64bit W00 = load_be<u64bit>(input, 0);
- u64bit W01 = load_be<u64bit>(input, 1);
- u64bit W02 = load_be<u64bit>(input, 2);
- u64bit W03 = load_be<u64bit>(input, 3);
- u64bit W04 = load_be<u64bit>(input, 4);
- u64bit W05 = load_be<u64bit>(input, 5);
- u64bit W06 = load_be<u64bit>(input, 6);
- u64bit W07 = load_be<u64bit>(input, 7);
- u64bit W08 = load_be<u64bit>(input, 8);
- u64bit W09 = load_be<u64bit>(input, 9);
- u64bit W10 = load_be<u64bit>(input, 10);
- u64bit W11 = load_be<u64bit>(input, 11);
- u64bit W12 = load_be<u64bit>(input, 12);
- u64bit W13 = load_be<u64bit>(input, 13);
- u64bit W14 = load_be<u64bit>(input, 14);
- u64bit W15 = load_be<u64bit>(input, 15);
+ uint64_t W00 = load_be<uint64_t>(input, 0);
+ uint64_t W01 = load_be<uint64_t>(input, 1);
+ uint64_t W02 = load_be<uint64_t>(input, 2);
+ uint64_t W03 = load_be<uint64_t>(input, 3);
+ uint64_t W04 = load_be<uint64_t>(input, 4);
+ uint64_t W05 = load_be<uint64_t>(input, 5);
+ uint64_t W06 = load_be<uint64_t>(input, 6);
+ uint64_t W07 = load_be<uint64_t>(input, 7);
+ uint64_t W08 = load_be<uint64_t>(input, 8);
+ uint64_t W09 = load_be<uint64_t>(input, 9);
+ uint64_t W10 = load_be<uint64_t>(input, 10);
+ uint64_t W11 = load_be<uint64_t>(input, 11);
+ uint64_t W12 = load_be<uint64_t>(input, 12);
+ uint64_t W13 = load_be<uint64_t>(input, 13);
+ uint64_t W14 = load_be<uint64_t>(input, 14);
+ uint64_t W15 = load_be<uint64_t>(input, 15);
SHA2_64_F(A, B, C, D, E, F, G, H, W00, W14, W09, W01, 0x428A2F98D728AE22);
SHA2_64_F(H, A, B, C, D, E, F, G, W01, W15, W10, W02, 0x7137449123EF65CD);
@@ -171,32 +171,32 @@ void compress(secure_vector<u64bit>& digest,
}
-void SHA_512_256::compress_n(const byte input[], size_t blocks)
+void SHA_512_256::compress_n(const uint8_t input[], size_t blocks)
{
SHA2_64::compress(m_digest, input, blocks);
}
-void SHA_384::compress_n(const byte input[], size_t blocks)
+void SHA_384::compress_n(const uint8_t input[], size_t blocks)
{
SHA2_64::compress(m_digest, input, blocks);
}
-void SHA_512::compress_n(const byte input[], size_t blocks)
+void SHA_512::compress_n(const uint8_t input[], size_t blocks)
{
SHA2_64::compress(m_digest, input, blocks);
}
-void SHA_512_256::copy_out(byte output[])
+void SHA_512_256::copy_out(uint8_t output[])
{
copy_out_vec_be(output, output_length(), m_digest);
}
-void SHA_384::copy_out(byte output[])
+void SHA_384::copy_out(uint8_t output[])
{
copy_out_vec_be(output, output_length(), m_digest);
}
-void SHA_512::copy_out(byte output[])
+void SHA_512::copy_out(uint8_t output[])
{
copy_out_vec_be(output, output_length(), m_digest);
}
diff --git a/src/lib/hash/sha2_64/sha2_64.h b/src/lib/hash/sha2_64/sha2_64.h
index a38f12dae..51bdb2b77 100644
--- a/src/lib/hash/sha2_64/sha2_64.h
+++ b/src/lib/hash/sha2_64/sha2_64.h
@@ -27,10 +27,10 @@ class BOTAN_DLL SHA_384 final : public MDx_HashFunction
SHA_384() : MDx_HashFunction(128, true, true, 16), 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<u64bit> m_digest;
+ secure_vector<uint64_t> m_digest;
};
/**
@@ -48,10 +48,10 @@ class BOTAN_DLL SHA_512 final : public MDx_HashFunction
SHA_512() : MDx_HashFunction(128, true, true, 16), 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<u64bit> m_digest;
+ secure_vector<uint64_t> m_digest;
};
/**
@@ -68,10 +68,10 @@ class BOTAN_DLL SHA_512_256 final : public MDx_HashFunction
SHA_512_256() : MDx_HashFunction(128, true, true, 16), 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<u64bit> m_digest;
+ secure_vector<uint64_t> m_digest;
};
}