From 7dc4b42fda8a8e2b1ea6101780737667c41a37f2 Mon Sep 17 00:00:00 2001 From: Jeremy Rand Date: Tue, 9 Aug 2022 03:17:32 +0000 Subject: [PATCH] p11mod: Friendly trace for GetAttributeValue query Refs https://github.com/namecoin/pkcs11mod/issues/58 --- p11mod/p11mod.go | 2 +- types.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/p11mod/p11mod.go b/p11mod/p11mod.go index 94ef65a..824f975 100644 --- a/p11mod/p11mod.go +++ b/p11mod/p11mod.go @@ -454,7 +454,7 @@ func (ll *llBackend) GetAttributeValue(sh pkcs11.SessionHandle, oh pkcs11.Object result := make([]*pkcs11.Attribute, len(a)) for i, t := range a { if trace { - log.Printf("p11mod GetAttributeValue: Type %d", t.Type) + log.Printf("p11mod GetAttributeValue: querying %s", pkcs11mod.AttrTrace(t)) } value, err := object.Attribute(t.Type) diff --git a/types.go b/types.go index deb5e7a..1167dad 100644 --- a/types.go +++ b/types.go @@ -132,7 +132,7 @@ func fromTemplate(template []*pkcs11.Attribute, clist C.CK_ATTRIBUTE_PTR) error bufferTooSmall := false for i, x := range template { if trace { - log.Printf("pkcs11mod fromTemplate: %s", attrTrace(x)) + log.Printf("pkcs11mod fromTemplate: %s", AttrTrace(x)) } c := l1[i] @@ -371,7 +371,7 @@ var strCKA = map[uint]string{ pkcs11.CKA_CERT_MD5_HASH:"CKA_CERT_MD5_HASH", } -func attrTrace(a *pkcs11.Attribute) string { +func AttrTrace(a *pkcs11.Attribute) string { t, ok := strCKA[a.Type] if !ok { t = fmt.Sprintf("%d", a.Type)