@@ -372,11 +372,19 @@ func (h *evpHash) Clone() (HashCloner, error) {
372
372
return h2 , nil
373
373
}
374
374
375
- var errHashNotMarshallable = errors .New ("openssl: hash state is not marshallable" )
375
+ type errMarshallUnsupported struct {}
376
+
377
+ func (e errMarshallUnsupported ) Error () string {
378
+ return "cryptokit: hash state is not marshallable"
379
+ }
380
+
381
+ func (e errMarshallUnsupported ) Unwrap () error {
382
+ return errors .ErrUnsupported
383
+ }
376
384
377
385
func (d * evpHash ) MarshalBinary () ([]byte , error ) {
378
386
if ! d .alg .marshallable {
379
- return nil , errHashNotMarshallable
387
+ return nil , errMarshallUnsupported {}
380
388
}
381
389
buf := make ([]byte , 0 , d .alg .marshalledSize )
382
390
return d .AppendBinary (buf )
@@ -385,7 +393,7 @@ func (d *evpHash) MarshalBinary() ([]byte, error) {
385
393
func (d * evpHash ) AppendBinary (buf []byte ) ([]byte , error ) {
386
394
defer runtime .KeepAlive (d )
387
395
if ! d .alg .marshallable {
388
- return nil , errHashNotMarshallable
396
+ return nil , errMarshallUnsupported {}
389
397
}
390
398
d .init ()
391
399
switch d .alg .provider {
@@ -402,7 +410,7 @@ func (d *evpHash) UnmarshalBinary(b []byte) error {
402
410
defer runtime .KeepAlive (d )
403
411
d .init ()
404
412
if ! d .alg .marshallable {
405
- return errHashNotMarshallable
413
+ return errMarshallUnsupported {}
406
414
}
407
415
if len (b ) < len (d .alg .magic ) || string (b [:len (d .alg .magic )]) != d .alg .magic {
408
416
return errors .New ("openssl: invalid hash state identifier" )
0 commit comments