add packaging
[platform/upstream/nettle.git] / testsuite / sha512-test.c
1 #include "testutils.h"
2
3 void
4 test_main(void)
5 {
6   test_hash(&nettle_sha512, SDATA("abc"),
7             SHEX("ddaf35a193617aba cc417349ae204131"
8                  "12e6fa4e89a97ea2 0a9eeee64b55d39a"
9                  "2192992a274fc1a8 36ba3c23a3feebbd"
10                  "454d4423643ce80e 2a9ac94fa54ca49f"));
11   
12   test_hash(&nettle_sha512,
13             SDATA("abcdefghbcdefghicdefghijdefg"
14                   "hijkefghijklfghijklmghijklmn"
15                   "hijklmnoijklmnopjklmnopqklmn"
16                   "opqrlmnopqrsmnopqrstnopqrstu"),
17             SHEX("8e959b75dae313da 8cf4f72814fc143f"
18                  "8f7779c6eb9f7fa1 7299aeadb6889018"
19                  "501d289e4900f7e4 331b99dec4b5433a"
20                  "c7d329eeb6dd2654 5e96e55b874be909"));
21
22   /* NESSIE, Set 1, vector #6 */
23   test_hash(&nettle_sha512,
24             SDATA("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
25                   "abcdefghijklmnopqrstuvwxyz"
26                   "0123456789"),
27             SHEX("1E07BE23C26A86EA37EA810C8EC78093"
28                  "52515A970E9253C26F536CFC7A9996C4"
29                  "5C8370583E0A78FA4A90041D71A4CEAB"
30                  "7423F19C71B9D5A3E01249F0BEBD5894"));
31   
32   /* NESSIE, Set 1, vector #7 */
33   test_hash(&nettle_sha512,
34             SDATA("1234567890123456789012345678901234567890"
35                   "1234567890123456789012345678901234567890"),
36             SHEX("72EC1EF1124A45B047E8B7C75A932195"
37                  "135BB61DE24EC0D1914042246E0AEC3A"
38                  "2354E093D76F3048B456764346900CB1"
39                  "30D2A4FD5DD16ABB5E30BCB850DEE843"));
40
41   /* Variants longer than one block (128 bytes), to test varying alignment. */
42   test_hash(&nettle_sha512,
43             SDATA("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
44                   "abcdefghijklmnopqrstuvwxyz"
45                   "0123456789"
46                   "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
47                   "abcdefghijklmnopqrstuvwxyz"
48                   "0123456789"
49                   "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
50                   "abcdefghijklmnopqrstuvwxyz"
51                   "0123456789"),
52             SHEX("5338370f5655f4da14572d4fb471539b"
53                  "201485ecfb3d3204048dc6b83e61fab5"
54                  "05bcbbd73e644a1a5d159a32a0889cf3"
55                  "c9591b69b26d31be56c68838ce3cd63d"));
56   test_hash(&nettle_sha512,
57             SDATA("1234567890123456789012345678901234567890"
58                   "1234567890123456789012345678901234567890"        
59                   "1234567890123456789012345678901234567890"
60                   "1234567890123456789012345678901234567890"        
61                   "1234567890123456789012345678901234567890"
62                   "1234567890123456789012345678901234567890"        
63                   "1234567890123456789012345678901234567890"
64                   "1234567890123456789012345678901234567890")       ,
65             SHEX("33f8901b053e4cc677d3cb4122d96ad9"
66                  "b96b13bf76194cf962488bb4de4998a7"
67                  "1455cb31582db527adf77a485b81cf5b"
68                  "722a5e8638eb6be487400f3aec006e7c"));
69
70   /* Additional test vectors, from Daniel Kahn Gillmor */
71   test_hash(&nettle_sha512, SDATA(""),
72             SHEX("cf83e1357eefb8bd f1542850d66d8007"
73                  "d620e4050b5715dc 83f4a921d36ce9ce"
74                  "47d0d13c5d85f2b0 ff8318d2877eec2f"
75                  "63b931bd47417a81 a538327af927da3e"));
76   test_hash(&nettle_sha512, SDATA("a"),
77             SHEX("1f40fc92da241694 750979ee6cf582f2"
78                  "d5d7d28e18335de0 5abc54d0560e0f53"
79                  "02860c652bf08d56 0252aa5e74210546"
80                  "f369fbbbce8c12cf c7957b2652fe9a75"));
81   test_hash(&nettle_sha512, SDATA("38"),
82             SHEX("caae34a5e8103126 8bcdaf6f1d8c04d3"
83                  "7b7f2c349afb705b 575966f63e2ebf0f"
84                  "d910c3b05160ba08 7ab7af35d40b7c71"
85                  "9c53cd8b947c9611 1f64105fd45cc1b2"));
86   test_hash(&nettle_sha512, SDATA("message digest"),
87             SHEX("107dbf389d9e9f71 a3a95f6c055b9251"
88                  "bc5268c2be16d6c1 3492ea45b0199f33"
89                  "09e16455ab1e9611 8e8a905d5597b720"
90                  "38ddb372a8982604 6de66687bb420e7c"));
91   test_hash(&nettle_sha512, SDATA("abcdefghijklmnopqrstuvwxyz"),
92             SHEX("4dbff86cc2ca1bae 1e16468a05cb9881"
93                  "c97f1753bce36190 34898faa1aabe429"
94                  "955a1bf8ec483d74 21fe3c1646613a59"
95                  "ed5441fb0f321389 f77f48a879c7b1f1"));
96   test_hash(&nettle_sha512,
97             SDATA("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef"
98                   "ghijklmnopqrstuvwxyz0123456789"),
99             SHEX("1e07be23c26a86ea 37ea810c8ec78093"
100                  "52515a970e9253c2 6f536cfc7a9996c4"
101                  "5c8370583e0a78fa 4a90041d71a4ceab"
102                  "7423f19c71b9d5a3 e01249f0bebd5894"));
103   test_hash(&nettle_sha512,
104             SDATA("12345678901234567890123456789012"
105                   "34567890123456789012345678901234"
106                   "5678901234567890"),
107             SHEX("72ec1ef1124a45b0 47e8b7c75a932195"
108                  "135bb61de24ec0d1 914042246e0aec3a"
109                  "2354e093d76f3048 b456764346900cb1"
110                  "30d2a4fd5dd16abb 5e30bcb850dee843"));
111 }
112
113 /* For first test case.
114 -1: 6a09e667f3bcc908 bb67ae8584caa73b 3c6ef372fe94f82b a54ff53a5f1d36f1  510e527fade682d1 9b05688c2b3e6c1f 1f83d9abfb41bd6b 5be0cd19137e2179
115  0: 6a09e667f3bcc908 bb67ae8584caa73b 3c6ef372fe94f82b 58cb02347ab51f91  510e527fade682d1 9b05688c2b3e6c1f 1f83d9abfb41bd6b f6afceb8bcfcddf5
116  1: 6a09e667f3bcc908 bb67ae8584caa73b c3d4ebfd48650ffa 58cb02347ab51f91  510e527fade682d1 9b05688c2b3e6c1f 1320f8c9fb872cc0 f6afceb8bcfcddf5
117  6:  b47b4bb1928990e c4875b0c7abc076b af573b02403e89cd b680953951604860  5a83cb3e80050e82 5a6c781f54dcc00c 96f60209b6dc35ba 745aca4a342ed2e2
118  7: 8093d195e0054fa3 c4875b0c7abc076b af573b02403e89cd b680953951604860  86f67263a0f0ec0a 5a6c781f54dcc00c 96f60209b6dc35ba 745aca4a342ed2e2
119  8: 8093d195e0054fa3 c4875b0c7abc076b af573b02403e89cd d0403c398fc40002  86f67263a0f0ec0a 5a6c781f54dcc00c 96f60209b6dc35ba f1eca5544cb89225
120  9: 8093d195e0054fa3 c4875b0c7abc076b    91f460be46c52 d0403c398fc40002  86f67263a0f0ec0a 5a6c781f54dcc00c 81782d4a5db48f03 f1eca5544cb89225
121 14: 475975b91a7a462c fa967eed85a08028 44249631255d2ca0 5e41214388186c14  db0a9963f80c2eaa 874bfe5f6aae9f2f 860acf9effba6f61 cdf3bff2883fc9d9
122 15:  ae07c86b1181c75 fa967eed85a08028 44249631255d2ca0 5e41214388186c14  a77b7c035dd4c161 874bfe5f6aae9f2f 860acf9effba6f61 cdf3bff2883fc9d9
123 16:  ae07c86b1181c75 fa967eed85a08028 44249631255d2ca0 2deecc6b39d64d78  a77b7c035dd4c161 874bfe5f6aae9f2f 860acf9effba6f61 caf81a425d800537
124 17:  ae07c86b1181c75 fa967eed85a08028 f47e8353f8047455 2deecc6b39d64d78  a77b7c035dd4c161 874bfe5f6aae9f2f 4725be249ad19e6b caf81a425d800537
125 18:  ae07c86b1181c75 29695fd88d81dbd0 f47e8353f8047455 2deecc6b39d64d78  a77b7c035dd4c161 3c4b4104168e3edb 4725be249ad19e6b caf81a425d800537
126 30:  9068a4e255a0dac 4c4fbbb75f1873a6 74bf40f869094c63 e62349090f47d30a  eab4a9e5771b8d09 73e025d91b9efea3 f0aec2fe1437f085  fcdf99710f21584
127 31: ff4d3f1f0d46a736 4c4fbbb75f1873a6 74bf40f869094c63 e62349090f47d30a  3cd388e119e8162e 73e025d91b9efea3 f0aec2fe1437f085  fcdf99710f21584
128 32: ff4d3f1f0d46a736 4c4fbbb75f1873a6 74bf40f869094c63 e1034573654a106f  3cd388e119e8162e 73e025d91b9efea3 f0aec2fe1437f085 a0509015ca08c8d4
129 33: ff4d3f1f0d46a736 4c4fbbb75f1873a6 efabbd8bf47c041a e1034573654a106f  3cd388e119e8162e 73e025d91b9efea3 60d4e6995ed91fe6 a0509015ca08c8d4
130 34: ff4d3f1f0d46a736  fbae670fa780fd3 efabbd8bf47c041a e1034573654a106f  3cd388e119e8162e 2c59ec7743632621 60d4e6995ed91fe6 a0509015ca08c8d4
131 46: cc5100997f5710f2 f61e672694de2d67  21fbadbabab5ac6 c47c9d5c7ea8a234  35d7e7f41defcbd5 c6bc35740d8daa9a e95c2a57572d64d9 858d832ae0e8911c
132 47: 6b69fc1bb482feac f61e672694de2d67  21fbadbabab5ac6 c47c9d5c7ea8a234  35264334c03ac8ad c6bc35740d8daa9a e95c2a57572d64d9 858d832ae0e8911c
133 48: 6b69fc1bb482feac f61e672694de2d67  21fbadbabab5ac6 271580ed6c3e5650  35264334c03ac8ad c6bc35740d8daa9a e95c2a57572d64d9 571f323d96b3a047
134 49: 6b69fc1bb482feac f61e672694de2d67 dfe091dab182e645 271580ed6c3e5650  35264334c03ac8ad c6bc35740d8daa9a ca9bd862c5050918 571f323d96b3a047
135 50: 6b69fc1bb482feac  7a0d8ef821c5e1a dfe091dab182e645 271580ed6c3e5650  35264334c03ac8ad 813a43dd2c502043 ca9bd862c5050918 571f323d96b3a047
136 62: 4797cde4ed370692 a81dedbb9f19e643 cfcd928c5424e2b6 3857dfd2fc37d3ba  2c074484ef1eac8c 84058865d60a05fa  9aee5bda1644de5 a6af4e9c9f807e51
137 63: ab44e86276478d85 a81dedbb9f19e643 cfcd928c5424e2b6 3857dfd2fc37d3ba  cd881ee59ca6bc53 84058865d60a05fa  9aee5bda1644de5 a6af4e9c9f807e51
138 64: ab44e86276478d85 a81dedbb9f19e643 cfcd928c5424e2b6 aa84b086688a5c45  cd881ee59ca6bc53 84058865d60a05fa  9aee5bda1644de5 5a806d7e9821a501
139 65: ab44e86276478d85 a81dedbb9f19e643 3b5fed0d6a1f96e1 aa84b086688a5c45  cd881ee59ca6bc53 84058865d60a05fa eeb9c21bb0102598 5a806d7e9821a501
140 66: ab44e86276478d85 29fab5a7bff53366 3b5fed0d6a1f96e1 aa84b086688a5c45  cd881ee59ca6bc53 46c4210ab2cc155d eeb9c21bb0102598 5a806d7e9821a501
141 78: 995019a6ff3ba3de 10d9c4c4295599f6 d67806db8b148677 654ef9abec389ca9  c8960e6be864b916 9bb4d39778c07f9e 25c96a7768fb2aa3 ceb9fc3691ce8326
142 79: 73a54f399fa4b1b2 10d9c4c4295599f6 d67806db8b148677 654ef9abec389ca9  d08446aa79693ed7 9bb4d39778c07f9e 25c96a7768fb2aa3 ceb9fc3691ce8326
143 99: ddaf35a193617aba cc417349ae204131 12e6fa4e89a97ea2  a9eeee64b55d39a  2192992a274fc1a8 36ba3c23a3feebbd 454d4423643ce80e 2a9ac94fa54ca49f
144 */