ecgdsa

package
v1.0.4016 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2024 License: Apache-2.0 Imports: 13 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 ECGDSA public key")
	ErrNotECPrivateKey     = errors.New("key is not a valid ECGDSA private key")
)

Functions

This section is empty.

Types

type ECGDSA

type ECGDSA struct {

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

*

  • EC-GDSA *
  • @create 2024-9-26
  • @author deatil

func FromBase64String

func FromBase64String(data string) ECGDSA

Base64

func FromBytes

func FromBytes(data []byte) ECGDSA

字节

func FromHexString

func FromHexString(data string) ECGDSA

Hex

func FromPKCS1PrivateKey

func FromPKCS1PrivateKey(key []byte) ECGDSA

私钥

func FromPKCS1PrivateKeyWithPassword

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

私钥带密码

func FromPKCS8PrivateKey

func FromPKCS8PrivateKey(key []byte) ECGDSA

PKCS8 私钥

func FromPKCS8PrivateKeyWithPassword

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

PKCS8 私钥带密码

func FromPrivateKey

func FromPrivateKey(key []byte) ECGDSA

私钥

func FromPrivateKeyWithPassword

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

私钥

func FromPublicKey

func FromPublicKey(key []byte) ECGDSA

公钥

func FromString

func FromString(data string) ECGDSA

字符

func GenerateKey

func GenerateKey(curve string) ECGDSA

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

func GenerateKeyWithSeed

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

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

func New

func New() ECGDSA

构造函数

func NewECGDSA

func NewECGDSA() ECGDSA

构造函数

func (ECGDSA) AppendError

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

添加错误

func (ECGDSA) CheckKeyPair

func (this ECGDSA) CheckKeyPair() bool

检测公钥私钥是否匹配

func (ECGDSA) CreatePKCS1PrivateKey

func (this ECGDSA) CreatePKCS1PrivateKey() ECGDSA

生成私钥 pem 数据

func (ECGDSA) CreatePKCS1PrivateKeyWithPassword

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

生成私钥带密码 pem 数据

func (ECGDSA) CreatePKCS8PrivateKey

func (this ECGDSA) CreatePKCS8PrivateKey() ECGDSA

生成 PKCS8 私钥 pem 数据

func (ECGDSA) CreatePKCS8PrivateKeyWithPassword

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

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

func (ECGDSA) CreatePrivateKey

func (this ECGDSA) CreatePrivateKey() ECGDSA

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

func (ECGDSA) CreatePrivateKeyWithPassword

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

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

func (ECGDSA) CreatePublicKey

func (this ECGDSA) CreatePublicKey() ECGDSA

生成公钥 pem 数据

func (ECGDSA) Error

func (this ECGDSA) Error() error

获取错误

func (ECGDSA) FromBase64String

func (this ECGDSA) FromBase64String(data string) ECGDSA

Base64

func (ECGDSA) FromBytes

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

字节

func (ECGDSA) FromHexString

func (this ECGDSA) FromHexString(data string) ECGDSA

Hex

func (ECGDSA) FromPKCS1PrivateKey

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

私钥

func (ECGDSA) FromPKCS1PrivateKeyDer

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

DER 私钥

func (ECGDSA) FromPKCS1PrivateKeyWithPassword

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

私钥带密码

func (ECGDSA) FromPKCS8PrivateKey

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

PKCS8 私钥

func (ECGDSA) FromPKCS8PrivateKeyDer

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

DER 私钥

func (ECGDSA) FromPKCS8PrivateKeyWithPassword

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

Pkcs8WithPassword

func (ECGDSA) FromPrivateKey

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

私钥

func (ECGDSA) FromPrivateKeyBytes

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

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

func (ECGDSA) FromPrivateKeyString

func (this ECGDSA) FromPrivateKeyString(keyString string) ECGDSA

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

func (ECGDSA) FromPrivateKeyWithPassword

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

私钥带密码

func (ECGDSA) FromPublicKey

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

公钥

func (ECGDSA) FromPublicKeyBytes

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

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

func (ECGDSA) FromPublicKeyCompressString

func (this ECGDSA) FromPublicKeyCompressString(key string) ECGDSA

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

func (ECGDSA) FromPublicKeyDer

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

DER 公钥

func (ECGDSA) FromPublicKeyString

func (this ECGDSA) FromPublicKeyString(key string) ECGDSA

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

func (ECGDSA) FromPublicKeyUncompressString

func (this ECGDSA) FromPublicKeyUncompressString(key string) ECGDSA

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

func (ECGDSA) FromPublicKeyXYBytes

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

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

func (ECGDSA) FromPublicKeyXYString

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

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

func (ECGDSA) FromString

func (this ECGDSA) FromString(data string) ECGDSA

字符

func (ECGDSA) GenerateKey

func (this ECGDSA) GenerateKey() ECGDSA

生成密钥

func (ECGDSA) GenerateKeyWithSeed

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

生成密钥

func (ECGDSA) GetCurve

func (this ECGDSA) GetCurve() elliptic.Curve

get Curve

func (ECGDSA) GetData

func (this ECGDSA) GetData() []byte

get data

func (ECGDSA) GetEncoding

func (this ECGDSA) GetEncoding() EncodingType

get Encoding type

func (ECGDSA) GetErrors

func (this ECGDSA) GetErrors() []error

get errors

func (ECGDSA) GetKeyData

func (this ECGDSA) GetKeyData() []byte

get keyData

func (ECGDSA) GetParsedData

func (this ECGDSA) GetParsedData() []byte

get parsedData

func (ECGDSA) GetPrivateKey

func (this ECGDSA) GetPrivateKey() *ecgdsa.PrivateKey

get PrivateKey

func (ECGDSA) GetPrivateKeyCurve

func (this ECGDSA) GetPrivateKeyCurve() elliptic.Curve

get PrivateKey Curve

func (ECGDSA) GetPrivateKeyDString

func (this ECGDSA) GetPrivateKeyDString() string

get PrivateKey D hex string

func (ECGDSA) GetPrivateKeyString

func (this ECGDSA) GetPrivateKeyString() string

get PrivateKey data hex string

func (ECGDSA) GetPublicKey

func (this ECGDSA) GetPublicKey() *ecgdsa.PublicKey

get PublicKey

func (ECGDSA) GetPublicKeyCompressString

func (this ECGDSA) GetPublicKeyCompressString() string

get PublicKey Compress Hex string

func (ECGDSA) GetPublicKeyCurve

func (this ECGDSA) GetPublicKeyCurve() elliptic.Curve

get PublicKey Curve

func (ECGDSA) GetPublicKeyUncompressString

func (this ECGDSA) GetPublicKeyUncompressString() string

get PublicKey Uncompress Hex string

func (ECGDSA) GetPublicKeyXString

func (this ECGDSA) GetPublicKeyXString() string

get PublicKey X hex string

func (ECGDSA) GetPublicKeyXYString

func (this ECGDSA) GetPublicKeyXYString() string

get PublicKey X and Y Hex string

func (ECGDSA) GetPublicKeyYString

func (this ECGDSA) GetPublicKeyYString() string

get PublicKey Y hex string

func (ECGDSA) GetSignHash

func (this ECGDSA) GetSignHash() HashFunc

get signHash type

func (ECGDSA) GetVerify

func (this ECGDSA) GetVerify() bool

get verify data

func (ECGDSA) MakeKeyDer

func (this ECGDSA) MakeKeyDer() ECGDSA

生成密钥 der 数据

func (ECGDSA) MakePublicKey

func (this ECGDSA) MakePublicKey() ECGDSA

生成公钥

func (ECGDSA) OnError

func (this ECGDSA) OnError(fn EcgdsaErrorFunc) ECGDSA

引出错误信息

func (ECGDSA) ParsePKCS1PrivateKeyFromPEM

func (this ECGDSA) ParsePKCS1PrivateKeyFromPEM(key []byte) (*ecgdsa.PrivateKey, error)

解析私钥

func (ECGDSA) ParsePKCS1PrivateKeyFromPEMWithPassword

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

解析私钥带密码

func (ECGDSA) ParsePKCS8PrivateKeyFromPEM

func (this ECGDSA) ParsePKCS8PrivateKeyFromPEM(key []byte) (*ecgdsa.PrivateKey, error)

解析私钥

func (ECGDSA) ParsePKCS8PrivateKeyFromPEMWithPassword

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

解析 PKCS8 带密码的私钥

func (ECGDSA) ParsePublicKeyFromPEM

func (this ECGDSA) ParsePublicKeyFromPEM(key []byte) (*ecgdsa.PublicKey, error)

解析公钥

func (ECGDSA) SetCurve

func (this ECGDSA) SetCurve(curve string) ECGDSA

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

func (ECGDSA) SetSignHash

func (this ECGDSA) SetSignHash(hash string) ECGDSA

设置 hash 类型

func (ECGDSA) Sign

func (this ECGDSA) Sign() ECGDSA

私钥签名

func (ECGDSA) SignASN1

func (this ECGDSA) SignASN1() ECGDSA

私钥签名 ASN1

func (ECGDSA) SignBytes

func (this ECGDSA) SignBytes() ECGDSA

私钥签名 Bytes

func (ECGDSA) ToBase64String

func (this ECGDSA) ToBase64String() string

输出Base64

func (ECGDSA) ToBytes

func (this ECGDSA) ToBytes() []byte

输出字节

func (ECGDSA) ToHexString

func (this ECGDSA) ToHexString() string

输出Hex

func (ECGDSA) ToKeyBytes

func (this ECGDSA) ToKeyBytes() []byte

私钥/公钥

func (ECGDSA) ToKeyString

func (this ECGDSA) ToKeyString() string

私钥/公钥

func (ECGDSA) ToString

func (this ECGDSA) ToString() string

输出字符

func (ECGDSA) ToVerify

func (this ECGDSA) ToVerify() bool

验证结果

func (ECGDSA) ToVerifyInt

func (this ECGDSA) ToVerifyInt() int

验证结果,返回 int 类型

func (ECGDSA) Verify

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

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

func (ECGDSA) VerifyASN1

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

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

func (ECGDSA) VerifyBytes

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

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

func (ECGDSA) WithCurve

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

设置曲线类型

func (ECGDSA) WithData

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

设置 data

func (ECGDSA) WithEncoding

func (this ECGDSA) WithEncoding(encoding EncodingType) ECGDSA

设置编码方式

func (ECGDSA) WithEncodingASN1

func (this ECGDSA) WithEncodingASN1() ECGDSA

设置 ASN1 编码方式

func (ECGDSA) WithEncodingBytes

func (this ECGDSA) WithEncodingBytes() ECGDSA

设置明文编码方式

func (ECGDSA) WithErrors

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

设置错误

func (ECGDSA) WithParsedData

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

设置 parsedData

func (ECGDSA) WithPrivateKey

func (this ECGDSA) WithPrivateKey(data *ecgdsa.PrivateKey) ECGDSA

设置 PrivateKey

func (ECGDSA) WithPublicKey

func (this ECGDSA) WithPublicKey(data *ecgdsa.PublicKey) ECGDSA

设置 PublicKey

func (ECGDSA) WithSignHash

func (this ECGDSA) WithSignHash(hash HashFunc) ECGDSA

设置 hash 类型

func (ECGDSA) WithVerify

func (this ECGDSA) WithVerify(data bool) ECGDSA

设置验证结果

type EcgdsaErrorFunc

type EcgdsaErrorFunc = func([]error)

错误方法

type EncodingType

type EncodingType uint

数据编码方式 marshal data type

const (
	EncodingASN1 EncodingType = 1 + iota
	EncodingBytes
)

type HashFunc

type HashFunc = func() hash.Hash

HashFunc

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