sdf

package
v2.3.4 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: Apache-2.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

View Source
const (
	BLOCK_MODE_ECB = "ECB"
	BLOCK_MODE_CTR = "CTR"
)

Variables

This section is empty.

Functions

func CCharArrToGoSlice

func CCharArrToGoSlice(buf []C.uchar) []byte

util funcs

func NewPrivateKey

func NewPrivateKey(sdf *SDFHandle, keyId string, keyPwd []byte, tp bccrypto.KeyType) (bccrypto.PrivateKey, error)

func NewSecretKey

func NewSecretKey(sdf *SDFHandle, keyId string, keyPwd []byte, tp bccrypto.KeyType) (bccrypto.SymmetricKey, error)

Types

type ECCSignature

type ECCSignature struct {
	R *big.Int
	S *big.Int
}

type SDFHandle

type SDFHandle struct {
	// contains filtered or unexported fields
}

func New

func New(lib string, sessionCacheSize int) (*SDFHandle, error)

New returns a HSM SDFHandle to provide go-sdf functionalities.

func (*SDFHandle) Close

func (h *SDFHandle) Close() error

func (*SDFHandle) Decrypt

func (h *SDFHandle) Decrypt(key SDFKey, cipher []byte) ([]byte, error)

Encrypt encrypts a plaintext with a given mechanism.

func (*SDFHandle) ECCInternalSign

func (h *SDFHandle) ECCInternalSign(key SDFKey, msg []byte) ([]byte, error)

Sign signs the input with a given mechanism.

func (*SDFHandle) Encrypt

func (h *SDFHandle) Encrypt(key SDFKey, plain []byte) ([]byte, error)

Encrypt encrypts a plaintext with a given mechanism.

func (*SDFHandle) ExportECDSAPublicKey

func (h *SDFHandle) ExportECDSAPublicKey(key SDFKey) (interface{}, error)

ExportECDSAPublicKey export a ecdsa/sm2 public key of pkcs11 ecdsa/sm2 private key

func (*SDFHandle) GenKeyPair

func (h *SDFHandle) GenKeyPair() (pri *base.ECCrefPrivateKey, pub *base.ECCrefPublicKey, err error)

GenKeyPair returns asym keypair

func (*SDFHandle) GenerateKey

func (h *SDFHandle) GenerateKey(length int) ([]byte, error)

GenerateKey returns sym key

func (*SDFHandle) GenerateRandom

func (h *SDFHandle) GenerateRandom(length int) ([]byte, error)

func (*SDFHandle) SymDecrypt

func (h *SDFHandle) SymDecrypt(keyHandle base.SessionHandle, mode uint, iv []byte, cipher []byte) ([]byte, error)

Encrypt encrypts a plaintext with a given mechanism.

func (*SDFHandle) SymEncrypt

func (h *SDFHandle) SymEncrypt(keyHandle base.SessionHandle, mode uint, iv []byte, plain []byte) ([]byte, error)

Encrypt encrypts a plaintext with a given mechanism.

func (*SDFHandle) Verify

func (h *SDFHandle) Verify(key SDFKey, msg []byte, sig base.ECCSignature) error

Verify verifies a signature over a message with a given mechanism.

type SDFKey

type SDFKey struct {
	KeyId   uint
	KeyPwd  []byte
	KeyType SDFKeyType
}

type SDFKeyType

type SDFKeyType string
const (
	RSA   SDFKeyType = "RSA"
	ECDSA SDFKeyType = "ECDSA"
	SM2   SDFKeyType = "SM2"

	AES SDFKeyType = "AES"
	SM4 SDFKeyType = "SM4"

	UNKNOWN SDFKeyType = "UNKNOWN"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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