pubkey

package
v0.20260928.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package pubkey implements functions for managing the public keys that correspond to TBSCertificateLogEntries. It provides functions for marshaling them into bundles for storage in tiles, unmarshaling the tile bundles into sequences of the custom MTCPublicKey type, and returning the inner SubjectPublicKeyInfo.

Pubkey bundles are sequences of uint16 length-prefixed MTCPublicKey objects.

MTCPublicKey is a custom type that provides the type switching necessary to express null pubkey values in parallel with null_entry in the entries tiles, and for extensibility.

SubjectPublicKeyInfo structures are part of the X.509 layer. They will be used to build certificates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BundleReader

type BundleReader struct {
	// contains filtered or unexported fields
}

BundleReader reads records of MTCPubkey from the underlying buffer in the pubkey bundle format.

func NewBundleReader

func NewBundleReader(buf []byte) *BundleReader

NewBundleReader returns a new BundleReader.

func (*BundleReader) ReadPubkey

func (br *BundleReader) ReadPubkey() (*MTCPublicKey, []byte, error)

ReadPubkey reads the bytes of a single pubkey.

Returns the parsed MTCPubkey structure as well as its public key bytes, both of which reference the same memory as the original buffer.

Returns MTCPubkey{}, nil, io.EOF when there is no more to read.

type MTCPublicKey

type MTCPublicKey struct {
	// contains filtered or unexported fields
}

MTCPublicKey is a local data type to store public keys alongside tlog-tiles entries for constructing MTCs. It is not defined in the MTC or tlog-tiles spec. This struct's "typ" is used to signal whether the "pub" is null, or is populated with the DER-encoded bytes of an RFC 5280 subjectPublicKeyInfo structure.

func FromCryptoPubkey

func FromCryptoPubkey(in crypto.PublicKey) (*MTCPublicKey, error)

FromCryptoPubkey feeds a crypto.PublicKey into position in an MTCPublicKey struct, returning an error if the input public key is nil

func (*MTCPublicKey) Marshal

func (mtcpk *MTCPublicKey) Marshal() ([]byte, error)

Marshal returns encoded pubkey bundle bytes, or an error

Rejects unknown MTCPubkey types with an error. Also errors if the public key does not Marshal, or if pub contains bytes when typ signals all should be nil.

func (*MTCPublicKey) Pubkey

func (mtcpk *MTCPublicKey) Pubkey() []byte

Pubkey returns the subjectPublicKeyInfo structure bytes of an MTCPublicKey if its type is typeSPKI, otherwise nil.

Jump to

Keyboard shortcuts

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