dh

package
v1.0.2067 Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: Apache-2.0 Imports: 10 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 dh private key")
	ErrNotPublicKey        = errors.New("key is not a valid dh public key")
)

Functions

func RandomString added in v1.0.1028

func RandomString(n int64, allowedChars ...[]rune) string

生成随机字符

Types

type DH added in v1.0.2048

type DH struct {

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

*

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

func FromKeyXYHexString added in v1.0.2014

func FromKeyXYHexString(xString string, yString string) DH

根据私钥 x, y 生成

func FromPrivateKey added in v1.0.2014

func FromPrivateKey(key []byte) DH

私钥

func FromPrivateKeyWithPassword added in v1.0.2014

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

私钥

func FromPrivateKeyXHexString added in v1.0.2014

func FromPrivateKeyXHexString(xString string) DH

根据私钥 x 生成

func FromPublicKey added in v1.0.2014

func FromPublicKey(key []byte) DH

公钥

func FromPublicKeyYHexString added in v1.0.2014

func FromPublicKeyYHexString(yString string) DH

根据公钥 y 生成

func GenerateKey added in v1.0.2014

func GenerateKey(name string) DH

生成密钥

func GenerateKeyWithSeed added in v1.0.2026

func GenerateKeyWithSeed(reader io.Reader, name string) DH

生成密钥

func New

func New() DH

构造函数

func NewDH added in v1.0.2014

func NewDH() DH

构造函数

func (DH) AppendError added in v1.0.2048

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

添加错误

func (DH) CheckKeyPair added in v1.0.2048

func (this DH) CheckKeyPair() bool

检测公钥私钥是否匹配

func (DH) CreatePrivateKey added in v1.0.2048

func (this DH) CreatePrivateKey() DH

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

func (DH) CreatePrivateKeyWithPassword added in v1.0.2048

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

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

func (DH) CreatePublicKey added in v1.0.2048

func (this DH) CreatePublicKey() DH

生成公钥 pem 数据

func (DH) CreateSecretKey added in v1.0.2048

func (this DH) CreateSecretKey() DH

根据公钥和私钥生成密钥

func (DH) Error added in v1.0.2048

func (this DH) Error() error

获取错误

func (DH) FromKeyXYHexString added in v1.0.2048

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

根据密钥 x, y 生成

func (DH) FromPrivateKey added in v1.0.2048

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

私钥

func (DH) FromPrivateKeyDer added in v1.0.2048

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

DER 私钥

func (DH) FromPrivateKeyWithPassword added in v1.0.2048

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

私钥带密码

func (DH) FromPrivateKeyXHexString added in v1.0.2048

func (this DH) FromPrivateKeyXHexString(xString string) DH

根据私钥 x 生成

func (DH) FromPublicKey added in v1.0.2048

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

公钥

func (DH) FromPublicKeyDer added in v1.0.2048

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

DER 公钥

func (DH) FromPublicKeyYHexString added in v1.0.2048

func (this DH) FromPublicKeyYHexString(yString string) DH

根据公钥 y 生成

func (DH) GenerateKey added in v1.0.2048

func (this DH) GenerateKey() DH

生成密钥

func (DH) GenerateKeyWithSeed added in v1.0.2048

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

生成密钥

func (DH) GetErrors added in v1.0.2048

func (this DH) GetErrors() []error

获取错误

func (DH) GetGroup added in v1.0.2048

func (this DH) GetGroup() *dh.Group

获取分组

func (DH) GetKeyData added in v1.0.2048

func (this DH) GetKeyData() []byte

获取 keyData

func (DH) GetPrivateKey added in v1.0.2048

func (this DH) GetPrivateKey() *dh.PrivateKey

获取 PrivateKey

func (DH) GetPrivateKeyXHexString added in v1.0.2048

func (this DH) GetPrivateKeyXHexString() string

获取 X 16进制字符

func (DH) GetPublicKey added in v1.0.2048

func (this DH) GetPublicKey() *dh.PublicKey

获取 PublicKey

func (DH) GetPublicKeyParametersGHexString added in v1.0.2048

func (this DH) GetPublicKeyParametersGHexString() string

获取 G 16进制字符

func (DH) GetPublicKeyParametersPHexString added in v1.0.2048

func (this DH) GetPublicKeyParametersPHexString() string

获取 P 16进制字符

func (DH) GetPublicKeyYHexString added in v1.0.2048

func (this DH) GetPublicKeyYHexString() string

获取 Y 16进制字符

func (DH) GetSecretData added in v1.0.2048

func (this DH) GetSecretData() []byte

获取 secretData

func (DH) MakeKeyDer added in v1.0.2048

func (this DH) MakeKeyDer() DH

生成密钥 der 数据

func (DH) MakePublicKey added in v1.0.2048

func (this DH) MakePublicKey() DH

生成公钥

func (DH) OnError added in v1.0.2048

func (this DH) OnError(fn ErrorFunc) DH

引出错误信息

func (DH) ParsePrivateKeyFromPEM added in v1.0.2048

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

解析私钥

func (DH) ParsePrivateKeyFromPEMWithPassword added in v1.0.2048

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

解析私钥带密码

func (DH) ParsePublicKeyFromPEM added in v1.0.2048

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

解析公钥

func (DH) SetGroup added in v1.0.2048

func (this DH) SetGroup(name string) DH

根据 Group 数据设置分组

func (DH) SetGroupPG added in v1.0.2048

func (this DH) SetGroupPG(p string, g int64) DH

根据 Group P和G 数据设置分组

func (DH) SetRandGroup added in v1.0.2048

func (this DH) SetRandGroup(num int64) DH

随机数

func (DH) ToBase64String added in v1.0.2048

func (this DH) ToBase64String() string

输出Base64

func (DH) ToBytes added in v1.0.2048

func (this DH) ToBytes() []byte

输出字节

func (DH) ToHexString added in v1.0.2048

func (this DH) ToHexString() string

输出Hex

func (DH) ToKeyBytes added in v1.0.2048

func (this DH) ToKeyBytes() []byte

私钥/公钥

func (DH) ToKeyString added in v1.0.2048

func (this DH) ToKeyString() string

私钥/公钥

func (DH) ToString added in v1.0.2048

func (this DH) ToString() string

输出字符

func (DH) WithError added in v1.0.2048

func (this DH) WithError(errs []error) DH

设置错误

func (DH) WithGroup added in v1.0.2048

func (this DH) WithGroup(data *dh.Group) DH

设置分组

func (DH) WithKeyData added in v1.0.2048

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

设置 keyData

func (DH) WithPrivateKey added in v1.0.2048

func (this DH) WithPrivateKey(data *dh.PrivateKey) DH

设置 PrivateKey

func (DH) WithPublicKey added in v1.0.2048

func (this DH) WithPublicKey(data *dh.PublicKey) DH

设置 PublicKey

func (DH) WithSecretData added in v1.0.2048

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

设置 secretData

type ErrorFunc

type ErrorFunc = func([]error)

错误方法

type Group added in v1.0.1025

type Group = cryptobin_dh.Group

Group 别名

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