summaryrefslogtreecommitdiff
path: root/lib/nettle
diff options
context:
space:
mode:
authorDaiki Ueno <dueno@redhat.com>2020-03-14 06:01:49 +0100
committerDaiki Ueno <dueno@redhat.com>2020-03-19 07:12:59 +0100
commit3462a7fc813da9576f8dda41a81b86ca03b99344 (patch)
treee9ea1400ba436928192d20f66b763404eeb2e864 /lib/nettle
parentea2a81e5bd115826d2ecd0b0ecc634c95b285a48 (diff)
downloadgnutls-3462a7fc813da9576f8dda41a81b86ca03b99344.tar.gz
cipher: expose raw ChaCha20 cipher
Signed-off-by: Daiki Ueno <dueno@redhat.com>
Diffstat (limited to 'lib/nettle')
-rw-r--r--lib/nettle/cipher.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/nettle/cipher.c b/lib/nettle/cipher.c
index 5e9f25b2ec..e46ce4afe4 100644
--- a/lib/nettle/cipher.c
+++ b/lib/nettle/cipher.c
@@ -247,6 +247,13 @@ _ccm_decrypt(struct nettle_cipher_ctx *ctx,
}
static void
+_chacha_set_nonce (struct chacha_poly1305_ctx *ctx,
+ size_t length, const uint8_t *nonce)
+{
+ chacha_set_nonce(ctx, nonce);
+}
+
+static void
_chacha_poly1305_set_nonce (struct chacha_poly1305_ctx *ctx,
size_t length, const uint8_t *nonce)
{
@@ -607,6 +614,20 @@ static const struct nettle_cipher_st builtin_ciphers[] = {
.set_decrypt_key = (nettle_set_key_func*)salsa20_256_set_key,
.max_iv_size = SALSA20_NONCE_SIZE,
},
+ { .algo = GNUTLS_CIPHER_CHACHA20_64,
+ .block_size = 1,
+ .key_size = CHACHA_KEY_SIZE,
+ .encrypt_block = (nettle_cipher_func*)chacha_crypt,
+ .decrypt_block = (nettle_cipher_func*)chacha_crypt,
+
+ .ctx_size = sizeof(struct chacha_ctx),
+ .encrypt = _stream_encrypt,
+ .decrypt = _stream_encrypt,
+ .set_encrypt_key = (nettle_set_key_func*)chacha_set_key,
+ .set_decrypt_key = (nettle_set_key_func*)chacha_set_key,
+ .set_iv = (setiv_func)_chacha_set_nonce,
+ .max_iv_size = CHACHA_NONCE_SIZE,
+ },
{ .algo = GNUTLS_CIPHER_CHACHA20_POLY1305,
.block_size = CHACHA_POLY1305_BLOCK_SIZE,
.key_size = CHACHA_POLY1305_KEY_SIZE,