summaryrefslogtreecommitdiff
path: root/lib/pubkey.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2017-07-25 12:01:52 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2017-08-03 11:57:52 +0200
commit2b9280383710838fcfd61bcee13a7725b7cd08b1 (patch)
tree99259a5f16cedcc7a2c0572457bd9636feb9dfed /lib/pubkey.c
parent0a479073ba2b34368440f3c977391a7602df1b56 (diff)
downloadgnutls-2b9280383710838fcfd61bcee13a7725b7cd08b1.tar.gz
abstract.h: added functions to read and write SPKI information
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Diffstat (limited to 'lib/pubkey.c')
-rw-r--r--lib/pubkey.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/lib/pubkey.c b/lib/pubkey.c
index 670282f929..18872cd227 100644
--- a/lib/pubkey.c
+++ b/lib/pubkey.c
@@ -2139,3 +2139,57 @@ int gnutls_pubkey_verify_params(gnutls_pubkey_t key)
return 0;
}
+
+/**
+ * gnutls_pubkey_get_spki:
+ * @pubkey: a public key of type #gnutls_pubkey_t
+ * @spki: a SubjectPublicKeyInfo structure of type #gnutls_pubkey_spki_t
+ * @flags: must be zero
+ *
+ * This function will return the public key information if available.
+ * The provided @spki must be initialized.
+ *
+ * Returns: On success, %GNUTLS_E_SUCCESS (0) is returned, otherwise a
+ * negative error value.
+ *
+ * Since: 3.6.0
+ **/
+int
+gnutls_pubkey_get_spki(gnutls_pubkey_t pubkey, gnutls_x509_spki_t spki, unsigned int flags)
+{
+ if (pubkey == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
+ memcpy(spki, &pubkey->params.spki, sizeof(gnutls_x509_spki_st));
+
+ return 0;
+}
+
+/**
+ * gnutls_pubkey_set_spki:
+ * @pubkey: a public key of type #gnutls_pubkey_t
+ * @spki: a SubjectPublicKeyInfo structure of type #gnutls_pubkey_spki_t
+ * @flags: must be zero
+ *
+ * This function will set the public key information.
+ * The provided @spki must be initialized.
+ *
+ * Returns: On success, %GNUTLS_E_SUCCESS (0) is returned, otherwise a
+ * negative error value.
+ *
+ * Since: 3.6.0
+ **/
+int
+gnutls_pubkey_set_spki(gnutls_pubkey_t pubkey, const gnutls_x509_spki_t spki, unsigned int flags)
+{
+ if (pubkey == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
+ memcpy(&pubkey->params.spki, spki, sizeof(gnutls_x509_spki_st));
+
+ return 0;
+}