gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [libfints] branch master updated: +detailed logs as of pub


From: gnunet
Subject: [GNUnet-SVN] [libfints] branch master updated: +detailed logs as of pub key import.
Date: Fri, 12 Oct 2018 13:04:48 +0200

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository libfints.

The following commit(s) were added to refs/heads/master by this push:
     new 251f84c  +detailed logs as of pub key import.
251f84c is described below

commit 251f84c396d3401c65667a715e99fdd81685e979
Author: Marcello Stanisci <address@hidden>
AuthorDate: Fri Oct 12 13:04:14 2018 +0200

    +detailed logs as of pub key import.
---
 src/libebics.c | 43 +++++++++++++++++++++++++++----------------
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/src/libebics.c b/src/libebics.c
index e6456dc..90212ac 100644
--- a/src/libebics.c
+++ b/src/libebics.c
@@ -379,6 +379,7 @@ init_keymaterial (struct EBICS_Key keyList[],
 
 
       /* convert x509 priv to abstract type first.  */
+      gnutls_privkey_init (&abspriv);
       GNUNET_assert
         (GNUTLS_E_SUCCESS == (gnutls_privkey_import_x509 (abspriv,
                                                           privkey,
@@ -402,7 +403,7 @@ init_keymaterial (struct EBICS_Key keyList[],
         LOG (EBICS_LOGLEVEL_DEBUG,
              "Succefully extracted public key from private at %s\n",
              filepath);
-
+        gnutls_privkey_deinit (abspriv);
         key->publickey = pubkey;
         key->type |= EBICS_KEY_RSA_PUBLIC;
       }
@@ -415,23 +416,33 @@ init_keymaterial (struct EBICS_Key keyList[],
            gnutls_strerror (retv));
     }
 
-    if (GNUTLS_E_SUCCESS != (
-      retv = gnutls_pubkey_import (pubkey,
-                                   &rawkey,
-                                   GNUTLS_X509_FMT_PEM)))
 
+    /**
+     * The policy prioritizes public keys extracted from privs.
+     * Therefore whenever a private key got detected in the current
+     * file, then the associated public key is extracted from _that_
+     * private key, discarding any other potential public key appended
+     * to the file.
+     */
+    if (0 == (EBICS_KEY_RSA_PRIVATE & key->type))
     {
-      LOG (EBICS_LOGLEVEL_ERROR,
-      "Could not import publickey from file %s. GnuTLS Error: %s",
-      gnutls_strerror (retv));
-    }
-    else
-    {
-      LOG (EBICS_LOGLEVEL_DEBUG,
-           "Found public key in %s!",
-           filepath);
-      key->publickey = pubkey;
-      key->type |= EBICS_KEY_RSA_PUBLIC;
+      if (GNUTLS_E_SUCCESS == (
+          retv = gnutls_pubkey_import (pubkey,
+                                       &rawkey,
+                                       GNUTLS_X509_FMT_PEM)))
+      {
+        LOG (EBICS_LOGLEVEL_DEBUG,
+             "Found public key in %s!",
+             filepath);
+        key->publickey = pubkey;
+        key->type |= EBICS_KEY_RSA_PUBLIC;
+      }
+      else
+      {
+        LOG (EBICS_LOGLEVEL_ERROR,
+        "Could not import publickey from file %s. GnuTLS Error: %s",
+        gnutls_strerror (retv));
+      }
     }
 
     strncpy (key->name,

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]