]> Cypherpunks repositories - gostls13.git/commitdiff
crypto: rename some FooError to ErrFoo
authorBrad Fitzpatrick <bradfitz@golang.org>
Tue, 24 Jan 2012 16:32:43 +0000 (08:32 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 24 Jan 2012 16:32:43 +0000 (08:32 -0800)
Also, add an explicit error type when the right hand side is an unexported
function.

R=golang-dev, gri, rogpeppe, agl, rsc
CC=golang-dev
https://golang.org/cl/5564048

src/pkg/crypto/dsa/dsa.go
src/pkg/crypto/openpgp/errors/errors.go
src/pkg/crypto/openpgp/packet/symmetrically_encrypted.go
src/pkg/crypto/openpgp/read.go
src/pkg/crypto/openpgp/read_test.go

index be478468455b1178b195fbf2a8186cd79c8291e5..7aaad1ca19954e53f07cebd14426795125efafeb 100644 (file)
@@ -35,11 +35,11 @@ func (invalidPublicKeyError) Error() string {
        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.
@@ -194,7 +194,7 @@ func Sign(rand io.Reader, priv *PrivateKey, hash []byte) (r, s *big.Int, err err
 
        n := priv.Q.BitLen()
        if n&7 != 0 {
-               err = InvalidPublicKeyError
+               err = ErrInvalidPublicKey
                return
        }
        n >>= 3
index c434b764c9b2a621814be42ef537ce8aa5a44b63..b9016bd42df6f400fd754a3211c8f1fa8005f72c 100644 (file)
@@ -47,7 +47,7 @@ func (ki keyIncorrectError) Error() string {
        return "the given key was incorrect"
 }
 
-var KeyIncorrectError = keyIncorrectError(0)
+var ErrKeyIncorrect error = keyIncorrectError(0)
 
 type unknownIssuerError int
 
@@ -55,7 +55,7 @@ func (unknownIssuerError) Error() string {
        return "signature make by unknown entity"
 }
 
-var UnknownIssuerError = unknownIssuerError(0)
+var ErrUnknownIssuer error = unknownIssuerError(0)
 
 type UnknownPacketTypeError uint8
 
index e99a23b9fb205ecc8f50152708b9b80286fe002b..f2133ac27fad3d9eed16a082dcb6e0b6aa2e6e51 100644 (file)
@@ -71,7 +71,7 @@ func (se *SymmetricallyEncrypted) Decrypt(c CipherFunction, key []byte) (io.Read
 
        s := cipher.NewOCFBDecrypter(c.new(key), se.prefix, ocfbResync)
        if s == nil {
-               return nil, errors.KeyIncorrectError
+               return nil, errors.ErrKeyIncorrect
        }
 
        plaintext := cipher.StreamReader{S: s, R: se.contents}
index 1d2343470412309278305b952cbec34b818d836f..1a6e27c5a68d16e89f9fbac8a252b388eabea28e 100644 (file)
@@ -161,7 +161,7 @@ FindKey:
                                        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 {
@@ -179,11 +179,11 @@ FindKey:
                }
 
                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)
@@ -197,7 +197,7 @@ FindKey:
                                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 {
@@ -353,8 +353,8 @@ func (scr *signatureCheckReader) Read(buf []byte) (n int, err error) {
 }
 
 // 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 {
@@ -372,7 +372,7 @@ func CheckDetachedSignature(keyring KeyRing, signed, signature io.Reader) (signe
 
        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)
@@ -399,7 +399,7 @@ func CheckDetachedSignature(keyring KeyRing, signed, signature io.Reader) (signe
                return
        }
 
-       return nil, errors.UnknownIssuerError
+       return nil, errors.ErrUnknownIssuer
 }
 
 // CheckArmoredDetachedSignature performs the same actions as
index d1ecad3817958cff067ffc8ff60771c2da05ec78..1a449f5d3eb657eb036f433151daccf5de1ed199 100644 (file)
@@ -161,18 +161,18 @@ func TestSignedEncryptedMessage(t *testing.T) {
                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