crypto

package
v0.0.0-...-0b06f50 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2020 License: BSD-3-Clause Imports: 22 Imported by: 2

README

To test YubiHSM crypto module:

YUBIHSM_CFG_FILE=yubihsm_test.cfg go test -tags "evm" -v

Documentation

Index

Constants

View Source
const (
	PrivateKeyTypeEd25519   = "ed25519"
	PrivateKeyTypeSecp256k1 = "secp256k1"
)
View Source
const (
	YubiDefConnURL       = "127.0.0.1:12345"
	YubiDefAuthKeyID     = 1
	YubiDefPassword      = "password"
	YubiDefPrivKeyDomain = 1
	YubiDefPrivKeyType   = PrivateKeyTypeEd25519

	YubiSecp256k1PubKeySize  = 33
	YubiSecp256k1SignDataLen = 65

	YubiEd25519PubKeySize  = 32
	YubiEd25519SignDataLen = 64
)

Variables

This section is empty.

Functions

func LoadBtecSecp256k1PrivKey

func LoadBtecSecp256k1PrivKey(file string) (*ecdsa.PrivateKey, error)

LoadBtecSecp256k1PrivKey converts private key from btec secp256k1 to ecdsa

func LoadBtecSecp256k1PrivKeyByte

func LoadBtecSecp256k1PrivKeyByte(file string) ([]byte, error)

LoadBtecSecp256k1PrivKeyByte reads 64 byte from private key file

func LoadEd25519PrivKey

func LoadEd25519PrivKey(path string) ([]byte, error)

func LoadSecp256k1PrivKey

func LoadSecp256k1PrivKey(filePath string) (interface{}, error)

func Sign

func Sign(hash []byte, prv PrivateKey) (sig []byte, err error)

func YubiHsmSign

func YubiHsmSign(msg []byte, privKey *YubiHsmPrivateKey) (sig []byte, err error)

YubiHsmSign signs using private key in YubiHSM token

Types

type PrivateKey

type PrivateKey interface{}

type YubiHsmConfig

type YubiHsmConfig struct {
	HsmConnURL    string `json:"YubiHsmConnURL"`
	AuthKeyID     uint16 `json:"AuthKeyID"`
	AuthPasswd    string `json:"Password"`
	PrivKeyID     uint16 `json:"PrivKeyID"`
	PrivKeyDomain uint16 `json:"PrivKeyDomain"`
	PrivKeyType   string `json:"PrivKeyType"`
}

type YubiHsmPrivateKey

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

func GenYubiHsmPrivKey

func GenYubiHsmPrivKey(filePath string) (*YubiHsmPrivateKey, error)

func InitYubiHsmPrivKey

func InitYubiHsmPrivKey(hsmConfig *YubiHsmConfig) (*YubiHsmPrivateKey, error)

func LoadYubiHsmPrivKey

func LoadYubiHsmPrivKey(filePath string) (*YubiHsmPrivateKey, error)

func (*YubiHsmPrivateKey) ExportPubKey

func (privKey *YubiHsmPrivateKey) ExportPubKey() error

export YubiHsm public key by private key ID

func (*YubiHsmPrivateKey) GenPrivKey

func (privKey *YubiHsmPrivateKey) GenPrivKey() error

func (*YubiHsmPrivateKey) GetKeyType

func (privKey *YubiHsmPrivateKey) GetKeyType() string

get key type

func (*YubiHsmPrivateKey) GetPrivKeyID

func (privKey *YubiHsmPrivateKey) GetPrivKeyID() uint16

func (*YubiHsmPrivateKey) GetPubKeyAddr

func (privKey *YubiHsmPrivateKey) GetPubKeyAddr() string

get pubkey address

func (*YubiHsmPrivateKey) GetPubKeyAddrB64Encoded

func (privKey *YubiHsmPrivateKey) GetPubKeyAddrB64Encoded() (string, error)

get base64 encoded pubkey address

func (*YubiHsmPrivateKey) GetPubKeyBytes

func (privKey *YubiHsmPrivateKey) GetPubKeyBytes() []byte

get pubkey bytes

func (*YubiHsmPrivateKey) UnloadYubiHsmPrivKey

func (privKey *YubiHsmPrivateKey) UnloadYubiHsmPrivKey()

unload YubiHsm private key

Jump to

Keyboard shortcuts

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