Merge remote-tracking branch 'upstream-public/development' into development-restricted-merge-20230925

Conflicts:
* `include/mbedtls/build_info.h`: a new fragment to auto-enable
  `MBEDTLS_CIPHER_PADDING_PKCS7` was added in
  c9f4040f7f in `development-restricted`.
  In `development`, this section of the file has moved to
  `include/mbedtls/config_adjust_legacy_crypto.h`.
* `library/bignum.c`: function name change in `development-restricted` vs
  comment change in development. The comment change in `development` is not
  really relevant, so just take the line from `development-restricted`.
This commit is contained in:
Gilles Peskine
2023-09-25 16:16:26 +02:00
2 changed files with 14 additions and 3 deletions
+9 -2
View File
@@ -19,12 +19,19 @@
import os
import inspect
def looks_like_psa_crypto_root(path: str) -> bool:
"""Whether the given directory looks like the root of the PSA Crypto source tree."""
return all(os.path.isdir(os.path.join(path, subdir))
for subdir in ['include', 'core', 'drivers', 'programs', 'tests'])
def looks_like_mbedtls_root(path: str) -> bool:
"""Whether the given directory looks like the root of the Mbed TLS source tree."""
return all(os.path.isdir(os.path.join(path, subdir))
for subdir in ['include', 'library', 'programs', 'tests'])
def looks_like_root(path: str) -> bool:
return looks_like_psa_crypto_root(path) or looks_like_mbedtls_root(path)
def check_repo_path():
"""
Check that the current working directory is the project root, and throw
@@ -42,7 +49,7 @@ def chdir_to_root() -> None:
for d in [os.path.curdir,
os.path.pardir,
os.path.join(os.path.pardir, os.path.pardir)]:
if looks_like_mbedtls_root(d):
if looks_like_root(d):
os.chdir(d)
return
raise Exception('Mbed TLS source tree not found')
@@ -62,6 +69,6 @@ def guess_mbedtls_root():
if d in dirs:
continue
dirs.add(d)
if looks_like_mbedtls_root(d):
if looks_like_root(d):
return d
raise Exception('Mbed TLS source tree not found')
+5 -1
View File
@@ -27,6 +27,7 @@ from typing import Dict, List, Optional, Set, Union
import unittest
from . import c_build_helper
from . import build_tree
class Expr:
@@ -51,13 +52,16 @@ class Expr:
def update_cache(self) -> None:
"""Update `value_cache` for expressions registered in `unknown_values`."""
expressions = sorted(self.unknown_values)
includes = ['include']
if build_tree.looks_like_psa_crypto_root('.'):
includes.append('drivers/builtin/include')
values = c_build_helper.get_c_expression_values(
'unsigned long', '%lu',
expressions,
header="""
#include <psa/crypto.h>
""",
include_path=['include']) #type: List[str]
include_path=includes) #type: List[str]
for e, v in zip(expressions, values):
self.value_cache[e] = int(v, 0)
self.unknown_values.clear()