ecdh

package
v1.0.2065 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// 方式
	P521 = elliptic.P521
	P384 = elliptic.P384
	P256 = elliptic.P256
	P224 = elliptic.P224
)

Functions

func ComputeSecret added in v1.0.1040

func ComputeSecret(private *PrivateKey, peersPublic *PublicKey) (secret []byte)

生成密码

func GenerateKey added in v1.0.1040

func GenerateKey(curve elliptic.Curve, rand io.Reader) (*PrivateKey, *PublicKey, error)

生成密钥对

func MarshalPrivateKey added in v1.0.1040

func MarshalPrivateKey(key *PrivateKey) ([]byte, error)

包装私钥

func MarshalPublicKey added in v1.0.1040

func MarshalPublicKey(key *PublicKey) ([]byte, error)

包装公钥

Types

type Curve added in v1.0.1040

type Curve = elliptic.Curve

type PrivateKey

type PrivateKey struct {
	PublicKey

	X []byte
}

私钥

func ParsePrivateKey added in v1.0.1040

func ParsePrivateKey(derBytes []byte) (*PrivateKey, error)

解析私钥

func (*PrivateKey) ComputeSecret added in v1.0.1040

func (this *PrivateKey) ComputeSecret(peersPublic *PublicKey) (secret []byte)

生成密码

func (*PrivateKey) Public added in v1.0.1040

func (this *PrivateKey) Public() crypto.PublicKey

type PublicKey

type PublicKey struct {
	elliptic.Curve

	Y []byte
}

公钥

func GeneratePublicKey added in v1.0.1040

func GeneratePublicKey(private *PrivateKey) (*PublicKey, error)

从私钥获取公钥

func ParsePublicKey added in v1.0.1040

func ParsePublicKey(derBytes []byte) (pub *PublicKey, err error)

解析公钥

func (*PublicKey) Check added in v1.0.1040

func (this *PublicKey) Check() (err error)

检测

Jump to

Keyboard shortcuts

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