core: github.com/katzenpost/core/crypto/ecdh Index | Files

package ecdh

import "github.com/katzenpost/core/crypto/ecdh"

Package ecdh provides ECDH (X25519) wrappers.

Index

Package Files

ecdh.go

Constants

const (
    // GroupElementLength is the length of a ECDH group element in bytes.
    GroupElementLength = 32

    // PublicKeySize is the size of a serialized PublicKey in bytes.
    PublicKeySize = GroupElementLength

    // PrivateKeySize is the size of a serialized PrivateKey in bytes.
    PrivateKeySize = GroupElementLength
)

func Exp Uses

func Exp(dst, x, y *[GroupElementLength]byte)

Exp sets the group element dst to be the result of x^y, over the ECDH group.

type PrivateKey Uses

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

PrivateKey is a ECDH private key.

func Load Uses

func Load(privFile, pubFile string, r io.Reader) (*PrivateKey, error)

Load loads a new PrivateKey from the PEM encoded file privFile, optionally creating and saving a PrivateKey instead if an entropy source is provided. If pubFile is specified and a key has been created, the corresponding PublicKey will be wrtten to pubFile in PEM format.

func NewKeypair Uses

func NewKeypair(r io.Reader) (*PrivateKey, error)

NewKeypair generates a new PrivateKey sampled from the provided entropy source.

func (*PrivateKey) Bytes Uses

func (k *PrivateKey) Bytes() []byte

Bytes returns the raw private key.

func (*PrivateKey) Exp Uses

func (k *PrivateKey) Exp(sharedSecret *[GroupElementLength]byte, publicKey *PublicKey)

Exp calculates the shared secret with the provided public key.

func (*PrivateKey) FromBytes Uses

func (k *PrivateKey) FromBytes(b []byte) error

FromBytes deserializes the byte slice b into the PrivateKey.

func (*PrivateKey) MarshalBinary Uses

func (k *PrivateKey) MarshalBinary() ([]byte, error)

MarshalBinary is an implementation of a method on the BinaryMarshaler interface defined in https://golang.org/pkg/encoding/

func (*PrivateKey) PublicKey Uses

func (k *PrivateKey) PublicKey() *PublicKey

PublicKey returns the PublicKey corresponding to the PrivateKey.

func (*PrivateKey) Reset Uses

func (k *PrivateKey) Reset()

Reset clears the PrivateKey structure such that no sensitive data is left in memory.

func (*PrivateKey) UnmarshalBinary Uses

func (k *PrivateKey) UnmarshalBinary(data []byte) error

UnmarshalBinary is an implementation of a method on the BinaryUnmarshaler interface defined in https://golang.org/pkg/encoding/

type PublicKey Uses

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

PublicKey is a ECDH public key.

func (*PublicKey) Blind Uses

func (k *PublicKey) Blind(blindingFactor *[GroupElementLength]byte)

Blind blinds the public key with the provided blinding factor.

func (*PublicKey) Bytes Uses

func (k *PublicKey) Bytes() []byte

Bytes returns the raw public key.

func (*PublicKey) Equal Uses

func (k *PublicKey) Equal(cmp *PublicKey) bool

Equal returns true iff the public key is byte for byte identical.

func (*PublicKey) FromBytes Uses

func (k *PublicKey) FromBytes(b []byte) error

FromBytes deserializes the byte slice b into the PublicKey.

func (*PublicKey) FromPEMFile Uses

func (k *PublicKey) FromPEMFile(f string) error

FromPEMFile reads the PublicKey from a PEM file at path f.

func (*PublicKey) FromString Uses

func (k *PublicKey) FromString(s string) error

FromString deserializes the string s into the PublicKey.

func (*PublicKey) MarshalBinary Uses

func (k *PublicKey) MarshalBinary() ([]byte, error)

MarshalBinary is an implementation of a method on the BinaryMarshaler interface defined in https://golang.org/pkg/encoding/

func (*PublicKey) MarshalText Uses

func (k *PublicKey) MarshalText() ([]byte, error)

MarshalText is an implementation of a method on the TextMarshaler interface defined in https://golang.org/pkg/encoding/

func (*PublicKey) Reset Uses

func (k *PublicKey) Reset()

Reset clears the PublicKey structure such that no sensitive data is left in memory.

func (*PublicKey) String Uses

func (k *PublicKey) String() string

String returns the public key as a base64 encoded string.

func (*PublicKey) ToPEMFile Uses

func (k *PublicKey) ToPEMFile(f string) error

ToPEMFile writes out the PublicKey to a PEM file at path f.

func (*PublicKey) UnmarshalBinary Uses

func (k *PublicKey) UnmarshalBinary(data []byte) error

UnmarshalBinary is an implementation of a method on the BinaryUnmarshaler interface defined in https://golang.org/pkg/encoding/

func (*PublicKey) UnmarshalText Uses

func (k *PublicKey) UnmarshalText(data []byte) error

UnmarshalText is an implementation of a method on the TextUnmarshaler interface defined in https://golang.org/pkg/encoding/

Package ecdh imports 11 packages (graph) and is imported by 41 packages. Updated 2019-07-30. Refresh now. Tools for package owners.