Blame SOURCES/0066-p11_child-NSS-print-key-type-in-a-debug-message.patch

71e593
From 6286f8120ac9986b418f4f08f26d6808cf028a9b Mon Sep 17 00:00:00 2001
71e593
From: Sumit Bose <sbose@redhat.com>
71e593
Date: Fri, 9 Nov 2018 13:34:33 +0100
71e593
Subject: [PATCH 66/74] p11_child(NSS): print key type in a debug message
71e593
71e593
NSS can handle EC keys automatically but a debug message indicating
71e593
which key type is used might be useful.
71e593
71e593
Related to https://pagure.io/SSSD/sssd/issue/3887
71e593
71e593
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
71e593
---
71e593
 src/p11_child/p11_child_nss.c | 36 +++++++++++++++++++++++++++++++++++
71e593
 1 file changed, 36 insertions(+)
71e593
71e593
diff --git a/src/p11_child/p11_child_nss.c b/src/p11_child/p11_child_nss.c
71e593
index f9cbf3f37..d3064ff98 100644
71e593
--- a/src/p11_child/p11_child_nss.c
71e593
+++ b/src/p11_child/p11_child_nss.c
71e593
@@ -477,6 +477,40 @@ bool do_verification_b64(struct p11_ctx *p11_ctx, const char *cert_b64)
71e593
     return res;
71e593
 }
71e593
 
71e593
+static const char *keytype2str(KeyType keyType) {
71e593
+    switch (keyType) {
71e593
+        case nullKey:
71e593
+            return "nullKey";
71e593
+            break;
71e593
+        case rsaKey:
71e593
+            return "rsaKey";
71e593
+            break;
71e593
+        case dsaKey:
71e593
+            return "dsaKey";
71e593
+            break;
71e593
+        case fortezzaKey:
71e593
+            return "fortezzaKey";
71e593
+            break;
71e593
+        case dhKey:
71e593
+            return "dhKey";
71e593
+            break;
71e593
+        case keaKey:
71e593
+            return "keaKey";
71e593
+            break;
71e593
+        case ecKey:
71e593
+            return "ecKey";
71e593
+            break;
71e593
+        case rsaPssKey:
71e593
+            return "rsaPssKey";
71e593
+            break;
71e593
+        case rsaOaepKey:
71e593
+            return "rsaOaepKey";
71e593
+            break;
71e593
+        default:
71e593
+            return "Unknown key type";
71e593
+    }
71e593
+}
71e593
+
71e593
 errno_t do_card(TALLOC_CTX *mem_ctx, struct p11_ctx *p11_ctx,
71e593
                 enum op_mode mode, const char *pin,
71e593
                 const char *module_name_in, const char *token_name_in,
71e593
@@ -798,6 +832,8 @@ errno_t do_card(TALLOC_CTX *mem_ctx, struct p11_ctx *p11_ctx,
71e593
             goto done;
71e593
         }
71e593
 
71e593
+        DEBUG(SSSDBG_TRACE_ALL, "Private key has type [%s].\n",
71e593
+                                keytype2str(priv_key->keyType));
71e593
         algtag = SEC_GetSignatureAlgorithmOidTag(priv_key->keyType,
71e593
                                                   SEC_OID_SHA1);
71e593
         if (algtag == SEC_OID_UNKNOWN) {
71e593
-- 
71e593
2.19.1
71e593