ecdh

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: 8 Imported by: 9

Documentation

Overview

Package ecdh implements ECDH encryption, suitable for OpenPGP, as specified in RFC 6637, section 8.

Index

Constants

View Source
const (
	KDFVersion1          = 1
	KDFVersionForwarding = 255
)

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(priv *PrivateKey, vsG, c, curveOID, fingerprint []byte) (msg []byte, err error)

func DeriveProxyParam

func DeriveProxyParam(recipientKey, forwardeeKey *PrivateKey) (proxyParam []byte, err error)

func Encrypt

func Encrypt(random io.Reader, pub *PublicKey, msg, curveOID, fingerprint []byte) (vsG, c []byte, err error)

func ProxyTransform

func ProxyTransform(ephemeral, proxyParam []byte) ([]byte, error)

func Validate

func Validate(priv *PrivateKey) error

Types

type KDF

type KDF struct {
	Version                int // Defaults to v1; 255 for forwarding
	Hash                   algorithm.Hash
	Cipher                 algorithm.Cipher
	ReplacementFingerprint []byte // (forwarding only) fingerprint to use instead of recipient's (20 octets)
}

func (*KDF) Serialize

func (kdf *KDF) Serialize(w io.Writer) (err error)

type PrivateKey

type PrivateKey struct {
	PublicKey
	D []byte
}

func GenerateKey

func GenerateKey(rand io.Reader, c ecc.ECDHCurve, kdf KDF) (priv *PrivateKey, err error)

func NewPrivateKey

func NewPrivateKey(key PublicKey) *PrivateKey

func (*PrivateKey) MarshalByteSecret

func (sk *PrivateKey) MarshalByteSecret() []byte

func (*PrivateKey) UnmarshalByteSecret

func (sk *PrivateKey) UnmarshalByteSecret(d []byte) error

type PublicKey

type PublicKey struct {
	Point []byte
	KDF
	// contains filtered or unexported fields
}

func NewPublicKey

func NewPublicKey(curve ecc.ECDHCurve, kdf KDF) *PublicKey

func (*PublicKey) GetCurve

func (pk *PublicKey) GetCurve() ecc.ECDHCurve

func (*PublicKey) MarshalPoint

func (pk *PublicKey) MarshalPoint() []byte

func (*PublicKey) UnmarshalPoint

func (pk *PublicKey) UnmarshalPoint(p []byte) error

Jump to

Keyboard shortcuts

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