elgamal

package
v1.0.4011 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 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 PKCS1 or PKCS8 key")
	ErrNotEIGamalPrivateKey = errors.New("key is not a valid EIGamal private key")
	ErrNotEIGamalPublicKey  = errors.New("key is not a valid EIGamal public key")
)

Functions

This section is empty.

Types

type DSAErrorFunc

type DSAErrorFunc = func([]error)

错误方法

type EIGamal

type EIGamal struct {

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

*

  • EIGamal *
  • @create 2023-6-22
  • @author deatil

func FromBase64String

func FromBase64String(data string) EIGamal

Base64

func FromBytes

func FromBytes(data []byte) EIGamal

字节

func FromHexString

func FromHexString(data string) EIGamal

Hex

func FromPKCS1PrivateKey

func FromPKCS1PrivateKey(key []byte) EIGamal

PKCS1 私钥

func FromPKCS1PrivateKeyWithPassword

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

PKCS1 私钥带密码

func FromPKCS1PublicKey

func FromPKCS1PublicKey(key []byte) EIGamal

PKCS1 公钥

func FromPKCS8PrivateKey

func FromPKCS8PrivateKey(key []byte) EIGamal

PKCS8 私钥

func FromPKCS8PrivateKeyWithPassword

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

PKCS8 私钥带密码

func FromPKCS8PublicKey

func FromPKCS8PublicKey(key []byte) EIGamal

PKCS8 公钥

func FromPrivateKey

func FromPrivateKey(key []byte) EIGamal

私钥

func FromPrivateKeyWithPassword

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

私钥带密码

func FromPublicKey

func FromPublicKey(key []byte) EIGamal

公钥

func FromString

func FromString(data string) EIGamal

字符

func FromXMLPrivateKey

func FromXMLPrivateKey(key []byte) EIGamal

XML 私钥

func FromXMLPublicKey

func FromXMLPublicKey(key []byte) EIGamal

XML 公钥

func GenerateKey

func GenerateKey(bitsize, probability int) EIGamal

生成密钥

func GenerateKeyWithSeed added in v1.0.2026

func GenerateKeyWithSeed(reader io.Reader, bitsize, probability int) EIGamal

使用数据生成密钥对

func New

func New() EIGamal

构造函数

func NewEIGamal

func NewEIGamal() EIGamal

构造函数

func (EIGamal) AppendError

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

添加错误

func (EIGamal) CheckKeyPair

func (this EIGamal) CheckKeyPair() bool

检测公钥私钥是否匹配

func (EIGamal) CreatePKCS1PrivateKey

func (this EIGamal) CreatePKCS1PrivateKey() EIGamal

生成 pkcs1 私钥 pem 数据

func (EIGamal) CreatePKCS1PrivateKeyWithPassword

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

生成 pkcs1 私钥带密码 pem 数据 CreatePKCS1PrivateKeyWithPassword("123", "AES256CBC") PEMCipher: DESCBC | DESEDE3CBC | AES128CBC | AES192CBC | AES256CBC

func (EIGamal) CreatePKCS1PublicKey

func (this EIGamal) CreatePKCS1PublicKey() EIGamal

生成 pkcs1 公钥 pem 数据

func (EIGamal) CreatePKCS8PrivateKey

func (this EIGamal) CreatePKCS8PrivateKey() EIGamal

生成 pkcs8 私钥 pem 数据

func (EIGamal) CreatePKCS8PrivateKeyWithPassword

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

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

func (EIGamal) CreatePKCS8PublicKey

func (this EIGamal) CreatePKCS8PublicKey() EIGamal

生成公钥 pem 数据

func (EIGamal) CreatePrivateKey

func (this EIGamal) CreatePrivateKey() EIGamal

生成私钥 pem 数据 elgamal := New().GenerateKey("L2048N256") priKey := elgamal.CreatePrivateKey().ToKeyString()

func (EIGamal) CreatePrivateKeyWithPassword

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

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

func (EIGamal) CreatePublicKey

func (this EIGamal) CreatePublicKey() EIGamal

生成公钥 pem 数据

func (EIGamal) CreateXMLPrivateKey

func (this EIGamal) CreateXMLPrivateKey() EIGamal

生成私钥 xml 数据

func (EIGamal) CreateXMLPublicKey

func (this EIGamal) CreateXMLPublicKey() EIGamal

生成公钥 xml 数据

func (EIGamal) Decrypt

func (this EIGamal) Decrypt() EIGamal

私钥解密

func (EIGamal) Encrypt

func (this EIGamal) Encrypt() EIGamal

公钥加密

func (EIGamal) Error

func (this EIGamal) Error() error

获取错误

func (EIGamal) FromBase64String

func (this EIGamal) FromBase64String(data string) EIGamal

Base64

func (EIGamal) FromBytes

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

字节

func (EIGamal) FromHexString

func (this EIGamal) FromHexString(data string) EIGamal

Hex

func (EIGamal) FromPKCS1PrivateKey

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

PKCS1 私钥

func (EIGamal) FromPKCS1PrivateKeyDer

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

Pkcs1 DER 私钥

func (EIGamal) FromPKCS1PrivateKeyWithPassword

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

PKCS1 私钥带密码

func (EIGamal) FromPKCS1PublicKey

func (this EIGamal) FromPKCS1PublicKey(key []byte) EIGamal

PKCS1 公钥

func (EIGamal) FromPKCS1PublicKeyDer

func (this EIGamal) FromPKCS1PublicKeyDer(der []byte) EIGamal

PKCS1 DER 公钥

func (EIGamal) FromPKCS8PrivateKey

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

PKCS8 私钥

func (EIGamal) FromPKCS8PrivateKeyDer

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

Pkcs8 DER 私钥

func (EIGamal) FromPKCS8PrivateKeyWithPassword

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

PKCS8 私钥带密码

func (EIGamal) FromPKCS8PublicKey

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

PKCS8 公钥

func (EIGamal) FromPKCS8PublicKeyDer

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

PKCS8 DER 公钥

func (EIGamal) FromPrivateKey

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

私钥

func (EIGamal) FromPrivateKeyWithPassword

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

私钥带密码

func (EIGamal) FromPublicKey

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

公钥

func (EIGamal) FromString

func (this EIGamal) FromString(data string) EIGamal

字符

func (EIGamal) FromXMLPrivateKey

func (this EIGamal) FromXMLPrivateKey(key []byte) EIGamal

XML 私钥

func (EIGamal) FromXMLPublicKey

func (this EIGamal) FromXMLPublicKey(key []byte) EIGamal

XML 公钥

func (EIGamal) GenerateKey

func (this EIGamal) GenerateKey(bitsize, probability int) EIGamal

生成密钥

func (EIGamal) GenerateKeyWithSeed added in v1.0.2026

func (this EIGamal) GenerateKeyWithSeed(reader io.Reader, bitsize, probability int) EIGamal

使用数据生成密钥对

func (EIGamal) GetData

func (this EIGamal) GetData() []byte

获取 data

func (EIGamal) GetErrors

func (this EIGamal) GetErrors() []error

获取错误

func (EIGamal) GetKeyData

func (this EIGamal) GetKeyData() []byte

获取 keyData

func (EIGamal) GetParsedData added in v1.0.2049

func (this EIGamal) GetParsedData() []byte

获取 parsedData

func (EIGamal) GetPrivateKey

func (this EIGamal) GetPrivateKey() *elgamal.PrivateKey

获取 PrivateKey

func (EIGamal) GetPublicKey

func (this EIGamal) GetPublicKey() *elgamal.PublicKey

获取 PublicKey

func (EIGamal) GetSignHash

func (this EIGamal) GetSignHash() HashFunc

获取 hash 类型

func (EIGamal) GetVerify

func (this EIGamal) GetVerify() bool

获取验证后情况

func (EIGamal) MakeKeyDer

func (this EIGamal) MakeKeyDer() EIGamal

生成密钥 der 数据

func (EIGamal) MakePublicKey

func (this EIGamal) MakePublicKey() EIGamal

生成公钥

func (EIGamal) OnError

func (this EIGamal) OnError(fn DSAErrorFunc) EIGamal

引出错误信息

func (EIGamal) ParsePKCS1PrivateKeyFromPEM

func (this EIGamal) ParsePKCS1PrivateKeyFromPEM(key []byte) (*elgamal.PrivateKey, error)

解析私钥

func (EIGamal) ParsePKCS1PrivateKeyFromPEMWithPassword

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

解析私钥带密码

func (EIGamal) ParsePKCS1PublicKeyFromPEM

func (this EIGamal) ParsePKCS1PublicKeyFromPEM(key []byte) (*elgamal.PublicKey, error)

解析公钥

func (EIGamal) ParsePKCS8PrivateKeyFromPEM

func (this EIGamal) ParsePKCS8PrivateKeyFromPEM(key []byte) (*elgamal.PrivateKey, error)

解析私钥 PKCS8

func (EIGamal) ParsePKCS8PrivateKeyFromPEMWithPassword

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

解析 PKCS8 带密码的私钥

func (EIGamal) ParsePKCS8PublicKeyFromPEM

func (this EIGamal) ParsePKCS8PublicKeyFromPEM(key []byte) (*elgamal.PublicKey, error)

解析公钥 PKCS8

func (EIGamal) ParsePrivateKeyFromXML

func (this EIGamal) ParsePrivateKeyFromXML(key []byte) (*elgamal.PrivateKey, error)

解析 xml 私钥

func (EIGamal) ParsePublicKeyFromXML

func (this EIGamal) ParsePublicKeyFromXML(key []byte) (*elgamal.PublicKey, error)

解析 xml 公钥

func (EIGamal) SetSignHash

func (this EIGamal) SetSignHash(data string) EIGamal

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

func (EIGamal) Sign

func (this EIGamal) Sign() EIGamal

私钥签名

func (EIGamal) ToBase64String

func (this EIGamal) ToBase64String() string

输出Base64

func (EIGamal) ToBytes

func (this EIGamal) ToBytes() []byte

输出字节

func (EIGamal) ToHexString

func (this EIGamal) ToHexString() string

输出Hex

func (EIGamal) ToKeyBytes

func (this EIGamal) ToKeyBytes() []byte

私钥/公钥

func (EIGamal) ToKeyString

func (this EIGamal) ToKeyString() string

私钥/公钥

func (EIGamal) ToString

func (this EIGamal) ToString() string

输出字符

func (EIGamal) ToVerify

func (this EIGamal) ToVerify() bool

验证结果

func (EIGamal) ToVerifyInt

func (this EIGamal) ToVerifyInt() int

验证结果,返回 int 类型

func (EIGamal) Verify

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

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

func (EIGamal) WithData

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

设置 data

func (EIGamal) WithErrors

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

设置错误

func (EIGamal) WithParsedData added in v1.0.2049

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

设置 parsedData

func (EIGamal) WithPrivateKey

func (this EIGamal) WithPrivateKey(data *elgamal.PrivateKey) EIGamal

设置 PrivateKey

func (EIGamal) WithPublicKey

func (this EIGamal) WithPublicKey(data *elgamal.PublicKey) EIGamal

设置 PublicKey

func (EIGamal) WithSignHash

func (this EIGamal) WithSignHash(data HashFunc) EIGamal

设置 hash 类型

func (EIGamal) WithVerify

func (this EIGamal) WithVerify(data bool) EIGamal

设置 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