x448

package
v1.1.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: BSD-3-Clause Imports: 7 Imported by: 3

Documentation

Index

Constants

View Source
const (

	// The size of a public or private key in bytes.
	KeySize = x448lib.Size
)

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(privateKey *PrivateKey, ephemeralPublicKey *PublicKey, ciphertext []byte) (encodedSessionKey []byte, err error)

Decrypt decrypts a session key stored in ciphertext with the provided x448 private key and ephemeral public key.

func EncodeFields

func EncodeFields(writer io.Writer, ephemeralPublicKey *PublicKey, encryptedSessionKey []byte, cipherFunction byte, v6 bool) (err error)

EncodeField encodes x448 session key encryption fields as ephemeral x448 public key | follow byte length | cipherFunction (v3 only) | encryptedSessionKey and writes it to writer.

func EncodedFieldsLength

func EncodedFieldsLength(encryptedSessionKey []byte, v6 bool) int

EncodeFieldsLength returns the length of the ciphertext encoding given the encrypted session key.

func Validate

func Validate(pk *PrivateKey) (err error)

Validate validates that the provided public key matches the private key.

Types

type PrivateKey

type PrivateKey struct {
	PublicKey
	// Secret represents the secret of the private key.
	Secret []byte
}

func GenerateKey

func GenerateKey(rand io.Reader) (*PrivateKey, error)

GenerateKey generates a new x448 key pair.

func NewPrivateKey

func NewPrivateKey(key PublicKey) *PrivateKey

NewPrivateKey creates a new empty private key including the public key.

type PublicKey

type PublicKey struct {
	// Point represents the encoded elliptic curve point of the public key.
	Point []byte
}

func DecodeFields

func DecodeFields(reader io.Reader, v6 bool) (ephemeralPublicKey *PublicKey, encryptedSessionKey []byte, cipherFunction byte, err error)

DecodeField decodes a x448 session key encryption as ephemeral x448 public key | follow byte length | cipherFunction (v3 only) | encryptedSessionKey.

func Encrypt

func Encrypt(rand io.Reader, publicKey *PublicKey, sessionKey []byte) (ephemeralPublicKey *PublicKey, encryptedSessionKey []byte, err error)

Encrypt encrypts a sessionKey with x448 according to the OpenPGP crypto refresh specification section 5.1.7. The function assumes that the sessionKey has the correct format and padding according to the specification.

Jump to

Keyboard shortcuts

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