ecdh

package
v1.0.1031 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 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 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) CreateKdfPrivateKeyWithPassword

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

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

func (Ecdh) CreatePbePrivateKeyWithPassword

func (this Ecdh) CreatePbePrivateKeyWithPassword(password string, alg string) Ecdh

生成 PKCS8 私钥带密码 pem 数据

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) CreateSecret

func (this Ecdh) CreateSecret() Ecdh

根据公钥和私钥生成密钥

func (Ecdh) Error

func (this Ecdh) Error() cryptobin_tool.Errors

获取错误

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) 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) FromPublicKeyYHexString added in v1.0.1025

func (this Ecdh) FromPublicKeyYHexString(yString string) Ecdh

根据公钥 y 生成

func (Ecdh) GenerateKey

func (this Ecdh) GenerateKey() 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) 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