return "crypto/dsa: invalid public key"
}
-// InvalidPublicKeyError results when a public key is not usable by this code.
+// ErrInvalidPublicKey results when a public key is not usable by this code.
// FIPS is quite strict about the format of DSA keys, but other code may be
// less so. Thus, when using keys which may have been generated by other code,
// this error must be handled.
-var InvalidPublicKeyError = invalidPublicKeyError(0)
+var ErrInvalidPublicKey error = invalidPublicKeyError(0)
// ParameterSizes is a enumeration of the acceptable bit lengths of the primes
// in a set of DSA parameters. See FIPS 186-3, section 4.2.
n := priv.Q.BitLen()
if n&7 != 0 {
- err = InvalidPublicKeyError
+ err = ErrInvalidPublicKey
return
}
n >>= 3
return "the given key was incorrect"
}
-var KeyIncorrectError = keyIncorrectError(0)
+var ErrKeyIncorrect error = keyIncorrectError(0)
type unknownIssuerError int
return "signature make by unknown entity"
}
-var UnknownIssuerError = unknownIssuerError(0)
+var ErrUnknownIssuer error = unknownIssuerError(0)
type UnknownPacketTypeError uint8
continue
}
decrypted, err = se.Decrypt(pk.encryptedKey.CipherFunc, pk.encryptedKey.Key)
- if err != nil && err != errors.KeyIncorrectError {
+ if err != nil && err != errors.ErrKeyIncorrect {
return nil, err
}
if decrypted != nil {
}
if len(candidates) == 0 && len(symKeys) == 0 {
- return nil, errors.KeyIncorrectError
+ return nil, errors.ErrKeyIncorrect
}
if prompt == nil {
- return nil, errors.KeyIncorrectError
+ return nil, errors.ErrKeyIncorrect
}
passphrase, err := prompt(candidates, len(symKeys) != 0)
err = s.Decrypt(passphrase)
if err == nil && !s.Encrypted {
decrypted, err = se.Decrypt(s.CipherFunc, s.Key)
- if err != nil && err != errors.KeyIncorrectError {
+ if err != nil && err != errors.ErrKeyIncorrect {
return nil, err
}
if decrypted != nil {
}
// CheckDetachedSignature takes a signed file and a detached signature and
-// returns the signer if the signature is valid. If the signer isn't know,
-// UnknownIssuerError is returned.
+// returns the signer if the signature is valid. If the signer isn't known,
+// ErrUnknownIssuer is returned.
func CheckDetachedSignature(keyring KeyRing, signed, signature io.Reader) (signer *Entity, err error) {
p, err := packet.Read(signature)
if err != nil {
keys := keyring.KeysById(*sig.IssuerKeyId)
if len(keys) == 0 {
- return nil, errors.UnknownIssuerError
+ return nil, errors.ErrUnknownIssuer
}
h, wrappedHash, err := hashForSignature(sig.Hash, sig.SigType)
return
}
- return nil, errors.UnknownIssuerError
+ return nil, errors.ErrUnknownIssuer
}
// CheckArmoredDetachedSignature performs the same actions as
prompt := func(keys []Key, symmetric bool) ([]byte, error) {
if symmetric {
t.Errorf("prompt: message was marked as symmetrically encrypted")
- return nil, errors.KeyIncorrectError
+ return nil, errors.ErrKeyIncorrect
}
if len(keys) == 0 {
t.Error("prompt: no keys requested")
- return nil, errors.KeyIncorrectError
+ return nil, errors.ErrKeyIncorrect
}
err := keys[0].PrivateKey.Decrypt([]byte("passphrase"))
if err != nil {
t.Errorf("prompt: error decrypting key: %s", err)
- return nil, errors.KeyIncorrectError
+ return nil, errors.ErrKeyIncorrect
}
return nil, nil