Documentation
¶
Overview ¶
Package pgp provides signed OpenPGP encryption and verified decryption helpers built on github.com/ProtonMail/go-crypto/openpgp.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrBlockTypeInvalid is returned when the armor block type does not match. ErrBlockTypeInvalid = errors.New("BlockType Invalid") // ErrEmptyKeyring is returned when a supplied key block contains no entities. ErrEmptyKeyring = errors.New("pgp: empty keyring") // ErrNotSigned is returned when the decrypted message carries no signature. ErrNotSigned = errors.New("pgp: message is not signed") // ErrUnknownSigner is returned when the signing key is not in the supplied keyrings. ErrUnknownSigner = errors.New("pgp: unknown signer") // ErrPrivateKeyMissing is returned when no decryptable private key is available. ErrPrivateKeyMissing = errors.New("pgp: private key unavailable") )
Functions ¶
func DecryptBytes ¶
func DecryptBytes(encBytes, privateKey, passphrase, signerPublicKey []byte, blockType string) ([]byte, error)
DecryptBytes decrypts armored ciphertext and verifies the signature.
- encBytes: armored ciphertext
- privateKey: armored recipient private key
- passphrase: passphrase for privateKey (may be nil if unencrypted)
- signerPublicKey: armored sender public key; when empty, signatures are verified against the entities in privateKey (self-signed messages)
- blockType: expected armor block type
It returns an error when the message is unsigned, the signature is invalid, or the signer is unknown.
func EncryptBytes ¶
func EncryptBytes(origBytes, recipientPublicKey, signerPrivateKey, signerPassphrase []byte, blockType string) ([]byte, error)
EncryptBytes encrypts origBytes to every entity in the armored recipientPublicKey block and signs the message with the first entity in signerPrivateKey.
- origBytes: plaintext
- recipientPublicKey: armored public key(s)
- signerPrivateKey: armored private key used to sign (required)
- signerPassphrase: passphrase for signerPrivateKey (may be nil if unencrypted)
- blockType: armor block type label, e.g. "PGP MESSAGE"
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.