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

> Add CFB variant with 8-bit segment size.

Thanks. I'm fine with separate functions like you do, that seems to be
the most straightforward interface.

> +void
> +cfb8_decrypt(const void *ctx, nettle_cipher_func *f,
> +          size_t block_size, uint8_t *iv,
> +          size_t length, uint8_t *dst,
> +          const uint8_t *src)
> +{
> +  TMP_DECL(buffer, uint8_t, NETTLE_MAX_CIPHER_BLOCK_SIZE * 2);
> +  TMP_DECL(outbuf, uint8_t, NETTLE_MAX_CIPHER_BLOCK_SIZE * 2);
> +  TMP_ALLOC(buffer, block_size * 2);
> +  TMP_ALLOC(outbuf, block_size * 2);
> +  uint8_t i = 0;
> +
> +  memcpy(buffer, iv, block_size);
> +  memcpy(buffer + block_size, src,
> +      length < block_size ? length : block_size);
> +
> +  while (length)
> +    {
> +
> +      for (i = 0; i < length && i < block_size; i++)
> +     f(ctx, block_size, outbuf + i, buffer + i);
> +
> +      if (src != dst)
> +     memxor3(dst, src, outbuf, i);
> +      else
> +     memxor(dst, outbuf, i);

If there's no other reason to handle src == dst and src != dst
separately in this function, I think it's better to use memxor3
unconditionally.

> diff --git a/nettle.texinfo b/nettle.texinfo
> index aa374449c527..e610e74c79ab 100644

> +@node CFB8, , CFB, Cipher modes
> +@comment  node-name,  next,  previous,  up
> +@subsection Cipher Feedback 8-bit mode
> +
> +@cindex Cipher Feedback 8-bit Mode
> +@cindex CFB8 Mode
> +
> +Cipher Feedback 8-bit mode (@acronym{CFB8}) transforms block cipher into a 
> stream
> +cipher. The message is encrypted byte after byte, not requiring any padding.

Do you think it would help the reader if the CFB and CFB8 docs were
merged into a single section?

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