From 5909e8328a91e4ae952c0ab760cddddbc3825b27 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 16 Apr 2016 15:46:37 +0300 Subject: [PATCH] Slightly shorten the names of the constant structs --- source/sha2.cpp | 36 ++++++++++++++++++------------------ source/sha2.h | 8 ++++---- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/source/sha2.cpp b/source/sha2.cpp index c7f51a5..3823643 100644 --- a/source/sha2.cpp +++ b/source/sha2.cpp @@ -39,8 +39,8 @@ SHA2::SHA2() { init(); } -template SHA2::SHA2(); -template SHA2::SHA2(); +template SHA2::SHA2(); +template SHA2::SHA2(); template SHA2::SHA2(const char *data, unsigned len) @@ -48,8 +48,8 @@ SHA2::SHA2(const char *data, unsigned len) init(); BlockHash::update(data, len); } -template SHA2::SHA2(const char *, unsigned); -template SHA2::SHA2(const char *, unsigned); +template SHA2::SHA2(const char *, unsigned); +template SHA2::SHA2(const char *, unsigned); template SHA2::SHA2(const string &str) @@ -57,8 +57,8 @@ SHA2::SHA2(const string &str) init(); BlockHash::update(str); } -template SHA2::SHA2(const string &); -template SHA2::SHA2(const string &); +template SHA2::SHA2(const string &); +template SHA2::SHA2(const string &); template void SHA2::init() @@ -66,8 +66,8 @@ void SHA2::init() copy(Constants::initial, Constants::initial+8, buffer); processed_bytes = 0; } -template void SHA2::init(); -template void SHA2::init(); +template void SHA2::init(); +template void SHA2::init(); template void SHA2::process_block(const char *data) @@ -110,8 +110,8 @@ void SHA2::process_block(const char *data) processed_bytes += Constants::BLOCK_SIZE; } -template void SHA2::process_block(const char *); -template void SHA2::process_block(const char *); +template void SHA2::process_block(const char *); +template void SHA2::process_block(const char *); template unsigned SHA2::get_digest(char *digest, unsigned len) const @@ -134,16 +134,16 @@ unsigned SHA2::get_digest(char *digest, unsigned len) const return Constants::DIGEST_SIZE; } -template unsigned SHA2::get_digest(char *, unsigned) const; -template unsigned SHA2::get_digest(char *, unsigned) const; +template unsigned SHA2::get_digest(char *, unsigned) const; +template unsigned SHA2::get_digest(char *, unsigned) const; -const SHA2_256Constants::WordType SHA2_256Constants::initial[8] = +const SHA256Constants::WordType SHA256Constants::initial[8] = { 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19 }; -const SHA2_256Constants::WordType SHA2_256Constants::round_constants[SHA2_256Constants::N_ROUNDS] = +const SHA256Constants::WordType SHA256Constants::round_constants[SHA256Constants::N_ROUNDS] = { 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, @@ -155,7 +155,7 @@ const SHA2_256Constants::WordType SHA2_256Constants::round_constants[SHA2_256Con 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2 }; -const unsigned SHA2_256Constants::sigma_constants[12] = +const unsigned SHA256Constants::sigma_constants[12] = { 2, 13, 22, // For Σ₀ 6, 11, 25, // For Σ₁ @@ -163,13 +163,13 @@ const unsigned SHA2_256Constants::sigma_constants[12] = 17, 19, 10 // For σ₁ }; -const SHA2_512Constants::WordType SHA2_512Constants::initial[8] = +const SHA512Constants::WordType SHA512Constants::initial[8] = { 0x6A09E667F3BCC908, 0xBB67AE8584CAA73B, 0x3C6EF372FE94F82B, 0xA54FF53A5F1D36F1, 0x510E527FADE682D1, 0x9B05688C2B3E6C1F, 0x1F83D9ABFB41BD6B, 0x5BE0CD19137E2179, }; -const SHA2_512Constants::WordType SHA2_512Constants::round_constants[SHA2_512Constants::N_ROUNDS] = +const SHA512Constants::WordType SHA512Constants::round_constants[SHA512Constants::N_ROUNDS] = { 0x428A2F98D728AE22, 0x7137449123EF65CD, 0xB5C0FBCFEC4D3B2F, 0xE9B5DBA58189DBBC, 0x3956C25BF348B538, 0x59F111F1B605D019, 0x923F82A4AF194F9B, 0xAB1C5ED5DA6D8118, @@ -192,7 +192,7 @@ const SHA2_512Constants::WordType SHA2_512Constants::round_constants[SHA2_512Con 0x28DB77F523047D84, 0x32CAAB7B40C72493, 0x3C9EBE0A15C9BEBC, 0x431D67C49C100D4C, 0x4CC5D4BECB3E42B6, 0x597F299CFC657E2A, 0x5FCB6FAB3AD6FAEC, 0x6C44198C4A475817 }; -const unsigned SHA2_512Constants::sigma_constants[12] = +const unsigned SHA512Constants::sigma_constants[12] = { 28, 34, 39, // For Σ₀ 14, 18, 41, // For Σ₁ diff --git a/source/sha2.h b/source/sha2.h index 060b8d7..88dee9a 100644 --- a/source/sha2.h +++ b/source/sha2.h @@ -34,7 +34,7 @@ private: }; -struct SHA2_256Constants +struct SHA256Constants { typedef UInt32 WordType; @@ -52,7 +52,7 @@ struct SHA2_256Constants static const unsigned sigma_constants[12]; }; -struct SHA2_512Constants +struct SHA512Constants { typedef UInt64 WordType; @@ -70,8 +70,8 @@ struct SHA2_512Constants static const unsigned sigma_constants[12]; }; -typedef SHA2 SHA256; -typedef SHA2 SHA512; +typedef SHA2 SHA256; +typedef SHA2 SHA512; } // namespace Crypto } // namespace Msp -- 2.45.2