Re: [PATCH 1/5] lib: add crypt subsystem

2021-04-22 Thread Simon Glass
Hi Steffen,

On Wed, 21 Apr 2021 at 20:21, Steffen Jaeckel
 wrote:
>
> Hi Simon,
>
> thanks for taking the time to review.
>
> On 4/21/21 9:14 AM, Simon Glass wrote:
> > On Tue, 13 Apr 2021 at 10:16, Steffen Jaeckel
> >  wrote:
> >>
> >> Add the basic functionality required to support the standard crypt
> >> format.
> >> The files crypt-sha256.c and crypt-sha512.c originate from libxcrypt and
> >> their formatting is therefor retained.
> >> The integration is done via a crypt_compare() function in crypt.c.
> >>
> >> ```
> >> libxcrypt $ git describe --long --always --all
> >> tags/v4.4.17-0-g6b110bc
> >> ```
> >>
> >> Signed-off-by: Steffen Jaeckel 
> >> ---
> >>
> >>  include/crypt.h  |  13 ++
> >>  lib/Kconfig  |   1 +
> >>  lib/Makefile |   1 +
> >>  lib/crypt/Kconfig|  29 
> >>  lib/crypt/Makefile   |  10 ++
> >>  lib/crypt/alg-sha256.h   |  17 ++
> >>  lib/crypt/alg-sha512.h   |  17 ++
> >>  lib/crypt/crypt-port.h   |  28 
> >>  lib/crypt/crypt-sha256.c | 313 +
> >>  lib/crypt/crypt-sha512.c | 328 +++
> >>  lib/crypt/crypt.c|  73 +
> >>  11 files changed, 830 insertions(+)
> >>  create mode 100644 include/crypt.h
> >>  create mode 100644 lib/crypt/Kconfig
> >>  create mode 100644 lib/crypt/Makefile
> >>  create mode 100644 lib/crypt/alg-sha256.h
> >>  create mode 100644 lib/crypt/alg-sha512.h
> >>  create mode 100644 lib/crypt/crypt-port.h
> >>  create mode 100644 lib/crypt/crypt-sha256.c
> >>  create mode 100644 lib/crypt/crypt-sha512.c
> >>  create mode 100644 lib/crypt/crypt.c
> >
> > This seems to use errno - is that necessary? Also are there any simple
> > unit tests we could usefully bring over?
>
> Regarding errno - that's the way how libxcrypt works internally, I'm not
> sure whether we should really touch this ... the default crypt_alg_rn()
> function has a void return type, so either we have to keep using errno
> or we have to change the return type...

Well you could add a wrapper function for U-Boot which returns errno,
then make errno a static int in the library.

>
> Regarding unit tests - good idea, I'll have a look.

Regards,
Simon


Re: [PATCH 1/5] lib: add crypt subsystem

2021-04-21 Thread Steffen Jaeckel
Hi Simon,

thanks for taking the time to review.

On 4/21/21 9:14 AM, Simon Glass wrote:
> On Tue, 13 Apr 2021 at 10:16, Steffen Jaeckel
>  wrote:
>>
>> Add the basic functionality required to support the standard crypt
>> format.
>> The files crypt-sha256.c and crypt-sha512.c originate from libxcrypt and
>> their formatting is therefor retained.
>> The integration is done via a crypt_compare() function in crypt.c.
>>
>> ```
>> libxcrypt $ git describe --long --always --all
>> tags/v4.4.17-0-g6b110bc
>> ```
>>
>> Signed-off-by: Steffen Jaeckel 
>> ---
>>
>>  include/crypt.h  |  13 ++
>>  lib/Kconfig  |   1 +
>>  lib/Makefile |   1 +
>>  lib/crypt/Kconfig|  29 
>>  lib/crypt/Makefile   |  10 ++
>>  lib/crypt/alg-sha256.h   |  17 ++
>>  lib/crypt/alg-sha512.h   |  17 ++
>>  lib/crypt/crypt-port.h   |  28 
>>  lib/crypt/crypt-sha256.c | 313 +
>>  lib/crypt/crypt-sha512.c | 328 +++
>>  lib/crypt/crypt.c|  73 +
>>  11 files changed, 830 insertions(+)
>>  create mode 100644 include/crypt.h
>>  create mode 100644 lib/crypt/Kconfig
>>  create mode 100644 lib/crypt/Makefile
>>  create mode 100644 lib/crypt/alg-sha256.h
>>  create mode 100644 lib/crypt/alg-sha512.h
>>  create mode 100644 lib/crypt/crypt-port.h
>>  create mode 100644 lib/crypt/crypt-sha256.c
>>  create mode 100644 lib/crypt/crypt-sha512.c
>>  create mode 100644 lib/crypt/crypt.c
> 
> This seems to use errno - is that necessary? Also are there any simple
> unit tests we could usefully bring over?

Regarding errno - that's the way how libxcrypt works internally, I'm not
sure whether we should really touch this ... the default crypt_alg_rn()
function has a void return type, so either we have to keep using errno
or we have to change the return type...

Regarding unit tests - good idea, I'll have a look.


Re: [PATCH 1/5] lib: add crypt subsystem

2021-04-21 Thread Simon Glass
On Tue, 13 Apr 2021 at 10:16, Steffen Jaeckel
 wrote:
>
> Add the basic functionality required to support the standard crypt
> format.
> The files crypt-sha256.c and crypt-sha512.c originate from libxcrypt and
> their formatting is therefor retained.
> The integration is done via a crypt_compare() function in crypt.c.
>
> ```
> libxcrypt $ git describe --long --always --all
> tags/v4.4.17-0-g6b110bc
> ```
>
> Signed-off-by: Steffen Jaeckel 
> ---
>
>  include/crypt.h  |  13 ++
>  lib/Kconfig  |   1 +
>  lib/Makefile |   1 +
>  lib/crypt/Kconfig|  29 
>  lib/crypt/Makefile   |  10 ++
>  lib/crypt/alg-sha256.h   |  17 ++
>  lib/crypt/alg-sha512.h   |  17 ++
>  lib/crypt/crypt-port.h   |  28 
>  lib/crypt/crypt-sha256.c | 313 +
>  lib/crypt/crypt-sha512.c | 328 +++
>  lib/crypt/crypt.c|  73 +
>  11 files changed, 830 insertions(+)
>  create mode 100644 include/crypt.h
>  create mode 100644 lib/crypt/Kconfig
>  create mode 100644 lib/crypt/Makefile
>  create mode 100644 lib/crypt/alg-sha256.h
>  create mode 100644 lib/crypt/alg-sha512.h
>  create mode 100644 lib/crypt/crypt-port.h
>  create mode 100644 lib/crypt/crypt-sha256.c
>  create mode 100644 lib/crypt/crypt-sha512.c
>  create mode 100644 lib/crypt/crypt.c

This seems to use errno - is that necessary? Also are there any simple
unit tests we could usefully bring over?

Regards,
Simon