elgamal

package
v1.0.4025 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 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")
	ErrNotElGamalPrivateKey = errors.New("key is not a valid ElGamal private key")
	ErrNotElGamalPublicKey  = errors.New("key is not a valid ElGamal public key")
)

Functions

This section is empty.

Types

type DSAErrorFunc

type DSAErrorFunc = func([]error)

错误方法

type ElGamal added in v1.0.4022

type ElGamal struct {

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

*

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

func FromBase64String

func FromBase64String(data string) ElGamal

Base64

func FromBytes

func FromBytes(data []byte) ElGamal

字节

func FromHexString

func FromHexString(data string) ElGamal

Hex

func FromPKCS1PrivateKey

func FromPKCS1PrivateKey(key []byte) ElGamal

PKCS1 私钥

func FromPKCS1PrivateKeyWithPassword

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

PKCS1 私钥带密码

func FromPKCS1PublicKey

func FromPKCS1PublicKey(key []byte) ElGamal

PKCS1 公钥

func FromPKCS8PrivateKey

func FromPKCS8PrivateKey(key []byte) ElGamal

PKCS8 私钥

func FromPKCS8PrivateKeyWithPassword

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

PKCS8 私钥带密码

func FromPKCS8PublicKey

func FromPKCS8PublicKey(key []byte) ElGamal

PKCS8 公钥

func FromPrivateKey

func FromPrivateKey(key []byte) ElGamal

私钥

func FromPrivateKeyWithPassword

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

私钥带密码

func FromPublicKey

func FromPublicKey(key []byte) ElGamal

公钥

func FromString

func FromString(data string) ElGamal

字符

func FromXMLPrivateKey

func FromXMLPrivateKey(key []byte) ElGamal

XML 私钥

func FromXMLPublicKey

func FromXMLPublicKey(key []byte) ElGamal

XML 公钥

func GenerateKey

func GenerateKey(bitsize, probability int) ElGamal

生成密钥

func GenerateKeyWithSeed added in v1.0.2026

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

使用数据生成密钥对

func New

func New() ElGamal

构造函数

func NewElGamal added in v1.0.4022

func NewElGamal() ElGamal

构造函数

func (ElGamal) AppendError added in v1.0.4022

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

添加错误

func (ElGamal) CheckKeyPair added in v1.0.4022

func (this ElGamal) CheckKeyPair() bool

检测公钥私钥是否匹配

func (ElGamal) CreatePKCS1PrivateKey added in v1.0.4022

func (this ElGamal) CreatePKCS1PrivateKey() ElGamal

生成 pkcs1 私钥 pem 数据

func (ElGamal) CreatePKCS1PrivateKeyWithPassword added in v1.0.4022

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

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

func (ElGamal) CreatePKCS1PublicKey added in v1.0.4022

func (this ElGamal) CreatePKCS1PublicKey() ElGamal

生成 pkcs1 公钥 pem 数据

func (ElGamal) CreatePKCS8PrivateKey added in v1.0.4022

func (this ElGamal) CreatePKCS8PrivateKey() ElGamal

生成 pkcs8 私钥 pem 数据

func (ElGamal) CreatePKCS8PrivateKeyWithPassword added in v1.0.4022

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

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

func (ElGamal) CreatePKCS8PublicKey added in v1.0.4022

func (this ElGamal) CreatePKCS8PublicKey() ElGamal

生成公钥 pem 数据

func (ElGamal) CreatePrivateKey added in v1.0.4022

func (this ElGamal) CreatePrivateKey() ElGamal

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

func (ElGamal) CreatePrivateKeyWithPassword added in v1.0.4022

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

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

func (ElGamal) CreatePublicKey added in v1.0.4022

func (this ElGamal) CreatePublicKey() ElGamal

生成公钥 pem 数据

func (ElGamal) CreateXMLPrivateKey added in v1.0.4022

func (this ElGamal) CreateXMLPrivateKey() ElGamal

生成私钥 xml 数据

func (ElGamal) CreateXMLPublicKey added in v1.0.4022

func (this ElGamal) CreateXMLPublicKey() ElGamal

生成公钥 xml 数据

func (ElGamal) Decrypt added in v1.0.4022

func (this ElGamal) Decrypt() ElGamal

私钥解密

func (ElGamal) Encrypt added in v1.0.4022

func (this ElGamal) Encrypt() ElGamal

公钥加密

func (ElGamal) Error added in v1.0.4022

func (this ElGamal) Error() error

获取错误

func (ElGamal) FromBase64String added in v1.0.4022

func (this ElGamal) FromBase64String(data string) ElGamal

Base64

func (ElGamal) FromBytes added in v1.0.4022

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

字节

func (ElGamal) FromHexString added in v1.0.4022

func (this ElGamal) FromHexString(data string) ElGamal

Hex

func (ElGamal) FromPKCS1PrivateKey added in v1.0.4022

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

PKCS1 私钥

func (ElGamal) FromPKCS1PrivateKeyDer added in v1.0.4022

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

Pkcs1 DER 私钥

func (ElGamal) FromPKCS1PrivateKeyWithPassword added in v1.0.4022

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

PKCS1 私钥带密码

func (ElGamal) FromPKCS1PublicKey added in v1.0.4022

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

PKCS1 公钥

func (ElGamal) FromPKCS1PublicKeyDer added in v1.0.4022

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

PKCS1 DER 公钥

func (ElGamal) FromPKCS8PrivateKey added in v1.0.4022

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

PKCS8 私钥

func (ElGamal) FromPKCS8PrivateKeyDer added in v1.0.4022

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

Pkcs8 DER 私钥

func (ElGamal) FromPKCS8PrivateKeyWithPassword added in v1.0.4022

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

PKCS8 私钥带密码

func (ElGamal) FromPKCS8PublicKey added in v1.0.4022

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

PKCS8 公钥

func (ElGamal) FromPKCS8PublicKeyDer added in v1.0.4022

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

PKCS8 DER 公钥

func (ElGamal) FromPrivateKey added in v1.0.4022

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

私钥

func (ElGamal) FromPrivateKeyWithPassword added in v1.0.4022

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

私钥带密码

func (ElGamal) FromPublicKey added in v1.0.4022

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

公钥

func (ElGamal) FromString added in v1.0.4022

func (this ElGamal) FromString(data string) ElGamal

字符

func (ElGamal) FromXMLPrivateKey added in v1.0.4022

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

XML 私钥

func (ElGamal) FromXMLPublicKey added in v1.0.4022

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

XML 公钥

func (ElGamal) GenerateKey added in v1.0.4022

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

生成密钥

func (ElGamal) GenerateKeyWithSeed added in v1.0.4022

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

使用数据生成密钥对

func (ElGamal) GetData added in v1.0.4022

func (this ElGamal) GetData() []byte

获取 data

func (ElGamal) GetErrors added in v1.0.4022

func (this ElGamal) GetErrors() []error

获取错误

func (ElGamal) GetKeyData added in v1.0.4022

func (this ElGamal) GetKeyData() []byte

获取 keyData

func (ElGamal) GetParsedData added in v1.0.4022

func (this ElGamal) GetParsedData() []byte

获取 parsedData

func (ElGamal) GetPrivateKey added in v1.0.4022

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

获取 PrivateKey

func (ElGamal) GetPublicKey added in v1.0.4022

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

获取 PublicKey

func (ElGamal) GetSignHash added in v1.0.4022

func (this ElGamal) GetSignHash() HashFunc

获取 hash 类型

func (ElGamal) GetVerify added in v1.0.4022

func (this ElGamal) GetVerify() bool

获取验证后情况

func (ElGamal) MakeKeyDer added in v1.0.4022

func (this ElGamal) MakeKeyDer() ElGamal

生成密钥 der 数据

func (ElGamal) MakePublicKey added in v1.0.4022

func (this ElGamal) MakePublicKey() ElGamal

生成公钥

func (ElGamal) OnError added in v1.0.4022

func (this ElGamal) OnError(fn DSAErrorFunc) ElGamal

引出错误信息

func (ElGamal) ParsePKCS1PrivateKeyFromPEM added in v1.0.4022

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

解析私钥

func (ElGamal) ParsePKCS1PrivateKeyFromPEMWithPassword added in v1.0.4022

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

解析私钥带密码

func (ElGamal) ParsePKCS1PublicKeyFromPEM added in v1.0.4022

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

解析公钥

func (ElGamal) ParsePKCS8PrivateKeyFromPEM added in v1.0.4022

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

解析私钥 PKCS8

func (ElGamal) ParsePKCS8PrivateKeyFromPEMWithPassword added in v1.0.4022

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

解析 PKCS8 带密码的私钥

func (ElGamal) ParsePKCS8PublicKeyFromPEM added in v1.0.4022

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

解析公钥 PKCS8

func (ElGamal) ParsePrivateKeyFromXML added in v1.0.4022

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

解析 xml 私钥

func (ElGamal) ParsePublicKeyFromXML added in v1.0.4022

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

解析 xml 公钥

func (ElGamal) SetSignHash added in v1.0.4022

func (this ElGamal) SetSignHash(data string) ElGamal

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

func (ElGamal) Sign added in v1.0.4022

func (this ElGamal) Sign() ElGamal

私钥签名

func (ElGamal) ToBase64String added in v1.0.4022

func (this ElGamal) ToBase64String() string

输出Base64

func (ElGamal) ToBytes added in v1.0.4022

func (this ElGamal) ToBytes() []byte

输出字节

func (ElGamal) ToHexString added in v1.0.4022

func (this ElGamal) ToHexString() string

输出Hex

func (ElGamal) ToKeyBytes added in v1.0.4022

func (this ElGamal) ToKeyBytes() []byte

私钥/公钥

func (ElGamal) ToKeyString added in v1.0.4022

func (this ElGamal) ToKeyString() string

私钥/公钥

func (ElGamal) ToString added in v1.0.4022

func (this ElGamal) ToString() string

输出字符

func (ElGamal) ToVerify added in v1.0.4022

func (this ElGamal) ToVerify() bool

验证结果

func (ElGamal) ToVerifyInt added in v1.0.4022

func (this ElGamal) ToVerifyInt() int

验证结果,返回 int 类型

func (ElGamal) Verify added in v1.0.4022

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

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

func (ElGamal) WithData added in v1.0.4022

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

设置 data

func (ElGamal) WithErrors added in v1.0.4022

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

设置错误

func (ElGamal) WithParsedData added in v1.0.4022

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

设置 parsedData

func (ElGamal) WithPrivateKey added in v1.0.4022

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

设置 PrivateKey

func (ElGamal) WithPublicKey added in v1.0.4022

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

设置 PublicKey

func (ElGamal) WithSignHash added in v1.0.4022

func (this ElGamal) WithSignHash(data HashFunc) ElGamal

设置 hash 类型

func (ElGamal) WithVerify added in v1.0.4022

func (this ElGamal) WithVerify(data bool) ElGamal

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