armor

package
v1.1.0-alpha.0-proton Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2024 License: BSD-3-Clause Imports: 5 Imported by: 104

Documentation

Overview

Package armor implements OpenPGP ASCII Armor, see RFC 4880. OpenPGP Armor is very similar to PEM except that it has an additional CRC checksum.

Index

Constants

This section is empty.

Variables

View Source
var ArmorCorrupt error = errors.StructuralError("armor invalid")

Functions

func Encode

func Encode(out io.Writer, blockType string, headers map[string]string) (w io.WriteCloser, err error)

Encode returns a WriteCloser which will encode the data written to it in OpenPGP armor.

func EncodeWithChecksumOption added in v1.1.0

func EncodeWithChecksumOption(out io.Writer, blockType string, headers map[string]string, doChecksum bool) (w io.WriteCloser, err error)

EncodeWithChecksumOption returns a WriteCloser which will encode the data written to it in OpenPGP armor and provides the option to include a checksum. When forming ASCII Armor, the CRC24 footer SHOULD NOT be generated, unless interoperability with implementations that require the CRC24 footer to be present is a concern.

Types

type Block

type Block struct {
	Type   string            // The type, taken from the preamble (i.e. "PGP SIGNATURE").
	Header map[string]string // Optional headers.
	Body   io.Reader         // A Reader from which the contents can be read
	// contains filtered or unexported fields
}

A Block represents an OpenPGP armored structure.

The encoded form is:

-----BEGIN Type-----
Headers

base64-encoded Bytes
'=' base64 encoded checksum (optional) not checked anymore
-----END Type-----

where Headers is a possibly empty sequence of Key: Value lines.

Since the armored data can be very large, this package presents a streaming interface.

func Decode

func Decode(in io.Reader) (p *Block, err error)

Decode reads a PGP armored block from the given Reader. It will ignore leading garbage. If it doesn't find a block, it will return nil, io.EOF. The given Reader is not usable after calling this function: an arbitrary amount of data may have been read past the end of the block.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL