pgptest

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package pgptest builds OpenPGP fixtures with an independent implementation, for tests in this module.

Internal, and imported only by tests: go-crypto is a reference implementation used to check this one, never a dependency of it. Keeping the fixtures here rather than duplicating them in each package's tests means one definition of "a real message on this curve" — and keeps go-crypto out of every non-test build graph, which depfootprint_test.go asserts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Agree

func Agree(t *testing.T, sub *openpgp.Subkey, ephemeral []byte, coordinateBytes int) []byte

agree performs the ECDH the key service would perform, returning the bare x-coordinate.

func CurveOIDFrom

func CurveOIDFrom(t *testing.T, raw []byte) []byte

CurveOIDFrom pulls the curve identifier out of a serialised public-key packet, with its leading length octet, which is the form KDFParams takes.

func EncryptTo

func EncryptTo(t *testing.T, entity *openpgp.Entity, plaintext []byte) []byte

func EncryptionSubkey

func EncryptionSubkey(t *testing.T, entity *openpgp.Entity) *openpgp.Subkey

func MinInt

func MinInt(a, b int) int

func NewECDHEntity

func NewECDHEntity(t *testing.T, curve packet.Curve) *openpgp.Entity

func NewFormatBody

func NewFormatBody(t *testing.T, p []byte) []byte

NewFormatBody reads the RFC 9580 header length encoding.

func OldFormatBody

func OldFormatBody(t *testing.T, p []byte) []byte

OldFormatBody reads the legacy CTB length types.

func PacketBody

func PacketBody(t *testing.T, p []byte) (tag byte, body []byte)

PacketBody returns a packet's tag and body, handling both the old-format CTB and the new-format header RFC 9580 uses. go-crypto emits new-format headers, so assuming one shape silently misreads the packet.

func ParsePKESK

func ParsePKESK(t *testing.T, message []byte) (ephemeral, wrapped []byte)

parsePKESK pulls the ephemeral point and the wrapped key out of the packet by hand: go-crypto keeps both unexported, and reading them independently is what stops this being a comparison of the library with itself. ParsePKESK pulls the ephemeral point and wrapped key out of a message composed elsewhere, so a test has something real to compare against.

func RandomBytes

func RandomBytes(t *testing.T, n int) []byte

Types

type CurveProfile

type CurveProfile struct {
	// Name is the curve's OpenPGP name, used as a subtest name.
	Name string

	// Curve is the identifier go-crypto generates keys for.
	Curve packet.Curve

	// CoordinateBytes is the curve's coordinate length, which the key
	// derivation pads the shared secret to.
	CoordinateBytes int
}

CurveProfile pairs a curve with the KDF parameters go-crypto selects for it, so the SHA-384 and SHA-512 arms are exercised against a real implementation rather than against a reconstruction.

func DifferentialCurves

func DifferentialCurves() []CurveProfile

Jump to

Keyboard shortcuts

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