ecdh

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package ecdh implements key agreement algorithm ECDH for COSE as defined in RFC9053. https://datatracker.ietf.org/doc/html/rfc9053#name-direct-key-agreement.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckKey

func CheckKey(k key.Key) error

CheckKey checks whether the given key is a valid ECDH key.

func GenerateKey

func GenerateKey(crv int) (key.Key, error)

GenerateKey generates a new Key with given curve for ECDH. crv is one of the iana.EllipticCurve* constants.

func KeyFromPrivate

func KeyFromPrivate(pk *goecdh.PrivateKey) (key.Key, error)

KeyFromPrivate returns a private Key with given ecdh.PrivateKey.

func KeyFromPublic

func KeyFromPublic(pk *goecdh.PublicKey) (key.Key, error)

KeyFromPublic returns a public Key with given ecdh.PublicKey.

func KeyToPrivate

func KeyToPrivate(k key.Key) (*goecdh.PrivateKey, error)

KeyToPrivate returns a *ecdh.PrivateKey for the given Key.

func KeyToPublic

func KeyToPublic(k key.Key) (*goecdh.PublicKey, error)

KeyToPublic returns a *ecdh.PublicKey for the given key.Key.

func ToCompressedKey

func ToCompressedKey(k key.Key) (key.Key, error)

ToCompressedKey converts the given key to a compressed Key. It can be used in Recipient.

func ToPublicKey

func ToPublicKey(k key.Key) (key.Key, error)

ToPublicKey converts the given private key to a public key. If the key is already a public key, it is returned as-is.

Types

type ECDHer

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

func NewECDHer

func NewECDHer(k key.Key) (*ECDHer, error)

NewECDHer creates a ECDHer for the given private key.

func (*ECDHer) ECDH

func (e *ECDHer) ECDH(remotePublic key.Key) ([]byte, error)

ECDH performs a ECDH exchange and returns the shared secret. The PrivateKey and PublicKey must use the same curve. https://pkg.go.dev/crypto/ecdh#PrivateKey.ECDH

func (*ECDHer) Key

func (e *ECDHer) Key() key.Key

Key returns the private key in ECDHer.

Jump to

Keyboard shortcuts

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