ecdh

package
v1.0.3029 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: Apache-2.0 Imports: 8 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 *
  • @create 2022-8-7
  • @author deatil

func FromKeyXYString added in v1.0.2071

func FromKeyXYString(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 FromPrivateKeyXString added in v1.0.2071

func FromPrivateKeyXString(xString string) ECDH

根据私钥 x 生成

func FromPublicKey added in v1.0.2014

func FromPublicKey(key []byte) ECDH

公钥

func FromPublicKeyYString added in v1.0.2071

func FromPublicKeyYString(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.2048

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

添加错误

func (ECDH) CheckKeyPair added in v1.0.2048

func (this ECDH) CheckKeyPair() bool

检测公钥私钥是否匹配

func (ECDH) CreatePrivateKey added in v1.0.2048

func (this ECDH) CreatePrivateKey() ECDH

生成私钥 pem 数据 使用: obj := New().GenerateKey("P2048") 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) FromKeyXYString added in v1.0.2071

func (this ECDH) FromKeyXYString(xString string, yString string) ECDH

根据私钥 x, y 生成

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) FromPrivateKeyXString added in v1.0.2071

func (this ECDH) FromPrivateKeyXString(xString string) ECDH

根据私钥 x 生成

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) FromPublicKeyYString added in v1.0.2071

func (this ECDH) FromPublicKeyYString(yString string) ECDH

根据公钥 y 生成

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) GetPrivateKeyXString added in v1.0.2071

func (this ECDH) GetPrivateKeyXString() string

获取 X 16进制字符

func (ECDH) GetPublicKey added in v1.0.2048

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

获取 PublicKey

func (ECDH) GetPublicKeyYString added in v1.0.2071

func (this ECDH) GetPublicKeyYString() string

获取 Y 16进制字符

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) 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(name string) ECDH

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

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