lkml.org 
[lkml]   [2024]   [Feb]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 01/10] crypto: ecdsa - Convert byte arrays with key coordinates to digits
On Thu, Feb 29, 2024 at 09:57:30AM -0500, Stefan Berger wrote:
> static inline void ecc_digits_from_bytes(const u8 *in, unsigned int nbytes,
> u64 *out, unsigned int ndigits)
> {
> unsigned int o = nbytes & 7;
> u64 msd = 0;
> size_t i;
>
> if (o == 0) {
> ecc_swap_digits(in, out, ndigits);
> } else {
> for (i = 0; i < o; i++)
> msd = (msd << 8) | in[i];
> out[ndigits - 1] = msd;
> ecc_swap_digits(&in[o], out, ndigits - 1);
> }
> }

Might be beneficial to add a code comment explaining the else-branch
is for curves with key length not a multiple of 64 bits (such as NIST P521).

Otherwise LGTM, thanks!

Lukas

\
 
 \ /
  Last update: 2024-05-27 15:28    [W:0.103 / U:1.772 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site