summaryrefslogtreecommitdiff
path: root/lib/gnutls_pubkey.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2010-12-16 17:06:45 +0100
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2010-12-16 17:06:45 +0100
commitd8e2f838bfb81141e7f44cbd2f7adcc756f26044 (patch)
tree45653966472bd2644c9604b15e9135279c7b1686 /lib/gnutls_pubkey.c
parente0e3e4324d753041aba8dfe70fc7b755cba2616d (diff)
downloadgnutls-d8e2f838bfb81141e7f44cbd2f7adcc756f26044.tar.gz
Added gnutls_pubkey_import_privkey(), that will copy the public key from a gnutls_privkey_t structure.
Diffstat (limited to 'lib/gnutls_pubkey.c')
-rw-r--r--lib/gnutls_pubkey.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/gnutls_pubkey.c b/lib/gnutls_pubkey.c
index 7169aecb80..113d5a0da0 100644
--- a/lib/gnutls_pubkey.c
+++ b/lib/gnutls_pubkey.c
@@ -37,6 +37,7 @@
#include <gnutls_num.h>
#include <x509/common.h>
#include <x509_b64.h>
+#include <abstract_int.h>
#define PK_PEM_HEADER "PUBLIC KEY"
@@ -188,6 +189,33 @@ gnutls_pubkey_import_x509 (gnutls_pubkey_t key, gnutls_x509_crt_t crt,
}
/**
+ * gnutls_pubkey_import_privkey:
+ * @key: The public key
+ * @pkey: The private key
+ * @usage: GNUTLS_KEY_* key usage flags.
+ * @flags: should be zero
+ *
+ * This function will import the given public key to the abstract
+ * #gnutls_pubkey_t structure.
+ *
+ * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
+ * negative error value.
+ **/
+int
+gnutls_pubkey_import_privkey (gnutls_pubkey_t key, gnutls_privkey_t pkey,
+ unsigned int usage, unsigned int flags)
+{
+ key->pk_algorithm = gnutls_privkey_get_pk_algorithm (pkey, &key->bits);
+
+ key->key_usage = usage;
+
+ key->params_size = sizeof (key->params) / sizeof (key->params[0]);
+
+ return _gnutls_privkey_get_public_mpis (pkey, key->params,
+ &key->params_size);
+}
+
+/**
* gnutls_pubkey_get_preferred_hash_algorithm:
* @key: Holds the certificate
* @hash: The result of the call with the hash algorithm used for signature