sha2: rename SHA2 class to SHA256

temporary rename for clarity in existing algorithm code. revisit when/if
we get implementations for each bit length.
This commit is contained in:
Danny Robson 2014-05-09 13:01:02 +10:00
parent 77ea57f530
commit 513b09c1c9
3 changed files with 11 additions and 11 deletions

View File

@ -156,7 +156,7 @@ uint64_t H_512[] = {
};
///////////////////////////////////////////////////////////////////////////////
SHA2::SHA2 ():
SHA256::SHA256 ():
m_total (0)
{
std::copy (std::begin (H_256), std::end (H_256), std::begin (H));
@ -164,7 +164,7 @@ SHA2::SHA2 ():
void
SHA2::update (const uint8_t *data, size_t length) {
SHA256::update (const uint8_t *data, size_t length) {
while (length) {
size_t buffered = m_total % sizeof (M);
size_t chunk = std::min (sizeof (M) - buffered, length);
@ -180,7 +180,7 @@ SHA2::update (const uint8_t *data, size_t length) {
void
SHA2::finish (void) {
SHA256::finish (void) {
// Append a single 1 bit followed by 0s.
size_t buffered = m_total % sizeof (M);
size_t used = m_total * 8;
@ -219,7 +219,7 @@ SHA2::finish (void) {
void
SHA2::process (void) {
SHA256::process (void) {
CHECK_EQ (m_total % sizeof (M), 0);
// Initialise the message schedule, W
@ -264,8 +264,8 @@ SHA2::process (void) {
}
SHA2::digest_t
SHA2::digest (void) const {
SHA256::digest_t
SHA256::digest (void) const {
digest_t out;
auto cursor = out.begin ();

View File

@ -16,12 +16,12 @@
namespace util {
namespace hash {
class SHA2 {
class SHA256 {
public:
typedef std::array<uint8_t,32> digest_t;
public:
SHA2();
SHA256();
void update (const uint8_t *, size_t);
void finish (void);

View File

@ -4,11 +4,11 @@
#include <cstring>
using util::hash::SHA2;
using util::hash::SHA256;
static const struct {
const char *input;
SHA2::digest_t output;
SHA256::digest_t output;
} TESTS[] = {
{ "",
{ 0xE3, 0xB0, 0xC4, 0x42, 0x98, 0xFC, 0x1C, 0x14, 0x9A, 0xFB, 0xF4, 0xC8, 0x99, 0x6F, 0xB9, 0x24,
@ -40,7 +40,7 @@ static const struct {
int
main (int, char **) {
for (auto i: TESTS) {
SHA2 obj;
SHA256 obj;
obj.update (reinterpret_cast<const uint8_t*> (i.input), strlen (i.input));
obj.finish ();