From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Florian Weimer <fweimer@redhat.com>
Cc: libc-alpha@sourceware.org, Carlos O'Donell <carlos@redhat.com>,
Szabolcs Nagy <szabolcs.nagy@arm.com>,
Yann Droneaud <ydroneaud@opteya.com>
Subject: Re: [PATCH v12 1/9] stdlib: Add arc4random, arc4random_buf, and arc4random_uniform (BZ #4417)
Date: Fri, 22 Jul 2022 10:00:50 -0300 [thread overview]
Message-ID: <f06fefd9-ef75-fdf6-2d9c-38271950bb6b@linaro.org> (raw)
In-Reply-To: <87wnc5e35s.fsf@oldenburg.str.redhat.com>
On 22/07/22 09:35, Florian Weimer wrote:
> * Adhemerval Zanella:
>
>> diff --git a/stdlib/chacha20.c b/stdlib/chacha20.c
>> new file mode 100644
>> index 0000000000..77e37655cd
>> --- /dev/null
>> +++ b/stdlib/chacha20.c
>> @@ -0,0 +1,179 @@
>
>> +static void
>> +chacha20_crypt (uint32_t *state, uint8_t *dst, const uint8_t *src)
>> +{
>> + size_t bytes = CHACHA20_BUFSIZE;
>> + while (bytes >= CHACHA20_BLOCK_SIZE)
>
> That doesn't look right. No bytes variable.
>
> The chacha20_crypt functions should probably use arguments in the style
> of
>
> uint8_t dst[static CHACHA20_BUFSIZE]
>
> for compiler size checking.
Would it be acceptable?
diff --git a/stdlib/chacha20.c b/stdlib/chacha20.c
index 07b7b203f2..4217ecb06f 100644
--- a/stdlib/chacha20.c
+++ b/stdlib/chacha20.c
@@ -166,14 +166,15 @@ chacha20_block (uint32_t *state, uint8_t *dst, const uint8_t *src)
static void
__attribute_maybe_unused__
-chacha20_crypt_generic (uint32_t *state, uint8_t *dst, const uint8_t *src)
+chacha20_crypt_generic (uint32_t *state, uint8_t dst[static CHACHA20_BUFSIZE],
+ const uint8_t *src)
{
- size_t bytes = CHACHA20_BUFSIZE;
- while (bytes >= CHACHA20_BLOCK_SIZE)
+ size_t dstlen = CHACHA20_BUFSIZE;
+ while (dstlen >= CHACHA20_BLOCK_SIZE)
{
chacha20_block (state, dst, src);
- bytes -= CHACHA20_BLOCK_SIZE;
+ dstlen -= CHACHA20_BLOCK_SIZE;
dst += CHACHA20_BLOCK_SIZE;
src += CHACHA20_BLOCK_SIZE;
}
next prev parent reply other threads:[~2022-07-22 13:00 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-22 12:21 [PATCH v12 0/9] Add arc4random support Adhemerval Zanella
2022-07-22 12:21 ` [PATCH v12 1/9] stdlib: Add arc4random, arc4random_buf, and arc4random_uniform (BZ #4417) Adhemerval Zanella
2022-07-22 12:35 ` Florian Weimer
2022-07-22 13:00 ` Adhemerval Zanella Netto [this message]
2022-07-22 15:31 ` Zack Weinberg
2022-07-22 17:00 ` Adhemerval Zanella Netto
2022-07-22 12:21 ` [PATCH v12 2/9] stdlib: Add arc4random tests Adhemerval Zanella
2022-07-22 12:21 ` [PATCH v12 3/9] benchtests: Add arc4random benchtest Adhemerval Zanella
2022-07-22 12:21 ` [PATCH v12 4/9] aarch64: Add optimized chacha20 Adhemerval Zanella
2022-07-22 12:21 ` [PATCH v12 5/9] x86: Add SSE2 " Adhemerval Zanella
2022-07-22 12:21 ` [PATCH v12 6/9] x86: Add AVX2 " Adhemerval Zanella
2022-07-22 12:21 ` [PATCH v12 7/9] powerpc64: Add " Adhemerval Zanella
2022-07-27 14:09 ` Tulio Magno Quites Machado Filho
2022-07-22 12:21 ` [PATCH v12 8/9] s390x: " Adhemerval Zanella
2022-07-22 12:21 ` [PATCH v12 9/9] manual: Add documentation for arc4random functions Adhemerval Zanella
2022-07-22 15:33 ` Zack Weinberg
2022-07-22 17:15 ` Adhemerval Zanella Netto
2022-07-24 15:20 ` Zack Weinberg
2022-07-22 19:12 ` [PATCH v12 0/9] Add arc4random support Cristian Rodríguez
2022-07-22 21:35 ` Adhemerval Zanella Netto
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f06fefd9-ef75-fdf6-2d9c-38271950bb6b@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=carlos@redhat.com \
--cc=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
--cc=szabolcs.nagy@arm.com \
--cc=ydroneaud@opteya.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).