ecdh

package
v1.0.3005 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// 获取 Cipher 类型
	GetCipherFromName = pkcs8.GetCipherFromName
	// 获取 hash 类型
	GetHashFromName = 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 added in v1.0.2048

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

func NewECDH() ECDH

构造函数

func (ECDH) AppendError added in v1.0.2048

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

添加错误

func (ECDH) CheckKeyPair added in v1.0.2048

func (this ECDH) CheckKeyPair() bool

检测公钥私钥是否匹配

func (ECDH) CreateECDHPrivateKey added in v1.0.2048

func (this ECDH) CreateECDHPrivateKey() ECDH

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

func (ECDH) CreateECDHPrivateKeyWithPassword added in v1.0.2048

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

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

func (ECDH) CreateECDHPublicKey added in v1.0.2048

func (this ECDH) CreateECDHPublicKey() ECDH

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

func (ECDH) CreatePrivateKey added in v1.0.2048

func (this ECDH) CreatePrivateKey() ECDH

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

func (ECDH) CreatePrivateKeyWithPassword added in v1.0.2048

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

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

func (ECDH) CreatePublicKey added in v1.0.2048

func (this ECDH) CreatePublicKey() ECDH

生成公钥 pem 数据

func (ECDH) CreateSecretKey added in v1.0.2048

func (this ECDH) CreateSecretKey() ECDH

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

func (ECDH) Error added in v1.0.2048

func (this ECDH) Error() error

获取错误

func (ECDH) FromECDHPrivateKey added in v1.0.2048

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

私钥, 库自使用的 asn1 格式

func (ECDH) FromECDHPrivateKeyDer added in v1.0.2048

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

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

func (ECDH) FromECDHPrivateKeyWithPassword added in v1.0.2048

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

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

func (ECDH) FromECDHPublicKey added in v1.0.2048

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

公钥, 库自使用的 asn1 格式

func (ECDH) FromECDHPublicKeyDer added in v1.0.2048

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

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

func (ECDH) FromPrivateKey added in v1.0.2048

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

私钥

func (ECDH) FromPrivateKeyDer added in v1.0.2048

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

DER 私钥

func (ECDH) FromPrivateKeyWithPassword added in v1.0.2048

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

私钥带密码

func (ECDH) FromPublicKey added in v1.0.2048

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

公钥

func (ECDH) FromPublicKeyDer added in v1.0.2048

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

DER 公钥

func (ECDH) GenerateKey added in v1.0.2048

func (this ECDH) GenerateKey() ECDH

生成密钥

func (ECDH) GenerateKeyWithSeed added in v1.0.2048

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

生成密钥

func (ECDH) GetCurve added in v1.0.2048

func (this ECDH) GetCurve() ecdh.Curve

获取散列方式

func (ECDH) GetErrors added in v1.0.2048

func (this ECDH) GetErrors() []error

获取错误

func (ECDH) GetKeyData added in v1.0.2048

func (this ECDH) GetKeyData() []byte

获取 keyData

func (ECDH) GetPrivateKey added in v1.0.2048

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

获取 PrivateKey

func (ECDH) GetPublicKey added in v1.0.2048

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

获取 PublicKey

func (ECDH) GetSecretData added in v1.0.2048

func (this ECDH) GetSecretData() []byte

获取 secretData

func (ECDH) MakeKeyDer added in v1.0.2048

func (this ECDH) MakeKeyDer() ECDH

生成密钥 der 数据

func (ECDH) MakePublicKey added in v1.0.2048

func (this ECDH) MakePublicKey() ECDH

生成公钥

func (ECDH) OnError added in v1.0.2048

func (this ECDH) OnError(fn ErrorFunc) ECDH

引出错误信息

func (ECDH) ParseECDHPrivateKeyFromPEM added in v1.0.2048

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

解析私钥

func (ECDH) ParseECDHPrivateKeyFromPEMWithPassword added in v1.0.2048

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

解析私钥带密码

func (ECDH) ParseECDHPublicKeyFromPEM added in v1.0.2048

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

解析公钥

func (ECDH) ParsePrivateKeyFromPEM added in v1.0.2048

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

解析私钥

func (ECDH) ParsePrivateKeyFromPEMWithPassword added in v1.0.2048

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

解析私钥带密码

func (ECDH) ParsePublicKeyFromPEM added in v1.0.2048

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

解析公钥

func (ECDH) SetCurve added in v1.0.2048

func (this ECDH) SetCurve(curve string) ECDH

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

func (ECDH) ToBase64String added in v1.0.2048

func (this ECDH) ToBase64String() string

输出Base64

func (ECDH) ToBytes added in v1.0.2048

func (this ECDH) ToBytes() []byte

输出字节

func (ECDH) ToHexString added in v1.0.2048

func (this ECDH) ToHexString() string

输出Hex

func (ECDH) ToKeyBytes added in v1.0.2048

func (this ECDH) ToKeyBytes() []byte

私钥/公钥

func (ECDH) ToKeyString added in v1.0.2048

func (this ECDH) ToKeyString() string

私钥/公钥

func (ECDH) ToString added in v1.0.2048

func (this ECDH) ToString() string

输出字符

func (ECDH) WithCurve added in v1.0.2048

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

设置散列方式

func (ECDH) WithErrors added in v1.0.2048

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

设置错误

func (ECDH) WithKeyData added in v1.0.2048

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

设置 keyData

func (ECDH) WithPrivateKey added in v1.0.2048

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

设置 PrivateKey

func (ECDH) WithPublicKey added in v1.0.2048

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

设置 PublicKey

func (ECDH) WithSecretData added in v1.0.2048

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

设置 secretData

type ErrorFunc

type ErrorFunc = func([]error)

错误方法

type Opts

type Opts = pkcs8.Opts

配置

type PBKDF2Opts

type PBKDF2Opts = pkcs8.PBKDF2Opts

PBKDF2 配置

type ScryptOpts

type ScryptOpts = pkcs8.ScryptOpts

Scrypt 配置

Jump to

Keyboard shortcuts

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