Dmitry Eremin-Solenikov <[email protected]> writes:

> If src == dst, ctr16 code will fail to increment src and dst pointers,
> always overwriting first block.
>
> Signed-off-by: Dmitry Eremin-Solenikov <[email protected]>
> ---
>  ctr16.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/ctr16.c b/ctr16.c
> index 60418e8b9032..7e1c23d20832 100644
> --- a/ctr16.c
> +++ b/ctr16.c
> @@ -91,7 +91,7 @@ _ctr_crypt16(const void *ctx, nettle_cipher_func *f,
>         f(ctx, CTR_BUFFER_LIMIT, buffer->b, buffer->b);
>         if (length - i < CTR_BUFFER_LIMIT)
>           goto done;
> -       memxor3 (dst, src, buffer->b, CTR_BUFFER_LIMIT);
> +       memxor3 (dst + i, src + i, buffer->b, CTR_BUFFER_LIMIT);
>       }
>  
>        if (blocks > 0)

Applied, thanks!

If I understand this correctly, bug is triggered only when processing >=
1024 bytes (2 * CTR_BUFFER_LIMIT) at a time. If you would like to write
a test case, that's appreciated.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.
_______________________________________________
nettle-bugs mailing list
[email protected]
http://lists.lysator.liu.se/mailman/listinfo/nettle-bugs

Reply via email to