...

Package ecdh

import "github.com/ProtonMail/go-crypto/openpgp/ecdh"
Overview
Index

Overview ▾

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

func Decrypt

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

func Encrypt

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

func Validate

func Validate(priv *PrivateKey) error

type KDF

type KDF struct {
    Hash   algorithm.Hash
    Cipher algorithm.Cipher
}

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, kdfHash algorithm.Hash, kdfCipher algorithm.Cipher) *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