ecdh

package
v1.0.2037 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: Apache-2.0 Imports: 12 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
  • go 最低版本需要 `1.20rc1`。 *
  • @create 2022-8-7
  • @author deatil

func FromECDHPrivateKey added in v1.0.2017

func FromECDHPrivateKey(key []byte) Ecdh

私钥, 库自使用的 asn1 格式

func FromECDHPrivateKeyWithPassword added in v1.0.2017

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

私钥, 库自使用的 asn1 格式

func FromECDHPublicKey added in v1.0.2017

func FromECDHPublicKey(key []byte) Ecdh

公钥, 库自使用的 asn1 格式

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 FromPublicKey added in v1.0.2014

func FromPublicKey(key []byte) Ecdh

公钥

func GenerateKey added in v1.0.2014

func GenerateKey(curve string) Ecdh

生成密钥

func GenerateKeyWithSeed added in v1.0.2026

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

生成密钥

func New

func New() Ecdh

构造函数

func NewEcdh

func NewEcdh() Ecdh

构造函数

func (Ecdh) AppendError

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

添加错误

func (Ecdh) CheckKeyPair added in v1.0.1046

func (this Ecdh) CheckKeyPair() bool

检测公钥私钥是否匹配

func (Ecdh) CreateECDHPrivateKey added in v1.0.2017

func (this Ecdh) CreateECDHPrivateKey() Ecdh

生成私钥 pem 数据, 库自使用的 asn1 格式

func (Ecdh) CreateECDHPrivateKeyWithPassword added in v1.0.2017

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

生成 PKCS8 私钥带密码 pem 数据, 库自使用的 asn1 格式

func (Ecdh) CreateECDHPublicKey added in v1.0.2017

func (this Ecdh) CreateECDHPublicKey() Ecdh

生成公钥 pem 数据, 库自使用的 asn1 格式

func (Ecdh) CreatePrivateKey

func (this Ecdh) CreatePrivateKey() Ecdh

生成私钥 pem 数据 使用: obj := New().SetCurve("P256").GenerateKey() 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

func (this Ecdh) CreateSecretKey() Ecdh

根据公钥和私钥生成对称密钥

func (Ecdh) Error

func (this Ecdh) Error() error

获取错误

func (Ecdh) FromECDHPrivateKey added in v1.0.2017

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

私钥, 库自使用的 asn1 格式

func (Ecdh) FromECDHPrivateKeyDer added in v1.0.2017

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

DER 私钥, 库自使用的 asn1 格式

func (Ecdh) FromECDHPrivateKeyWithPassword added in v1.0.2017

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

私钥带密码, 库自使用的 asn1 格式

func (Ecdh) FromECDHPublicKey added in v1.0.2017

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

公钥, 库自使用的 asn1 格式

func (Ecdh) FromECDHPublicKeyDer added in v1.0.2017

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

DER 公钥, 库自使用的 asn1 格式

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

func (this Ecdh) GetCurve() ecdh.Curve

获取散列方式

func (Ecdh) GetErrors

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

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

获取 PublicKey

func (Ecdh) GetSecretData

func (this Ecdh) GetSecretData() []byte

获取 secretData

func (Ecdh) MakeKeyDer

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) ParseECDHPrivateKeyFromPEM added in v1.0.2017

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

解析私钥

func (Ecdh) ParseECDHPrivateKeyFromPEMWithPassword added in v1.0.2017

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

解析私钥带密码

func (Ecdh) ParseECDHPublicKeyFromPEM added in v1.0.2017

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

解析公钥

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

func (this Ecdh) SetCurve(curve string) Ecdh

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

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

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

设置散列方式

func (Ecdh) WithErrors

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

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