@@ -81,6 +81,20 @@ func SHA512(p []byte) (sum [64]byte) {
81
81
return
82
82
}
83
83
84
+ func SHA512_224 (p []byte ) (sum [28 ]byte ) {
85
+ if ! hashOneShot (crypto .SHA512_224 , p , sum [:]) {
86
+ panic ("openssl: SHA512 failed" )
87
+ }
88
+ return
89
+ }
90
+
91
+ func SHA512_256 (p []byte ) (sum [32 ]byte ) {
92
+ if ! hashOneShot (crypto .SHA512_256 , p , sum [:]) {
93
+ panic ("openssl: SHA512_256 failed" )
94
+ }
95
+ return
96
+ }
97
+
84
98
// cacheHashSupported is a cache of crypto.Hash support.
85
99
var cacheHashSupported sync.Map
86
100
@@ -171,6 +185,16 @@ func NewSHA512() hash.Hash {
171
185
return newEvpHash (crypto .SHA512 )
172
186
}
173
187
188
+ // NewSHA512_224 returns a new SHA512_224 hash.
189
+ func NewSHA512_224 () hash.Hash {
190
+ return newEvpHash (crypto .SHA512_224 )
191
+ }
192
+
193
+ // NewSHA512_256 returns a new SHA512_256 hash.
194
+ func NewSHA512_256 () hash.Hash {
195
+ return newEvpHash (crypto .SHA512_256 )
196
+ }
197
+
174
198
// NewSHA3_224 returns a new SHA3-224 hash.
175
199
func NewSHA3_224 () hash.Hash {
176
200
return newEvpHash (crypto .SHA3_224 )
@@ -383,6 +407,10 @@ func (d *evpHash) AppendBinary(buf []byte) ([]byte, error) {
383
407
appender = (* sha512State )(state )
384
408
case crypto .SHA512 :
385
409
appender = (* sha512State )(state )
410
+ case crypto .SHA512_224 :
411
+ appender = (* sha512State )(state )
412
+ case crypto .SHA512_256 :
413
+ appender = (* sha512State )(state )
386
414
default :
387
415
panic ("openssl: unsupported hash function: " + strconv .Itoa (int (d .alg .ch )))
388
416
}
@@ -421,6 +449,10 @@ func (d *evpHash) UnmarshalBinary(b []byte) error {
421
449
unmarshaler = (* sha512State )(state )
422
450
case crypto .SHA512 :
423
451
unmarshaler = (* sha512State )(state )
452
+ case crypto .SHA512_224 :
453
+ unmarshaler = (* sha512State )(state )
454
+ case crypto .SHA512_256 :
455
+ unmarshaler = (* sha512State )(state )
424
456
default :
425
457
panic ("openssl: unsupported hash function: " + strconv .Itoa (int (d .alg .ch )))
426
458
}
0 commit comments