{"modulePath":"code.cloudfoundry.org/cli","version":"v6.1.1+incompatible","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package openpgp\n\nPackage openpgp implements high level operations on OpenPGP messages.\n\n## Variables\n\n```go\nvar PrivateKeyType = \"PGP PRIVATE KEY BLOCK\"\n```\nPrivateKeyType is the armor type for a PGP private key.\n\n```go\nvar PublicKeyType = \"PGP PUBLIC KEY BLOCK\"\n```\nPublicKeyType is the armor type for a PGP public key.\n\n```go\nvar SignatureType = \"PGP SIGNATURE\"\n```\nSignatureType is the armor type for a PGP signature.\n\n## Functions\n\n```go\nfunc ArmoredDetachSign(w io.Writer, signer *Entity, message io.Reader, config *packet.Config) (err error)\n```\nArmoredDetachSign signs message with the private key from signer (which must already have been decrypted) and writes an armored signature to w. If config is nil, sensible defaults will be used.\n\n```go\nfunc ArmoredDetachSignText(w io.Writer, signer *Entity, message io.Reader, config *packet.Config) error\n```\nArmoredDetachSignText signs message (after canonicalising the line endings) with the private key from signer (which must already have been decrypted) and writes an armored signature to w. If config is nil, sensible defaults will be used.\n\n```go\nfunc DetachSign(w io.Writer, signer *Entity, message io.Reader, config *packet.Config) error\n```\nDetachSign signs message with the private key from signer (which must already have been decrypted) and writes the signature to w. If config is nil, sensible defaults will be used.\n\n```go\nfunc DetachSignText(w io.Writer, signer *Entity, message io.Reader, config *packet.Config) error\n```\nDetachSignText signs message (after canonicalising the line endings) with the private key from signer (which must already have been decrypted) and writes the signature to w. If config is nil, sensible defaults will be used.\n\n```go\nfunc Encrypt(ciphertext io.Writer, to []*Entity, signed *Entity, hints *FileHints, config *packet.Config) (plaintext io.WriteCloser, err error)\n```\nEncrypt encrypts a message to a number of recipients and, optionally, signs it. hints contains optional information, that is also encrypted, that aids the recipients in processing the message. The resulting WriteCloser must be closed after the contents of the file have been written. If config is nil, sensible defaults will be used.\n\n```go\nfunc NewCanonicalTextHash(h hash.Hash) hash.Hash\n```\nNewCanonicalTextHash reformats text written to it into the canonical form and then applies the hash h.  See RFC 4880, section 5.2.1.\n\n```go\nfunc SymmetricallyEncrypt(ciphertext io.Writer, passphrase []byte, hints *FileHints, config *packet.Config) (plaintext io.WriteCloser, err error)\n```\nSymmetricallyEncrypt acts like gpg -c: it encrypts a file with a passphrase. The resulting WriteCloser must be closed after the contents of the file have been written. If config is nil, sensible defaults will be used.\n\n## Types\n\n```go\ntype Entity struct {\n\tPrimaryKey *packet.PublicKey\n\tPrivateKey *packet.PrivateKey\n\tIdentities map[string]*Identity // indexed by Identity.Name\n\tSubkeys    []Subkey\n}\n```\nAn Entity represents the components of an OpenPGP key: a primary public key (which must be a signing key), one or more identities claimed by that key, and zero or more subkeys, which may be encryption keys.\n\n```go\nfunc CheckArmoredDetachedSignature(keyring KeyRing, signed, signature io.Reader) (signer *Entity, err error)\n```\nCheckArmoredDetachedSignature performs the same actions as CheckDetachedSignature but expects the signature to be armored.\n\n```go\nfunc CheckDetachedSignature(keyring KeyRing, signed, signature io.Reader) (signer *Entity, err error)\n```\nCheckDetachedSignature takes a signed file and a detached signature and returns the signer if the signature is valid. If the signer isn't known, ErrUnknownIssuer is returned.\n\n```go\nfunc NewEntity(name, comment, email string, config *packet.Config) (*Entity, error)\n```\nNewEntity returns an Entity that contains a fresh RSA/RSA keypair with a single identity composed of the given full name, comment and email, any of which may be empty but must not contain any of \"()\\\u003c\u003e\\\\x00\". If config is nil, sensible defaults will be used.\n\n```go\nfunc ReadEntity(packets *packet.Reader) (*Entity, error)\n```\nReadEntity reads an entity (public key, identities, subkeys etc) from the given Reader.\n\n```go\nfunc (e *Entity) Serialize(w io.Writer) error\n```\nSerialize writes the public part of the given Entity to w. (No private key material will be output).\n\n```go\nfunc (e *Entity) SerializePrivate(w io.Writer, config *packet.Config) (err error)\n```\nSerializePrivate serializes an Entity, including private key material, to the given Writer. For now, it must only be used on an Entity returned from NewEntity. If config is nil, sensible defaults will be used.\n\n```go\nfunc (e *Entity) SignIdentity(identity string, signer *Entity, config *packet.Config) error\n```\nSignIdentity adds a signature to e, from signer, attesting that identity is associated with e. The provided identity must already be an element of e.Identities and the private key of signer must have been decrypted if necessary. If config is nil, sensible defaults will be used.\n\n```go\ntype EntityList []*Entity\n```\nAn EntityList contains one or more Entities.\n\n```go\nfunc ReadArmoredKeyRing(r io.Reader) (EntityList, error)\n```\nReadArmoredKeyRing reads one or more public/private keys from an armor keyring file.\n\n```go\nfunc ReadKeyRing(r io.Reader) (el EntityList, err error)\n```\nReadKeyRing reads one or more public/private keys. Unsupported keys are ignored as long as at least a single valid key is found.\n\n```go\nfunc (el EntityList) DecryptionKeys() (keys []Key)\n```\nDecryptionKeys returns all private keys that are valid for decryption.\n\n```go\nfunc (el EntityList) KeysById(id uint64) (keys []Key)\n```\nKeysById returns the set of keys that have the given key id.\n\n```go\ntype FileHints struct {\n\t// IsBinary can be set to hint that the contents are binary data.\n\tIsBinary bool\n\t// FileName hints at the name of the file that should be written. It's\n\t// truncated to 255 bytes if longer. It may be empty to suggest that the\n\t// file should not be written to disk. It may be equal to \"_CONSOLE\" to\n\t// suggest the data should not be written to disk.\n\tFileName string\n\t// ModTime contains the modification time of the file, or the zero time if not applicable.\n\tModTime time.Time\n}\n```\nFileHints contains metadata about encrypted files. This metadata is, itself, encrypted.\n\n```go\ntype Identity struct {\n\tName          string // by convention, has the form \"Full Name (comment) \u003cemail@example.com\u003e\"\n\tUserId        *packet.UserId\n\tSelfSignature *packet.Signature\n\tSignatures    []*packet.Signature\n}\n```\nAn Identity represents an identity claimed by an Entity and zero or more assertions by other entities about that claim.\n\n```go\ntype Key struct {\n\tEntity        *Entity\n\tPublicKey     *packet.PublicKey\n\tPrivateKey    *packet.PrivateKey\n\tSelfSignature *packet.Signature\n}\n```\nA Key identifies a specific public key in an Entity. This is either the Entity's primary key or a subkey.\n\n```go\ntype KeyRing interface {\n\t// KeysById returns the set of keys that have the given key id.\n\tKeysById(id uint64) []Key\n\t// DecryptionKeys returns all private keys that are valid for\n\t// decryption.\n\tDecryptionKeys() []Key\n}\n```\nA KeyRing provides access to public and private keys.\n\n```go\ntype MessageDetails struct {\n\tIsEncrypted              bool                // true if the message was encrypted.\n\tEncryptedToKeyIds        []uint64            // the list of recipient key ids.\n\tIsSymmetricallyEncrypted bool                // true if a passphrase could have decrypted the message.\n\tDecryptedWith            Key                 // the private key used to decrypt the message, if any.\n\tIsSigned                 bool                // true if the message is signed.\n\tSignedByKeyId            uint64              // the key id of the signer, if any.\n\tSignedBy                 *Key                // the key of the signer, if available.\n\tLiteralData              *packet.LiteralData // the metadata of the contents\n\tUnverifiedBody           io.Reader           // the contents of the message.\n\n\t// If IsSigned is true and SignedBy is non-zero then the signature will\n\t// be verified as UnverifiedBody is read. The signature cannot be\n\t// checked until the whole of UnverifiedBody is read so UnverifiedBody\n\t// must be consumed until EOF before the data can trusted. Even if a\n\t// message isn't signed (or the signer is unknown) the data may contain\n\t// an authentication code that is only checked once UnverifiedBody has\n\t// been consumed. Once EOF has been seen, the following fields are\n\t// valid. (An authentication code failure is reported as a\n\t// SignatureError error when reading from UnverifiedBody.)\n\tSignatureError error             // nil if the signature is good.\n\tSignature      *packet.Signature // the signature packet itself.\n\t// contains filtered or unexported fields\n}\n```\nMessageDetails contains the result of parsing an OpenPGP encrypted and/or signed message.\n\n```go\nfunc ReadMessage(r io.Reader, keyring KeyRing, prompt PromptFunction, config *packet.Config) (md *MessageDetails, err error)\n```\nReadMessage parses an OpenPGP message that may be signed and/or encrypted. The given KeyRing should contain both public keys (for signature verification) and, possibly encrypted, private keys for decrypting. If config is nil, sensible defaults will be used.\n\n```go\ntype PromptFunction func(keys []Key, symmetric bool) ([]byte, error)\n```\nA PromptFunction is used as a callback by functions that may need to decrypt a private key, or prompt for a passphrase. It is called with a list of acceptable, encrypted private keys and a boolean that indicates whether a passphrase is usable. It should either decrypt a private key or return a passphrase to try. If the decrypted private key or given passphrase isn't correct, the function will be called again, forever. Any error returned will be passed up.\n\n```go\ntype Subkey struct {\n\tPublicKey  *packet.PublicKey\n\tPrivateKey *packet.PrivateKey\n\tSig        *packet.Signature\n}\n```\nA Subkey is an additional public key in an Entity. Subkeys can be used for encryption.\n\n","path":"code.cloudfoundry.org/cli/src/code.google.com/p/go.crypto/openpgp","name":"openpgp","synopsis":"Package openpgp implements high level operations on OpenPGP messages.","isRedistributable":true}
