Documentation ¶
Overview ¶
Package ecdh provides support for ECDH with the IETF CFRG Curves as specified in RFC 7748.
Index ¶
Constants ¶
View Source
const X25519Size = 32
X25519Size is the X25519 private/public key and shared secret size in bytes.
View Source
const X448Size = 56
X448Size is the X448 private/public key and shared secret size in bytes.
Variables ¶
View Source
var ( // ErrInvalidCurve is the error returned when the curve is unknown/invalid. ErrInvalidCurve = errors.New("ecdh: invalid curve") // ErrInvalidPoint is the error returned when when the point is of small // order, where the order divides the cofactor of the curve. ErrInvalidPoint = errors.New("ecdh: invalid point") // ErrInvalidKeySize is the error returned when deserialization fails due // to an invalid length buffer. ErrInvalidKeySize = errors.New("ecdh: invalid key size") // ErrNotSupported is the error returned when a operation is not supported. ErrNotSupported = errors.New("ecdh: not supported") )
Functions ¶
This section is empty.
Types ¶
type PrivateKey ¶
type PrivateKey interface { // PublicKey returns the PublicKey corresponding to the PrivateKey. PublicKey() PublicKey // ScalarMult returns a shared secret given a peer's public key, suitable // for use as an input to a key derivation function. An error is returned // iff the result does not ensre contribuatory behavior from both parties. ScalarMult(PublicKey) ([]byte, error) // Curve returns the Curve that this private key is for. Curve() Curve // Size returns the size of the encoded private key in bytes. Size() int // ToBytes returns a byte slice pointing to the interal byte encoded // private key. ToBytes() []byte // Reset sanitizes private values from the PrivateKey such that they no // longer appear in memory. Reset() }
PrivateKey is an ECDH private key.
func New ¶
New generates a new PrivateKey in the provided curve using the random source rand. If uniform is true, an Elligator2 representative will also be generated if supported.
func PrivateKeyFromBytes ¶
func PrivateKeyFromBytes(curve Curve, b []byte) (PrivateKey, error)
PrivateKeyFromBytes returns the PrivateKey corresponding to the given curve and byte slice.
type PublicKey ¶
type PublicKey interface { // Curve returns the Curve that this public key is for. Curve() Curve // Size returns the size of the encoded public key in bytes. Size() int // ToBytes returns a byte slice pointing to the internal byte encoded // public key. ToBytes() []byte // ToUniformBytes returns the Elligator2 uniform representative of the // public key, if one is available or nil if one is not. ToUniformBytes() []byte }
PublicKey is an ECDH public key.
func PublicKeyFromBytes ¶
PublicKeyFromBytes returns the PublicKey corresponding to the given curve and byte slice.
Click to show internal directories.
Click to hide internal directories.