gost

package
v1.0.4008 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: Apache-2.0 Imports: 10 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 PKCS8 key")
	ErrNotGostPrivateKey   = errors.New("key is not a valid Gost private key")
	ErrNotGostPublicKey    = errors.New("key is not a valid Gost public key")
)

Functions

This section is empty.

Types

type DSAErrorFunc

type DSAErrorFunc = func([]error)

错误方法

type EncodingType added in v1.0.3009

type EncodingType uint

数据编码方式 marshal data type

const (
	EncodingASN1 EncodingType = 1 + iota
	EncodingBytes
)

type Gost

type Gost struct {

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

*

  • Gost *
  • @create 2024-2-25
  • @author deatil

func FromBase64String

func FromBase64String(data string) Gost

Base64

func FromBytes

func FromBytes(data []byte) Gost

字节

func FromHexString

func FromHexString(data string) Gost

Hex

func FromPKCS8PrivateKey

func FromPKCS8PrivateKey(key []byte) Gost

PKCS8 私钥

func FromPKCS8PrivateKeyWithPassword

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

PKCS8 私钥带密码

func FromPKCS8PublicKey

func FromPKCS8PublicKey(key []byte) Gost

PKCS8 公钥

func FromPrivateKey

func FromPrivateKey(key []byte) Gost

私钥

func FromPrivateKeyWithPassword

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

私钥带密码

func FromPublicKey

func FromPublicKey(key []byte) Gost

公钥

func FromString

func FromString(data string) Gost

字符

func GenerateKey

func GenerateKey(curve string) Gost

生成密钥

func GenerateKeyWithSeed

func GenerateKeyWithSeed(reader io.Reader) Gost

生成密钥

func New

func New() Gost

构造函数

func NewGost

func NewGost() Gost

构造函数

func (Gost) AppendError

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

添加错误

func (Gost) CheckKeyPair

func (this Gost) CheckKeyPair() bool

检测公钥私钥是否匹配

func (Gost) CreatePKCS8PrivateKey

func (this Gost) CreatePKCS8PrivateKey() Gost

生成 pkcs8 私钥 pem 数据

func (Gost) CreatePKCS8PrivateKeyWithPassword

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

生成 PKCS8 私钥带密码 pem 数据

func (Gost) CreatePKCS8PublicKey

func (this Gost) CreatePKCS8PublicKey() Gost

生成公钥 pem 数据

func (Gost) CreatePrivateKey

func (this Gost) CreatePrivateKey() Gost

生成私钥 pem 数据

func (Gost) CreatePrivateKeyWithPassword

func (this Gost) CreatePrivateKeyWithPassword(password string, opts ...any) Gost

生成私钥带密码 pem 数据

func (Gost) CreatePublicKey

func (this Gost) CreatePublicKey() Gost

生成公钥 pem 数据

func (Gost) Error

func (this Gost) Error() error

获取错误

func (Gost) FromBase64String

func (this Gost) FromBase64String(data string) Gost

Base64

func (Gost) FromBytes

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

字节

func (Gost) FromHexString

func (this Gost) FromHexString(data string) Gost

Hex

func (Gost) FromPKCS8PrivateKey

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

PKCS8 私钥

func (Gost) FromPKCS8PrivateKeyDer

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

Pkcs8 DER 私钥

func (Gost) FromPKCS8PrivateKeyWithPassword

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

PKCS8 私钥带密码

func (Gost) FromPKCS8PublicKey

func (this Gost) FromPKCS8PublicKey(key []byte) Gost

PKCS8 公钥

func (Gost) FromPKCS8PublicKeyDer

func (this Gost) FromPKCS8PublicKeyDer(der []byte) Gost

PKCS8 DER 公钥

func (Gost) FromPrivateKey

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

私钥

func (Gost) FromPrivateKeyBytes

func (this Gost) FromPrivateKeyBytes(priBytes []byte) Gost

私钥明文, hex 或者 base64 解码后

func (Gost) FromPrivateKeyWithPassword

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

私钥带密码

func (Gost) FromPublicKey

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

公钥

func (Gost) FromPublicKeyBytes

func (this Gost) FromPublicKeyBytes(pubBytes []byte) Gost

公钥明文, hex 或者 base64 解码后

func (Gost) FromString

func (this Gost) FromString(data string) Gost

字符

func (Gost) GenerateKey

func (this Gost) GenerateKey() Gost

生成密钥

func (Gost) GenerateKeyWithSeed

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

生成密钥

func (Gost) GetCurve

func (this Gost) GetCurve() *gost.Curve

获取 Curve

func (Gost) GetData

func (this Gost) GetData() []byte

获取 data

func (Gost) GetEncoding added in v1.0.3009

func (this Gost) GetEncoding() EncodingType

获取编码类型

func (Gost) GetErrors

func (this Gost) GetErrors() []error

获取错误

func (Gost) GetKeyData

func (this Gost) GetKeyData() []byte

获取 keyData

func (Gost) GetParsedData

func (this Gost) GetParsedData() []byte

获取 parsedData

func (Gost) GetPrivateKey

func (this Gost) GetPrivateKey() *gost.PrivateKey

获取 PrivateKey

func (Gost) GetPrivateKeyBytes added in v1.0.2051

func (this Gost) GetPrivateKeyBytes() []byte

获取 PrivateKey 明文

func (Gost) GetPublicKey

func (this Gost) GetPublicKey() *gost.PublicKey

获取 PublicKey

func (Gost) GetPublicKeyBytes added in v1.0.2051

func (this Gost) GetPublicKeyBytes() []byte

获取 PublicKey 明文

func (Gost) GetSecretData

func (this Gost) GetSecretData() []byte

获取 secretData

func (Gost) GetSignHash

func (this Gost) GetSignHash() HashFunc

获取 hash 类型

func (Gost) GetVerify

func (this Gost) GetVerify() bool

获取验证后情况

func (Gost) KEK

func (this Gost) KEK(ukm any) Gost

KEK

func (Gost) KEK2001

func (this Gost) KEK2001(ukm any) Gost

KEK2001

func (Gost) KEK2012256

func (this Gost) KEK2012256(ukm any) Gost

KEK2012256

func (Gost) KEK2012512

func (this Gost) KEK2012512(ukm any) Gost

KEK2012512

func (Gost) MakeKeyDer

func (this Gost) MakeKeyDer() Gost

生成密钥 der 数据

func (Gost) MakePublicKey

func (this Gost) MakePublicKey() Gost

生成公钥

func (Gost) OnError

func (this Gost) OnError(fn DSAErrorFunc) Gost

引出错误信息

func (Gost) ParsePrivateKeyFromPEM

func (this Gost) ParsePrivateKeyFromPEM(key []byte) (*gost.PrivateKey, error)

解析私钥

func (Gost) ParsePrivateKeyFromPEMWithPassword

func (this Gost) ParsePrivateKeyFromPEMWithPassword(key []byte, password string) (*gost.PrivateKey, error)

解析带密码的私钥

func (Gost) ParsePublicKeyFromPEM

func (this Gost) ParsePublicKeyFromPEM(key []byte) (*gost.PublicKey, error)

解析公钥

func (Gost) SetCurve

func (this Gost) SetCurve(curve string) Gost

设置曲线类型 可选参数: IdGostR34102001TestParamSet IdGostR34102001CryptoProAParamSet IdGostR34102001CryptoProBParamSet IdGostR34102001CryptoProCParamSet IdGostR34102001CryptoProXchAParamSet IdGostR34102001CryptoProXchBParamSet Idtc26gost34102012256paramSetA Idtc26gost34102012256paramSetB Idtc26gost34102012256paramSetC Idtc26gost34102012256paramSetD Idtc26gost34102012512paramSetTest Idtc26gost34102012512paramSetA Idtc26gost34102012512paramSetB Idtc26gost34102012512paramSetC

func (Gost) SetSignHash

func (this Gost) SetSignHash(data string) Gost

设置 hash 类型 可用参数可查看 Hash 结构体数据

func (Gost) Sign

func (this Gost) Sign() Gost

私钥签名 privateKey Sign

func (Gost) SignASN1

func (this Gost) SignASN1() Gost

私钥签名 privateKey Sign with asn.1

func (Gost) SignBytes added in v1.0.2069

func (this Gost) SignBytes() Gost

私钥签名 privateKey Sign with bytes

func (Gost) ToBase64String

func (this Gost) ToBase64String() string

输出Base64

func (Gost) ToBytes

func (this Gost) ToBytes() []byte

输出字节

func (Gost) ToHexString

func (this Gost) ToHexString() string

输出Hex

func (Gost) ToKeyBytes

func (this Gost) ToKeyBytes() []byte

私钥/公钥

func (Gost) ToKeyString

func (this Gost) ToKeyString() string

私钥/公钥

func (Gost) ToSecretBase64String

func (this Gost) ToSecretBase64String() string

输出密钥 Base64

func (Gost) ToSecretBytes

func (this Gost) ToSecretBytes() []byte

输出密钥字节

func (Gost) ToSecretHexString

func (this Gost) ToSecretHexString() string

输出密钥 Hex

func (Gost) ToSecretString

func (this Gost) ToSecretString() string

输出密钥字符

func (Gost) ToString

func (this Gost) ToString() string

输出字符

func (Gost) ToVerify

func (this Gost) ToVerify() bool

验证结果

func (Gost) ToVerifyInt

func (this Gost) ToVerifyInt() int

验证结果,返回 int 类型

func (Gost) Verify

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

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

func (Gost) VerifyASN1

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

公钥验证 使用原始数据[data]对比签名后数据 publicKey Verify with asn.1

func (Gost) VerifyBytes added in v1.0.2069

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

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

func (Gost) WithCurve

func (this Gost) WithCurve(curve *gost.Curve) Gost

设置曲线类型 set gost curve

func (Gost) WithData

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

设置 data

func (Gost) WithEncoding added in v1.0.3009

func (this Gost) WithEncoding(encoding EncodingType) Gost

设置编码方式

func (Gost) WithEncodingASN1 added in v1.0.3009

func (this Gost) WithEncodingASN1() Gost

设置 ASN1 编码方式

func (Gost) WithEncodingBytes added in v1.0.3009

func (this Gost) WithEncodingBytes() Gost

设置明文编码方式

func (Gost) WithErrors

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

设置错误

func (Gost) WithParsedData

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

设置 parsedData

func (Gost) WithPrivateKey

func (this Gost) WithPrivateKey(data *gost.PrivateKey) Gost

设置 PrivateKey

func (Gost) WithPublicKey

func (this Gost) WithPublicKey(data *gost.PublicKey) Gost

设置 PublicKey

func (Gost) WithSecretData

func (this Gost) WithSecretData(data []byte) Gost

设置 secretData

func (Gost) WithSignHash

func (this Gost) WithSignHash(data HashFunc) Gost

设置 hash 类型

func (Gost) WithVerify

func (this Gost) WithVerify(data bool) Gost

设置 verify

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