...

Source file src/github.com/ProtonMail/go-crypto/openpgp/errors/errors.go

Documentation: github.com/ProtonMail/go-crypto/openpgp/errors

     1  // Copyright 2010 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Package errors contains common error types for the OpenPGP packages.
     6  package errors // import "github.com/ProtonMail/go-crypto/openpgp/errors"
     7  
     8  import (
     9  	"strconv"
    10  )
    11  
    12  // A StructuralError is returned when OpenPGP data is found to be syntactically
    13  // invalid.
    14  type StructuralError string
    15  
    16  func (s StructuralError) Error() string {
    17  	return "openpgp: invalid data: " + string(s)
    18  }
    19  
    20  // UnsupportedError indicates that, although the OpenPGP data is valid, it
    21  // makes use of currently unimplemented features.
    22  type UnsupportedError string
    23  
    24  func (s UnsupportedError) Error() string {
    25  	return "openpgp: unsupported feature: " + string(s)
    26  }
    27  
    28  // InvalidArgumentError indicates that the caller is in error and passed an
    29  // incorrect value.
    30  type InvalidArgumentError string
    31  
    32  func (i InvalidArgumentError) Error() string {
    33  	return "openpgp: invalid argument: " + string(i)
    34  }
    35  
    36  // SignatureError indicates that a syntactically valid signature failed to
    37  // validate.
    38  type SignatureError string
    39  
    40  func (b SignatureError) Error() string {
    41  	return "openpgp: invalid signature: " + string(b)
    42  }
    43  
    44  var ErrMDCHashMismatch error = SignatureError("MDC hash mismatch")
    45  var ErrMDCMissing error = SignatureError("MDC packet not found")
    46  
    47  type signatureExpiredError int
    48  
    49  func (se signatureExpiredError) Error() string {
    50  	return "openpgp: signature expired"
    51  }
    52  
    53  var ErrSignatureExpired error = signatureExpiredError(0)
    54  
    55  type keyExpiredError int
    56  
    57  func (ke keyExpiredError) Error() string {
    58  	return "openpgp: key expired"
    59  }
    60  
    61  var ErrKeyExpired error = keyExpiredError(0)
    62  
    63  type keyIncorrectError int
    64  
    65  func (ki keyIncorrectError) Error() string {
    66  	return "openpgp: incorrect key"
    67  }
    68  
    69  var ErrKeyIncorrect error = keyIncorrectError(0)
    70  
    71  // KeyInvalidError indicates that the public key parameters are invalid
    72  // as they do not match the private ones
    73  type KeyInvalidError string
    74  
    75  func (e KeyInvalidError) Error() string {
    76  	return "openpgp: invalid key: " + string(e)
    77  }
    78  
    79  type unknownIssuerError int
    80  
    81  func (unknownIssuerError) Error() string {
    82  	return "openpgp: signature made by unknown entity"
    83  }
    84  
    85  var ErrUnknownIssuer error = unknownIssuerError(0)
    86  
    87  type keyRevokedError int
    88  
    89  func (keyRevokedError) Error() string {
    90  	return "openpgp: signature made by revoked key"
    91  }
    92  
    93  var ErrKeyRevoked error = keyRevokedError(0)
    94  
    95  type UnknownPacketTypeError uint8
    96  
    97  func (upte UnknownPacketTypeError) Error() string {
    98  	return "openpgp: unknown packet type: " + strconv.Itoa(int(upte))
    99  }
   100  
   101  // AEADError indicates that there is a problem when initializing or using a
   102  // AEAD instance, configuration struct, nonces or index values.
   103  type AEADError string
   104  
   105  func (ae AEADError) Error() string {
   106  	return "openpgp: aead error: " + string(ae)
   107  }
   108  
   109  // ErrDummyPrivateKey results when operations are attempted on a private key
   110  // that is just a dummy key. See
   111  // https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob;f=doc/DETAILS;h=fe55ae16ab4e26d8356dc574c9e8bc935e71aef1;hb=23191d7851eae2217ecdac6484349849a24fd94a#l1109
   112  type ErrDummyPrivateKey string
   113  
   114  func (dke ErrDummyPrivateKey) Error() string {
   115  	return "openpgp: s2k GNU dummy key: " + string(dke)
   116  }
   117  

View as plain text