]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
crypto-api: add _gnutls_cipher_set_key wrapper()
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Wed, 8 Jan 2020 22:11:50 +0000 (01:11 +0300)
committerDmitry Baryshkov <dbaryshkov@gmail.com>
Sat, 6 Jun 2020 21:59:24 +0000 (00:59 +0300)
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
lib/cipher_int.h
lib/crypto-api.c

index b06c397fc08c327d712a10a66addd3f8ec77ffae..a17afc381c172a1efec40f83be8dc2870e1d9ea5 100644 (file)
@@ -182,6 +182,8 @@ int _gnutls_cipher_exists(gnutls_cipher_algorithm_t cipher);
 int _gnutls_cipher_get_iv(gnutls_cipher_hd_t handle, void *iv,
                          size_t ivlen);
 
+int _gnutls_cipher_set_key(gnutls_cipher_hd_t handle, void *key, size_t keylen);
+
 #define _gnutls_cipher_is_aead(h) _gnutls_cipher_algo_is_aead((h)->e)
 
 /* returns the tag in AUTHENC ciphers */
index a815379e87e676cd98c0bf4fc2e6257c134f582e..ca78cb323725517ecfc74be464a2039258d81e16 100644 (file)
@@ -206,6 +206,31 @@ _gnutls_cipher_get_iv(gnutls_cipher_hd_t handle, void *iv, size_t ivlen)
        return _gnutls_cipher_getiv(&h->ctx_enc, iv, ivlen);
 }
 
+/*-
+ * _gnutls_cipher_set_key:
+ * @handle: is a #gnutls_cipher_hd_t type
+ * @key: the key to set
+ * @keylen: the length of the key
+ *
+ * This function will set the key used by the cipher
+ *
+ * This is solely for validation purposes of our crypto
+ * implementation.  For other purposes, the key should be set at the time of
+ * cipher setup.  As such, this function only works with the internally
+ * registered ciphers.
+ *
+ * Returns: Zero or a negative error code on error.
+ *
+ * Since: 3.6.14
+ -*/
+int
+_gnutls_cipher_set_key(gnutls_cipher_hd_t handle, void *key, size_t keylen)
+{
+       api_cipher_hd_st *h = handle;
+
+       return _gnutls_cipher_setkey(&h->ctx_enc, key, keylen);
+}
+
 /**
  * gnutls_cipher_encrypt:
  * @handle: is a #gnutls_cipher_hd_t type