2024-05-29 23:09:01

by Stefan Berger

[permalink] [raw]
Subject: [PATCH 0/2] ecdsa: Use ecc_digits_from_bytes to simplify code

Simplify two functions that were using temporary byte arrays for
converting too-short input byte arrays to digits. Use ecc_digits_from_bytes
since this function can now handle an input byte array that provides
less bytes than what a coordinate of a curve requires - the function
provides zeros for the missing (leading) bytes.

See: c6ab5c915da4 ("crypto: ecc - Prevent ecc_digits_from_bytes from reading too many bytes")

Regards,
Stefan

Stefan Berger (2):
crypto: ecdsa - Use ecc_digits_from_bytes to create hash digits array
crypto: ecdsa - Use ecc_digits_from_bytes to convert signature

crypto/ecdsa.c | 29 ++++++-----------------------
1 file changed, 6 insertions(+), 23 deletions(-)

--
2.43.0



2024-05-30 05:08:34

by Jarkko Sakkinen

[permalink] [raw]
Subject: Re: [PATCH 0/2] ecdsa: Use ecc_digits_from_bytes to simplify code

On Thu May 30, 2024 at 2:08 AM EEST, Stefan Berger wrote:
> Simplify two functions that were using temporary byte arrays for
> converting too-short input byte arrays to digits. Use ecc_digits_from_bytes
> since this function can now handle an input byte array that provides
> less bytes than what a coordinate of a curve requires - the function
> provides zeros for the missing (leading) bytes.
>
> See: c6ab5c915da4 ("crypto: ecc - Prevent ecc_digits_from_bytes from reading too many bytes")
>
> Regards,
> Stefan
>
> Stefan Berger (2):
> crypto: ecdsa - Use ecc_digits_from_bytes to create hash digits array
> crypto: ecdsa - Use ecc_digits_from_bytes to convert signature
>
> crypto/ecdsa.c | 29 ++++++-----------------------
> 1 file changed, 6 insertions(+), 23 deletions(-)

BTW, would it make sense split ecdsa signature encoding to its own patch
in my next patch set version and name it ecdsa_* style and put it to
ecdsa.c?

Just asking this because the part should be the same same for any ECDSA
signature. It must scale also to all NIST variants before my patch set
can land.

BR, Jarkko

2024-05-30 12:44:49

by Stefan Berger

[permalink] [raw]
Subject: Re: [PATCH 0/2] ecdsa: Use ecc_digits_from_bytes to simplify code



On 5/30/24 01:08, Jarkko Sakkinen wrote:
> On Thu May 30, 2024 at 2:08 AM EEST, Stefan Berger wrote:
>> Simplify two functions that were using temporary byte arrays for
>> converting too-short input byte arrays to digits. Use ecc_digits_from_bytes
>> since this function can now handle an input byte array that provides
>> less bytes than what a coordinate of a curve requires - the function
>> provides zeros for the missing (leading) bytes.
>>
>> See: c6ab5c915da4 ("crypto: ecc - Prevent ecc_digits_from_bytes from reading too many bytes")
>>
>> Regards,
>> Stefan
>>
>> Stefan Berger (2):
>> crypto: ecdsa - Use ecc_digits_from_bytes to create hash digits array
>> crypto: ecdsa - Use ecc_digits_from_bytes to convert signature
>>
>> crypto/ecdsa.c | 29 ++++++-----------------------
>> 1 file changed, 6 insertions(+), 23 deletions(-)
>
> BTW, would it make sense split ecdsa signature encoding to its own patch
> in my next patch set version and name it ecdsa_* style and put it to
> ecdsa.c?

I would only put it into ecdsa.c if functions inside this file (can)
make use of it, otherwise leave it in your file.

>
> Just asking this because the part should be the same same for any ECDSA
> signature. It must scale also to all NIST variants before my patch set
> can land.
>
> BR, Jarkko
>

2024-06-04 16:30:44

by Jarkko Sakkinen

[permalink] [raw]
Subject: Re: [PATCH 0/2] ecdsa: Use ecc_digits_from_bytes to simplify code

On Thu May 30, 2024 at 3:16 PM EEST, Stefan Berger wrote:
>
>
> On 5/30/24 01:08, Jarkko Sakkinen wrote:
> > On Thu May 30, 2024 at 2:08 AM EEST, Stefan Berger wrote:
> >> Simplify two functions that were using temporary byte arrays for
> >> converting too-short input byte arrays to digits. Use ecc_digits_from_bytes
> >> since this function can now handle an input byte array that provides
> >> less bytes than what a coordinate of a curve requires - the function
> >> provides zeros for the missing (leading) bytes.
> >>
> >> See: c6ab5c915da4 ("crypto: ecc - Prevent ecc_digits_from_bytes from reading too many bytes")
> >>
> >> Regards,
> >> Stefan
> >>
> >> Stefan Berger (2):
> >> crypto: ecdsa - Use ecc_digits_from_bytes to create hash digits array
> >> crypto: ecdsa - Use ecc_digits_from_bytes to convert signature
> >>
> >> crypto/ecdsa.c | 29 ++++++-----------------------
> >> 1 file changed, 6 insertions(+), 23 deletions(-)
> >
> > BTW, would it make sense split ecdsa signature encoding to its own patch
> > in my next patch set version and name it ecdsa_* style and put it to
> > ecdsa.c?
>
> I would only put it into ecdsa.c if functions inside this file (can)
> make use of it, otherwise leave it in your file.

Yep, that specific part has no binding per se to anything related to
TPM2. It is also dead easy to detach.

Here I would suggest to take a similar angle as with CRYPTO_LIB_AES so
that it is easily and directly callable from either side with no fuss.

I'll mangle it that way at least for the next version and we can see
then how it looks like.

BR, Jarkko