ecdh

package
v1.0.2029 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// 获取 Cipher 类型
	GetCipherFromName = cryptobin_pkcs8.GetCipherFromName
	// 获取 hash 类型
	GetHashFromName = cryptobin_pkcs8.GetHashFromName
)
View Source
var (
	ErrKeyMustBePEMEncoded = errors.New("invalid key: Key must be a PEM encoded PKCS1 or PKCS8 key")
	ErrNotPrivateKey       = errors.New("key is not a valid ecdh private key")
	ErrNotPublicKey        = errors.New("key is not a valid ecdh public key")
)

Functions

This section is empty.

Types

type Ecdh

type Ecdh struct {

	// 错误
	Errors []error
	// contains filtered or unexported fields
}

*

  • ecdh *
  • @create 2022-8-7
  • @author deatil

func FromKeyXYHexString added in v1.0.2014

func FromKeyXYHexString(xString string, yString string) Ecdh

根据私钥 x, y 生成

func FromPrivateKey added in v1.0.2014

func FromPrivateKey(key []byte) Ecdh

私钥

func FromPrivateKeyWithPassword added in v1.0.2014

func FromPrivateKeyWithPassword(key []byte, password string) Ecdh

私钥

func FromPrivateKeyXHexString added in v1.0.2014

func FromPrivateKeyXHexString(xString string) Ecdh

根据私钥 x 生成

func FromPublicKey added in v1.0.2014

func FromPublicKey(key []byte) Ecdh

公钥

func FromPublicKeyYHexString added in v1.0.2014

func FromPublicKeyYHexString(yString string) Ecdh

根据公钥 y 生成

func GenerateKey added in v1.0.2014

func GenerateKey(curve string) Ecdh

生成密钥 可用参数 [P521 | P384 | P256 | P224]

func GenerateKeyWithSeed added in v1.0.2026

func GenerateKeyWithSeed(reader io.Reader, curve string) Ecdh

生成密钥 可用参数 [P521 | P384 | P256 | P224]

func New

func New() Ecdh

构造函数

func NewEcdh

func NewEcdh() Ecdh

构造函数

func (Ecdh) AppendError added in v1.0.1026

func (this Ecdh) AppendError(err ...error) Ecdh

添加错误

func (Ecdh) CheckKeyPair added in v1.0.1046

func (this Ecdh) CheckKeyPair() bool

检测公钥私钥是否匹配

func (Ecdh) CreatePrivateKey

func (this Ecdh) CreatePrivateKey() Ecdh

生成私钥 pem 数据 使用: obj := New().GenerateKey("P2048") priKey := obj.CreatePrivateKey().ToKeyString()

func (Ecdh) CreatePrivateKeyWithPassword

func (this Ecdh) CreatePrivateKeyWithPassword(password string, opts ...any) Ecdh

生成 PKCS8 私钥带密码 pem 数据 CreatePrivateKeyWithPassword("123", "AES256CBC", "SHA256")

func (Ecdh) CreatePublicKey

func (this Ecdh) CreatePublicKey() Ecdh

生成公钥 pem 数据

func (Ecdh) CreateSecretKey added in v1.0.1038

func (this Ecdh) CreateSecretKey() Ecdh

根据公钥和私钥生成密钥

func (Ecdh) Error

func (this Ecdh) Error() error

获取错误

func (Ecdh) FromKeyXYHexString added in v1.0.1025

func (this Ecdh) FromKeyXYHexString(xString string, yString string) Ecdh

根据私钥 x, y 生成

func (Ecdh) FromPrivateKey

func (this Ecdh) FromPrivateKey(key []byte) Ecdh

私钥

func (Ecdh) FromPrivateKeyDer added in v1.0.2015

func (this Ecdh) FromPrivateKeyDer(der []byte) Ecdh

DER 私钥

func (Ecdh) FromPrivateKeyWithPassword

func (this Ecdh) FromPrivateKeyWithPassword(key []byte, password string) Ecdh

私钥带密码

func (Ecdh) FromPrivateKeyXHexString added in v1.0.1025

func (this Ecdh) FromPrivateKeyXHexString(xString string) Ecdh

根据私钥 x 生成

func (Ecdh) FromPublicKey

func (this Ecdh) FromPublicKey(key []byte) Ecdh

公钥

func (Ecdh) FromPublicKeyDer added in v1.0.2015

func (this Ecdh) FromPublicKeyDer(der []byte) Ecdh

DER 公钥

func (Ecdh) FromPublicKeyYHexString added in v1.0.1025

func (this Ecdh) FromPublicKeyYHexString(yString string) Ecdh

根据公钥 y 生成

func (Ecdh) GenerateKey

func (this Ecdh) GenerateKey() Ecdh

生成密钥

func (Ecdh) GenerateKeyWithSeed added in v1.0.2026

func (this Ecdh) GenerateKeyWithSeed(reader io.Reader) Ecdh

生成密钥

func (Ecdh) GetCurve added in v1.0.1026

func (this Ecdh) GetCurve() ecdh.Curve

获取散列方式

func (Ecdh) GetErrors added in v1.0.1026

func (this Ecdh) GetErrors() []error

获取错误

func (Ecdh) GetKeyData

func (this Ecdh) GetKeyData() []byte

获取 keyData

func (Ecdh) GetPrivateKey

func (this Ecdh) GetPrivateKey() *ecdh.PrivateKey

获取 PrivateKey

func (Ecdh) GetPrivateKeyXHexString added in v1.0.1025

func (this Ecdh) GetPrivateKeyXHexString() string

获取 X 16进制字符

func (Ecdh) GetPublicKey

func (this Ecdh) GetPublicKey() *ecdh.PublicKey

获取 PublicKey

func (Ecdh) GetPublicKeyYHexString added in v1.0.1025

func (this Ecdh) GetPublicKeyYHexString() string

获取 Y 16进制字符

func (Ecdh) GetSecretData added in v1.0.1026

func (this Ecdh) GetSecretData() []byte

获取 secretData

func (Ecdh) MakeKeyDer added in v1.0.1033

func (this Ecdh) MakeKeyDer() Ecdh

生成密钥 der 数据

func (Ecdh) MakePublicKey

func (this Ecdh) MakePublicKey() Ecdh

生成公钥

func (Ecdh) OnError

func (this Ecdh) OnError(fn ErrorFunc) Ecdh

引出错误信息

func (Ecdh) ParsePrivateKeyFromPEM

func (this Ecdh) ParsePrivateKeyFromPEM(key []byte) (crypto.PrivateKey, error)

解析私钥

func (Ecdh) ParsePrivateKeyFromPEMWithPassword

func (this Ecdh) ParsePrivateKeyFromPEMWithPassword(key []byte, password string) (crypto.PrivateKey, error)

解析私钥带密码

func (Ecdh) ParsePublicKeyFromPEM

func (this Ecdh) ParsePublicKeyFromPEM(key []byte) (crypto.PublicKey, error)

解析公钥

func (Ecdh) SetCurve added in v1.0.1026

func (this Ecdh) SetCurve(name string) Ecdh

设置散列方式 可用参数 [P521 | P384 | P256 | P224]

func (Ecdh) ToBase64String

func (this Ecdh) ToBase64String() string

输出Base64

func (Ecdh) ToBytes

func (this Ecdh) ToBytes() []byte

输出字节

func (Ecdh) ToHexString

func (this Ecdh) ToHexString() string

输出Hex

func (Ecdh) ToKeyBytes

func (this Ecdh) ToKeyBytes() []byte

私钥/公钥

func (Ecdh) ToKeyString

func (this Ecdh) ToKeyString() string

私钥/公钥

func (Ecdh) ToString

func (this Ecdh) ToString() string

输出字符

func (Ecdh) WithCurve added in v1.0.1026

func (this Ecdh) WithCurve(data ecdh.Curve) Ecdh

设置散列方式

func (Ecdh) WithErrors added in v1.0.1026

func (this Ecdh) WithErrors(errs []error) Ecdh

设置错误

func (Ecdh) WithKeyData

func (this Ecdh) WithKeyData(data []byte) Ecdh

设置 keyData

func (Ecdh) WithPrivateKey

func (this Ecdh) WithPrivateKey(data *ecdh.PrivateKey) Ecdh

设置 PrivateKey

func (Ecdh) WithPublicKey

func (this Ecdh) WithPublicKey(data *ecdh.PublicKey) Ecdh

设置 PublicKey

func (Ecdh) WithSecretData added in v1.0.1026

func (this Ecdh) WithSecretData(data []byte) Ecdh

设置 secretData

type ErrorFunc

type ErrorFunc = func([]error)

错误方法

type Opts

type Opts = cryptobin_pkcs8.Opts

配置

type PBKDF2Opts

type PBKDF2Opts = cryptobin_pkcs8.PBKDF2Opts

PBKDF2 配置

type ScryptOpts

type ScryptOpts = cryptobin_pkcs8.ScryptOpts

Scrypt 配置

Jump to

Keyboard shortcuts

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