mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-25 14:56:03 +00:00

Port mbedtls with adapted libc header files. Add mbedtls default config header file. Optimize mbedtls default config by disabling unused features to reduce the target size. Add mbedtls kbuild makefile. Add Kconfig skeleton and config submenu entry for selecting crypto libraries between mbedtls and legacy ones. Add the mbedtls include directories into the build system. Port u-boot hash functions as MbedTLS crypto alternatives and set it as default. Subsequent patches will separate those Kconfigs into pairs of _LEGACY and _MBEDTLS for controlling the implementations of legacy crypto libraries and MbedTLS ones respectively. The motivation of moving and adapting *INT* macros from kernel.h to limits.h is to fulfill the MbedTLS building requirement. The conditional compilation statements in MbedTLS expects the *INT* macros as constant expressions, thus expressions like `((int)(~0U >> 1))` will not work. Prerequisite ------------ This patch series requires mbedtls git repo to be added as a subtree to the main U-Boot repo via: $ git subtree add --prefix lib/mbedtls/external/mbedtls \ https://github.com/Mbed-TLS/mbedtls.git \ v3.6.0 --squash Moreover, due to the Windows-style files from mbedtls git repo, we need to convert the CRLF endings to LF and do a commit manually: $ git add --renormalize . $ git commit Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
57 lines
1.1 KiB
C
57 lines
1.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0+ */
|
|
/*
|
|
* Copyright (c) 2024 Linaro Limited
|
|
* Author: Raymond Mao <raymond.mao@linaro.org>
|
|
*/
|
|
#ifndef SHA1_ALT_H
|
|
#define SHA1_ALT_H
|
|
|
|
#include <image.h>
|
|
#include <u-boot/sha1.h>
|
|
|
|
typedef sha1_context mbedtls_sha1_context;
|
|
|
|
static inline void mbedtls_sha1_init(mbedtls_sha1_context *ctx)
|
|
{
|
|
}
|
|
|
|
static inline void mbedtls_sha1_free(mbedtls_sha1_context *ctx)
|
|
{
|
|
}
|
|
|
|
static inline void mbedtls_sha1_clone(mbedtls_sha1_context *dst,
|
|
const mbedtls_sha1_context *src)
|
|
{
|
|
*dst = *src;
|
|
}
|
|
|
|
static inline int mbedtls_sha1_starts(mbedtls_sha1_context *ctx)
|
|
{
|
|
sha1_starts(ctx);
|
|
return 0;
|
|
}
|
|
|
|
static inline int mbedtls_sha1_update(mbedtls_sha1_context *ctx,
|
|
const unsigned char *input,
|
|
size_t ilen)
|
|
{
|
|
sha1_update(ctx, input, ilen);
|
|
return 0;
|
|
}
|
|
|
|
static inline int mbedtls_sha1_finish(mbedtls_sha1_context *ctx,
|
|
unsigned char output[20])
|
|
{
|
|
sha1_finish(ctx, output);
|
|
return 0;
|
|
}
|
|
|
|
static inline int mbedtls_sha1(const unsigned char *input,
|
|
size_t ilen,
|
|
unsigned char output[20])
|
|
{
|
|
sha1_csum_wd(input, ilen, output, CHUNKSZ_SHA1);
|
|
return 0;
|
|
}
|
|
|
|
#endif /* sha1_alt.h */
|