[PATCH] kdf: Avoid redundant memcpy()
Gary Lin
glin at suse.com
Thu Nov 20 03:50:42 CET 2025
On Thu, Sep 25, 2025 at 09:28:22AM +0300, Jussi Kivilinna wrote:
> Hello,
>
> Thanks for the patch. Before this can be applied, we'd need "DCO" from you.
>
> Please check doc/HACKING for "License policy" and about sending "Libgcrypt Developer's Certificate of Origin".
>
Sorry for the delay. It took me a while to contact our legal team.
I'll sign the DCO later.
Gary Lin
> -Jussi
>
> On 02/09/2025 10:14, Gary Lin via Gcrypt-devel wrote:
> > * cipher/kdf.c (fill_block): Xor 'ref_block' and 'prev_block' directly to
> > avoid a redundant memcpy().
> >
> > Signed-off-by: Gary Lin <glin at suse.com>
> > ---
> > cipher/kdf.c | 9 +++++++--
> > 1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/cipher/kdf.c b/cipher/kdf.c
> > index 71156ea4..16cec4e4 100644
> > --- a/cipher/kdf.c
> > +++ b/cipher/kdf.c
> > @@ -588,9 +588,14 @@ fill_block (const u64 *prev_block, const u64 *ref_block, u64 *curr_block,
> > u64 block_tmp[ARGON2_WORDS_IN_BLOCK];
> > int i;
> > - memcpy (block_r, ref_block, 1024);
> > if (prev_block)
> > - xor_block (block_r, prev_block);
> > + {
> > + for (i = 0; i < ARGON2_WORDS_IN_BLOCK; i++)
> > + block_r[i] = ref_block[i] ^ prev_block[i];
> > + }
> > + else
> > + memcpy (block_r, ref_block, 1024);
> > +
> > memcpy (block_tmp, block_r, 1024);
> > if (with_xor)
>
More information about the Gcrypt-devel
mailing list