Documentation
¶
Index ¶
- func EncryptAndSign(r io.Reader, recipientPubKeys openpgp.EntityList, ...) (data, signature string, err error)
- func GenerateRSAKeyPair(bits int, name, comment, email string) (privKey string, pubKey string, err error)
- func ReadSigner(r io.Reader) (keyID string, err error)
- func Version() string
- type KeyIDs
- type MessageMetadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncryptAndSign ¶
func EncryptAndSign(r io.Reader, recipientPubKeys openpgp.EntityList, signingPrivKey *openpgp.Entity) (data, signature string, err error)
EncryptAndSign Takes an IO stream, recipient public keys, and a non-passworded signing private key, then encrypts the payload and signs the result. The order is important. If it's signed first, THEN encrypted, the signature can't be validated without the decryption key This operation is destructive - the reader is no longer accessible afterwards
func GenerateRSAKeyPair ¶
func GenerateRSAKeyPair(bits int, name, comment, email string) (privKey string, pubKey string, err error)
GenerateRSAKeyPair takes the bitlength and spits out a base64 encoded private/public RSA keypair
func ReadSigner ¶
ReadSigner returns the long key ID of whoever signed the message
Types ¶
type KeyIDs ¶
type KeyIDs struct {
PrimaryKeyID string `json:"primary_key_id"`
SubKeyIDs []string `json:"subkey_ids"`
UserID packet.UserId `json:"user_id"`
}
KeyIDs is the public key metadata container
func DecodePublicKey ¶
DecodePublicKey returns metadata about a public key
type MessageMetadata ¶
type MessageMetadata struct {
IsEncrypted bool // true if the message was encrypted.
EncryptedToKeyIds []string // the list of recipient key ids.
IsSymmetricallyEncrypted bool // true if a passphrase could have decrypted the message.
IsSigned bool // true if the message is signed.
SignedByKeyID string // the key id of the signer, if any.
// If IsSigned is true and SignedBy is non-zero then the signature will
// be verified as UnverifiedBody is read. The signature cannot be
// checked until the whole of UnverifiedBody is read so UnverifiedBody
// must be consumed until EOF before the data can be trusted. Even if a
// message isn't signed (or the signer is unknown) the data may contain
// an authentication code that is only checked once UnverifiedBody has
// been consumed. Once EOF has been seen, the following fields are
// valid. (An authentication code failure is reported as a
// SignatureError error when reading from UnverifiedBody.)
SignatureError error // nil if the signature is good.
Signature *packet.Signature // the signature packet itself, if v4 (default)
SignatureV3 *packet.SignatureV3 // the signature packet if it is a v2 or v3 signature
}
MessageMetadata contains the result of parsing an OpenPGP encrypted and/or signed message.
func ReadRecipients ¶
func ReadRecipients(r io.Reader) (md *MessageMetadata, err error)
ReadRecipients parses an OpenPGP message that may be signed and/or encrypted. An encrypted & signed message cannot be signature-validated without the decryption key