|
@@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
31
|
31
|
*
|
32
|
32
|
* http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA512.pdf
|
33
|
33
|
* http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA384.pdf
|
|
34
|
+ * http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA512_256.pdf
|
34
|
35
|
*
|
35
|
36
|
*/
|
36
|
37
|
|
|
@@ -101,6 +102,28 @@ DIGEST_TEST ( sha384_nist_abc_stu, &sha384_algorithm, DIGEST_NIST_ABC_STU,
|
101
|
102
|
0x55, 0x7e, 0x2d, 0xb9, 0x66, 0xc3, 0xe9, 0xfa, 0x91,
|
102
|
103
|
0x74, 0x60, 0x39 ) );
|
103
|
104
|
|
|
105
|
+/* Empty test vector (digest obtained from "shasum -a 512256 /dev/null") */
|
|
106
|
+DIGEST_TEST ( sha512_256_empty, &sha512_256_algorithm, DIGEST_EMPTY,
|
|
107
|
+ DIGEST ( 0xc6, 0x72, 0xb8, 0xd1, 0xef, 0x56, 0xed, 0x28, 0xab,
|
|
108
|
+ 0x87, 0xc3, 0x62, 0x2c, 0x51, 0x14, 0x06, 0x9b, 0xdd,
|
|
109
|
+ 0x3a, 0xd7, 0xb8, 0xf9, 0x73, 0x74, 0x98, 0xd0, 0xc0,
|
|
110
|
+ 0x1e, 0xce, 0xf0, 0x96, 0x7a ) );
|
|
111
|
+
|
|
112
|
+/* NIST test vector "abc" */
|
|
113
|
+DIGEST_TEST ( sha512_256_nist_abc, &sha512_256_algorithm, DIGEST_NIST_ABC,
|
|
114
|
+ DIGEST ( 0x53, 0x04, 0x8e, 0x26, 0x81, 0x94, 0x1e, 0xf9, 0x9b,
|
|
115
|
+ 0x2e, 0x29, 0xb7, 0x6b, 0x4c, 0x7d, 0xab, 0xe4, 0xc2,
|
|
116
|
+ 0xd0, 0xc6, 0x34, 0xfc, 0x6d, 0x46, 0xe0, 0xe2, 0xf1,
|
|
117
|
+ 0x31, 0x07, 0xe7, 0xaf, 0x23 ) );
|
|
118
|
+
|
|
119
|
+/* NIST test vector "abc...stu" */
|
|
120
|
+DIGEST_TEST ( sha512_256_nist_abc_stu, &sha512_256_algorithm,
|
|
121
|
+ DIGEST_NIST_ABC_STU,
|
|
122
|
+ DIGEST ( 0x39, 0x28, 0xe1, 0x84, 0xfb, 0x86, 0x90, 0xf8, 0x40,
|
|
123
|
+ 0xda, 0x39, 0x88, 0x12, 0x1d, 0x31, 0xbe, 0x65, 0xcb,
|
|
124
|
+ 0x9d, 0x3e, 0xf8, 0x3e, 0xe6, 0x14, 0x6f, 0xea, 0xc8,
|
|
125
|
+ 0x61, 0xe1, 0x9b, 0x56, 0x3a ) );
|
|
126
|
+
|
104
|
127
|
/**
|
105
|
128
|
* Perform SHA-512 family self-test
|
106
|
129
|
*
|
|
@@ -114,12 +137,17 @@ static void sha512_test_exec ( void ) {
|
114
|
137
|
digest_ok ( &sha384_empty );
|
115
|
138
|
digest_ok ( &sha384_nist_abc );
|
116
|
139
|
digest_ok ( &sha384_nist_abc_stu );
|
|
140
|
+ digest_ok ( &sha512_256_empty );
|
|
141
|
+ digest_ok ( &sha512_256_nist_abc );
|
|
142
|
+ digest_ok ( &sha512_256_nist_abc_stu );
|
117
|
143
|
|
118
|
144
|
/* Speed tests */
|
119
|
145
|
DBG ( "SHA512 required %ld cycles per byte\n",
|
120
|
146
|
digest_cost ( &sha512_algorithm ) );
|
121
|
147
|
DBG ( "SHA384 required %ld cycles per byte\n",
|
122
|
148
|
digest_cost ( &sha384_algorithm ) );
|
|
149
|
+ DBG ( "SHA512/256 required %ld cycles per byte\n",
|
|
150
|
+ digest_cost ( &sha512_256_algorithm ) );
|
123
|
151
|
}
|
124
|
152
|
|
125
|
153
|
/** SHA-512 family self-test */
|