Skip to content

Commit

Permalink
Convert key tests to tabular tests (#157)
Browse files Browse the repository at this point in the history
Signed-off-by: qmuntal <[email protected]>
  • Loading branch information
qmuntal authored Jul 10, 2023
1 parent d16fe13 commit c862f87
Show file tree
Hide file tree
Showing 2 changed files with 711 additions and 372 deletions.
13 changes: 9 additions & 4 deletions key.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,10 @@ func NewOKPKey(alg Algorithm, x, d []byte) (*Key, error) {
X: x,
D: d,
}
return key, key.validate(KeyOpInvalid)
if err := key.validate(KeyOpInvalid); err != nil {
return nil, err
}
return key, nil
}

// NewEC2Key returns a Key created using the provided elliptic curve key
Expand All @@ -303,17 +306,19 @@ func NewEC2Key(alg Algorithm, x, y, d []byte) (*Key, error) {
Y: y,
D: d,
}
return key, key.validate(KeyOpInvalid)
if err := key.validate(KeyOpInvalid); err != nil {
return nil, err
}
return key, nil
}

// NewSymmetricKey returns a Key created using the provided Symmetric key
// bytes.
func NewSymmetricKey(k []byte) *Key {
key := &Key{
return &Key{
KeyType: KeyTypeSymmetric,
K: k,
}
return key
}

// NewKeyFromPublic returns a Key created using the provided crypto.PublicKey.
Expand Down
Loading

0 comments on commit c862f87

Please sign in to comment.