package clearsign
import "github.com/ProtonMail/go-crypto/openpgp/clearsign"
Package clearsign generates and processes OpenPGP, clear-signed data. See RFC 4880, section 7.
Clearsigned messages are cryptographically signed, but the contents of the message are kept in plaintext so that it can be read without special tools.
Index ¶
- func Encode(w io.Writer, privateKey *packet.PrivateKey, config *packet.Config) (plaintext io.WriteCloser, err error)
- func EncodeMulti(w io.Writer, privateKeys []*packet.PrivateKey, config *packet.Config) (plaintext io.WriteCloser, err error)
- func EncodeMultiWithHeader(w io.Writer, privateKeys []*packet.PrivateKey, config *packet.Config, headers map[string]string) (plaintext io.WriteCloser, err error)
- func EncodeWithHeader(w io.Writer, privateKey *packet.PrivateKey, config *packet.Config, headers map[string]string) (plaintext io.WriteCloser, err error)
- type Block
Functions ¶
func Encode ¶
func Encode(w io.Writer, privateKey *packet.PrivateKey, config *packet.Config) (plaintext io.WriteCloser, err error)
Encode returns a WriteCloser which will clear-sign a message with privateKey and write it to w. If config is nil, sensible defaults are used.
func EncodeMulti ¶
func EncodeMulti(w io.Writer, privateKeys []*packet.PrivateKey, config *packet.Config) (plaintext io.WriteCloser, err error)
EncodeMulti returns a WriteCloser which will clear-sign a message with all the private keys indicated and write it to w. If config is nil, sensible defaults are used.
func EncodeMultiWithHeader ¶
func EncodeMultiWithHeader(w io.Writer, privateKeys []*packet.PrivateKey, config *packet.Config, headers map[string]string) (plaintext io.WriteCloser, err error)
EncodeMultiWithHeader returns a WriteCloser which will clear-sign a message with all the private keys indicated and write it to w. If config is nil, sensible defaults are used. Additionally provides a headers argument for custom headers.
func EncodeWithHeader ¶
func EncodeWithHeader(w io.Writer, privateKey *packet.PrivateKey, config *packet.Config, headers map[string]string) (plaintext io.WriteCloser, err error)
EncodeWithHeader returns a WriteCloser which will clear-sign a message with privateKey and write it to w. If config is nil, sensible defaults are used. Additionally provides a headers argument for custom headers.
Types ¶
type Block ¶
type Block struct { Headers textproto.MIMEHeader // Optional unverified Hash headers Plaintext []byte // The original message text Bytes []byte // The signed message ArmoredSignature *armor.Block // The signature block }
A Block represents a clearsigned message. A signature on a Block can be checked by calling Block.VerifySignature.
func Decode ¶
Decode finds the first clearsigned message in data and returns it, as well as the suffix of data which remains after the message. Any prefix data is discarded.
If no message is found, or if the message is invalid, Decode returns nil and the whole data slice. The only allowed header type is Hash, and it is not verified against the signature hash.
func (*Block) VerifySignature ¶
func (b *Block) VerifySignature(keyring openpgp.KeyRing, config *packet.Config) (signer *openpgp.Entity, err error)
VerifySignature checks a clearsigned message signature, and checks that the hash algorithm in the header matches the hash algorithm in the signature.
Source Files ¶
- Version
- v1.3.0 (latest)
- Published
- May 22, 2025
- Platform
- linux/amd64
- Imports
- 13 packages
- Last checked
- 2 days ago –
Tools for package owners.