ecdsa

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Get cipher from name
	GetCipherFromName = pkcs8.GetCipherFromName
	// Get hash from name
	GetHashFromName = pkcs8.GetHashFromName
)
View Source
var (
	ErrKeyMustBePEMEncoded = errors.New("go-cryptobin/ecdsa: invalid key: Key must be a PEM encoded PKCS1 or PKCS8 key")
	ErrNotECPublicKey      = errors.New("go-cryptobin/ecdsa: key is not a valid ECDSA public key")
	ErrNotECPrivateKey     = errors.New("go-cryptobin/ecdsa: key is not a valid ECDSA private key")
)

Functions

This section is empty.

Types

type ECDSA

type ECDSA struct {

	// error list
	Errors []error
	// contains filtered or unexported fields
}

*

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

func AddNamedCurve

func AddNamedCurve(curve elliptic.Curve, oid asn1.ObjectIdentifier) ECDSA

Add Named Curve

func FromBase64String

func FromBase64String(data string) ECDSA

From Base64 String

func FromBytes

func FromBytes(data []byte) ECDSA

From Bytes

func FromHexString

func FromHexString(data string) ECDSA

From Hex String

func FromPKCS1PrivateKey

func FromPKCS1PrivateKey(key []byte) ECDSA

From PKCS1 PrivateKey bytes

func FromPKCS1PrivateKeyDer

func FromPKCS1PrivateKeyDer(der []byte) ECDSA

From PKCS1 PrivateKey Der bytes

func FromPKCS1PrivateKeyWithPassword

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

From PKCS1 PrivateKey bytes With Password

func FromPKCS8PrivateKey

func FromPKCS8PrivateKey(key []byte) ECDSA

From PKCS8 PrivateKey bytes

func FromPKCS8PrivateKeyDer

func FromPKCS8PrivateKeyDer(der []byte) ECDSA

From PKCS8 PrivateKey Der bytes

func FromPKCS8PrivateKeyWithPassword

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

From PKCS8 PrivateKey bytes With Password

func FromPrivateKey

func FromPrivateKey(key []byte) ECDSA

From PrivateKey bytes

func FromPrivateKeyWithPassword

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

From PrivateKey bytes With Password

func FromPublicKey

func FromPublicKey(key []byte) ECDSA

From PublicKey bytes

func FromPublicKeyDer

func FromPublicKeyDer(der []byte) ECDSA

From PublicKey Der bytes

func FromString

func FromString(data string) ECDSA

From String

func GenerateKey

func GenerateKey(curve string) ECDSA

GenerateKey curve list [P521 | P384 | P256 | P224]

func GenerateKeyWithSeed

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

GenerateKey With Seed curve list [P521 | P384 | P256 | P224]

func New

func New() ECDSA

New ECDSA

func NewECDSA

func NewECDSA() ECDSA

NewECDSA

func (ECDSA) AddNamedCurve

func (this ECDSA) AddNamedCurve(curve elliptic.Curve, oid asn1.ObjectIdentifier) ECDSA

Add Named Curve

func (ECDSA) AppendError

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

append error

func (ECDSA) CheckKeyPair

func (this ECDSA) CheckKeyPair() bool

Check KeyPair

func (ECDSA) CreatePKCS1PrivateKey

func (this ECDSA) CreatePKCS1PrivateKey() ECDSA

Create PKCS1 PrivateKey PEM data

func (ECDSA) CreatePKCS1PrivateKeyWithPassword

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

Create PKCS1 PrivateKey PEM data with password

func (ECDSA) CreatePKCS8PrivateKey

func (this ECDSA) CreatePKCS8PrivateKey() ECDSA

Create PKCS8 PrivateKey PEM data

func (ECDSA) CreatePKCS8PrivateKeyWithPassword

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

Create PKCS8 PrivateKey PEM data with password CreatePKCS8PrivateKeyWithPassword("123", "AES256CBC", "SHA256")

func (ECDSA) CreatePrivateKey

func (this ECDSA) CreatePrivateKey() ECDSA

生成私钥 pem 数据, PKCS1 别名 Create PrivateKey PEM data example: obj := New().WithCurve("P521").GenerateKey() priKey := obj.CreatePrivateKey().ToKeyString()

func (ECDSA) CreatePrivateKeyWithPassword

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

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

func (ECDSA) CreatePublicKey

func (this ECDSA) CreatePublicKey() ECDSA

Create PublicKey PEM data

func (ECDSA) Decrypt

func (this ECDSA) Decrypt() ECDSA

privateKey Decrypt data ECDSA 核心为对称加密

func (ECDSA) Encrypt

func (this ECDSA) Encrypt() ECDSA

publicKey Encrypt data ECDSA 核心为对称加密

func (ECDSA) Error

func (this ECDSA) Error() error

return error

func (ECDSA) FromBase64String

func (this ECDSA) FromBase64String(data string) ECDSA

From Base64 String

func (ECDSA) FromBytes

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

From Bytes

func (ECDSA) FromHexString

func (this ECDSA) FromHexString(data string) ECDSA

From Hex String

func (ECDSA) FromPKCS1PrivateKey

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

From PKCS1 PrivateKey bytes

func (ECDSA) FromPKCS1PrivateKeyDer

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

From PKCS1 PrivateKey Der bytes

func (ECDSA) FromPKCS1PrivateKeyWithPassword

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

From PKCS1 PrivateKey bytes With Password

func (ECDSA) FromPKCS8PrivateKey

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

From PKCS8 PrivateKey bytes

func (ECDSA) FromPKCS8PrivateKeyDer

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

From PKCS8 PrivateKey Der bytes

func (ECDSA) FromPKCS8PrivateKeyWithPassword

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

From PKCS8 PrivateKey bytes With Password

func (ECDSA) FromPrivateKey

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

From PrivateKey bytes

func (ECDSA) FromPrivateKeyBytes

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

From PublicKey Bytes and need set curve 明文私钥生成私钥结构体 需要设置对应的 curve

func (ECDSA) FromPrivateKeyString

func (this ECDSA) FromPrivateKeyString(keyString string) ECDSA

From PrivateKey String and need set curve private-key: 07e4********;

func (ECDSA) FromPrivateKeyWithPassword

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

From PrivateKey bytes With Password

func (ECDSA) FromPublicKey

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

From PublicKey bytes

func (ECDSA) FromPublicKeyBytes

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

From PublicKey Bytes and need set curve 公钥明文, hex 或者 base64 解码后 需要设置对应的 curve

func (ECDSA) FromPublicKeyCompressString

func (this ECDSA) FromPublicKeyCompressString(key string) ECDSA

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

func (ECDSA) FromPublicKeyDer

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

From PublicKey Der bytes

func (ECDSA) FromPublicKeyString

func (this ECDSA) FromPublicKeyString(key string) ECDSA

From PublicKey String and need set curve 公钥明文,需要设置对应的 curve

func (ECDSA) FromPublicKeyUncompressString

func (this ECDSA) FromPublicKeyUncompressString(key string) ECDSA

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

func (ECDSA) FromPublicKeyXYBytes

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

From PublicKey XY Bytes 公钥字符对,需要设置对应的 curve

func (ECDSA) FromPublicKeyXYString

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

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

func (ECDSA) FromString

func (this ECDSA) FromString(data string) ECDSA

From String

func (ECDSA) GenerateKey

func (this ECDSA) GenerateKey() ECDSA

GenerateKey

func (ECDSA) GenerateKeyWithSeed

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

GenerateKey With Seed

func (ECDSA) GetCurve

func (this ECDSA) GetCurve() elliptic.Curve

get Curve

func (ECDSA) GetData

func (this ECDSA) GetData() []byte

get data

func (ECDSA) GetEncoding

func (this ECDSA) GetEncoding() EncodingType

get Encoding type

func (ECDSA) GetErrors

func (this ECDSA) GetErrors() []error

get errors

func (ECDSA) GetKeyData

func (this ECDSA) GetKeyData() []byte

get keyData

func (ECDSA) GetParsedData

func (this ECDSA) GetParsedData() []byte

get parsedData

func (ECDSA) GetPrivateKey

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

get PrivateKey

func (ECDSA) GetPrivateKeyCurve

func (this ECDSA) GetPrivateKeyCurve() elliptic.Curve

get PrivateKey Curve

func (ECDSA) GetPrivateKeyDString

func (this ECDSA) GetPrivateKeyDString() string

get PrivateKey D hex string

func (ECDSA) GetPrivateKeyString

func (this ECDSA) GetPrivateKeyString() string

get PrivateKey data hex string

func (ECDSA) GetPublicKey

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

get PublicKey

func (ECDSA) GetPublicKeyCompressString

func (this ECDSA) GetPublicKeyCompressString() string

get PublicKey Compress Hex string

func (ECDSA) GetPublicKeyCurve

func (this ECDSA) GetPublicKeyCurve() elliptic.Curve

get PublicKey Curve

func (ECDSA) GetPublicKeyUncompressString

func (this ECDSA) GetPublicKeyUncompressString() string

get PublicKey Uncompress Hex string

func (ECDSA) GetPublicKeyXString

func (this ECDSA) GetPublicKeyXString() string

get PublicKey X hex string

func (ECDSA) GetPublicKeyXYString

func (this ECDSA) GetPublicKeyXYString() string

get PublicKey X and Y Hex string

func (ECDSA) GetPublicKeyYString

func (this ECDSA) GetPublicKeyYString() string

get PublicKey Y hex string

func (ECDSA) GetSignHash

func (this ECDSA) GetSignHash() HashFunc

get signHash type

func (ECDSA) GetVerify

func (this ECDSA) GetVerify() bool

get verify data

func (ECDSA) MakeKeyDer

func (this ECDSA) MakeKeyDer() ECDSA

Make Key Der data

func (ECDSA) MakePublicKey

func (this ECDSA) MakePublicKey() ECDSA

Make PublicKey

func (ECDSA) OnError

func (this ECDSA) OnError(fn func([]error)) ECDSA

func (ECDSA) ParsePKCS1PrivateKeyFromPEM

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

Parse PKCS1 PrivateKey From PEM

func (ECDSA) ParsePKCS1PrivateKeyFromPEMWithPassword

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

Parse PKCS1 PrivateKey From PEM With Password

func (ECDSA) ParsePKCS8PrivateKeyFromPEM

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

Parse PKCS8 PrivateKey From PEM

func (ECDSA) ParsePKCS8PrivateKeyFromPEMWithPassword

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

Parse PKCS8 PrivateKey From PEM With Password

func (ECDSA) ParsePublicKeyFromPEM

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

Parse PublicKey From PEM

func (ECDSA) SetCurve

func (this ECDSA) SetCurve(curve string) ECDSA

set curve params [P521 | P384 | P256 | P224]

func (ECDSA) SetSignHash

func (this ECDSA) SetSignHash(name string) ECDSA

With hash type

func (ECDSA) Sign

func (this ECDSA) Sign() ECDSA

privateKey Sign

func (ECDSA) SignASN1

func (this ECDSA) SignASN1() ECDSA

privateKey Sign and return asn1 encode

func (ECDSA) SignBytes

func (this ECDSA) SignBytes() ECDSA

privateKey Sign and return bytes encode

func (ECDSA) ToBase64String

func (this ECDSA) ToBase64String() string

output base64 data

func (ECDSA) ToBytes

func (this ECDSA) ToBytes() []byte

output bytes data

func (ECDSA) ToHexString

func (this ECDSA) ToHexString() string

output hex data

func (ECDSA) ToKeyBytes

func (this ECDSA) ToKeyBytes() []byte

output key bytes data

func (ECDSA) ToKeyString

func (this ECDSA) ToKeyString() string

output key string data

func (ECDSA) ToString

func (this ECDSA) ToString() string

output string data

func (ECDSA) ToVerify

func (this ECDSA) ToVerify() bool

output verify data

func (ECDSA) ToVerifyInt

func (this ECDSA) ToVerifyInt() int

output verify int data

func (ECDSA) Verify

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

publicKey Verify 使用原始数据[data]对比签名后数据

func (ECDSA) VerifyASN1

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

publicKey Verify from asn1 encode data 使用原始数据[data]对比签名后数据

func (ECDSA) VerifyBytes

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

publicKey Verify from bytes encode data 使用原始数据[data]对比签名后数据

func (ECDSA) WithCurve

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

With curve

func (ECDSA) WithData

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

With data

func (ECDSA) WithEncoding

func (this ECDSA) WithEncoding(encoding EncodingType) ECDSA

With encoding

func (ECDSA) WithEncodingASN1

func (this ECDSA) WithEncodingASN1() ECDSA

encoding ASN1 encoding type

func (ECDSA) WithEncodingBytes

func (this ECDSA) WithEncodingBytes() ECDSA

encoding Bytes encoding type

func (ECDSA) WithErrors

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

WithErrors

func (ECDSA) WithParsedData

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

With parsedData

func (ECDSA) WithPrivateKey

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

With PrivateKey

func (ECDSA) WithPublicKey

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

With PublicKey

func (ECDSA) WithSignHash

func (this ECDSA) WithSignHash(hash HashFunc) ECDSA

With hash type

func (ECDSA) WithVerify

func (this ECDSA) WithVerify(data bool) ECDSA

WithVerify

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

Options

type PBKDF2Opts

type PBKDF2Opts = pkcs8.PBKDF2Opts

PBKDF2 Options

type ScryptOpts

type ScryptOpts = pkcs8.ScryptOpts

Scrypt Options

Jump to

Keyboard shortcuts

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