ecdsa

package
v1.0.2032 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// 获取 Cipher 类型
	GetCipherFromName = cryptobin_pkcs8.GetCipherFromName
	// 获取 hash 类型
	GetHashFromName = cryptobin_pkcs8.GetHashFromName
)
View Source
var (
	ErrKeyMustBePEMEncoded = errors.New("invalid key: Key must be a PEM encoded PKCS1 or PKCS8 key")
	ErrNotECPublicKey      = errors.New("key is not a valid ECDSA public key")
	ErrNotECPrivateKey     = errors.New("key is not a valid ECDSA private key")
)

Functions

This section is empty.

Types

type Ecdsa

type Ecdsa struct {

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

*

  • Ecdsa *
  • @create 2022-4-3
  • @author deatil

func FromBase64String added in v1.0.1018

func FromBase64String(data string) Ecdsa

Base64

func FromBytes added in v1.0.1018

func FromBytes(data []byte) Ecdsa

字节

func FromHexString added in v1.0.1018

func FromHexString(data string) Ecdsa

Hex

func FromPKCS1PrivateKey added in v1.0.2015

func FromPKCS1PrivateKey(key []byte) Ecdsa

私钥

func FromPKCS1PrivateKeyWithPassword added in v1.0.2015

func FromPKCS1PrivateKeyWithPassword(key []byte, password string) Ecdsa

私钥带密码

func FromPKCS8PrivateKey added in v1.0.1018

func FromPKCS8PrivateKey(key []byte) Ecdsa

PKCS8 私钥

func FromPKCS8PrivateKeyWithPassword added in v1.0.1018

func FromPKCS8PrivateKeyWithPassword(key []byte, password string) Ecdsa

PKCS8 私钥带密码

func FromPrivateKey added in v1.0.1018

func FromPrivateKey(key []byte) Ecdsa

私钥

func FromPrivateKeyWithPassword added in v1.0.1018

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

私钥

func FromPublicKey added in v1.0.1018

func FromPublicKey(key []byte) Ecdsa

公钥

func FromString added in v1.0.1018

func FromString(data string) Ecdsa

字符

func GenerateKey added in v1.0.1018

func GenerateKey(curve string) Ecdsa

生成密钥 可选 [P521 | P384 | P256 | P224]

func GenerateKeyWithSeed added in v1.0.2026

func GenerateKeyWithSeed(reader io.Reader, curve string) Ecdsa

生成密钥 可选 [P521 | P384 | P256 | P224]

func New added in v1.0.1018

func New() Ecdsa

构造函数

func NewEcdsa

func NewEcdsa() Ecdsa

构造函数

func (Ecdsa) AppendError added in v1.0.1026

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

添加错误

func (Ecdsa) CheckKeyPair added in v1.0.1043

func (this Ecdsa) CheckKeyPair() bool

检测公钥私钥是否匹配

func (Ecdsa) CreatePKCS1PrivateKey added in v1.0.1028

func (this Ecdsa) CreatePKCS1PrivateKey() Ecdsa

生成私钥 pem 数据

func (Ecdsa) CreatePKCS1PrivateKeyWithPassword added in v1.0.1028

func (this Ecdsa) CreatePKCS1PrivateKeyWithPassword(password string, opts ...string) Ecdsa

生成私钥带密码 pem 数据

func (Ecdsa) CreatePKCS8PrivateKey

func (this Ecdsa) CreatePKCS8PrivateKey() Ecdsa

生成 PKCS8 私钥 pem 数据

func (Ecdsa) CreatePKCS8PrivateKeyWithPassword

func (this Ecdsa) CreatePKCS8PrivateKeyWithPassword(password string, opts ...any) Ecdsa

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

func (Ecdsa) CreatePrivateKey

func (this Ecdsa) CreatePrivateKey() Ecdsa

生成私钥 pem 数据, PKCS1 别名 使用: obj := New().WithCurve("P521").GenerateKey() priKey := obj.CreatePrivateKey().ToKeyString()

func (Ecdsa) CreatePrivateKeyWithPassword

func (this Ecdsa) CreatePrivateKeyWithPassword(password string, opts ...string) Ecdsa

生成私钥带密码 pem 数据, PKCS1 别名 CreatePrivateKeyWithPassword("123", "AES256CBC") PEMCipher: DESCBC | DESEDE3CBC | AES128CBC | AES192CBC | AES256CBC

func (Ecdsa) CreatePublicKey

func (this Ecdsa) CreatePublicKey() Ecdsa

生成公钥 pem 数据

func (Ecdsa) DataHash

func (this Ecdsa) DataHash(fn HashFunc, data []byte) ([]byte, error)

签名后数据

func (Ecdsa) Decrypt added in v1.0.2003

func (this Ecdsa) Decrypt() Ecdsa

私钥解密 Ecdsa 核心为对称加密

func (Ecdsa) Encrypt added in v1.0.2003

func (this Ecdsa) Encrypt() Ecdsa

公钥加密 Ecdsa 核心为对称加密

func (Ecdsa) Error

func (this Ecdsa) Error() error

获取错误

func (Ecdsa) FromBase64String

func (this Ecdsa) FromBase64String(data string) Ecdsa

Base64

func (Ecdsa) FromBytes

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

字节

func (Ecdsa) FromHexString

func (this Ecdsa) FromHexString(data string) Ecdsa

Hex

func (Ecdsa) FromPKCS1PrivateKey added in v1.0.2014

func (this Ecdsa) FromPKCS1PrivateKey(key []byte) Ecdsa

私钥

func (Ecdsa) FromPKCS1PrivateKeyDer added in v1.0.2015

func (this Ecdsa) FromPKCS1PrivateKeyDer(der []byte) Ecdsa

DER 私钥

func (Ecdsa) FromPKCS1PrivateKeyWithPassword added in v1.0.2014

func (this Ecdsa) FromPKCS1PrivateKeyWithPassword(key []byte, password string) Ecdsa

私钥带密码

func (Ecdsa) FromPKCS8PrivateKey

func (this Ecdsa) FromPKCS8PrivateKey(key []byte) Ecdsa

PKCS8 私钥

func (Ecdsa) FromPKCS8PrivateKeyDer added in v1.0.2015

func (this Ecdsa) FromPKCS8PrivateKeyDer(der []byte) Ecdsa

DER 私钥

func (Ecdsa) FromPKCS8PrivateKeyWithPassword

func (this Ecdsa) FromPKCS8PrivateKeyWithPassword(key []byte, password string) Ecdsa

Pkcs8WithPassword

func (Ecdsa) FromPrivateKey

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

私钥

func (Ecdsa) FromPrivateKeyBytes

func (this Ecdsa) FromPrivateKeyBytes(priByte []byte) Ecdsa

明文私钥生成私钥结构体 需要设置对应的 curve

func (Ecdsa) FromPrivateKeyString

func (this Ecdsa) FromPrivateKeyString(keyString string) Ecdsa

私钥明文,需要设置对应的 curve private-key: 07e4********;

func (Ecdsa) FromPrivateKeyWithPassword

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

私钥带密码

func (Ecdsa) FromPublicKey

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

公钥

func (Ecdsa) FromPublicKeyBytes added in v1.0.2031

func (this Ecdsa) FromPublicKeyBytes(pub []byte) Ecdsa

公钥明文, hex 或者 base64 解码后 需要设置对应的 curve

func (Ecdsa) FromPublicKeyCompressString added in v1.0.2031

func (this Ecdsa) FromPublicKeyCompressString(key string) Ecdsa

公钥明文压缩 需要设置对应的 curve public-key hex: 027c******** || 036c********

func (Ecdsa) FromPublicKeyDer added in v1.0.2015

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

DER 公钥

func (Ecdsa) FromPublicKeyString

func (this Ecdsa) FromPublicKeyString(key string) Ecdsa

公钥明文,需要设置对应的 curve

func (Ecdsa) FromPublicKeyUncompressString added in v1.0.2031

func (this Ecdsa) FromPublicKeyUncompressString(key string) Ecdsa

公钥明文未压缩 需要设置对应的 curve public-key hex: 047c********.

func (Ecdsa) FromPublicKeyXYBytes

func (this Ecdsa) FromPublicKeyXYBytes(xBytes, yBytes []byte) Ecdsa

公钥字符对,需要设置对应的 curve

func (Ecdsa) FromPublicKeyXYString added in v1.0.1018

func (this Ecdsa) FromPublicKeyXYString(xString string, yString string) Ecdsa

公钥 x,y 16进制字符对 需要设置对应的 curve [xString: xHexString, yString: yHexString]

func (Ecdsa) FromString

func (this Ecdsa) FromString(data string) Ecdsa

字符

func (Ecdsa) GenerateKey

func (this Ecdsa) GenerateKey() Ecdsa

生成密钥

func (Ecdsa) GenerateKeyWithSeed added in v1.0.2026

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

生成密钥

func (Ecdsa) GetData

func (this Ecdsa) GetData() []byte

获取 data

func (Ecdsa) GetErrors added in v1.0.1026

func (this Ecdsa) GetErrors() []error

获取错误

func (Ecdsa) GetKeyData

func (this Ecdsa) GetKeyData() []byte

获取 keyData

func (Ecdsa) GetParedData

func (this Ecdsa) GetParedData() []byte

获取 paredData

func (Ecdsa) GetPrivateKey

func (this Ecdsa) GetPrivateKey() *ecdsa.PrivateKey

获取 PrivateKey

func (Ecdsa) GetPrivateKeyCurve

func (this Ecdsa) GetPrivateKeyCurve() elliptic.Curve

获取 PrivateKeyCurve

func (Ecdsa) GetPrivateKeyDHexString added in v1.0.1018

func (this Ecdsa) GetPrivateKeyDHexString() string

获取 PrivateKeyD

func (Ecdsa) GetPrivateKeyString added in v1.0.2031

func (this Ecdsa) GetPrivateKeyString() string

获取私钥明文

func (Ecdsa) GetPublicKey

func (this Ecdsa) GetPublicKey() *ecdsa.PublicKey

获取 PublicKey

func (Ecdsa) GetPublicKeyCompressString added in v1.0.2031

func (this Ecdsa) GetPublicKeyCompressString() string

获取压缩公钥

func (Ecdsa) GetPublicKeyCurve

func (this Ecdsa) GetPublicKeyCurve() elliptic.Curve

获取 PublicKeyCurve

func (Ecdsa) GetPublicKeyUncompressString added in v1.0.2031

func (this Ecdsa) GetPublicKeyUncompressString() string

获取未压缩公钥

func (Ecdsa) GetPublicKeyXHexString added in v1.0.1018

func (this Ecdsa) GetPublicKeyXHexString() string

获取 PublicKeyX

func (Ecdsa) GetPublicKeyXYHexString added in v1.0.2031

func (this Ecdsa) GetPublicKeyXYHexString() string

获取 PublicKeyXYHex

func (Ecdsa) GetPublicKeyYHexString added in v1.0.1018

func (this Ecdsa) GetPublicKeyYHexString() string

获取 PublicKeyY

func (Ecdsa) GetSignHash

func (this Ecdsa) GetSignHash() HashFunc

获取 hash 类型

func (Ecdsa) GetVerify added in v1.0.1032

func (this Ecdsa) GetVerify() bool

获取验证后情况

func (Ecdsa) MakePublicKey

func (this Ecdsa) MakePublicKey() Ecdsa

生成公钥

func (Ecdsa) OnError

func (this Ecdsa) OnError(fn EcdsaErrorFunc) Ecdsa

引出错误信息

func (Ecdsa) ParsePKCS1PrivateKeyFromPEM added in v1.0.2014

func (this Ecdsa) ParsePKCS1PrivateKeyFromPEM(key []byte) (*ecdsa.PrivateKey, error)

解析私钥

func (Ecdsa) ParsePKCS1PrivateKeyFromPEMWithPassword added in v1.0.2014

func (this Ecdsa) ParsePKCS1PrivateKeyFromPEMWithPassword(key []byte, password string) (*ecdsa.PrivateKey, error)

解析私钥带密码

func (Ecdsa) ParsePKCS8PrivateKeyFromPEM added in v1.0.2014

func (this Ecdsa) ParsePKCS8PrivateKeyFromPEM(key []byte) (*ecdsa.PrivateKey, error)

解析私钥

func (Ecdsa) ParsePKCS8PrivateKeyFromPEMWithPassword added in v1.0.1043

func (this Ecdsa) ParsePKCS8PrivateKeyFromPEMWithPassword(key []byte, password string) (*ecdsa.PrivateKey, error)

解析 PKCS8 带密码的私钥

func (Ecdsa) ParsePublicKeyFromPEM added in v1.0.1043

func (this Ecdsa) ParsePublicKeyFromPEM(key []byte) (*ecdsa.PublicKey, error)

解析公钥

func (Ecdsa) SetCurve added in v1.0.2014

func (this Ecdsa) SetCurve(curve string) Ecdsa

设置曲线类型 可选参数 [P521 | P384 | P256 | P224]

func (Ecdsa) SetSignHash added in v1.0.2014

func (this Ecdsa) SetSignHash(hash string) Ecdsa

设置 hash 类型

func (Ecdsa) Sign

func (this Ecdsa) Sign(separator ...string) Ecdsa

私钥签名

func (Ecdsa) SignASN1 added in v1.0.1050

func (this Ecdsa) SignASN1() Ecdsa

私钥签名, 官方默认

func (Ecdsa) SignAsn1

func (this Ecdsa) SignAsn1() Ecdsa

私钥签名

func (Ecdsa) SignHex

func (this Ecdsa) SignHex() Ecdsa

私钥签名

func (Ecdsa) ToBase64String

func (this Ecdsa) ToBase64String() string

输出Base64

func (Ecdsa) ToBytes

func (this Ecdsa) ToBytes() []byte

输出字节

func (Ecdsa) ToHexString

func (this Ecdsa) ToHexString() string

输出Hex

func (Ecdsa) ToKeyBytes

func (this Ecdsa) ToKeyBytes() []byte

私钥/公钥

func (Ecdsa) ToKeyString

func (this Ecdsa) ToKeyString() string

私钥/公钥

func (Ecdsa) ToString

func (this Ecdsa) ToString() string

输出字符

func (Ecdsa) ToVerify added in v1.0.1032

func (this Ecdsa) ToVerify() bool

验证结果

func (Ecdsa) ToVerifyInt added in v1.0.1033

func (this Ecdsa) ToVerifyInt() int

验证结果,返回 int 类型

func (Ecdsa) Verify added in v1.0.1033

func (this Ecdsa) Verify(data []byte, separator ...string) Ecdsa

公钥验证

func (Ecdsa) VerifyASN1 added in v1.0.1050

func (this Ecdsa) VerifyASN1(data []byte) Ecdsa

公钥验证, 官方默认 使用原始数据[data]对比签名后数据

func (Ecdsa) VerifyAsn1

func (this Ecdsa) VerifyAsn1(data []byte) Ecdsa

公钥验证 使用原始数据[data]对比签名后数据

func (Ecdsa) VerifyHex

func (this Ecdsa) VerifyHex(data []byte) Ecdsa

公钥验证 使用原始数据[data]对比签名后数据

func (Ecdsa) WithCurve

func (this Ecdsa) WithCurve(curve elliptic.Curve) Ecdsa

设置曲线类型

func (Ecdsa) WithData

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

设置 data

func (Ecdsa) WithErrors added in v1.0.1026

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

设置错误

func (Ecdsa) WithParedData

func (this Ecdsa) WithParedData(data []byte) Ecdsa

设置 paredData

func (Ecdsa) WithPrivateKey

func (this Ecdsa) WithPrivateKey(data *ecdsa.PrivateKey) Ecdsa

设置 PrivateKey

func (Ecdsa) WithPublicKey

func (this Ecdsa) WithPublicKey(data *ecdsa.PublicKey) Ecdsa

设置 PublicKey

func (Ecdsa) WithSignHash

func (this Ecdsa) WithSignHash(hash HashFunc) Ecdsa

设置 hash 类型

func (Ecdsa) WithVerify added in v1.0.1032

func (this Ecdsa) WithVerify(data bool) Ecdsa

设置验证结果

type EcdsaErrorFunc

type EcdsaErrorFunc = func([]error)

错误方法

type HashFunc added in v1.0.2014

type HashFunc = func() hash.Hash

HashFunc

type Opts added in v1.0.1018

type Opts = cryptobin_pkcs8.Opts

配置

type PBKDF2Opts added in v1.0.1018

type PBKDF2Opts = cryptobin_pkcs8.PBKDF2Opts

PBKDF2 配置

type ScryptOpts added in v1.0.1018

type ScryptOpts = cryptobin_pkcs8.ScryptOpts

Scrypt 配置

Jump to

Keyboard shortcuts

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