Skip to content

Commit

Permalink
fix ES signature length (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
cristaloleg authored Jul 31, 2020
1 parent ee74a57 commit f6b9324
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions algo_es.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (h esAlg) Algorithm() Algorithm {
}

func (h esAlg) SignSize() int {
return 2 * h.curveBits
return (h.privateKey.Curve.Params().BitSize + 7) / 4
}

func (h esAlg) Sign(payload []byte) ([]byte, error) {
Expand All @@ -84,11 +84,7 @@ func (h esAlg) Sign(payload []byte) ([]byte, error) {
return nil, err
}

curveBits := h.privateKey.Curve.Params().BitSize
keyBytes := curveBits / 8
if curveBits%8 > 0 {
keyBytes++
}
keyBytes := h.SignSize() / 2

rBytes, sBytes := r.Bytes(), s.Bytes()
signature := make([]byte, keyBytes*2)
Expand Down

0 comments on commit f6b9324

Please sign in to comment.