Skip to content

Commit d2be460

Browse files
committed
fix: bug in validate() with length 0 slice
1 parent b745bfa commit d2be460

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

key.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,13 +476,13 @@ func (k Key) validate(op KeyOp) error {
476476
}
477477

478478
// If present, x, y, and d must match the expected size.
479-
if len(x) > 0 && len(x) != size {
479+
if x != nil && len(x) != size {
480480
return errCoordSizeMismatch
481481
}
482-
if len(y) > 0 && len(y) != size {
482+
if y != nil && len(y) != size {
483483
return errCoordSizeMismatch
484484
}
485-
if len(d) > 0 && len(d) != size {
485+
if d != nil && len(d) != size {
486486
return errCoordSizeMismatch
487487
}
488488
}
@@ -513,10 +513,10 @@ func (k Key) validate(op KeyOp) error {
513513
// If the curve size is known, validate the length of each parameter if present.
514514
if size := keySizeOKP(crv); size > 0 {
515515
// If present, x and d must match the expected size.
516-
if len(x) > 0 && len(x) != size {
516+
if x != nil && len(x) != size {
517517
return errCoordSizeMismatch
518518
}
519-
if len(d) > 0 && len(d) != size {
519+
if d != nil && len(d) != size {
520520
return errCoordSizeMismatch
521521
}
522522
}

0 commit comments

Comments
 (0)