ecdh

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(cipherText []byte, ECCPrivateKey *PrivateKey, ECCPublicKey *PublicKey) (plaintext []byte, err error)

Decrypt 使用ECC密钥对进行解密

func Encrypt

func Encrypt(plainText []byte, ECCPrivateKey *PrivateKey, ECCPublicKey *PublicKey) (ciphertext []byte, err error)

Encrypt 使用ECC密钥对进行加密

func GenerateKeyPair

func GenerateKeyPair(curve string) (ECCPrivateKey *PrivateKey, ECCPublicKey *PublicKey, err error)

GenerateKeyPair 生成ECC密钥对

  • curve: 曲线类型,可选值为 P256,P384,P521,X25519

Types

type PrivateKey

type PrivateKey struct {
	Key *ecdh.PrivateKey
}

func PEMKeyToPrivateKey

func PEMKeyToPrivateKey(PEMKey []byte) (ECCPrivateKey *PrivateKey, err error)

func (*PrivateKey) ToPEM

func (PrivateKey *PrivateKey) ToPEM() (PEMKey []byte, err error)

type PublicKey

type PublicKey struct {
	Key *ecdh.PublicKey
}

func PEMKeyToPublicKey

func PEMKeyToPublicKey(PEMKey []byte) (ECCPublicKey *PublicKey, err error)

func (*PublicKey) ToPEM

func (PublicKey *PublicKey) ToPEM() (PEMKey []byte, err error)

Jump to

Keyboard shortcuts

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