ed448

package
v1.0.2065 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

// 生成公钥私钥 / CreateKey: obj := ed448.

New().
GenerateKey()

objPriKey := obj.

CreatePrivateKey().
// CreatePrivateKeyWithPassword("123", "AES256CBC").
ToKeyString()

objPubKey := obj.

CreatePublicKey().
ToKeyString()

// 签名验证 / Sign or Verify: obj := ed448.New()

ctx := "123sedrftd35"

pri := `-----BEGIN PRIVATE KEY-----...-----END PRIVATE KEY-----` priEn := `-----BEGIN ENCRYPTED PRIVATE KEY-----...-----END ENCRYPTED PRIVATE KEY-----` sig := obj.

FromString("test-pass").
FromPrivateKey([]byte(pri)).
// FromPrivateKeyWithPassword([]byte(priEn), "123").
// 其他设置, 默认为 ED448 模式, ctx 为空
// SetOptions("ED448", "").
// SetOptions("ED448", ctx).
// SetOptions("ED448Ph", ctx).
Sign().
ToBase64String()

pub := `-----BEGIN PUBLIC KEY-----...-----END PUBLIC KEY-----` text := obj.

FromBase64String("MjkzNzYzMDE1NjgzNDExMTM0ODE1MzgxOTAxMDIxNzQ0Nzg3NTc3NTAxNTU2MDIwNzg4OTc1MzY4Mzc0OTE5NzcyOTg3NjI1MTc2OTErNDgzNDU3NDAyMzYyODAzMDM3MzE1NjE1NDk1NDEzOTQ4MDQ3NDQ3ODA0MDE4NDY5NDA1OTA3ODExNjM1Mzk3MDEzOTY4MTM5NDg2NDc=").
FromPublicKey([]byte(pub)).
// SetOptions("ED448", "").
// SetOptions("ED448", ctx).
// SetOptions("ED448Ph", ctx).
Verify([]byte("test-pass")).
ToVerify()

Index

Constants

View Source
const (
	SchemeED448   = ed448.ED448
	SchemeED448Ph = ed448.ED448Ph
)

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 PKCS8 key")
	ErrNotEdPrivateKey     = errors.New("key is not a valid ED448 private key")
	ErrNotEdPublicKey      = errors.New("key is not a valid ED448 public key")
)

Functions

This section is empty.

Types

type ED448

type ED448 struct {

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

*

  • ED448 *
  • @create 2023-10-25
  • @author deatil

func FromBase64String

func FromBase64String(data string) ED448

Base64

func FromBytes

func FromBytes(data []byte) ED448

字节

func FromHexString

func FromHexString(data string) ED448

Hex

func FromPrivateKey

func FromPrivateKey(key []byte) ED448

私钥

func FromPrivateKeySeed

func FromPrivateKeySeed(seed []byte) ED448

私钥 Seed

func FromPrivateKeyWithPassword

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

私钥

func FromPublicKey

func FromPublicKey(key []byte) ED448

公钥

func FromString

func FromString(data string) ED448

字符

func GenerateKey

func GenerateKey() ED448

生成密钥

func GenerateKeyWithSeed

func GenerateKeyWithSeed(reader io.Reader) ED448

生成密钥

func New

func New() ED448

构造函数

func NewED448

func NewED448() ED448

构造函数

func (ED448) AppendError

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

添加错误

func (ED448) CheckKeyPair

func (this ED448) CheckKeyPair() bool

检测公钥私钥是否匹配

func (ED448) CreatePrivateKey

func (this ED448) CreatePrivateKey() ED448

生成私钥 pem 数据

func (ED448) CreatePrivateKeyWithPassword

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

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

func (ED448) CreatePublicKey

func (this ED448) CreatePublicKey() ED448

生成公钥 pem 数据

func (ED448) Error

func (this ED448) Error() error

获取错误

func (ED448) FromBase64String

func (this ED448) FromBase64String(data string) ED448

Base64

func (ED448) FromBytes

func (this ED448) FromBytes(data []byte) ED448

字节

func (ED448) FromHexString

func (this ED448) FromHexString(data string) ED448

Hex

func (ED448) FromPrivateKey

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

私钥

func (ED448) FromPrivateKeyDer

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

DER 私钥

func (ED448) FromPrivateKeySeed

func (this ED448) FromPrivateKeySeed(seed []byte) ED448

私钥 Seed

func (ED448) FromPrivateKeyWithPassword

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

私钥带密码

func (ED448) FromPublicKey

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

公钥

func (ED448) FromPublicKeyDer

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

DER 公钥

func (ED448) FromString

func (this ED448) FromString(data string) ED448

字符

func (ED448) GenerateKey

func (this ED448) GenerateKey() ED448

生成密钥

func (ED448) GenerateKeyWithSeed

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

生成密钥

func (ED448) GetData

func (this ED448) GetData() []byte

获取 data

func (ED448) GetErrors

func (this ED448) GetErrors() []error

获取错误

func (ED448) GetKeyData

func (this ED448) GetKeyData() []byte

获取 keyData

func (ED448) GetOptions

func (this ED448) GetOptions() *Options

获取 Options

func (ED448) GetParsedData added in v1.0.2049

func (this ED448) GetParsedData() []byte

获取 parsedData

func (ED448) GetPrivateKey

func (this ED448) GetPrivateKey() ed448.PrivateKey

获取 PrivateKey

func (ED448) GetPrivateKeySeed

func (this ED448) GetPrivateKeySeed() []byte

获取 PrivateKeySeed

func (ED448) GetPublicKey

func (this ED448) GetPublicKey() ed448.PublicKey

获取 PublicKey

func (ED448) GetVerify

func (this ED448) GetVerify() bool

获取验证后情况

func (ED448) MakeKeyDer

func (this ED448) MakeKeyDer() ED448

生成密钥 der 数据

func (ED448) MakePublicKey

func (this ED448) MakePublicKey() ED448

生成公钥

func (ED448) OnError

func (this ED448) OnError(fn EdDSAErrorFunc) ED448

引出错误信息

func (ED448) ParsePrivateKeyFromPEM

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

解析私钥

func (ED448) ParsePrivateKeyFromPEMWithPassword

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

解析私钥带密码

func (ED448) ParsePublicKeyFromPEM

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

解析公钥

func (ED448) SetOptions

func (this ED448) SetOptions(name string, context ...string) ED448

设置 options 可用类型 [ED448Ph | ED448]

func (ED448) Sign

func (this ED448) Sign() ED448

私钥签名

func (ED448) ToBase64String

func (this ED448) ToBase64String() string

输出Base64

func (ED448) ToBytes

func (this ED448) ToBytes() []byte

输出字节

func (ED448) ToHexString

func (this ED448) ToHexString() string

输出Hex

func (ED448) ToKeyBytes

func (this ED448) ToKeyBytes() []byte

私钥/公钥

func (ED448) ToKeyString

func (this ED448) ToKeyString() string

私钥/公钥

func (ED448) ToString

func (this ED448) ToString() string

输出字符

func (ED448) ToVerify

func (this ED448) ToVerify() bool

验证结果

func (ED448) ToVerifyInt

func (this ED448) ToVerifyInt() int

验证结果,返回 int 类型

func (ED448) Verify

func (this ED448) Verify(data []byte) ED448

公钥验证

func (ED448) WithData

func (this ED448) WithData(data []byte) ED448

设置 data

func (ED448) WithErrors

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

设置错误

func (ED448) WithOptions

func (this ED448) WithOptions(op *Options) ED448

设置 options

func (ED448) WithParsedData added in v1.0.2049

func (this ED448) WithParsedData(data []byte) ED448

设置 parsedData

func (ED448) WithPrivateKey

func (this ED448) WithPrivateKey(data ed448.PrivateKey) ED448

设置 PrivateKey

func (ED448) WithPublicKey

func (this ED448) WithPublicKey(data ed448.PublicKey) ED448

设置 PublicKey

func (ED448) WithVerify

func (this ED448) WithVerify(data bool) ED448

设置 verify

type EdDSAErrorFunc

type EdDSAErrorFunc = func([]error)

错误方法

type Options

type Options = ed448.Options

设置

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