summaryrefslogtreecommitdiff
path: root/lib/x509/privkey.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2012-09-15 11:15:07 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2012-09-15 11:15:07 +0200
commit155bb9fac75701776f277f9b3de317243f576312 (patch)
tree59dd63bad589809d6382b90bb234c67dfc7f4290 /lib/x509/privkey.c
parent48a440388526f239281aeac55d8a79c6a3ca80a3 (diff)
downloadgnutls-155bb9fac75701776f277f9b3de317243f576312.tar.gz
Added gnutls_x509_privkey_get_pk_algorithm2(). Certtool prints the number of bits in a private key.
Diffstat (limited to 'lib/x509/privkey.c')
-rw-r--r--lib/x509/privkey.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/x509/privkey.c b/lib/x509/privkey.c
index 98095aa5a0..a88e332665 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.