Re: random: ensure use of aligned buffers with ChaCha20

2018-09-11 Thread Eric Biggers
To revive this... On Fri, Aug 10, 2018 at 08:27:58AM +0200, Stephan Mueller wrote: > 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,

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.

Re: random: ensure use of aligned buffers with ChaCha20

2018-08-09 Thread Yann Droneaud
Hi, Le jeudi 09 août 2018 à 12:40 -0700, Eric Biggers a écrit : > From: Eric Biggers > Subject: [PATCH] crypto: chacha20 - Fix keystream alignment for > chacha20_block() (again) > > In commit 9f480faec58cd6 ("crypto: chacha20 - Fix keystream alignment > for chacha20_block()") I had missed that

Re: random: ensure use of aligned buffers with ChaCha20

2018-08-09 Thread Eric Biggers
On Thu, Aug 09, 2018 at 12:07:18PM -0700, Eric Biggers wrote: > On Thu, Aug 09, 2018 at 08:38:56PM +0200, Stephan Müller wrote: > > The function extract_crng invokes the ChaCha20 block operation directly > > on the user-provided buffer. The block operation operates on u32 words. > > Thus the

Re: random: ensure use of aligned buffers with ChaCha20

2018-08-09 Thread Theodore Y. Ts'o
On Thu, Aug 09, 2018 at 08:38:56PM +0200, Stephan Müller wrote: > The function extract_crng invokes the ChaCha20 block operation directly > on the user-provided buffer. The block operation operates on u32 words. > Thus the extract_crng function expects the buffer to be aligned to u32 > as it is

Re: random: ensure use of aligned buffers with ChaCha20

2018-08-09 Thread Eric Biggers
On Thu, Aug 09, 2018 at 08:38:56PM +0200, Stephan Müller wrote: > The function extract_crng invokes the ChaCha20 block operation directly > on the user-provided buffer. The block operation operates on u32 words. > Thus the extract_crng function expects the buffer to be aligned to u32 > as it is