File tree 1 file changed +18
-1
lines changed
1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 1
1
// //////////////////////////////////////////////////////////
2
2
// sha256.cpp
3
- // Copyright (c) 2014,2015 Stephan Brumme. All rights reserved.
3
+ // Copyright (c) 2014,2015,2021 Stephan Brumme. All rights reserved.
4
4
// see http://create.stephan-brumme.com/disclaimer.html
5
5
//
6
6
11
11
#include < endian.h>
12
12
#endif
13
13
14
+ // #define SHA2_224_SEED_VECTOR
15
+
14
16
15
17
// / same as reset()
16
18
SHA256::SHA256 ()
@@ -26,6 +28,8 @@ void SHA256::reset()
26
28
m_bufferSize = 0 ;
27
29
28
30
// according to RFC 1321
31
+ // "These words were obtained by taking the first thirty-two bits of the
32
+ // fractional parts of the square roots of the first eight prime numbers"
29
33
m_hash[0 ] = 0x6a09e667 ;
30
34
m_hash[1 ] = 0xbb67ae85 ;
31
35
m_hash[2 ] = 0x3c6ef372 ;
@@ -34,6 +38,19 @@ void SHA256::reset()
34
38
m_hash[5 ] = 0x9b05688c ;
35
39
m_hash[6 ] = 0x1f83d9ab ;
36
40
m_hash[7 ] = 0x5be0cd19 ;
41
+
42
+ #ifdef SHA2_224_SEED_VECTOR
43
+ // if you want SHA2-224 instead then use these seeds
44
+ // and throw away the last 32 bits of getHash
45
+ m_hash[0 ] = 0xc1059ed8 ;
46
+ m_hash[1 ] = 0x367cd507 ;
47
+ m_hash[2 ] = 0x3070dd17 ;
48
+ m_hash[3 ] = 0xf70e5939 ;
49
+ m_hash[4 ] = 0xffc00b31 ;
50
+ m_hash[5 ] = 0x68581511 ;
51
+ m_hash[6 ] = 0x64f98fa7 ;
52
+ m_hash[7 ] = 0xbefa4fa4 ;
53
+ #endif
37
54
}
38
55
39
56
You can’t perform that action at this time.
0 commit comments