ecdsa

package
v1.0.1022 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2022 License: Apache-2.0 Imports: 12 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")
)
View Source
var PEMCiphers = map[string]x509.PEMCipher{
	"DESCBC":     x509.PEMCipherDES,
	"DESEDE3CBC": x509.PEMCipher3DES,
	"AES128CBC":  x509.PEMCipherAES128,
	"AES192CBC":  x509.PEMCipherAES192,
	"AES256CBC":  x509.PEMCipherAES256,
}

pem 加密方式

Functions

This section is empty.

Types

type Ecdsa

type Ecdsa struct {

	// 错误
	Error 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 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(hash string) Ecdsa

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

func New added in v1.0.1018

func New() Ecdsa

构造函数

func NewEcdsa

func NewEcdsa() Ecdsa

构造函数

func (Ecdsa) CreatePKCS8KdfPrivateKeyWithPassword added in v1.0.1022

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

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

func (Ecdsa) CreatePKCS8PbePrivateKeyWithPassword added in v1.0.1022

func (this Ecdsa) CreatePKCS8PbePrivateKeyWithPassword(password string, alg string) Ecdsa

生成 PKCS8 私钥带密码 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 数据 使用: obj := New().WithCurve("P521").GenerateKey() priKey := obj.CreatePrivateKey().ToKeyString()

func (Ecdsa) CreatePrivateKeyWithPassword

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

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

func (Ecdsa) CreatePublicKey

func (this Ecdsa) CreatePublicKey() Ecdsa

生成公钥 pem 数据

func (Ecdsa) DataHash

func (this Ecdsa) DataHash(signHash string, data []byte) []byte

签名后数据

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) FromPKCS8PrivateKey

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

PKCS8 私钥

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

明文私钥生成私钥结构体

func (Ecdsa) FromPrivateKeyDBytes

func (this Ecdsa) FromPrivateKeyDBytes(DBytes []byte) Ecdsa

私钥字符,必须先添加公钥

func (Ecdsa) FromPrivateKeyString

func (this Ecdsa) FromPrivateKeyString(keyString string) Ecdsa

私钥字符,必须先添加公钥 (hexStringD)

func (Ecdsa) FromPrivateKeyWithPassword

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

私钥带密码

func (Ecdsa) FromPublicKey

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

公钥

func (Ecdsa) FromPublicKeyString

func (this Ecdsa) FromPublicKeyString(keyString string) Ecdsa

公钥字符 (hexStringX + hexStringY)

func (Ecdsa) FromPublicKeyXYBytes

func (this Ecdsa) FromPublicKeyXYBytes(XBytes, YBytes []byte) Ecdsa

公钥字符对

func (Ecdsa) FromPublicKeyXYString added in v1.0.1018

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

公钥 x,y 16进制字符对 [xString: xHexString, yString: yHexString]

func (Ecdsa) FromString

func (this Ecdsa) FromString(data string) Ecdsa

字符

func (Ecdsa) GenerateKey

func (this Ecdsa) GenerateKey() Ecdsa

生成密钥

func (Ecdsa) GetData

func (this Ecdsa) GetData() []byte

获取 data

func (Ecdsa) GetError

func (this Ecdsa) GetError() 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) GetPrivateKeyXHexString added in v1.0.1018

func (this Ecdsa) GetPrivateKeyXHexString() string

获取 PrivateKeyX

func (Ecdsa) GetPrivateKeyYHexString added in v1.0.1018

func (this Ecdsa) GetPrivateKeyYHexString() string

获取 PrivateKeyY

func (Ecdsa) GetPublicKey

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

获取 PublicKey

func (Ecdsa) GetPublicKeyCurve

func (this Ecdsa) GetPublicKeyCurve() elliptic.Curve

获取 PublicKeyCurve

func (Ecdsa) GetPublicKeyXHexString added in v1.0.1018

func (this Ecdsa) GetPublicKeyXHexString() string

获取 PublicKeyX

func (Ecdsa) GetPublicKeyYHexString added in v1.0.1018

func (this Ecdsa) GetPublicKeyYHexString() string

获取 PublicKeyY

func (Ecdsa) GetSignHash

func (this Ecdsa) GetSignHash() string

获取 hash 类型

func (Ecdsa) GetVeryed

func (this Ecdsa) GetVeryed() bool

获取验证后情况

func (Ecdsa) MakePublicKey

func (this Ecdsa) MakePublicKey() Ecdsa

生成公钥

func (Ecdsa) OnError

func (this Ecdsa) OnError(fn EcdsaErrorFunc) Ecdsa

引出错误信息

func (Ecdsa) ParseECPKCS8PrivateKeyFromPEMWithPassword

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

解析 PKCS8 带密码的私钥

func (Ecdsa) ParseECPrivateKeyFromPEM

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

解析私钥

func (Ecdsa) ParseECPrivateKeyFromPEMWithPassword

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

解析私钥带密码

func (Ecdsa) ParseECPublicKeyFromPEM

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

解析公钥

func (Ecdsa) Sign

func (this Ecdsa) Sign(separator ...string) 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) ToVeryed

func (this Ecdsa) ToVeryed() bool

验证结果

func (Ecdsa) VerifyAsn1

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

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

func (Ecdsa) VerifyHex

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

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

func (Ecdsa) Very

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

公钥验证

func (Ecdsa) WithCurve

func (this Ecdsa) WithCurve(curve string) Ecdsa

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

func (Ecdsa) WithData

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

设置 data

func (Ecdsa) WithError

func (this Ecdsa) WithError(err 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 string) Ecdsa

设置 hash 类型

func (Ecdsa) WithVeryed

func (this Ecdsa) WithVeryed(data bool) Ecdsa

设置验证结果

type EcdsaErrorFunc

type EcdsaErrorFunc = func(error)

错误方法

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