keypairs

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const ECDSA_Curve_P224 = "P224"
View Source
const ECDSA_Curve_P256 = "P256"
View Source
const ECDSA_Curve_P384 = "P384"
View Source
const ECDSA_Curve_P521 = "P521"
View Source
const RSA_bits_1024 = 1024
View Source
const RSA_bits_2048 = 2048
View Source
const RSA_bits_3072 = 3072
View Source
const RSA_bits_4096 = 4096

Variables

This section is empty.

Functions

This section is empty.

Types

type IKeypair

type IKeypair struct {

	/* 公钥 */
	PublicKey PublicKey

	/* 私钥 */
	PrivateKey PrivateKey
}

非对称加密的秘钥对

type IKeypairGenerator

type IKeypairGenerator interface {

	/* 获取生成器名称 */
	GetNames() []string

	/* 生成秘钥对 */
	GenerateKeyPair() (*IKeypair, error)

	/* 导入公钥 */
	ImportPublicKey(publicKeyBytes []byte) (PublicKey, error)

	/* 导出公钥 */
	ExportPublicKey(publicKey PublicKey) ([]byte, error)

	/* 导入私钥 */
	ImportPrivateKey(privateKeyBytes []byte) (PrivateKey, error)

	/* 导出私钥 */
	ExportPrivateKey(privateKey PrivateKey) ([]byte, error)
}

秘钥对生成器

type IPublicKeyCompressor

type IPublicKeyCompressor interface {

	/* 压缩公钥 */
	CompressPublicKey(publicKey PublicKey) ([]byte, error)

	/* 解压公钥 */
	DecompressPublicKey(data []byte) (PublicKey, error)
}

公钥压缩器

type Key

type Key any

秘钥

type KeypairGenerator_ECDSA

type KeypairGenerator_ECDSA struct {
	IKeypairGenerator
	// contains filtered or unexported fields
}

func NewKeypairGenerator_ECDSA

func NewKeypairGenerator_ECDSA(curve string) *KeypairGenerator_ECDSA

func (KeypairGenerator_ECDSA) ExportPrivateKey

func (KeypairGenerator_ECDSA) ExportPrivateKey(privateKey PrivateKey) ([]byte, error)

func (KeypairGenerator_ECDSA) ExportPublicKey

func (KeypairGenerator_ECDSA) ExportPublicKey(publicKey PublicKey) ([]byte, error)

func (KeypairGenerator_ECDSA) GenerateKeyPair

func (KeypairGenerator_ECDSA) GenerateKeyPair() (*IKeypair, error)

func (KeypairGenerator_ECDSA) GetNames

func (k KeypairGenerator_ECDSA) GetNames() []string

func (KeypairGenerator_ECDSA) ImportPrivateKey

func (KeypairGenerator_ECDSA) ImportPrivateKey(privateKeyBytes []byte) (PrivateKey, error)

func (KeypairGenerator_ECDSA) ImportPublicKey

func (KeypairGenerator_ECDSA) ImportPublicKey(publicKeyBytes []byte) (PublicKey, error)

type KeypairGenerator_RSA

type KeypairGenerator_RSA struct {
	IKeypairGenerator
	// contains filtered or unexported fields
}

func NewKeypairGenerator_RSA

func NewKeypairGenerator_RSA(bits int) *KeypairGenerator_RSA

func (KeypairGenerator_RSA) ExportPrivateKey

func (KeypairGenerator_RSA) ExportPrivateKey(privateKey PrivateKey) ([]byte, error)

func (KeypairGenerator_RSA) ExportPublicKey

func (KeypairGenerator_RSA) ExportPublicKey(publicKey PublicKey) ([]byte, error)

func (KeypairGenerator_RSA) GenerateKeyPair

func (k KeypairGenerator_RSA) GenerateKeyPair() (*IKeypair, error)

func (KeypairGenerator_RSA) GetNames

func (k KeypairGenerator_RSA) GetNames() []string

func (KeypairGenerator_RSA) ImportPrivateKey

func (KeypairGenerator_RSA) ImportPrivateKey(privateKeyBytes []byte) (PrivateKey, error)

func (KeypairGenerator_RSA) ImportPublicKey

func (KeypairGenerator_RSA) ImportPublicKey(publicKeyBytes []byte) (PublicKey, error)

type KeypairGenerator_SM2

type KeypairGenerator_SM2 struct {
	IKeypairGenerator
	IPublicKeyCompressor
}

func NewKeypairGenerator_SM2

func NewKeypairGenerator_SM2() *KeypairGenerator_SM2

func (KeypairGenerator_SM2) CompressPublicKey

func (KeypairGenerator_SM2) CompressPublicKey(publicKey PublicKey) ([]byte, error)

func (KeypairGenerator_SM2) DecompressPublicKey

func (KeypairGenerator_SM2) DecompressPublicKey(data []byte) (publicKey PublicKey, err error)

func (KeypairGenerator_SM2) ExportPrivateKey

func (KeypairGenerator_SM2) ExportPrivateKey(privateKey PrivateKey) ([]byte, error)

func (KeypairGenerator_SM2) ExportPublicKey

func (KeypairGenerator_SM2) ExportPublicKey(publicKey PublicKey) ([]byte, error)

func (KeypairGenerator_SM2) GenerateKeyPair

func (KeypairGenerator_SM2) GenerateKeyPair() (*IKeypair, error)

func (KeypairGenerator_SM2) GetNames

func (KeypairGenerator_SM2) GetNames() []string

func (KeypairGenerator_SM2) ImportPrivateKey

func (KeypairGenerator_SM2) ImportPrivateKey(privateKeyBytes []byte) (PrivateKey, error)

func (KeypairGenerator_SM2) ImportPublicKey

func (KeypairGenerator_SM2) ImportPublicKey(publicKeyBytes []byte) (PublicKey, error)

type PrivateKey

type PrivateKey Key

私钥

type PublicKey

type PublicKey Key

公钥

Jump to

Keyboard shortcuts

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