[gnutls-devel] GnuTLS | Allow registering ciphers with higher priority (!1404)

Read-only notification of GnuTLS library development activities gnutls-devel at lists.gnutls.org
Wed Mar 17 08:28:53 CET 2021




Daiki Ueno commented on a discussion on lib/accelerated/afalg.c: https://gitlab.com/gnutls/gnutls/-/merge_requests/1404#note_531119301

> +	struct kcapi_ctx *ctx = _ctx;
> +
> +	if (iv_size > kcapi_cipher_ivsize(ctx->handle))
> +		return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST);
> +
> +	memcpy(ctx->iv, iv, iv_size);
> +
> +	return 0;
> +}
> +
> +static int afalg_cipher_encrypt(void *_ctx, const void *src, size_t src_size,
> +				void *dst, size_t dst_size)
> +{
> +	struct kcapi_ctx *ctx = _ctx;
> +
> +	if (kcapi_cipher_encrypt(ctx->handle, src, src_size, ctx->iv,

Let's take AES-128-CBC as an example: first encrypt 32-byte data with two calls to `afalg_cipher_encrypt` (backed by `kcapi_cipher_encrypt`), 16-byte each time, and then decrypt the resulting 32-byte data in one-shot. After that, the latter half of the plaintext is garbled.

Here is a reproducer: [test-cbc.c](/uploads/04d43ace12adf58d41a837566f361bea/test-cbc.c).

-- 
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/-/merge_requests/1404#note_531119301
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20210317/2522d09a/attachment-0001.html>


More information about the Gnutls-devel mailing list