ecdsa

package
v1.0.5006 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 17 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")
	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 added in v1.0.2048

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 added in v1.0.2048

func NewECDSA() ECDSA

构造函数

func (ECDSA) AppendError added in v1.0.2048

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

添加错误

func (ECDSA) CheckKeyPair added in v1.0.2048

func (this ECDSA) CheckKeyPair() bool

检测公钥私钥是否匹配

func (ECDSA) CreatePKCS1PrivateKey added in v1.0.2048

func (this ECDSA) CreatePKCS1PrivateKey() ECDSA

生成私钥 pem 数据

func (ECDSA) CreatePKCS1PrivateKeyWithPassword added in v1.0.2048

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

生成私钥带密码 pem 数据

func (ECDSA) CreatePKCS8PrivateKey added in v1.0.2048

func (this ECDSA) CreatePKCS8PrivateKey() ECDSA

生成 PKCS8 私钥 pem 数据

func (ECDSA) CreatePKCS8PrivateKeyWithPassword added in v1.0.2048

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

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

func (ECDSA) CreatePrivateKey added in v1.0.2048

func (this ECDSA) CreatePrivateKey() ECDSA

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

func (ECDSA) CreatePrivateKeyWithPassword added in v1.0.2048

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

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

func (ECDSA) CreatePublicKey added in v1.0.2048

func (this ECDSA) CreatePublicKey() ECDSA

生成公钥 pem 数据

func (ECDSA) Decrypt added in v1.0.2048

func (this ECDSA) Decrypt() ECDSA

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

func (ECDSA) Encrypt added in v1.0.2048

func (this ECDSA) Encrypt() ECDSA

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

func (ECDSA) Error added in v1.0.2048

func (this ECDSA) Error() error

获取错误

func (ECDSA) FromBase64String added in v1.0.2048

func (this ECDSA) FromBase64String(data string) ECDSA

Base64

func (ECDSA) FromBytes added in v1.0.2048

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

字节

func (ECDSA) FromHexString added in v1.0.2048

func (this ECDSA) FromHexString(data string) ECDSA

Hex

func (ECDSA) FromPKCS1PrivateKey added in v1.0.2048

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

私钥

func (ECDSA) FromPKCS1PrivateKeyDer added in v1.0.2048

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

DER 私钥

func (ECDSA) FromPKCS1PrivateKeyWithPassword added in v1.0.2048

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

私钥带密码

func (ECDSA) FromPKCS8PrivateKey added in v1.0.2048

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

PKCS8 私钥

func (ECDSA) FromPKCS8PrivateKeyDer added in v1.0.2048

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

DER 私钥

func (ECDSA) FromPKCS8PrivateKeyWithPassword added in v1.0.2048

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

Pkcs8WithPassword

func (ECDSA) FromPrivateKey added in v1.0.2048

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

私钥

func (ECDSA) FromPrivateKeyBytes added in v1.0.2048

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

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

func (ECDSA) FromPrivateKeyString added in v1.0.2048

func (this ECDSA) FromPrivateKeyString(keyString string) ECDSA

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

func (ECDSA) FromPrivateKeyWithPassword added in v1.0.2048

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

私钥带密码

func (ECDSA) FromPublicKey added in v1.0.2048

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

公钥

func (ECDSA) FromPublicKeyBytes added in v1.0.2048

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

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

func (ECDSA) FromPublicKeyCompressString added in v1.0.2048

func (this ECDSA) FromPublicKeyCompressString(key string) ECDSA

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

func (ECDSA) FromPublicKeyDer added in v1.0.2048

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

DER 公钥

func (ECDSA) FromPublicKeyString added in v1.0.2048

func (this ECDSA) FromPublicKeyString(key string) ECDSA

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

func (ECDSA) FromPublicKeyUncompressString added in v1.0.2048

func (this ECDSA) FromPublicKeyUncompressString(key string) ECDSA

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

func (ECDSA) FromPublicKeyXYBytes added in v1.0.2048

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

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

func (ECDSA) FromPublicKeyXYString added in v1.0.2048

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

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

func (ECDSA) FromString added in v1.0.2048

func (this ECDSA) FromString(data string) ECDSA

字符

func (ECDSA) GenerateKey added in v1.0.2048

func (this ECDSA) GenerateKey() ECDSA

生成密钥

func (ECDSA) GenerateKeyWithSeed added in v1.0.2048

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

生成密钥

func (ECDSA) GetCurve added in v1.0.2050

func (this ECDSA) GetCurve() elliptic.Curve

get Curve

func (ECDSA) GetData added in v1.0.2048

func (this ECDSA) GetData() []byte

get data

func (ECDSA) GetEncoding added in v1.0.3009

func (this ECDSA) GetEncoding() EncodingType

get Encoding type

func (ECDSA) GetErrors added in v1.0.2048

func (this ECDSA) GetErrors() []error

get errors

func (ECDSA) GetKeyData added in v1.0.2048

func (this ECDSA) GetKeyData() []byte

get keyData

func (ECDSA) GetParsedData added in v1.0.2049

func (this ECDSA) GetParsedData() []byte

get parsedData

func (ECDSA) GetPrivateKey added in v1.0.2048

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

get PrivateKey

func (ECDSA) GetPrivateKeyCurve added in v1.0.2048

func (this ECDSA) GetPrivateKeyCurve() elliptic.Curve

get PrivateKey Curve

func (ECDSA) GetPrivateKeyDString added in v1.0.2071

func (this ECDSA) GetPrivateKeyDString() string

get PrivateKey D hex string

func (ECDSA) GetPrivateKeyString added in v1.0.2048

func (this ECDSA) GetPrivateKeyString() string

get PrivateKey data hex string

func (ECDSA) GetPublicKey added in v1.0.2048

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

get PublicKey

func (ECDSA) GetPublicKeyCompressString added in v1.0.2048

func (this ECDSA) GetPublicKeyCompressString() string

get PublicKey Compress Hex string

func (ECDSA) GetPublicKeyCurve added in v1.0.2048

func (this ECDSA) GetPublicKeyCurve() elliptic.Curve

get PublicKey Curve

func (ECDSA) GetPublicKeyUncompressString added in v1.0.2048

func (this ECDSA) GetPublicKeyUncompressString() string

get PublicKey Uncompress Hex string

func (ECDSA) GetPublicKeyXString added in v1.0.2071

func (this ECDSA) GetPublicKeyXString() string

get PublicKey X hex string

func (ECDSA) GetPublicKeyXYString added in v1.0.2071

func (this ECDSA) GetPublicKeyXYString() string

get PublicKey X and Y Hex string

func (ECDSA) GetPublicKeyYString added in v1.0.2071

func (this ECDSA) GetPublicKeyYString() string

get PublicKey Y hex string

func (ECDSA) GetSignHash added in v1.0.2048

func (this ECDSA) GetSignHash() HashFunc

get signHash type

func (ECDSA) GetVerify added in v1.0.2048

func (this ECDSA) GetVerify() bool

get verify data

func (ECDSA) MakeKeyDer added in v1.0.2048

func (this ECDSA) MakeKeyDer() ECDSA

生成密钥 der 数据

func (ECDSA) MakePublicKey added in v1.0.2048

func (this ECDSA) MakePublicKey() ECDSA

生成公钥

func (ECDSA) OnError added in v1.0.2048

func (this ECDSA) OnError(fn EcdsaErrorFunc) ECDSA

引出错误信息

func (ECDSA) ParsePKCS1PrivateKeyFromPEM added in v1.0.2048

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

解析私钥

func (ECDSA) ParsePKCS1PrivateKeyFromPEMWithPassword added in v1.0.2048

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

解析私钥带密码

func (ECDSA) ParsePKCS8PrivateKeyFromPEM added in v1.0.2048

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

解析私钥

func (ECDSA) ParsePKCS8PrivateKeyFromPEMWithPassword added in v1.0.2048

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

解析 PKCS8 带密码的私钥

func (ECDSA) ParsePublicKeyFromPEM added in v1.0.2048

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

解析公钥

func (ECDSA) SetCurve added in v1.0.2048

func (this ECDSA) SetCurve(curve string) ECDSA

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

func (ECDSA) SetSignHash added in v1.0.2048

func (this ECDSA) SetSignHash(name string) ECDSA

设置 hash 类型

func (ECDSA) Sign added in v1.0.2048

func (this ECDSA) Sign() ECDSA

私钥签名

func (ECDSA) SignASN1 added in v1.0.2048

func (this ECDSA) SignASN1() ECDSA

私钥签名 ASN1

func (ECDSA) SignBytes added in v1.0.2048

func (this ECDSA) SignBytes() ECDSA

私钥签名 Bytes

func (ECDSA) ToBase64String added in v1.0.2048

func (this ECDSA) ToBase64String() string

输出Base64

func (ECDSA) ToBytes added in v1.0.2048

func (this ECDSA) ToBytes() []byte

输出字节

func (ECDSA) ToHexString added in v1.0.2048

func (this ECDSA) ToHexString() string

输出Hex

func (ECDSA) ToKeyBytes added in v1.0.2048

func (this ECDSA) ToKeyBytes() []byte

私钥/公钥

func (ECDSA) ToKeyString added in v1.0.2048

func (this ECDSA) ToKeyString() string

私钥/公钥

func (ECDSA) ToString added in v1.0.2048

func (this ECDSA) ToString() string

输出字符

func (ECDSA) ToVerify added in v1.0.2048

func (this ECDSA) ToVerify() bool

验证结果

func (ECDSA) ToVerifyInt added in v1.0.2048

func (this ECDSA) ToVerifyInt() int

验证结果,返回 int 类型

func (ECDSA) Verify added in v1.0.2048

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

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

func (ECDSA) VerifyASN1 added in v1.0.2048

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

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

func (ECDSA) VerifyBytes added in v1.0.2048

func (this ECDSA) VerifyBytes(data []byte) ECDSA

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

func (ECDSA) WithCurve added in v1.0.2048

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

设置曲线类型

func (ECDSA) WithData added in v1.0.2048

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

设置 data

func (ECDSA) WithEncoding added in v1.0.3009

func (this ECDSA) WithEncoding(encoding EncodingType) ECDSA

设置编码方式

func (ECDSA) WithEncodingASN1 added in v1.0.3009

func (this ECDSA) WithEncodingASN1() ECDSA

设置 ASN1 编码方式

func (ECDSA) WithEncodingBytes added in v1.0.3009

func (this ECDSA) WithEncodingBytes() ECDSA

设置明文编码方式

func (ECDSA) WithErrors added in v1.0.2048

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

设置错误

func (ECDSA) WithParsedData added in v1.0.2049

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

设置 parsedData

func (ECDSA) WithPrivateKey added in v1.0.2048

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

设置 PrivateKey

func (ECDSA) WithPublicKey added in v1.0.2048

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

设置 PublicKey

func (ECDSA) WithSignHash added in v1.0.2048

func (this ECDSA) WithSignHash(hash HashFunc) ECDSA

设置 hash 类型

func (ECDSA) WithVerify added in v1.0.2048

func (this ECDSA) WithVerify(data bool) ECDSA

设置验证结果

type EcdsaErrorFunc

type EcdsaErrorFunc = func([]error)

错误方法

type EncodingType added in v1.0.3009

type EncodingType uint

数据编码方式 marshal data type

const (
	EncodingASN1 EncodingType = 1 + iota
	EncodingBytes
)

type HashFunc added in v1.0.2014

type HashFunc = func() hash.Hash

HashFunc

type Opts added in v1.0.1018

type Opts = pkcs8.Opts

配置

type PBKDF2Opts added in v1.0.1018

type PBKDF2Opts = pkcs8.PBKDF2Opts

PBKDF2 配置

type ScryptOpts added in v1.0.1018

type ScryptOpts = pkcs8.ScryptOpts

Scrypt 配置

Jump to

Keyboard shortcuts

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