From c127d367fc5e21fad24435500b226c6728fc08f2 Mon Sep 17 00:00:00 2001 From: KingAnointig Date: Wed, 19 Oct 2022 21:17:54 +0100 Subject: [PATCH] implement initpin function in p11mod #128 --- p11mod/p11mod.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/p11mod/p11mod.go b/p11mod/p11mod.go index 2f05e85..4f94129 100644 --- a/p11mod/p11mod.go +++ b/p11mod/p11mod.go @@ -222,9 +222,20 @@ func (ll *llBackend) GetMechanismInfo(slotID uint, m []*pkcs11.Mechanism) (pkcs1 } func (ll *llBackend) InitPIN(sh pkcs11.SessionHandle, pin string) error { - // TODO - log.Println("p11mod InitPIN: not implemented") - return pkcs11.Error(pkcs11.CKR_FUNCTION_NOT_SUPPORTED) + session, err := ll.getSessionByHandle(sh) + if err != nil { + return err + } + + if trace { + log.Printf("p11mod initpin") + } + + if err := session.session.InitPIN(pin); err != nil { + return err + } + + return nil } func (ll *llBackend) SetPIN(sh pkcs11.SessionHandle, oldpin, newpin string) error {