gnutls-commit
[Top][All Lists]
Advanced

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

[SCM] GNU gnutls branch, gnutls_3_1_x, updated. gnutls_3_1_1-12-g6c7ac15


From: Nikos Mavrogiannopoulos
Subject: [SCM] GNU gnutls branch, gnutls_3_1_x, updated. gnutls_3_1_1-12-g6c7ac15
Date: Sat, 15 Sep 2012 09:16:21 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU gnutls".

http://git.savannah.gnu.org/cgit/gnutls.git/commit/?id=6c7ac1511f936111828e4d512bb20d1e8d47ad8e

The branch, gnutls_3_1_x has been updated
       via  6c7ac1511f936111828e4d512bb20d1e8d47ad8e (commit)
       via  090f64955827cbb8652a21fa48b18d294927f3f9 (commit)
      from  036642950ec9ed9f37495c48ddfcced137e951ea (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 6c7ac1511f936111828e4d512bb20d1e8d47ad8e
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Sat Sep 15 11:16:13 2012 +0200

    documented update

commit 090f64955827cbb8652a21fa48b18d294927f3f9
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Sat Sep 15 11:15:07 2012 +0200

    Added gnutls_x509_privkey_get_pk_algorithm2(). Certtool prints the number 
of bits in a private key.

-----------------------------------------------------------------------

Summary of changes:
 NEWS                       |    5 ++++-
 lib/includes/gnutls/x509.h |    1 +
 lib/libgnutls.map          |    1 +
 lib/x509/privkey.c         |   32 ++++++++++++++++++++++++++++++++
 src/certtool.c             |    9 +++------
 5 files changed, 41 insertions(+), 7 deletions(-)

diff --git a/NEWS b/NEWS
index 6514e1c..74b6404 100644
--- a/NEWS
+++ b/NEWS
@@ -8,8 +8,11 @@ See the end for copying conditions.
 and gnutls_x509_trust_list_add_trust_mem() that prevented the loading
 of certificates in the windows platform.
 
+** certtool: Prints the number of bits of the public key algorithm
+parameter in a private key.
+
 ** API and ABI modifications:
-No changes since last version.
+gnutls_x509_privkey_get_pk_algorithm2: Added
 
 
 * Version 3.1.1 (released 2012-09-02)
diff --git a/lib/includes/gnutls/x509.h b/lib/includes/gnutls/x509.h
index 3c86c34..6c06cd0 100644
--- a/lib/includes/gnutls/x509.h
+++ b/lib/includes/gnutls/x509.h
@@ -767,6 +767,7 @@ extern "C"
                                           const gnutls_datum_t * x);
 
   int gnutls_x509_privkey_get_pk_algorithm (gnutls_x509_privkey_t key);
+  int gnutls_x509_privkey_get_pk_algorithm2 (gnutls_x509_privkey_t key, 
unsigned int *bits);
   int gnutls_x509_privkey_get_key_id (gnutls_x509_privkey_t key,
                                       unsigned int flags,
                                       unsigned char *output_data,
diff --git a/lib/libgnutls.map b/lib/libgnutls.map
index 50a6872..a1b2341 100644
--- a/lib/libgnutls.map
+++ b/lib/libgnutls.map
@@ -829,6 +829,7 @@ GNUTLS_3_1_0 {
        gnutls_sign_get_pk_algorithm;
        gnutls_sign_get_hash_algorithm;
        gnutls_sign_algorithm_get;
+       gnutls_x509_privkey_get_pk_algorithm2;
 } GNUTLS_3_0_0;
 
 GNUTLS_PRIVATE {
diff --git a/lib/x509/privkey.c b/lib/x509/privkey.c
index 98095aa..a88e332 100644
--- a/lib/x509/privkey.c
+++ b/lib/x509/privkey.c
@@ -985,6 +985,38 @@ gnutls_x509_privkey_get_pk_algorithm 
(gnutls_x509_privkey_t key)
 }
 
 /**
+ * gnutls_x509_privkey_get_pk_algorithm2:
+ * @key: should contain a #gnutls_x509_privkey_t structure
+ * @bits: The number of bits in the public key algorithm
+ *
+ * This function will return the public key algorithm of a private
+ * key.
+ *
+ * Returns: a member of the #gnutls_pk_algorithm_t enumeration on
+ *   success, or a negative error code on error.
+ **/
+int
+gnutls_x509_privkey_get_pk_algorithm2 (gnutls_x509_privkey_t key, unsigned int 
*bits)
+{
+int ret;
+
+  if (key == NULL)
+    {
+      gnutls_assert ();
+      return GNUTLS_E_INVALID_REQUEST;
+    }
+
+  if (bits)
+    {
+      ret = pubkey_to_bits(key->pk_algorithm, &key->params);
+      if (ret < 0) ret = 0;
+      *bits = ret;
+    }
+
+  return key->pk_algorithm;
+}
+
+/**
  * gnutls_x509_privkey_export:
  * @key: Holds the key
  * @format: the format of output params. One of PEM or DER.
diff --git a/src/certtool.c b/src/certtool.c
index 4e027ed..1040bdc 100644
--- a/src/certtool.c
+++ b/src/certtool.c
@@ -1576,15 +1576,15 @@ const char *cprint;
   /* Public key algorithm
    */
   fprintf (outfile, "Public Key Info:\n");
-  ret = gnutls_x509_privkey_get_pk_algorithm (key);
+  ret = gnutls_x509_privkey_get_pk_algorithm2 (key, &bits);
   fprintf (outfile, "\tPublic Key Algorithm: ");
 
   key_type = ret;
 
   cprint = gnutls_pk_algorithm_get_name (key_type);
   fprintf (outfile, "%s\n", cprint ? cprint : "Unknown");
-  fprintf (outfile, "\tKey Security Level: %s\n\n",
-           gnutls_sec_param_get_name (gnutls_x509_privkey_sec_param (key)));
+  fprintf (outfile, "\tKey Security Level: %s (%u bits)\n\n",
+           gnutls_sec_param_get_name (gnutls_x509_privkey_sec_param (key)), 
bits);
 
   /* Print the raw public and private keys
    */
@@ -1601,7 +1601,6 @@ const char *cprint;
       else
         {
           print_rsa_pkey (outfile, &m, &e, &d, &p, &q, &u, &exp1, &exp2);
-          bits = m.size * 8;
 
           gnutls_free (m.data);
           gnutls_free (e.data);
@@ -1624,7 +1623,6 @@ const char *cprint;
       else
         {
           print_dsa_pkey (outfile, &x, &y, &p, &q, &g);
-          bits = y.size * 8;
 
           gnutls_free (x.data);
           gnutls_free (y.data);
@@ -1645,7 +1643,6 @@ const char *cprint;
       else
         {
           print_ecc_pkey (outfile, curve, &k, &x, &y);
-          bits = gnutls_ecc_curve_get_size(curve) * 8;
 
           gnutls_free (x.data);
           gnutls_free (y.data);


hooks/post-receive
-- 
GNU gnutls



reply via email to

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