CryptoPkg: Add mbedtls_config and MbedTlsLib.inf

Add MbedTlsLib support.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4177

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Yi Li <yi1.li@intel.com>
Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Signed-off-by: Wenxing Hou <wenxing.hou@intel.com>
Reviewed-by: Yi Li <yi1.li@intel.com>
This commit is contained in:
Wenxing Hou 2023-08-09 21:56:17 +08:00 committed by mergify[bot]
parent 1a79cc7d95
commit 586f05b9de
5 changed files with 4760 additions and 0 deletions

View File

@ -0,0 +1,96 @@
/** @file
C Run-Time Libraries (CRT) Wrapper Implementation for MbedTLS-based
Cryptographic Library.
Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <Base.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <stdio.h>
#include <Library/MemoryAllocationLib.h>
int
my_snprintf (
char *str,
size_t size,
const char *format,
...
)
{
return 0;
}
//
// Extra header to record the memory buffer size from malloc routine.
//
#define CRYPTMEM_HEAD_SIGNATURE SIGNATURE_32('c','m','h','d')
typedef struct {
UINT32 Signature;
UINT32 Reserved;
UINTN Size;
} CRYPTMEM_HEAD;
#define CRYPTMEM_OVERHEAD sizeof(CRYPTMEM_HEAD)
//
// -- Memory-Allocation Routines --
//
/* Allocates memory blocks */
void *
mbedtls_calloc (
size_t num,
size_t size
)
{
CRYPTMEM_HEAD *PoolHdr;
UINTN NewSize;
VOID *Data;
//
// Adjust the size by the buffer header overhead
//
NewSize = (UINTN)(size * num) + CRYPTMEM_OVERHEAD;
Data = AllocateZeroPool (NewSize);
if (Data != NULL) {
PoolHdr = (CRYPTMEM_HEAD *)Data;
//
// Record the memory brief information
//
PoolHdr->Signature = CRYPTMEM_HEAD_SIGNATURE;
PoolHdr->Size = size;
return (VOID *)(PoolHdr + 1);
} else {
//
// The buffer allocation failed.
//
return NULL;
}
}
/* De-allocates or frees a memory block */
void
mbedtls_free (
void *ptr
)
{
CRYPTMEM_HEAD *PoolHdr;
//
// In Standard C, free() handles a null pointer argument transparently. This
// is not true of FreePool() below, so protect it.
//
if (ptr != NULL) {
PoolHdr = (CRYPTMEM_HEAD *)ptr - 1;
ASSERT (PoolHdr->Signature == CRYPTMEM_HEAD_SIGNATURE);
FreePool (PoolHdr);
}
}

View File

@ -0,0 +1,495 @@
/** @file
Null implementation of EC and SM2 functions called by BaseCryptLib.
Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <Library/DebugLib.h>
#include <mbedtls/ecp.h>
#include <mbedtls/ecdh.h>
#include <mbedtls/ecdsa.h>
#include <mbedtls/bignum.h>
#include <library/bignum_core.h>
/*
* Get the curve info for the internal identifier
*/
const mbedtls_ecp_curve_info *
mbedtls_ecp_curve_info_from_grp_id (
mbedtls_ecp_group_id grp_id
)
{
ASSERT (FALSE);
return (NULL);
}
void
mbedtls_ecdh_init (
mbedtls_ecdh_context *ctx
)
{
ASSERT (FALSE);
}
/*
* Free context
*/
void
mbedtls_ecdh_free (
mbedtls_ecdh_context *ctx
)
{
ASSERT (FALSE);
}
int
mbedtls_ecdh_calc_secret (
mbedtls_ecdh_context *ctx,
size_t *olen,
unsigned char *buf,
size_t blen,
int ( *f_rng )(void *, unsigned char *, size_t),
void *p_rng
)
{
ASSERT (FALSE);
return -1;
}
void
mbedtls_ecp_keypair_init (
mbedtls_ecp_keypair *key
)
{
ASSERT (FALSE);
}
void
mbedtls_ecp_keypair_free (
mbedtls_ecp_keypair *key
)
{
ASSERT (FALSE);
}
int
mbedtls_ecp_check_pub_priv (
const mbedtls_ecp_keypair *pub,
const mbedtls_ecp_keypair *prv,
int ( *f_rng )(void *, unsigned char *, size_t),
void *p_rng
)
{
ASSERT (FALSE);
return -1;
}
int
mbedtls_ecdsa_write_signature (
mbedtls_ecdsa_context *ctx,
mbedtls_md_type_t md_alg,
const unsigned char *hash,
size_t hlen,
unsigned char *sig,
size_t sig_size,
size_t *slen,
int ( *f_rng )(void *, unsigned char *, size_t),
void *p_rng
)
{
ASSERT (FALSE);
return -1;
}
int
mbedtls_ecdsa_write_signature_restartable (
mbedtls_ecdsa_context *ctx,
mbedtls_md_type_t md_alg,
const unsigned char *hash,
size_t hlen,
unsigned char *sig,
size_t sig_size,
size_t *slen,
int ( *f_rng )(void *, unsigned char *, size_t),
void *p_rng,
mbedtls_ecdsa_restart_ctx *rs_ctx
)
{
ASSERT (FALSE);
return -1;
}
int
mbedtls_ecdsa_read_signature (
mbedtls_ecdsa_context *ctx,
const unsigned char *hash,
size_t hlen,
const unsigned char *sig,
size_t slen
)
{
ASSERT (FALSE);
return -1;
}
int
mbedtls_ecdsa_read_signature_restartable (
mbedtls_ecdsa_context *ctx,
const unsigned char *hash,
size_t hlen,
const unsigned char *sig,
size_t slen,
mbedtls_ecdsa_restart_ctx *rs_ctx
)
{
ASSERT (FALSE);
return -1;
}
int
mbedtls_ecdsa_from_keypair (
mbedtls_ecdsa_context *ctx,
const mbedtls_ecp_keypair *key
)
{
ASSERT (FALSE);
return -1;
}
void
mbedtls_ecdsa_init (
mbedtls_ecdsa_context *ctx
)
{
ASSERT (FALSE);
}
void
mbedtls_ecdsa_free (
mbedtls_ecdsa_context *ctx
)
{
ASSERT (FALSE);
}
void
mbedtls_ecdsa_restart_init (
mbedtls_ecdsa_restart_ctx *ctx
)
{
ASSERT (FALSE);
}
void
mbedtls_ecdsa_restart_free (
mbedtls_ecdsa_restart_ctx *ctx
)
{
ASSERT (FALSE);
}
int
mbedtls_ecp_point_write_binary (
const mbedtls_ecp_group *grp,
const mbedtls_ecp_point *P,
int format,
size_t *olen,
unsigned char *buf,
size_t buflen
)
{
ASSERT (FALSE);
return -1;
}
int
mbedtls_ecp_point_read_binary (
const mbedtls_ecp_group *grp,
mbedtls_ecp_point *P,
const unsigned char *buf,
size_t ilen
)
{
ASSERT (FALSE);
return -1;
}
int
mbedtls_ecp_write_key (
mbedtls_ecp_keypair *key,
unsigned char *buf,
size_t buflen
)
{
ASSERT (FALSE);
return -1;
}
int
mbedtls_ecp_group_load (
mbedtls_ecp_group *grp,
mbedtls_ecp_group_id id
)
{
ASSERT (FALSE);
return -1;
}
int
mbedtls_ecp_mul (
mbedtls_ecp_group *grp,
mbedtls_ecp_point *R,
const mbedtls_mpi *m,
const mbedtls_ecp_point *P,
int ( *f_rng )(void *, unsigned char *, size_t),
void *p_rng
)
{
ASSERT (FALSE);
return -1;
}
int
mbedtls_ecp_check_pubkey (
const mbedtls_ecp_group *grp,
const mbedtls_ecp_point *pt
)
{
ASSERT (FALSE);
return -1;
}
int
mbedtls_ecp_check_privkey (
const mbedtls_ecp_group *grp,
const mbedtls_mpi *d
)
{
ASSERT (FALSE);
return -1;
}
int
mbedtls_ecp_restart_is_enabled (
void
)
{
ASSERT (FALSE);
return -1;
}
const mbedtls_ecp_curve_info *
mbedtls_ecp_curve_info_from_tls_id (
uint16_t tls_id
)
{
ASSERT (FALSE);
return (NULL);
}
int
mbedtls_ecdh_setup (
mbedtls_ecdh_context *ctx,
mbedtls_ecp_group_id grp_id
)
{
ASSERT (FALSE);
return -1;
}
int
mbedtls_ecdh_make_params (
mbedtls_ecdh_context *ctx,
size_t *olen,
unsigned char *buf,
size_t blen,
int ( *f_rng )(void *, unsigned char *, size_t),
void *p_rng
)
{
ASSERT (FALSE);
return -1;
}
int
mbedtls_ecdh_get_params (
mbedtls_ecdh_context *ctx,
const mbedtls_ecp_keypair *key,
mbedtls_ecdh_side side
)
{
ASSERT (FALSE);
return -1;
}
int
mbedtls_ecdh_read_public (
mbedtls_ecdh_context *ctx,
const unsigned char *buf,
size_t blen
)
{
ASSERT (FALSE);
return -1;
}
int
mbedtls_ecdh_read_params (
mbedtls_ecdh_context *ctx,
const unsigned char **buf,
const unsigned char *end
)
{
ASSERT (FALSE);
return -1;
}
int
mbedtls_ecdh_make_public (
mbedtls_ecdh_context *ctx,
size_t *olen,
unsigned char *buf,
size_t blen,
int ( *f_rng )(void *, unsigned char *, size_t),
void *p_rng
)
{
ASSERT (FALSE);
return -1;
}
void
mbedtls_ecdh_enable_restart (
mbedtls_ecdh_context *ctx
)
{
ASSERT (FALSE);
}
void
mbedtls_ecp_point_init (
mbedtls_ecp_point *pt
)
{
ASSERT (FALSE);
}
void
mbedtls_ecp_group_init (
mbedtls_ecp_group *grp
)
{
ASSERT (FALSE);
}
void
mbedtls_ecp_point_free (
mbedtls_ecp_point *pt
)
{
ASSERT (FALSE);
}
void
mbedtls_ecp_group_free (
mbedtls_ecp_group *grp
)
{
ASSERT (FALSE);
}
int
mbedtls_ecp_is_zero (
mbedtls_ecp_point *pt
)
{
ASSERT (FALSE);
return -1;
}
int
mbedtls_ecp_point_cmp (
const mbedtls_ecp_point *P,
const mbedtls_ecp_point *Q
)
{
ASSERT (FALSE);
return -1;
}
int
mbedtls_ecp_muladd (
mbedtls_ecp_group *grp,
mbedtls_ecp_point *R,
const mbedtls_mpi *m,
const mbedtls_ecp_point *P,
const mbedtls_mpi *n,
const mbedtls_ecp_point *Q
)
{
ASSERT (FALSE);
return -1;
}
int
mbedtls_ecdh_gen_public (
mbedtls_ecp_group *grp,
mbedtls_mpi *d,
mbedtls_ecp_point *Q,
int ( *f_rng )(void *, unsigned char *, size_t),
void *p_rng
)
{
ASSERT (FALSE);
return -1;
}
int
mbedtls_ecdh_compute_shared (
mbedtls_ecp_group *grp,
mbedtls_mpi *z,
const mbedtls_ecp_point *Q,
const mbedtls_mpi *d,
int ( *f_rng )(void *, unsigned char *, size_t),
void *p_rng
)
{
ASSERT (FALSE);
return -1;
}
int
mbedtls_ecdsa_verify (
mbedtls_ecp_group *grp,
const unsigned char *buf,
size_t blen,
const mbedtls_ecp_point *Q,
const mbedtls_mpi *r,
const mbedtls_mpi *s
)
{
ASSERT (FALSE);
return -1;
}
/*
* Compute ECDSA signature of a hashed message
*/
int
mbedtls_ecdsa_sign (
mbedtls_ecp_group *grp,
mbedtls_mpi *r,
mbedtls_mpi *s,
const mbedtls_mpi *d,
const unsigned char *buf,
size_t blen,
int ( *f_rng )(void *, unsigned char *, size_t),
void *p_rng
)
{
ASSERT (FALSE);
return -1;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,171 @@
## @file
# library for the MbedTls.
#
# Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = MbedTlsLib
FILE_GUID = BB8E7D92-3E14-4907-A890-B28C7A0A1931
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = MbedTlsLib
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 ARM AARCH64
#
[Sources]
Include/mbedtls/mbedtls_config.h
mbedtls/library/aes.c
mbedtls/library/asn1parse.c
mbedtls/library/asn1write.c
mbedtls/library/base64.c
mbedtls/library/bignum.c
mbedtls/library/ccm.c
mbedtls/library/chacha20.c
mbedtls/library/chachapoly.c
mbedtls/library/cipher.c
mbedtls/library/cipher_wrap.c
mbedtls/library/cmac.c
mbedtls/library/ctr_drbg.c
mbedtls/library/debug.c
mbedtls/library/des.c
mbedtls/library/dhm.c
EcSm2Null.c
mbedtls/library/error.c
mbedtls/library/gcm.c
mbedtls/library/hkdf.c
mbedtls/library/hmac_drbg.c
mbedtls/library/md.c
mbedtls/library/md5.c
mbedtls/library/ssl_msg.c
mbedtls/library/ssl_tls12_client.c
mbedtls/library/ssl_tls12_server.c
mbedtls/library/ssl_client.c
mbedtls/library/ssl_debug_helpers_generated.c
mbedtls/library/rsa_alt_helpers.c
mbedtls/library/hash_info.c
mbedtls/library/bignum_core.c
mbedtls/library/constant_time.c
mbedtls/library/memory_buffer_alloc.c
mbedtls/library/nist_kw.c
mbedtls/library/oid.c
mbedtls/library/padlock.c
mbedtls/library/pem.c
mbedtls/library/pk.c
mbedtls/library/pkcs12.c
mbedtls/library/pkcs5.c
mbedtls/library/pkparse.c
mbedtls/library/pkwrite.c
mbedtls/library/pk_wrap.c
mbedtls/library/poly1305.c
mbedtls/library/ripemd160.c
mbedtls/library/rsa.c
mbedtls/library/sha1.c
mbedtls/library/sha256.c
mbedtls/library/sha512.c
mbedtls/library/ssl_cache.c
mbedtls/library/ssl_ciphersuites.c
mbedtls/library/ssl_cookie.c
mbedtls/library/ssl_ticket.c
mbedtls/library/ssl_tls.c
mbedtls/library/threading.c
mbedtls/library/version.c
mbedtls/library/version_features.c
mbedtls/library/x509.c
mbedtls/library/x509write_crt.c
mbedtls/library/x509write_csr.c
mbedtls/library/x509_create.c
mbedtls/library/x509_crl.c
mbedtls/library/x509_crt.c
mbedtls/library/x509_csr.c
mbedtls/library/pkcs7.c
mbedtls/library/platform_util.c
CrtWrapper.c
[Packages]
MdePkg/MdePkg.dec
CryptoPkg/CryptoPkg.dec
[LibraryClasses]
BaseLib
BaseMemoryLib
DebugLib
MemoryAllocationLib
[BuildOptions]
#
# Disables the following Visual Studio compiler warnings brought by Mbedtls source,
# warning C4244: '=': conversion from 'int' to 'unsigned char', possible loss of data
# warning C4132: 'S': const object should be initialized
# warning C4245: '=': conversion from 'int' to 'mbedtls_mpi_uint', signed/unsigned mismatch
# warning C4310: cast truncates constant value
# warning C4204: nonstandard extension used
#
MSFT:*_*_IA32_CC_FLAGS = /DEFI32 /wd4244 /wd4132 /wd4245 /wd4310 /wd4204
MSFT:*_*_X64_CC_FLAGS = /DEFI32 /wd4244 /wd4132 /wd4245 /wd4310 /wd4204
#
# Disable following Visual Studio 2015 compiler warnings brought by mbedtls source,
# so we do not break the build with /WX option:
# C4718: recursive call has no side effects, deleting
#
MSFT:*_VS2015x86_IA32_CC_FLAGS = /wd4718
MSFT:*_VS2015x86_X64_CC_FLAGS = /wd4718
INTEL:*_*_IA32_CC_FLAGS = -U_WIN32 -U_WIN64 /w
INTEL:*_*_X64_CC_FLAGS = -U_WIN32 -U_WIN64 /w
#
# Suppress the following build warnings in mbedtls so we don't break the build with -Werror
# -Werror=maybe-uninitialized: there exist some other paths for which the variable is not initialized.
# -Werror=format: Check calls to printf and scanf, etc., to make sure that the arguments supplied have
# types appropriate to the format string specified.
# -Werror=unused-but-set-variable: Warn whenever a local variable is assigned to, but otherwise unused (aside from its declaration).
#
GCC:*_*_IA32_CC_FLAGS = -U_WIN32 -U_WIN64 -Wno-error=maybe-uninitialized -Wno-error=unused-but-set-variable
GCC:*_*_X64_CC_FLAGS = -U_WIN32 -U_WIN64 -Wno-error=maybe-uninitialized -Wno-error=format -Wno-format -Wno-error=unused-but-set-variable -DNO_MSABI_VA_FUNCS
GCC:*_*_ARM_CC_FLAGS = -Wno-error=maybe-uninitialized -Wno-error=unused-but-set-variable
GCC:*_*_AARCH64_CC_FLAGS = -Wno-error=maybe-uninitialized -Wno-format -Wno-error=unused-but-set-variable -Wno-error=format
GCC:*_*_RISCV64_CC_FLAGS = -Wno-error=maybe-uninitialized -Wno-format -Wno-error=unused-but-set-variable
GCC:*_*_LOONGARCH64_CC_FLAGS = -Wno-error=maybe-uninitialized -Wno-format -Wno-error=unused-but-set-variable
GCC:*_CLANG35_*_CC_FLAGS = -std=c99 -Wno-error=uninitialized
GCC:*_CLANG38_*_CC_FLAGS = -std=c99 -Wno-error=uninitialized
GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=uninitialized -Wno-error=incompatible-pointer-types -Wno-error=pointer-sign -Wno-error=implicit-function-declaration -Wno-error=ignored-pragma-optimize
# suppress the following warnings in mbedtls so we don't break the build with warnings-as-errors:
# 1295: Deprecated declaration <entity> - give arg types
# 550: <entity> was set but never used
# 1293: assignment in condition
# 111: statement is unreachable (invariably "break;" after "return X;" in case statement)
# 68: integer conversion resulted in a change of sign ("if (Status == -1)")
# 177: <entity> was declared but never referenced
# 223: function <entity> declared implicitly
# 144: a value of type <type> cannot be used to initialize an entity of type <type>
# 513: a value of type <type> cannot be assigned to an entity of type <type>
# 188: enumerated type mixed with another type (i.e. passing an integer as an enum without a cast)
# 1296: Extended constant initialiser used
# 128: loop is not reachable - may be emitted inappropriately if code follows a conditional return
# from the function that evaluates to true at compile time
# 546: transfer of control bypasses initialization - may be emitted inappropriately if the uninitialized
# variable is never referenced after the jump
# 1: ignore "#1-D: last line of file ends without a newline"
XCODE:*_*_IA32_CC_FLAGS = -mmmx -msse -U_WIN32 -U_WIN64 -w -std=c99 -Wno-error=uninitialized
XCODE:*_*_X64_CC_FLAGS = -mmmx -msse -U_WIN32 -U_WIN64 -w -std=c99 -Wno-error=uninitialized
#
# AARCH64 uses strict alignment and avoids SIMD registers for code that may execute
# with the MMU off. This involves SEC, PEI_CORE and PEIM modules as well as BASE
# libraries, given that they may be included into such modules.
# This library, even though of the BASE type, is never used in such cases, and
# avoiding the SIMD register file (which is shared with the FPU) prevents the
# compiler from successfully building some of the mbedtls source files that
# use floating point types, so clear the flags here.
#
GCC:*_*_AARCH64_CC_XIPFLAGS ==

View File

@ -0,0 +1,175 @@
## @file
# library for the MbedTls.
#
# Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = MbedTlsLibFull
FILE_GUID = BE9B7BBC-F003-4D88-A7E3-EB73E951F5BF
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = MbedTlsLib
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 ARM AARCH64
#
[Sources]
Include/mbedtls/mbedtls_config.h
mbedtls/library/aes.c
mbedtls/library/asn1parse.c
mbedtls/library/asn1write.c
mbedtls/library/base64.c
mbedtls/library/bignum.c
mbedtls/library/ccm.c
mbedtls/library/chacha20.c
mbedtls/library/chachapoly.c
mbedtls/library/cipher.c
mbedtls/library/cipher_wrap.c
mbedtls/library/cmac.c
mbedtls/library/ctr_drbg.c
mbedtls/library/debug.c
mbedtls/library/des.c
mbedtls/library/dhm.c
mbedtls/library/ecdh.c
mbedtls/library/ecdsa.c
mbedtls/library/ecjpake.c
mbedtls/library/ecp.c
mbedtls/library/ecp_curves.c
mbedtls/library/error.c
mbedtls/library/gcm.c
mbedtls/library/hkdf.c
mbedtls/library/hmac_drbg.c
mbedtls/library/md.c
mbedtls/library/md5.c
mbedtls/library/ssl_msg.c
mbedtls/library/ssl_tls12_client.c
mbedtls/library/ssl_tls12_server.c
mbedtls/library/ssl_client.c
mbedtls/library/ssl_debug_helpers_generated.c
mbedtls/library/rsa_alt_helpers.c
mbedtls/library/hash_info.c
mbedtls/library/bignum_core.c
mbedtls/library/constant_time.c
mbedtls/library/memory_buffer_alloc.c
mbedtls/library/nist_kw.c
mbedtls/library/oid.c
mbedtls/library/padlock.c
mbedtls/library/pem.c
mbedtls/library/pk.c
mbedtls/library/pkcs12.c
mbedtls/library/pkcs5.c
mbedtls/library/pkparse.c
mbedtls/library/pkwrite.c
mbedtls/library/pk_wrap.c
mbedtls/library/poly1305.c
mbedtls/library/ripemd160.c
mbedtls/library/rsa.c
mbedtls/library/sha1.c
mbedtls/library/sha256.c
mbedtls/library/sha512.c
mbedtls/library/ssl_cache.c
mbedtls/library/ssl_ciphersuites.c
mbedtls/library/ssl_cookie.c
mbedtls/library/ssl_ticket.c
mbedtls/library/ssl_tls.c
mbedtls/library/threading.c
mbedtls/library/version.c
mbedtls/library/version_features.c
mbedtls/library/x509.c
mbedtls/library/x509write_crt.c
mbedtls/library/x509write_csr.c
mbedtls/library/x509_create.c
mbedtls/library/x509_crl.c
mbedtls/library/x509_crt.c
mbedtls/library/x509_csr.c
mbedtls/library/pkcs7.c
mbedtls/library/platform_util.c
CrtWrapper.c
[Packages]
MdePkg/MdePkg.dec
CryptoPkg/CryptoPkg.dec
[LibraryClasses]
BaseLib
BaseMemoryLib
DebugLib
MemoryAllocationLib
[BuildOptions]
#
# Disables the following Visual Studio compiler warnings brought by Mbedtls source,
# warning C4244: '=': conversion from 'int' to 'unsigned char', possible loss of data
# warning C4132: 'S': const object should be initialized
# warning C4245: '=': conversion from 'int' to 'mbedtls_mpi_uint', signed/unsigned mismatch
# warning C4310: cast truncates constant value
# warning C4204: nonstandard extension used
#
MSFT:*_*_IA32_CC_FLAGS = /DEFI32 /wd4244 /wd4132 /wd4245 /wd4310 /wd4204
MSFT:*_*_X64_CC_FLAGS = /DEFI32 /wd4244 /wd4132 /wd4245 /wd4310 /wd4204
#
# Disable following Visual Studio 2015 compiler warnings brought by mbedtls source,
# so we do not break the build with /WX option:
# C4718: recursive call has no side effects, deleting
#
MSFT:*_VS2015x86_IA32_CC_FLAGS = /wd4718
MSFT:*_VS2015x86_X64_CC_FLAGS = /wd4718
INTEL:*_*_IA32_CC_FLAGS = -U_WIN32 -U_WIN64 /w
INTEL:*_*_X64_CC_FLAGS = -U_WIN32 -U_WIN64 /w
#
# Suppress the following build warnings in mbedtls so we don't break the build with -Werror
# -Werror=maybe-uninitialized: there exist some other paths for which the variable is not initialized.
# -Werror=format: Check calls to printf and scanf, etc., to make sure that the arguments supplied have
# types appropriate to the format string specified.
# -Werror=unused-but-set-variable: Warn whenever a local variable is assigned to, but otherwise unused (aside from its declaration).
#
GCC:*_*_IA32_CC_FLAGS = -U_WIN32 -U_WIN64 -Wno-error=maybe-uninitialized -Wno-error=unused-but-set-variable
GCC:*_*_X64_CC_FLAGS = -U_WIN32 -U_WIN64 -Wno-error=maybe-uninitialized -Wno-error=format -Wno-format -Wno-error=unused-but-set-variable -DNO_MSABI_VA_FUNCS
GCC:*_*_ARM_CC_FLAGS = -Wno-error=maybe-uninitialized -Wno-error=unused-but-set-variable
GCC:*_*_AARCH64_CC_FLAGS = -Wno-error=maybe-uninitialized -Wno-format -Wno-error=unused-but-set-variable -Wno-error=format
GCC:*_*_RISCV64_CC_FLAGS = -Wno-error=maybe-uninitialized -Wno-format -Wno-error=unused-but-set-variable
GCC:*_*_LOONGARCH64_CC_FLAGS = -Wno-error=maybe-uninitialized -Wno-format -Wno-error=unused-but-set-variable
GCC:*_CLANG35_*_CC_FLAGS = -std=c99 -Wno-error=uninitialized
GCC:*_CLANG38_*_CC_FLAGS = -std=c99 -Wno-error=uninitialized
GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=uninitialized -Wno-error=incompatible-pointer-types -Wno-error=pointer-sign -Wno-error=implicit-function-declaration -Wno-error=ignored-pragma-optimize
# suppress the following warnings in mbedtls so we don't break the build with warnings-as-errors:
# 1295: Deprecated declaration <entity> - give arg types
# 550: <entity> was set but never used
# 1293: assignment in condition
# 111: statement is unreachable (invariably "break;" after "return X;" in case statement)
# 68: integer conversion resulted in a change of sign ("if (Status == -1)")
# 177: <entity> was declared but never referenced
# 223: function <entity> declared implicitly
# 144: a value of type <type> cannot be used to initialize an entity of type <type>
# 513: a value of type <type> cannot be assigned to an entity of type <type>
# 188: enumerated type mixed with another type (i.e. passing an integer as an enum without a cast)
# 1296: Extended constant initialiser used
# 128: loop is not reachable - may be emitted inappropriately if code follows a conditional return
# from the function that evaluates to true at compile time
# 546: transfer of control bypasses initialization - may be emitted inappropriately if the uninitialized
# variable is never referenced after the jump
# 1: ignore "#1-D: last line of file ends without a newline"
XCODE:*_*_IA32_CC_FLAGS = -mmmx -msse -U_WIN32 -U_WIN64 -w -std=c99 -Wno-error=uninitialized
XCODE:*_*_X64_CC_FLAGS = -mmmx -msse -U_WIN32 -U_WIN64 -w -std=c99 -Wno-error=uninitialized
#
# AARCH64 uses strict alignment and avoids SIMD registers for code that may execute
# with the MMU off. This involves SEC, PEI_CORE and PEIM modules as well as BASE
# libraries, given that they may be included into such modules.
# This library, even though of the BASE type, is never used in such cases, and
# avoiding the SIMD register file (which is shared with the FPU) prevents the
# compiler from successfully building some of the mbedtls source files that
# use floating point types, so clear the flags here.
#
GCC:*_*_AARCH64_CC_XIPFLAGS ==