aboutsummaryrefslogtreecommitdiffstats
path: root/src/hash/sha2
diff options
context:
space:
mode:
Diffstat (limited to 'src/hash/sha2')
-rw-r--r--src/hash/sha2/sha2_32.cpp60
-rw-r--r--src/hash/sha2/sha2_32.h30
-rw-r--r--src/hash/sha2/sha2_64.cpp58
-rw-r--r--src/hash/sha2/sha2_64.h28
4 files changed, 92 insertions, 84 deletions
diff --git a/src/hash/sha2/sha2_32.cpp b/src/hash/sha2/sha2_32.cpp
index 52528e6fd..7c3114daf 100644
--- a/src/hash/sha2/sha2_32.cpp
+++ b/src/hash/sha2/sha2_32.cpp
@@ -1,8 +1,10 @@
-/*************************************************
-* SHA-{224,256} Source File *
-* (C) 1999-2008 Jack Lloyd *
-* 2007 FlexSecure GmbH *
-*************************************************/
+/*
+* SHA-{224,256}
+* (C) 1999-2008 Jack Lloyd
+* 2007 FlexSecure GmbH
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/sha2_32.h>
#include <botan/loadstor.h>
@@ -12,26 +14,26 @@ namespace Botan {
namespace {
-/*************************************************
-* SHA-256 Rho Function *
-*************************************************/
+/*
+* SHA-256 Rho Function
+*/
inline u32bit rho(u32bit X, u32bit rot1, u32bit rot2, u32bit rot3)
{
return (rotate_right(X, rot1) ^ rotate_right(X, rot2) ^
rotate_right(X, rot3));
}
-/*************************************************
-* SHA-256 Sigma Function *
-*************************************************/
+/*
+* SHA-256 Sigma Function
+*/
inline u32bit sigma(u32bit X, u32bit rot1, u32bit rot2, u32bit shift)
{
return (rotate_right(X, rot1) ^ rotate_right(X, rot2) ^ (X >> shift));
}
-/*************************************************
-* SHA-256 F1 Function *
-*************************************************/
+/*
+* SHA-256 F1 Function
+*/
inline void F1(u32bit A, u32bit B, u32bit C, u32bit& D,
u32bit E, u32bit F, u32bit G, u32bit& H,
u32bit msg, u32bit magic)
@@ -43,9 +45,9 @@ inline void F1(u32bit A, u32bit B, u32bit C, u32bit& D,
}
-/*************************************************
-* SHA-256 Compression Function *
-*************************************************/
+/*
+* SHA-256 Compression Function
+*/
void SHA_224_256_BASE::compress_n(const byte input[], u32bit blocks)
{
u32bit A = digest[0], B = digest[1], C = digest[2],
@@ -138,27 +140,27 @@ void SHA_224_256_BASE::compress_n(const byte input[], u32bit blocks)
}
}
-/*************************************************
-* Copy out the digest *
-*************************************************/
+/*
+* Copy out the digest
+*/
void SHA_224_256_BASE::copy_out(byte output[])
{
for(u32bit j = 0; j != OUTPUT_LENGTH; j += 4)
store_be(digest[j/4], output + j);
}
-/*************************************************
-* Clear memory of sensitive data *
-*************************************************/
+/*
+* Clear memory of sensitive data
+*/
void SHA_224_256_BASE::clear() throw()
{
MDx_HashFunction::clear();
W.clear();
}
-/*************************************************
-* Clear memory of sensitive data *
-*************************************************/
+/*
+* Clear memory of sensitive data
+*/
void SHA_224::clear() throw()
{
SHA_224_256_BASE::clear();
@@ -172,9 +174,9 @@ void SHA_224::clear() throw()
digest[7] = 0xbefa4fa4;
}
-/*************************************************
-* Clear memory of sensitive data *
-*************************************************/
+/*
+* Clear memory of sensitive data
+*/
void SHA_256::clear() throw()
{
SHA_224_256_BASE::clear();
diff --git a/src/hash/sha2/sha2_32.h b/src/hash/sha2/sha2_32.h
index f4c8d978a..05083d19d 100644
--- a/src/hash/sha2/sha2_32.h
+++ b/src/hash/sha2/sha2_32.h
@@ -1,8 +1,10 @@
-/*************************************************
-* SHA-{224,256} Header File *
-* (C) 1999-2008 Jack Lloyd *
-* 2007 FlexSecure GmbH *
-*************************************************/
+/*
+* SHA-{224,256}
+* (C) 1999-2008 Jack Lloyd
+* 2007 FlexSecure GmbH
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_SHA_256_H__
#define BOTAN_SHA_256_H__
@@ -11,9 +13,9 @@
namespace Botan {
-/*************************************************
-* SHA-{224,256} Base *
-*************************************************/
+/*
+* SHA-{224,256} Base
+*/
class BOTAN_DLL SHA_224_256_BASE : public MDx_HashFunction
{
protected:
@@ -28,9 +30,9 @@ class BOTAN_DLL SHA_224_256_BASE : public MDx_HashFunction
void copy_out(byte[]);
};
-/*************************************************
-* SHA-224 *
-*************************************************/
+/*
+* SHA-224
+*/
class BOTAN_DLL SHA_224 : public SHA_224_256_BASE
{
public:
@@ -40,9 +42,9 @@ class BOTAN_DLL SHA_224 : public SHA_224_256_BASE
SHA_224() : SHA_224_256_BASE(28) { clear(); }
};
-/*************************************************
-* SHA-256 *
-*************************************************/
+/*
+* SHA-256
+*/
class BOTAN_DLL SHA_256 : public SHA_224_256_BASE
{
public:
diff --git a/src/hash/sha2/sha2_64.cpp b/src/hash/sha2/sha2_64.cpp
index cafa06e53..dbbfc5a96 100644
--- a/src/hash/sha2/sha2_64.cpp
+++ b/src/hash/sha2/sha2_64.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* SHA-{384,512} Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* SHA-{384,512}
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/sha2_64.h>
#include <botan/loadstor.h>
@@ -11,18 +13,18 @@ namespace Botan {
namespace {
-/*************************************************
-* SHA-{384,512} Rho Function *
-*************************************************/
+/*
+* SHA-{384,512} Rho Function
+*/
inline u64bit rho(u64bit X, u32bit rot1, u32bit rot2, u32bit rot3)
{
return (rotate_right(X, rot1) ^ rotate_right(X, rot2) ^
rotate_right(X, rot3));
}
-/*************************************************
-* SHA-{384,512} F1 Function *
-*************************************************/
+/*
+* SHA-{384,512} F1 Function
+*/
inline void F1(u64bit A, u64bit B, u64bit C, u64bit& D,
u64bit E, u64bit F, u64bit G, u64bit& H,
u64bit msg, u64bit magic)
@@ -32,9 +34,9 @@ inline void F1(u64bit A, u64bit B, u64bit C, u64bit& D,
H += magic + rho(A, 28, 34, 39) + ((A & B) ^ (A & C) ^ (B & C));
}
-/*************************************************
-* SHA-{384,512} Sigma Function *
-*************************************************/
+/*
+* SHA-{384,512} Sigma Function
+*/
inline u64bit sigma(u64bit X, u32bit rot1, u32bit rot2, u32bit shift)
{
return (rotate_right(X, rot1) ^ rotate_right(X, rot2) ^ (X >> shift));
@@ -42,9 +44,9 @@ inline u64bit sigma(u64bit X, u32bit rot1, u32bit rot2, u32bit shift)
}
-/*************************************************
-* SHA-{384,512} Compression Function *
-*************************************************/
+/*
+* SHA-{384,512} Compression Function
+*/
void SHA_384_512_BASE::compress_n(const byte input[], u32bit blocks)
{
u64bit A = digest[0], B = digest[1], C = digest[2],
@@ -153,27 +155,27 @@ void SHA_384_512_BASE::compress_n(const byte input[], u32bit blocks)
}
}
-/*************************************************
-* Copy out the digest *
-*************************************************/
+/*
+* Copy out the digest
+*/
void SHA_384_512_BASE::copy_out(byte output[])
{
for(u32bit j = 0; j != OUTPUT_LENGTH; j += 8)
store_be(digest[j/8], output + j);
}
-/*************************************************
-* Clear memory of sensitive data *
-*************************************************/
+/*
+* Clear memory of sensitive data
+*/
void SHA_384_512_BASE::clear() throw()
{
MDx_HashFunction::clear();
W.clear();
}
-/*************************************************
-* Clear memory of sensitive data *
-*************************************************/
+/*
+* Clear memory of sensitive data
+*/
void SHA_384::clear() throw()
{
SHA_384_512_BASE::clear();
@@ -187,9 +189,9 @@ void SHA_384::clear() throw()
digest[7] = 0x47B5481DBEFA4FA4;
}
-/*************************************************
-* Clear memory of sensitive data *
-*************************************************/
+/*
+* Clear memory of sensitive data
+*/
void SHA_512::clear() throw()
{
SHA_384_512_BASE::clear();
diff --git a/src/hash/sha2/sha2_64.h b/src/hash/sha2/sha2_64.h
index 51efb455b..dcc6dc83b 100644
--- a/src/hash/sha2/sha2_64.h
+++ b/src/hash/sha2/sha2_64.h
@@ -1,7 +1,9 @@
-/*************************************************
-* SHA-{384,512} Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* SHA-{384,512}
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_SHA_64BIT_H__
#define BOTAN_SHA_64BIT_H__
@@ -10,9 +12,9 @@
namespace Botan {
-/*************************************************
-* SHA-{384,512} Base *
-*************************************************/
+/*
+* SHA-{384,512} Base
+*/
class BOTAN_DLL SHA_384_512_BASE : public MDx_HashFunction
{
protected:
@@ -29,9 +31,9 @@ class BOTAN_DLL SHA_384_512_BASE : public MDx_HashFunction
SecureBuffer<u64bit, 80> W;
};
-/*************************************************
-* SHA-384 *
-*************************************************/
+/*
+* SHA-384
+*/
class BOTAN_DLL SHA_384 : public SHA_384_512_BASE
{
public:
@@ -41,9 +43,9 @@ class BOTAN_DLL SHA_384 : public SHA_384_512_BASE
SHA_384() : SHA_384_512_BASE(48) { clear(); }
};
-/*************************************************
-* SHA-512 *
-*************************************************/
+/*
+* SHA-512
+*/
class BOTAN_DLL SHA_512 : public SHA_384_512_BASE
{
public: