Re: random: ensure use of aligned buffers with ChaCha20

2018-08-10 Thread Theodore Y. Ts'o
On Fri, Aug 10, 2018 at 08:20:51AM +0200, Stephan Mueller wrote: > > while (nbytes >= CHACHA20_BLOCK_SIZE) { > > int adjust = (unsigned long)buf & (sizeof(tmp[0]) - 1); > > > > extract_crng(buf); > > Why this line? > > > buf += CHACHA20_BLOCK_SIZE;

Re: random: ensure use of aligned buffers with ChaCha20

2018-08-10 Thread Stephan Mueller
Am Donnerstag, 9. August 2018, 21:40:12 CEST schrieb Eric Biggers: Hi Eric, > while (bytes >= CHACHA20_BLOCK_SIZE) { > chacha20_block(state, stream); > - crypto_xor(dst, (const u8 *)stream, CHACHA20_BLOCK_SIZE); > + crypto_xor(dst, stream,

Re: random: ensure use of aligned buffers with ChaCha20

2018-08-10 Thread Stephan Mueller
Am Donnerstag, 9. August 2018, 21:21:32 CEST schrieb Theodore Y. Ts'o: Hi Theodore, > I'm wondering whether we have kernel code that actually tries to > extract more than 64 bytes, so I'm not sure how often we enter the > while loop at all. Out of curiosity, did you find this from code >

Re: random: ensure use of aligned buffers with ChaCha20

2018-08-10 Thread Stephan Mueller
Am Donnerstag, 9. August 2018, 21:07:18 CEST schrieb Eric Biggers: Hi Eric, > This patch is backwards: the temporary buffer is used when the buffer is > *aligned*, not misaligned. And more problematically, 'buf' is never > incremented in one of the cases... Of course, it needs to be reversed.