File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,11 +33,11 @@ using rmd160_320 = rmd::algorithm<rmd::h160<320>>; // not fully implemented
3333
3434// / bc::system sha algorithm aliases (compressed, vectorized, cached).
3535using sha160 = sha::algorithm<sha::h160>;
36- using sha256_224 = sha::algorithm<sha::h256<224 >>; // not fully implemented
36+ using sha256_224 = sha::algorithm<sha::h256<224 >>;
3737using sha256 = sha::algorithm<sha::h256<>>;
38- using sha512_256 = sha::algorithm<sha::h512<256 >>; // not fully implemented
39- using sha512_224 = sha::algorithm<sha::h512<224 >>; // not fully implemented
40- using sha512_384 = sha::algorithm<sha::h512<384 >>; // not fully implemented
38+ using sha512_256 = sha::algorithm<sha::h512<256 >>;
39+ using sha512_224 = sha::algorithm<sha::h512<224 >>;
40+ using sha512_384 = sha::algorithm<sha::h512<384 >>;
4141using sha512 = sha::algorithm<sha::h512<>>;
4242
4343} // namespace system
Original file line number Diff line number Diff line change @@ -58,13 +58,19 @@ struct k256
5858 };
5959};
6060
61- // Digest 224 changes IV (specialize template).
6261template <size_t Digest = 256 ,
6362 bool_if<Digest == 224 || Digest == 256 > = true >
6463struct h256
6564 : public h<k256, Digest>
6665{
67- using state_t = typename h<k256, Digest>::state_t ;
66+ // Digest 224/256 have unique IV (specialize template).
67+ };
68+
69+ template <>
70+ struct h256 <256 >
71+ : public h<k256, 256 >
72+ {
73+ using state_t = typename h<k256, 256 >::state_t ;
6874
6975 // initial value (H)
7076 static constexpr state_t get
@@ -80,6 +86,26 @@ struct h256
8086 };
8187};
8288
89+ template <>
90+ struct h256 <224 >
91+ : public h<k256, 224 >
92+ {
93+ using state_t = typename h<k256, 224 >::state_t ;
94+
95+ // initial value (H)
96+ static constexpr state_t get
97+ {
98+ 0xc1059ed8 ,
99+ 0x367cd507 ,
100+ 0x3070dd17 ,
101+ 0xf70e5939 ,
102+ 0xffc00b31 ,
103+ 0x68581511 ,
104+ 0x64f98fa7 ,
105+ 0xbefa4fa4
106+ };
107+ };
108+
83109} // namespace sha
84110} // namespace system
85111} // namespace libbitcoin
Original file line number Diff line number Diff line change @@ -84,14 +84,20 @@ struct k512
8484 };
8585};
8686
87- // Digest 224/256/384 change IV (specialize template).
8887template <size_t Digest = 512 ,
8988 bool_if<Digest == 224 || Digest == 256 ||
9089 Digest == 384 || Digest == 512 > = true >
9190struct h512
9291 : public h<k512, Digest>
9392{
94- using state_t = typename h<k512, Digest>::state_t ;
93+ // Digest 224/256/384/512 have unique IV (specialize template).
94+ };
95+
96+ template <>
97+ struct h512 <512 >
98+ : public h<k512, 512 >
99+ {
100+ using state_t = typename h<k512, 512 >::state_t ;
95101
96102 // initial value (H)
97103 static constexpr state_t get
@@ -107,6 +113,66 @@ struct h512
107113 };
108114};
109115
116+ template <>
117+ struct h512 <384 >
118+ : public h<k512, 384 >
119+ {
120+ using state_t = typename h<k512, 384 >::state_t ;
121+
122+ // initial value (H)
123+ static constexpr state_t get
124+ {
125+ 0xcbbb9d5dc1059ed8 ,
126+ 0x629a292a367cd507 ,
127+ 0x9159015a3070dd17 ,
128+ 0x152fecd8f70e5939 ,
129+ 0x67332667ffc00b31 ,
130+ 0x8eb44a8768581511 ,
131+ 0xdb0c2e0d64f98fa7 ,
132+ 0x47b5481dbefa4fa4
133+ };
134+ };
135+
136+ template <>
137+ struct h512 <256 >
138+ : public h<k512, 256 >
139+ {
140+ using state_t = typename h<k512, 256 >::state_t ;
141+
142+ // initial value (H)
143+ static constexpr state_t get
144+ {
145+ 0x22312194fc2bf72c ,
146+ 0x9f555fa3c84c64c2 ,
147+ 0x2393b86b6f53b151 ,
148+ 0x963877195940eabd ,
149+ 0x96283ee2a88effe3 ,
150+ 0xbe5e1e2553863992 ,
151+ 0x2b0199fc2c85b8aa ,
152+ 0x0eb72ddc81c52ca2
153+ };
154+ };
155+
156+ template <>
157+ struct h512 <224 >
158+ : public h<k512, 224 >
159+ {
160+ using state_t = typename h<k512, 224 >::state_t ;
161+
162+ // initial value (H)
163+ static constexpr state_t get
164+ {
165+ 0x8c3d37c819544da2 ,
166+ 0x73e1996689dcd4d6 ,
167+ 0x1dfab7ae32ff9c82 ,
168+ 0x679dd514582f9fcf ,
169+ 0x0f6d2b697bd44da8 ,
170+ 0x77e36f7304c48942 ,
171+ 0x3f9d85a86a1d36c8 ,
172+ 0x1112e6ad91d692a1
173+ };
174+ };
175+
110176} // namespace sha
111177} // namespace system
112178} // namespace libbitcoin
You can’t perform that action at this time.
0 commit comments