Update documentation
parent
5267723a49
commit
8c29b1a4d3
|
|
@ -10,7 +10,7 @@ Digest: 00000000 62eeedd9 d1f2d46b dc10e4e2 4167c487 5cf2f7a2 297da02b 8f4ba8e0
|
||||||
Test: NotVerify
|
Test: NotVerify
|
||||||
#
|
#
|
||||||
Source: SM3 Hash function, https://tools.ietf.org/html/draft-shen-sm3-hash
|
Source: SM3 Hash function, https://tools.ietf.org/html/draft-shen-sm3-hash
|
||||||
Comment: Appendix B, test vector 1
|
Comment: Appendix B, test vector 2
|
||||||
Message: 61626364 61626364 61626364 61626364 61626364 61626364 61626364 61626364 \
|
Message: 61626364 61626364 61626364 61626364 61626364 61626364 61626364 61626364 \
|
||||||
61626364 61626364 61626364 61626364 61626364 61626364 61626364 61626364
|
61626364 61626364 61626364 61626364 61626364 61626364 61626364 61626364
|
||||||
Digest: debe9ff9 2275b8a1 38604889 c18e5a4d 6fdb70e5 387e5765 293dcba3 9c0c5732
|
Digest: debe9ff9 2275b8a1 38604889 c18e5a4d 6fdb70e5 387e5765 293dcba3 9c0c5732
|
||||||
|
|
|
||||||
14
sm3.cpp
14
sm3.cpp
|
|
@ -73,19 +73,18 @@ inline word32 SM3_E(word32 W0, word32 W7, word32 W13, word32 W3, word32 W10)
|
||||||
return P1(W0 ^ W7 ^ rotlFixed(W13, 15)) ^ rotlFixed(W3, 7) ^ W10;
|
return P1(W0 ^ W7 ^ rotlFixed(W13, 15)) ^ rotlFixed(W3, 7) ^ W10;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t SM3_HashMultipleBlocks_CXX(word32 *state, const word32 *input, size_t length)
|
static size_t SM3_HashMultipleBlocks_CXX(word32 *state, const word32 *data, size_t length)
|
||||||
{
|
{
|
||||||
CRYPTOPP_ASSERT(input);
|
CRYPTOPP_ASSERT(data);
|
||||||
|
|
||||||
word32 A = state[0], B = state[1], C = state[2], D = state[3];
|
word32 A = state[0], B = state[1], C = state[2], D = state[3];
|
||||||
word32 E = state[4], F = state[5], G = state[6], H = state[7];
|
word32 E = state[4], F = state[5], G = state[6], H = state[7];
|
||||||
|
|
||||||
size_t blocks = length / SM3::BLOCKSIZE;
|
while (length >= SM3::BLOCKSIZE)
|
||||||
for(size_t i = 0; i < blocks; ++i)
|
|
||||||
{
|
{
|
||||||
// Reverse bytes on LittleEndian; align pointer on BigEndian
|
// Reverse bytes on LittleEndian; align pointer on BigEndian
|
||||||
typedef GetBlock<word32, BigEndian, false> InBlock;
|
typedef GetBlock<word32, BigEndian, false> InBlock;
|
||||||
InBlock iblk(input);
|
InBlock iblk(data);
|
||||||
|
|
||||||
word32 W00, W01, W02, W03, W04, W05, W06, W07, W08, W09, W10, W11, W12, W13, W14, W15;
|
word32 W00, W01, W02, W03, W04, W05, W06, W07, W08, W09, W10, W11, W12, W13, W14, W15;
|
||||||
iblk(W00)(W01)(W02)(W03)(W04)(W05)(W06)(W07)(W08)(W09)(W10)(W11)(W12)(W13)(W14)(W15);
|
iblk(W00)(W01)(W02)(W03)(W04)(W05)(W06)(W07)(W08)(W09)(W10)(W11)(W12)(W13)(W14)(W15);
|
||||||
|
|
@ -216,10 +215,11 @@ static size_t SM3_HashMultipleBlocks_CXX(word32 *state, const word32 *input, siz
|
||||||
G = (state[6] ^= G);
|
G = (state[6] ^= G);
|
||||||
H = (state[7] ^= H);
|
H = (state[7] ^= H);
|
||||||
|
|
||||||
input += SM3::BLOCKSIZE/sizeof(word32);
|
data += SM3::BLOCKSIZE/sizeof(word32);
|
||||||
|
length -= SM3::BLOCKSIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return length & (SM3::BLOCKSIZE-1);
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
ANONYMOUS_NAMESPACE_END
|
ANONYMOUS_NAMESPACE_END
|
||||||
|
|
|
||||||
12
sm3.h
12
sm3.h
|
|
@ -29,23 +29,21 @@ public:
|
||||||
//! \param state the state of the hash
|
//! \param state the state of the hash
|
||||||
//! \details InitState sets a state array to SHA256 initial values
|
//! \details InitState sets a state array to SHA256 initial values
|
||||||
//! \details Hashes which derive from IteratedHashWithStaticTransform provide static
|
//! \details Hashes which derive from IteratedHashWithStaticTransform provide static
|
||||||
//! member functions InitState and Transform. External classes, like SEAL and MDC,
|
//! member functions InitState() and Transform(). External classes, like SEAL and MDC,
|
||||||
//! can initialize state with a user provided key and operate the hash on the data
|
//! can initialize state with a user provided key and operate the hash on the data
|
||||||
//! with the user supplied state.
|
//! with the user supplied state.
|
||||||
//! \note On Intel platforms the state array must be 16-byte aligned for SSE2.
|
|
||||||
static void InitState(HashWordType *state);
|
static void InitState(HashWordType *state);
|
||||||
|
|
||||||
//! \brief Operate the hash
|
//! \brief Operate the hash
|
||||||
//! \param digest the state of the hash
|
//! \param digest the state of the hash
|
||||||
//! \param data the data to be digested
|
//! \param data the data to be digested
|
||||||
//! \details Transform operates the hash on <tt>data</tt>. When the call is invoked
|
//! \details Transform() operates the hash on <tt>data</tt>. When the call is invoked
|
||||||
//! <tt>digest</tt> holds initial state. Upon return <tt>digest</tt> holds the hash
|
//! <tt>digest</tt> holds initial or current state. Upon return <tt>digest</tt> holds
|
||||||
//! or updated state.
|
//! the hash or updated state.
|
||||||
//! \details Hashes which derive from IteratedHashWithStaticTransform provide static
|
//! \details Hashes which derive from IteratedHashWithStaticTransform provide static
|
||||||
//! member functions InitState and Transform. External classes, like SEAL and MDC,
|
//! member functions InitState() and Transform(). External classes, like SEAL and MDC,
|
||||||
//! can initialize state with a user provided key and operate the hash on the data
|
//! can initialize state with a user provided key and operate the hash on the data
|
||||||
//! with the user supplied state.
|
//! with the user supplied state.
|
||||||
//! \note On Intel platforms the state array and data must be 16-byte aligned for SSE2.
|
|
||||||
static void Transform(HashWordType *digest, const HashWordType *data);
|
static void Transform(HashWordType *digest, const HashWordType *data);
|
||||||
|
|
||||||
//! \brief The algorithm name
|
//! \brief The algorithm name
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue