curve25519

package
v1.0.3023 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 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 curve25519 private key")
	ErrNotPublicKey        = errors.New("key is not a valid curve25519 public key")
)

Functions

This section is empty.

Types

type Curve25519

type Curve25519 struct {

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

*

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

func FromKeyXYString added in v1.0.2071

func FromKeyXYString(xString string, yString string) Curve25519

根据私钥 x, y 生成

func FromPrivateKey added in v1.0.2014

func FromPrivateKey(key []byte) Curve25519

私钥

func FromPrivateKeyWithPassword added in v1.0.2014

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

私钥

func FromPrivateKeyXString added in v1.0.2071

func FromPrivateKeyXString(xString string) Curve25519

根据私钥 x 生成

func FromPublicKey added in v1.0.2014

func FromPublicKey(key []byte) Curve25519

公钥

func FromPublicKeyYString added in v1.0.2071

func FromPublicKeyYString(yString string) Curve25519

根据公钥 y 生成

func GenerateKey added in v1.0.2014

func GenerateKey() Curve25519

生成密钥

func GenerateKeyWithSeed added in v1.0.2026

func GenerateKeyWithSeed(reader io.Reader) Curve25519

生成密钥

func New

func New() Curve25519

构造函数

func NewCurve25519 added in v1.0.2014

func NewCurve25519() Curve25519

构造函数

func (Curve25519) AppendError added in v1.0.1026

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

添加错误

func (Curve25519) CheckKeyPair added in v1.0.1046

func (this Curve25519) CheckKeyPair() bool

检测公钥私钥是否匹配

func (Curve25519) CreatePrivateKey

func (this Curve25519) CreatePrivateKey() Curve25519

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

func (Curve25519) CreatePrivateKeyWithPassword

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

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

func (Curve25519) CreatePublicKey

func (this Curve25519) CreatePublicKey() Curve25519

生成公钥 pem 数据

func (Curve25519) CreateSecretKey added in v1.0.1038

func (this Curve25519) CreateSecretKey() Curve25519

根据公钥和私钥生成密钥

func (Curve25519) Error

func (this Curve25519) Error() error

获取错误

func (Curve25519) FromKeyXYString added in v1.0.2071

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

根据私钥 x, y 生成

func (Curve25519) FromPrivateKey

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

私钥

func (Curve25519) FromPrivateKeyDer added in v1.0.2015

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

DER 私钥

func (Curve25519) FromPrivateKeyWithPassword

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

私钥带密码

func (Curve25519) FromPrivateKeyXString added in v1.0.2071

func (this Curve25519) FromPrivateKeyXString(xString string) Curve25519

根据私钥 x 生成

func (Curve25519) FromPublicKey

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

公钥

func (Curve25519) FromPublicKeyDer added in v1.0.2015

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

DER 公钥

func (Curve25519) FromPublicKeyYString added in v1.0.2071

func (this Curve25519) FromPublicKeyYString(yString string) Curve25519

根据公钥 y 生成

func (Curve25519) GenerateKey

func (this Curve25519) GenerateKey() Curve25519

生成密钥

func (Curve25519) GenerateKeyWithSeed added in v1.0.2026

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

生成密钥

func (Curve25519) GetErrors added in v1.0.1026

func (this Curve25519) GetErrors() []error

获取错误

func (Curve25519) GetKeyData

func (this Curve25519) GetKeyData() []byte

获取 keyData

func (Curve25519) GetPrivateKey

func (this Curve25519) GetPrivateKey() *curve25519.PrivateKey

获取 PrivateKey

func (Curve25519) GetPrivateKeyXString added in v1.0.2071

func (this Curve25519) GetPrivateKeyXString() string

获取 X 16进制字符

func (Curve25519) GetPublicKey

func (this Curve25519) GetPublicKey() *curve25519.PublicKey

获取 PublicKey

func (Curve25519) GetPublicKeyYString added in v1.0.2071

func (this Curve25519) GetPublicKeyYString() string

获取 Y 16进制字符

func (Curve25519) GetSecretData added in v1.0.1026

func (this Curve25519) GetSecretData() []byte

获取 secretData

func (Curve25519) MakeKeyDer added in v1.0.1033

func (this Curve25519) MakeKeyDer() Curve25519

生成密钥 der 数据

func (Curve25519) MakePublicKey

func (this Curve25519) MakePublicKey() Curve25519

生成公钥

func (Curve25519) OnError

func (this Curve25519) OnError(fn ErrorFunc) Curve25519

引出错误信息

func (Curve25519) ParsePrivateKeyFromPEM

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

解析私钥

func (Curve25519) ParsePrivateKeyFromPEMWithPassword

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

解析私钥带密码

func (Curve25519) ParsePublicKeyFromPEM

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

解析公钥

func (Curve25519) ToBase64String

func (this Curve25519) ToBase64String() string

输出Base64

func (Curve25519) ToBytes

func (this Curve25519) ToBytes() []byte

输出字节

func (Curve25519) ToHexString

func (this Curve25519) ToHexString() string

输出Hex

func (Curve25519) ToKeyBytes

func (this Curve25519) ToKeyBytes() []byte

私钥/公钥

func (Curve25519) ToKeyString

func (this Curve25519) ToKeyString() string

私钥/公钥

func (Curve25519) ToString

func (this Curve25519) ToString() string

输出字符

func (Curve25519) WithErrors added in v1.0.1026

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

设置错误

func (Curve25519) WithKeyData

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

设置 keyData

func (Curve25519) WithPrivateKey

func (this Curve25519) WithPrivateKey(data *curve25519.PrivateKey) Curve25519

设置 PrivateKey

func (Curve25519) WithPublicKey

func (this Curve25519) WithPublicKey(data *curve25519.PublicKey) Curve25519

设置 PublicKey

func (Curve25519) WithSecretData added in v1.0.1026

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

设置 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