bign

package
v1.0.4033 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 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 Bign public key")
)

Functions

This section is empty.

Types

type Bign

type Bign struct {

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

*

  • Bign *
  • @create 2024-10-29
  • @author deatil

func FromBase64String

func FromBase64String(data string) Bign

Base64

func FromBytes

func FromBytes(data []byte) Bign

字节

func FromHexString

func FromHexString(data string) Bign

Hex

func FromPKCS1PrivateKey

func FromPKCS1PrivateKey(key []byte) Bign

私钥

func FromPKCS1PrivateKeyWithPassword

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

私钥带密码

func FromPKCS8PrivateKey

func FromPKCS8PrivateKey(key []byte) Bign

PKCS8 私钥

func FromPKCS8PrivateKeyWithPassword

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

PKCS8 私钥带密码

func FromPrivateKey

func FromPrivateKey(key []byte) Bign

私钥

func FromPrivateKeyWithPassword

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

私钥

func FromPublicKey

func FromPublicKey(key []byte) Bign

公钥

func FromString

func FromString(data string) Bign

字符

func GenerateKey

func GenerateKey(curve string) Bign

生成密钥 可选 [Bign256v1 | Bign384v1 | Bign512v1]

func GenerateKeyWithSeed

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

生成密钥 可选 [Bign256v1 | Bign384v1 | Bign512v1]

func New

func New() Bign

构造函数

func NewBign

func NewBign() Bign

构造函数

func (Bign) AppendError

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

添加错误

func (Bign) CheckKeyPair

func (this Bign) CheckKeyPair() bool

检测公钥私钥是否匹配

func (Bign) CreatePKCS1PrivateKey

func (this Bign) CreatePKCS1PrivateKey() Bign

生成私钥 pem 数据

func (Bign) CreatePKCS1PrivateKeyWithPassword

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

生成私钥带密码 pem 数据

func (Bign) CreatePKCS8PrivateKey

func (this Bign) CreatePKCS8PrivateKey() Bign

生成 PKCS8 私钥 pem 数据

func (Bign) CreatePKCS8PrivateKeyWithPassword

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

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

func (Bign) CreatePrivateKey

func (this Bign) CreatePrivateKey() Bign

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

func (Bign) CreatePrivateKeyWithPassword

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

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

func (Bign) CreatePublicKey

func (this Bign) CreatePublicKey() Bign

生成公钥 pem 数据

func (Bign) Error

func (this Bign) Error() error

获取错误

func (Bign) FromBase64String

func (this Bign) FromBase64String(data string) Bign

Base64

func (Bign) FromBytes

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

字节

func (Bign) FromHexString

func (this Bign) FromHexString(data string) Bign

Hex

func (Bign) FromPKCS1PrivateKey

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

私钥

func (Bign) FromPKCS1PrivateKeyDer

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

DER 私钥

func (Bign) FromPKCS1PrivateKeyWithPassword

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

私钥带密码

func (Bign) FromPKCS8PrivateKey

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

PKCS8 私钥

func (Bign) FromPKCS8PrivateKeyDer

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

DER 私钥

func (Bign) FromPKCS8PrivateKeyWithPassword

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

Pkcs8WithPassword

func (Bign) FromPrivateKey

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

私钥

func (Bign) FromPrivateKeyBytes

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

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

func (Bign) FromPrivateKeyString

func (this Bign) FromPrivateKeyString(keyString string) Bign

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

func (Bign) FromPrivateKeyWithPassword

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

私钥带密码

func (Bign) FromPublicKey

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

公钥

func (Bign) FromPublicKeyBytes

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

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

func (Bign) FromPublicKeyCompressString

func (this Bign) FromPublicKeyCompressString(key string) Bign

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

func (Bign) FromPublicKeyDer

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

DER 公钥

func (Bign) FromPublicKeyString

func (this Bign) FromPublicKeyString(key string) Bign

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

func (Bign) FromPublicKeyUncompressString

func (this Bign) FromPublicKeyUncompressString(key string) Bign

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

func (Bign) FromPublicKeyXYBytes

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

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

func (Bign) FromPublicKeyXYString

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

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

func (Bign) FromString

func (this Bign) FromString(data string) Bign

字符

func (Bign) GenerateKey

func (this Bign) GenerateKey() Bign

生成密钥

func (Bign) GenerateKeyWithSeed

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

生成密钥

func (Bign) GetAdata

func (this Bign) GetAdata() []byte

get adata

func (Bign) GetCurve

func (this Bign) GetCurve() elliptic.Curve

get Curve

func (Bign) GetData

func (this Bign) GetData() []byte

get data

func (Bign) GetEncoding

func (this Bign) GetEncoding() EncodingType

get Encoding type

func (Bign) GetErrors

func (this Bign) GetErrors() []error

get errors

func (Bign) GetKeyData

func (this Bign) GetKeyData() []byte

get keyData

func (Bign) GetParsedData

func (this Bign) GetParsedData() []byte

get parsedData

func (Bign) GetPrivateKey

func (this Bign) GetPrivateKey() *bign.PrivateKey

get PrivateKey

func (Bign) GetPrivateKeyCurve

func (this Bign) GetPrivateKeyCurve() elliptic.Curve

get PrivateKey Curve

func (Bign) GetPrivateKeyDString

func (this Bign) GetPrivateKeyDString() string

get PrivateKey D hex string

func (Bign) GetPrivateKeyString

func (this Bign) GetPrivateKeyString() string

get PrivateKey data hex string

func (Bign) GetPublicKey

func (this Bign) GetPublicKey() *bign.PublicKey

get PublicKey

func (Bign) GetPublicKeyCompressString

func (this Bign) GetPublicKeyCompressString() string

get PublicKey Compress Hex string

func (Bign) GetPublicKeyCurve

func (this Bign) GetPublicKeyCurve() elliptic.Curve

get PublicKey Curve

func (Bign) GetPublicKeyUncompressString

func (this Bign) GetPublicKeyUncompressString() string

get PublicKey Uncompress Hex string

func (Bign) GetPublicKeyXString

func (this Bign) GetPublicKeyXString() string

get PublicKey X hex string

func (Bign) GetPublicKeyXYString

func (this Bign) GetPublicKeyXYString() string

get PublicKey X and Y Hex string

func (Bign) GetPublicKeyYString

func (this Bign) GetPublicKeyYString() string

get PublicKey Y hex string

func (Bign) GetSignHash

func (this Bign) GetSignHash() HashFunc

get signHash type

func (Bign) GetVerify

func (this Bign) GetVerify() bool

get verify data

func (Bign) MakeKeyDer

func (this Bign) MakeKeyDer() Bign

生成密钥 der 数据

func (Bign) MakePublicKey

func (this Bign) MakePublicKey() Bign

生成公钥

func (Bign) OnError

func (this Bign) OnError(fn EcgdsaErrorFunc) Bign

引出错误信息

func (Bign) ParsePKCS1PrivateKeyFromPEM

func (this Bign) ParsePKCS1PrivateKeyFromPEM(key []byte) (*bign.PrivateKey, error)

解析私钥

func (Bign) ParsePKCS1PrivateKeyFromPEMWithPassword

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

解析私钥带密码

func (Bign) ParsePKCS8PrivateKeyFromPEM

func (this Bign) ParsePKCS8PrivateKeyFromPEM(key []byte) (*bign.PrivateKey, error)

解析私钥

func (Bign) ParsePKCS8PrivateKeyFromPEMWithPassword

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

解析 PKCS8 带密码的私钥

func (Bign) ParsePublicKeyFromPEM

func (this Bign) ParsePublicKeyFromPEM(key []byte) (*bign.PublicKey, error)

解析公钥

func (Bign) SetCurve

func (this Bign) SetCurve(curve string) Bign

设置曲线类型 可选 [Bign256v1 | Bign384v1 | Bign512v1]

func (Bign) SetSignHash

func (this Bign) SetSignHash(name string) Bign

设置 hash 类型

func (Bign) Sign

func (this Bign) Sign() Bign

私钥签名

func (Bign) SignASN1

func (this Bign) SignASN1() Bign

私钥签名 ASN1

func (Bign) SignBytes

func (this Bign) SignBytes() Bign

私钥签名 Bytes

func (Bign) ToBase64String

func (this Bign) ToBase64String() string

输出Base64

func (Bign) ToBytes

func (this Bign) ToBytes() []byte

输出字节

func (Bign) ToHexString

func (this Bign) ToHexString() string

输出Hex

func (Bign) ToKeyBytes

func (this Bign) ToKeyBytes() []byte

私钥/公钥

func (Bign) ToKeyString

func (this Bign) ToKeyString() string

私钥/公钥

func (Bign) ToString

func (this Bign) ToString() string

输出字符

func (Bign) ToVerify

func (this Bign) ToVerify() bool

验证结果

func (Bign) ToVerifyInt

func (this Bign) ToVerifyInt() int

验证结果,返回 int 类型

func (Bign) Verify

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

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

func (Bign) VerifyASN1

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

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

func (Bign) VerifyBytes

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

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

func (Bign) WithAdata

func (this Bign) WithAdata(adata []byte) Bign

设置 adata

func (Bign) WithCurve

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

设置曲线类型

func (Bign) WithData

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

设置 data

func (Bign) WithEncoding

func (this Bign) WithEncoding(encoding EncodingType) Bign

设置编码方式

func (Bign) WithEncodingASN1

func (this Bign) WithEncodingASN1() Bign

设置 ASN1 编码方式

func (Bign) WithEncodingBytes

func (this Bign) WithEncodingBytes() Bign

设置明文编码方式

func (Bign) WithErrors

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

设置错误

func (Bign) WithParsedData

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

设置 parsedData

func (Bign) WithPrivateKey

func (this Bign) WithPrivateKey(data *bign.PrivateKey) Bign

设置 PrivateKey

func (Bign) WithPublicKey

func (this Bign) WithPublicKey(data *bign.PublicKey) Bign

设置 PublicKey

func (Bign) WithSignHash

func (this Bign) WithSignHash(hash HashFunc) Bign

设置 hash 类型

func (Bign) WithVerify

func (this Bign) WithVerify(data bool) Bign

设置验证结果

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