Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertBip32PathFromString(pathStr string) (path []uint32, err error)
- func GetMechanismSimple(mech uint) []*pkcs11.Mechanism
- func NewPkcs11(pkcs11Ctx *pkcs11.Ctx, namedCurveOid []byte) *pkcs11Api
- func SetContextLogger(logger ContextLogFunc)
- func SetLogger(logger LogFunc)
- type ContextLogFunc
- type LogFunc
- type LogLevel
- type Pkcs11
- type PublicKeyBytes
- type SignatureBytes
Constants ¶
Variables ¶
View Source
var ( // EC Curve: secp256k1 CurveSecp256k1 = []byte{0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x0a} // EC Curve: prime256k1 CurvePrime256v1 = []byte{0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07} // EC Curve: ed25519 CurveEd25519 = []byte{0x06, 0x09, 0x2B, 0x06, 0x01, 0x04, 0x01, 0xDA, 0x47, 0x0F, 0x01} // Error: label not found ErrLabelNotFound = stderrors.New("target label is empty") // Error: lavel already exist ErrLabelAlreadyExist = stderrors.New("target label is already exist") )
Functions ¶
func GetMechanismSimple ¶ added in v1.0.1
Types ¶
type ContextLogFunc ¶
ContextLogFunc ...
type Pkcs11 ¶
type Pkcs11 interface { GetPkcs11Context() *pkcs11.Ctx GetCurrentSlot() (slotID uint, exist bool) Initialize(ctx context.Context) error Finalize(ctx context.Context) // OpenSession creates a session and login an user. OpenSession( ctx context.Context, pin string, ) (session pkcs11.SessionHandle, err error) // OpenSessionWithPartition creates a session for a partition, and login an user. OpenSessionWithSlot( ctx context.Context, slotID uint, pin string, ) (session pkcs11.SessionHandle, err error) OpenSessionWithPartitionAndSlot( ctx context.Context, slotID uint, partitionID uint, pin string, ) (session pkcs11.SessionHandle, err error) // CloseSession deletes a session and logout an user. CloseSession(ctx context.Context, session pkcs11.SessionHandle) // CloseSessionAll deletes all sessions. CloseSessionAll(ctx context.Context, slotID uint) // ReLogin does logout and re-login. ReLogin(ctx context.Context, session pkcs11.SessionHandle, pin string) error FindKeyByLabel( ctx context.Context, session pkcs11.SessionHandle, label string, ) (key pkcs11.ObjectHandle, err error) GenerateSeed( ctx context.Context, session pkcs11.SessionHandle, label string, length uint, ) (seedHandle pkcs11.ObjectHandle, err error) GenerateKeyPairWithCurve( ctx context.Context, session pkcs11.SessionHandle, mechanism *pkcs11.Mechanism, namedCurveOid []byte, keyType int, pubkeyLabel, privkeyLabel string, canExport bool, ) (pubkeyHandle pkcs11.ObjectHandle, privkeyHandle pkcs11.ObjectHandle, err error) DestroyKey( ctx context.Context, session pkcs11.SessionHandle, keyHandle pkcs11.ObjectHandle, ) error CreateXprivFromSeed( ctx context.Context, session pkcs11.SessionHandle, seedHandle pkcs11.ObjectHandle, xpubLabel, xprivLabel string, canExport bool, ) (pubkeyHandle pkcs11.ObjectHandle, privkeyHandle pkcs11.ObjectHandle, err error) DeriveKeyPairWithBIP32( ctx context.Context, session pkcs11.SessionHandle, masterXprivHandle pkcs11.ObjectHandle, path []uint32, skLabel string, ) (pubkeyHandle pkcs11.ObjectHandle, privkeyHandle pkcs11.ObjectHandle, err error) DeriveEcKey( ctx context.Context, session pkcs11.SessionHandle, basePrivkeyHandle pkcs11.ObjectHandle, data []byte, valueLen int, ) (privkey []byte, err error) ImportEcKey( ctx context.Context, session pkcs11.SessionHandle, privkey []byte, label string, canExport bool, ) (privkeyHandle pkcs11.ObjectHandle, err error) GenerateSignature( ctx context.Context, session pkcs11.SessionHandle, privkeyHandle pkcs11.ObjectHandle, mechanismType uint, message []byte, ) (signature SignatureBytes, err error) GetPublicKey( ctx context.Context, session pkcs11.SessionHandle, pubkeyHandle pkcs11.ObjectHandle, ) (pubkey PublicKeyBytes, err error) Verify( ctx context.Context, session pkcs11.SessionHandle, pubkeyHandle pkcs11.ObjectHandle, data []byte, signature []byte, ) (err error) ImportSeed( ctx context.Context, session pkcs11.SessionHandle, seedBytes []byte, label string, ) (seedHandle pkcs11.ObjectHandle, err error) ImportXpriv( ctx context.Context, session pkcs11.SessionHandle, xpriv, label string, canExport bool, ) (xprivHandle pkcs11.ObjectHandle, err error) ExportXpriv( ctx context.Context, session pkcs11.SessionHandle, xprivHandle pkcs11.ObjectHandle, ) (xpriv string, err error) }
type PublicKeyBytes ¶ added in v1.0.1
type PublicKeyBytes []byte
func (PublicKeyBytes) ToHex ¶ added in v1.0.1
func (s PublicKeyBytes) ToHex() string
func (PublicKeyBytes) ToSlice ¶ added in v1.0.1
func (s PublicKeyBytes) ToSlice() []byte
type SignatureBytes ¶ added in v1.0.1
type SignatureBytes [64]byte
func (SignatureBytes) ToHex ¶ added in v1.0.1
func (s SignatureBytes) ToHex() string
func (SignatureBytes) ToSlice ¶ added in v1.0.1
func (s SignatureBytes) ToSlice() []byte
Click to show internal directories.
Click to hide internal directories.