[PATCH 1/5] lib: add crypt subsystem

Simon Glass sjg at chromium.org
Fri Apr 23 01:55:48 CEST 2021


Hi Steffen,

On Wed, 21 Apr 2021 at 20:21, Steffen Jaeckel
<jaeckel-floss at eyet-services.de> 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
> > <jaeckel-floss at eyet-services.de> 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 <jaeckel-floss at eyet-services.de>
> >> ---
> >>
> >>  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


More information about the U-Boot mailing list