ecdh

package
v0.0.0-...-de78d2c Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2020 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AESKeyUnwrap

func AESKeyUnwrap(key, cipherText []byte) ([]byte, error)

AESKeyUnwrap implements RFC 3394 Key Unwrapping. See http://tools.ietf.org/html/rfc3394#section-2.2.1 Note: The second described algorithm ("index-based") is implemented here.

func AESKeyWrap

func AESKeyWrap(key, plainText []byte) ([]byte, error)

AESKeyWrap implements RFC 3394 Key Wrapping. See https://tools.ietf.org/html/rfc3394#section-2.2.2 Note: The second described algorithm ("index-based") is implemented here.

func Marshal

func Marshal(curve elliptic.Curve, x, y *big.Int) (buf []byte, bitSize int)

Marshal encodes point into either 0x4 uncompressed point form, or 0x40 compressed point for Curve 25519.

func PadBuffer

func PadBuffer(buf []byte, blockLen int) []byte

PadBuffer pads byte buffer buf to a length being multiple of blockLen. Additional bytes appended to the buffer have value of the number padded bytes. E.g. if the buffer is 3 bytes short of being 40 bytes total, the appended bytes will be [03, 03, 03].

func Unmarshal

func Unmarshal(curve elliptic.Curve, data []byte) (x, y *big.Int)

Unmarshal converts point, serialized by Marshal, into x, y pair. For 0x40 compressed points (for Curve 25519), y will always be 0. It is an error if point is not on the curve, On error, x = nil.

func UnpadBuffer

func UnpadBuffer(buf []byte, dataLen int) []byte

UnpadBuffer verifies that buffer contains proper padding and returns buffer without the padding, or nil if the padding was invalid.

Types

type PrivateKey

type PrivateKey struct {
	PublicKey
	X *big.Int
}

func GenerateKey

func GenerateKey(curve elliptic.Curve, random io.Reader) (priv *PrivateKey, err error)

func (*PrivateKey) DecryptShared

func (e *PrivateKey) DecryptShared(X, Y *big.Int) []byte

type PublicKey

type PublicKey struct {
	elliptic.Curve
	X, Y *big.Int
}

func (*PublicKey) Encrypt

func (e *PublicKey) Encrypt(random io.Reader, kdfParams []byte, plain []byte, hash crypto.Hash, kdfKeySize int) (Vx *big.Int, Vy *big.Int, C []byte, err error)

func (*PublicKey) KDF

func (e *PublicKey) KDF(S []byte, kdfParams []byte, hash crypto.Hash) []byte

KDF implements Key Derivation Function as described in https://tools.ietf.org/html/rfc6637#section-7

Jump to

Keyboard shortcuts

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