diff options
author | Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | 2020-01-09 01:11:50 +0300 |
---|---|---|
committer | Dmitry Baryshkov <dbaryshkov@gmail.com> | 2020-06-07 00:59:24 +0300 |
commit | d57b652b42ff97950e1f8cc3acb83d937253315a (patch) | |
tree | 846494cdb66f586cdcf993cd0e184176935537b0 | |
parent | e4bc91220bce4e7e421f99ad652fd8fae8525141 (diff) | |
download | gnutls-d57b652b42ff97950e1f8cc3acb83d937253315a.tar.gz |
crypto-api: add _gnutls_cipher_set_key wrapper()
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
-rw-r--r-- | lib/cipher_int.h | 2 | ||||
-rw-r--r-- | lib/crypto-api.c | 25 |
2 files changed, 27 insertions, 0 deletions
diff --git a/lib/cipher_int.h b/lib/cipher_int.h index b06c397fc0..a17afc381c 100644 --- a/lib/cipher_int.h +++ b/lib/cipher_int.h @@ -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 */ diff --git a/lib/crypto-api.c b/lib/crypto-api.c index a815379e87..ca78cb3237 100644 --- a/lib/crypto-api.c +++ b/lib/crypto-api.c @@ -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 |