Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ type transport struct {

func (t *transport) RoundTrip(req *http.Request) (*http.Response, error) {
if t.sign {
req = req.Clone(req.Context())
// Signing does not read or close the body
err := t.signer.Sign(req)
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions keyutil/jwk.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ func (ec *jwkEC) PublicKey() (*ecdsa.PublicKey, error) {
return nil, err
}

if len(ec.X.Bytes()) != byteLen {
return nil, fmt.Errorf("X coordinate must be %d byte length for curve '%s'. Got '%d'", byteLen, ec.Curve, len(ec.X.Bytes()))
if ec.X.BitLen() > byteLen*8 {
return nil, fmt.Errorf("X coordinate exceeds %d bytes for curve '%s'", byteLen, ec.Curve)
}
if len(ec.Y.Bytes()) != byteLen {
return nil, fmt.Errorf("Y coordinate must be %d byte length for curve '%s'. Got '%d'", byteLen, ec.Curve, len(ec.Y.Bytes()))
if ec.Y.BitLen() > byteLen*8 {
return nil, fmt.Errorf("Y coordinate exceeds %d bytes for curve '%s'", byteLen, ec.Curve)
}

return &ecdsa.PublicKey{
Expand Down Expand Up @@ -249,8 +249,8 @@ func (ec *jwkEC) PrivateKey() (*ecdsa.PrivateKey, error) {
return nil, err
}

if len(ec.D.Bytes()) != byteLen {
return nil, fmt.Errorf("D coordinate must be %d byte length for curve '%s'. Got '%d'", byteLen, ec.Curve, len(ec.D.Bytes()))
if ec.D.BitLen() > byteLen*8 {
return nil, fmt.Errorf("D coordinate exceeds %d bytes for curve '%s'", byteLen, ec.Curve)
}

return &ecdsa.PrivateKey{
Expand Down
Loading