Skip to content

Raise an error in FindKey when returning a nil empty key #121

@nicop311

Description

@nicop311

When FindKey methods return an empty (nil) key, they should return an error Error: could not find a key with ID and Label ..., and not return nil, nil.

This should be modified in the following methods:

  • crypto11/keys.go

    Lines 246 to 261 in 9fba4fe

    func (c *Context) FindKeyPair(id []byte, label []byte) (Signer, error) {
    if c.closed.Get() {
    return nil, errClosed
    }
    result, err := c.FindKeyPairs(id, label)
    if err != nil {
    return nil, err
    }
    if len(result) == 0 {
    return nil, nil
    }
    return result[0], nil
    }
  • func (c *Context) FindKeyPairWithAttributes(attributes AttributeSet) (Signer, error) {
  • func (c *Context) FindKey(id []byte, label []byte) (*SecretKey, error) {
  • func (c *Context) FindKeyWithAttributes(attributes AttributeSet) (*SecretKey, error) {
  • func (c *Context) FindPrivateKey(id []byte, label []byte) (PrivateKey, error) {
  • func (c *Context) FindPrivateKeyWithAttributes(attributes AttributeSet) (PrivateKey, error) {
  • crypto11/rsa.go

    Line 213 in 9fba4fe

    func (c *Context) FindRSAPrivateKey(id []byte, label []byte) (RSAPrivateKey, error) {
  • crypto11/rsa.go

    Line 345 in 9fba4fe

    func (c *Context) FindRSAKeyPair(id []byte, label []byte) (SignerDecrypter, error) {

Metadata

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions