ecdsa

package
v1.0.1017 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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 EcdsaFromBase64String

func EcdsaFromBase64String(data string) Ecdsa

Base64

func EcdsaFromBytes

func EcdsaFromBytes(data []byte) Ecdsa

字节

func EcdsaFromHexString

func EcdsaFromHexString(data string) Ecdsa

Hex

func EcdsaFromPKCS8PrivateKey

func EcdsaFromPKCS8PrivateKey(key []byte) Ecdsa

PKCS8 私钥

func EcdsaFromPKCS8PrivateKeyWithPassword

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

PKCS8 私钥带密码

func EcdsaFromPrivateKey

func EcdsaFromPrivateKey(key []byte) Ecdsa

私钥

func EcdsaFromPrivateKeyWithPassword

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

私钥

func EcdsaFromPublicKey

func EcdsaFromPublicKey(key []byte) Ecdsa

公钥

func EcdsaFromString

func EcdsaFromString(data string) Ecdsa

字符

func EcdsaFromYoumarkPKCS8PrivateKeyWithPassword

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

设置私钥带密码

func EcdsaGenerateKey

func EcdsaGenerateKey(hash string) Ecdsa

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

func NewEcdsa

func NewEcdsa() Ecdsa

构造函数

func (Ecdsa) CreatePKCS8PrivateKey

func (this Ecdsa) CreatePKCS8PrivateKey() Ecdsa

PKCS8 私钥

func (Ecdsa) CreatePKCS8PrivateKeyWithPassword

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

PKCS8 私钥带密码 CreatePKCS8PrivateKeyWithPassword("123", "AES256CBC", "SHA256")

func (Ecdsa) CreatePrivateKey

func (this Ecdsa) CreatePrivateKey() Ecdsa

私钥

func (Ecdsa) CreatePrivateKeyWithPassword

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

私钥带密码 CreatePrivateKeyWithPassword("123", "AES256CBC")

func (Ecdsa) CreatePublicKey

func (this Ecdsa) CreatePublicKey() Ecdsa

公钥

func (Ecdsa) CreateYoumarkPKCS8PrivateKeyWithPassword

func (this Ecdsa) CreateYoumarkPKCS8PrivateKeyWithPassword(password string, opt ...tool.YoumarkPKCS8Opts) Ecdsa

创建私钥带密码

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

func (this Ecdsa) FromString(data string) Ecdsa

字符

func (Ecdsa) FromYoumarkPKCS8PrivateKeyWithPassword

func (this Ecdsa) FromYoumarkPKCS8PrivateKeyWithPassword(key []byte, password 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) GetPrivateKeyD

func (this Ecdsa) GetPrivateKeyD() *big.Int

获取 PrivateKeyD privateKeyDHex := cryptobin_tool.NewEncoding().HexEncode(GetPrivateKeyD().Bytes())

func (Ecdsa) GetPrivateKeyX

func (this Ecdsa) GetPrivateKeyX() *big.Int

获取 PrivateKeyX privateKeyXHex := cryptobin_tool.NewEncoding().HexEncode(GetPrivateKeyX().Bytes())

func (Ecdsa) GetPrivateKeyY

func (this Ecdsa) GetPrivateKeyY() *big.Int

获取 PrivateKeyY privateKeyYHex := cryptobin_tool.NewEncoding().HexEncode(GetPrivateKeyY().Bytes())

func (Ecdsa) GetPublicKey

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

获取 PublicKey

func (Ecdsa) GetPublicKeyCurve

func (this Ecdsa) GetPublicKeyCurve() elliptic.Curve

获取 PublicKeyCurve

func (Ecdsa) GetPublicKeyX

func (this Ecdsa) GetPublicKeyX() *big.Int

获取 PublicKeyX publicKeyXHex := cryptobin_tool.NewEncoding().HexEncode(GetPublicKeyX().Bytes())

func (Ecdsa) GetPublicKeyY

func (this Ecdsa) GetPublicKeyY() *big.Int

获取 PublicKeyY publicKeyYHex := cryptobin_tool.NewEncoding().HexEncode(GetPublicKeyY().Bytes())

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

设置 data 可选 [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

设置 veryed

type EcdsaErrorFunc

type EcdsaErrorFunc = func(error)

错误方法

Jump to

Keyboard shortcuts

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