1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 20:38:10 +00:00

chore(core): separate crypto sources in build scripts

[no changelog]
This commit is contained in:
Ondřej Vejpustek 2024-04-10 15:11:12 +02:00
parent bfbb6f8685
commit 6b81d24b5c
8 changed files with 49 additions and 21 deletions

View File

@ -24,6 +24,7 @@ CCFLAGS_MOD = ''
CPPPATH_MOD = []
CPPDEFINES_MOD = ["BOARDLOADER"]
SOURCE_MOD = []
SOURCE_MOD_CRYPTO = []
CPPDEFINES_HAL = []
SOURCE_HAL = []
PATH_HAL = []
@ -41,6 +42,9 @@ CPPDEFINES_MOD += [
'ED25519_NO_PRECOMP',
]
SOURCE_MOD += [
'vendor/trezor-storage/flash_area.c',
]
SOURCE_MOD_CRYPTO += [
'vendor/trezor-crypto/blake2s.c',
'vendor/trezor-crypto/ed25519-donna/curve25519-donna-32bit.c',
'vendor/trezor-crypto/ed25519-donna/curve25519-donna-helpers.c',
@ -50,7 +54,6 @@ SOURCE_MOD += [
'vendor/trezor-crypto/ed25519-donna/modm-donna-32bit.c',
'vendor/trezor-crypto/memzero.c',
'vendor/trezor-crypto/sha2.c',
'vendor/trezor-storage/flash_area.c',
]
# modtrezorui
@ -130,7 +133,7 @@ env.Replace(
)
env.Replace(
ALLSOURCES=SOURCE_MOD + SOURCE_BOARDLOADER + SOURCE_HAL,
ALLSOURCES=SOURCE_MOD + SOURCE_MOD_CRYPTO + SOURCE_BOARDLOADER + SOURCE_HAL,
ALLDEFS=tools.get_defs_for_cmake(env['CPPDEFINES'] + env['CPPDEFINES_IMPLICIT']))
cmake_gen = env.Command(
@ -145,6 +148,7 @@ cmake_gen = env.Command(
obj_program = []
obj_program += env.Object(source=SOURCE_MOD)
obj_program += env.Object(source=SOURCE_MOD_CRYPTO)
obj_program += env.Object(source=SOURCE_BOARDLOADER)
obj_program += env.Object(source=SOURCE_HAL)

View File

@ -26,6 +26,7 @@ CCFLAGS_MOD = ''
CPPPATH_MOD = []
CPPDEFINES_MOD = []
SOURCE_MOD = []
SOURCE_MOD_CRYPTO = []
CPPDEFINES_HAL = []
SOURCE_HAL = []
PATH_HAL = []
@ -71,6 +72,9 @@ CPPDEFINES_MOD += [
]
SOURCE_MOD += [
'vendor/trezor-storage/flash_area.c',
]
SOURCE_MOD_CRYPTO = [
'vendor/trezor-crypto/blake2s.c',
'vendor/trezor-crypto/chacha_drbg.c',
'vendor/trezor-crypto/chacha20poly1305/chacha_merged.c',
@ -83,7 +87,6 @@ SOURCE_MOD += [
'vendor/trezor-crypto/memzero.c',
'vendor/trezor-crypto/rand.c',
'vendor/trezor-crypto/sha2.c',
'vendor/trezor-storage/flash_area.c',
]
# modtrezorui
@ -201,7 +204,7 @@ env.Replace(
)
env.Replace(
ALLSOURCES=SOURCE_MOD + SOURCE_BOOTLOADER + SOURCE_NANOPB + SOURCE_HAL,
ALLSOURCES=SOURCE_MOD + SOURCE_MOD_CRYPTO + SOURCE_BOOTLOADER + SOURCE_NANOPB + SOURCE_HAL,
ALLDEFS=tools.get_defs_for_cmake(env['CPPDEFINES'] + env['CPPDEFINES_IMPLICIT'] + [f"PRODUCTION={int(PRODUCTION)}", f"BOOTLOADER_QA={int(BOOTLOADER_QA)}"]))
cmake_gen = env.Command(
@ -265,6 +268,7 @@ env.Append(LINKFLAGS=f' -l{RUST_LIB}')
obj_program = []
obj_program += env.Object(source=SOURCE_MOD)
obj_program += env.Object(source=SOURCE_MOD_CRYPTO)
obj_program += env.Object(source=SOURCE_BOOTLOADER)
obj_program += env.Object(source=SOURCE_NANOPB)
obj_program += env.Object(source=SOURCE_HAL)

View File

@ -24,6 +24,7 @@ CCFLAGS_MOD = ''
CPPPATH_MOD = []
CPPDEFINES_MOD = []
SOURCE_MOD = []
SOURCE_MOD_CRYPTO = []
CPPDEFINES_HAL = []
SOURCE_HAL = []
PATH_HAL = []
@ -66,6 +67,9 @@ CPPDEFINES_MOD += [
'ED25519_NO_PRECOMP',
]
SOURCE_MOD += [
'vendor/trezor-storage/flash_area.c',
]
SOURCE_MOD_CRYPTO += [
'vendor/trezor-crypto/blake2s.c',
'vendor/trezor-crypto/chacha_drbg.c',
'vendor/trezor-crypto/chacha20poly1305/chacha_merged.c',
@ -78,7 +82,6 @@ SOURCE_MOD += [
'vendor/trezor-crypto/memzero.c',
'vendor/trezor-crypto/rand.c',
'vendor/trezor-crypto/sha2.c',
'vendor/trezor-storage/flash_area.c',
]
# modtrezorui
@ -181,14 +184,14 @@ env.Replace(
] + CPPDEFINES_MOD + CPPDEFINES_HAL,
ASFLAGS=env.get('ENV')['CPU_ASFLAGS'],
ASPPFLAGS='$CFLAGS $CCFLAGS',
ALLSOURCES=SOURCE_MOD + SOURCE_BOOTLOADER + SOURCE_HAL+ SOURCE_NANOPB, )
ALLSOURCES=SOURCE_MOD + SOURCE_MOD_CRYPTO + SOURCE_BOOTLOADER + SOURCE_HAL+ SOURCE_NANOPB, )
env.Replace(
HEADERTOOL='tools/headertool.py',
)
env.Replace(
ALLSOURCES=SOURCE_MOD + SOURCE_BOOTLOADER + SOURCE_NANOPB + SOURCE_HAL,
ALLSOURCES=SOURCE_MOD + SOURCE_MOD_CRYPTO + SOURCE_BOOTLOADER + SOURCE_NANOPB + SOURCE_HAL,
ALLDEFS=tools.get_defs_for_cmake(env['CPPDEFINES'] + env['CPPDEFINES_IMPLICIT']))
cmake_gen = env.Command(
@ -204,6 +207,7 @@ cmake_gen = env.Command(
obj_program = []
obj_program += env.Object(source=SOURCE_MOD)
obj_program += env.Object(source=SOURCE_MOD_CRYPTO)
obj_program += env.Object(source=SOURCE_BOOTLOADER)
obj_program += env.Object(source=SOURCE_NANOPB)
obj_program += env.Object(source=SOURCE_HAL)

View File

@ -26,6 +26,7 @@ CCFLAGS_MOD = ''
CPPPATH_MOD = []
CPPDEFINES_MOD = []
SOURCE_MOD = []
SOURCE_MOD_CRYPTO = []
if TREZOR_MODEL in ('1', 'R'):
FONT_NORMAL='Font_PixelOperator_Regular_8'
@ -66,7 +67,7 @@ CPPDEFINES_MOD += [
'TREZOR_UI2',
'FANCY_FATAL_ERROR'
]
SOURCE_MOD += [
SOURCE_MOD_CRYPTO += [
'vendor/trezor-crypto/blake2s.c',
'vendor/trezor-crypto/chacha_drbg.c',
'vendor/trezor-crypto/chacha20poly1305/chacha_merged.c',
@ -254,7 +255,7 @@ except OSError:
env.Replace(
ALLSOURCES=SOURCE_MOD + SOURCE_BOOTLOADER + SOURCE_NANOPB + SOURCE_TREZORHAL + SOURCE_UNIX,
ALLSOURCES=SOURCE_MOD + SOURCE_MOD_CRYPTO + SOURCE_BOOTLOADER + SOURCE_NANOPB + SOURCE_TREZORHAL + SOURCE_UNIX,
ALLDEFS=tools.get_defs_for_cmake(env['CPPDEFINES']))
cmake_gen = env.Command(
@ -328,6 +329,7 @@ env.Append(LINKFLAGS='-lm')
obj_program = []
obj_program += env.Object(source=SOURCE_MOD)
obj_program += env.Object(source=SOURCE_MOD_CRYPTO)
obj_program += env.Object(source=SOURCE_BOOTLOADER)
obj_program += env.Object(source=SOURCE_NANOPB)
obj_program += env.Object(source=SOURCE_TREZORHAL)

View File

@ -31,6 +31,7 @@ CCFLAGS_MOD = ''
CPPPATH_MOD = []
CPPDEFINES_MOD = []
SOURCE_MOD = []
SOURCE_MOD_CRYPTO = []
CPPDEFINES_HAL = []
SOURCE_HAL = []
PATH_HAL = []
@ -88,6 +89,8 @@ SOURCE_MOD += [
'embed/extmod/modtrezorcrypto/crc.c',
'embed/extmod/modtrezorcrypto/modtrezorcrypto.c',
'embed/extmod/modtrezorcrypto/rand.c',
]
SOURCE_MOD_CRYPTO += [
'vendor/trezor-crypto/address.c',
'vendor/trezor-crypto/aes/aes_modes.c',
'vendor/trezor-crypto/aes/aesccm.c',
@ -143,7 +146,7 @@ SOURCE_MOD += [
'vendor/trezor-crypto/tls_prf.c',
]
if EVERYTHING:
SOURCE_MOD += [
SOURCE_MOD_CRYPTO += [
'vendor/trezor-crypto/cardano.c',
'vendor/trezor-crypto/monero/base58.c',
'vendor/trezor-crypto/monero/serialize.c',
@ -177,7 +180,7 @@ if FEATURE_FLAGS["SECP256K1_ZKP"]:
'vendor/secp256k1-zkp/src/precomputed_ecmult_gen.c',
'vendor/secp256k1-zkp/src/asm/field_10x26_arm.s'
]
SOURCE_MOD += [
SOURCE_MOD_CRYPTO += [
'vendor/trezor-crypto/zkp_context.c',
'vendor/trezor-crypto/zkp_ecdsa.c',
'vendor/trezor-crypto/zkp_bip340.c',
@ -189,7 +192,7 @@ if FEATURE_FLAGS["AES_GCM"]:
'USE_AES_GCM',
'AES_VAR',
]
SOURCE_MOD += [
SOURCE_MOD_CRYPTO += [
'vendor/trezor-crypto/aes/gf128mul.c',
'vendor/trezor-crypto/aes/aesgcm.c',
]
@ -731,9 +734,10 @@ if FROZEN:
# Program objects
#
source_files = SOURCE_MOD + SOURCE_FIRMWARE + SOURCE_MICROPYTHON + SOURCE_MICROPYTHON_SPEED + SOURCE_HAL
source_files = SOURCE_MOD + SOURCE_MOD_CRYPTO + SOURCE_FIRMWARE + SOURCE_MICROPYTHON + SOURCE_MICROPYTHON_SPEED + SOURCE_HAL
obj_program = []
obj_program.extend(env.Object(source=SOURCE_MOD))
obj_program.extend(env.Object(source=SOURCE_MOD_CRYPTO))
if FEATURE_FLAGS["SECP256K1_ZKP"]:
obj_program.extend(env.Object(source=SOURCE_MOD_SECP256K1_ZKP, CCFLAGS='$CCFLAGS -Wno-unused-function'))
source_files.extend(SOURCE_MOD_SECP256K1_ZKP)

View File

@ -28,6 +28,7 @@ CPPDEFINES_MOD = [
'USE_INSECURE_PRNG',
]
SOURCE_MOD = []
SOURCE_MOD_CRYPTO = []
CPPDEFINES_HAL = []
SOURCE_HAL = []
PATH_HAL = []
@ -55,6 +56,9 @@ CPPPATH_MOD += [
'vendor/trezor-storage',
]
SOURCE_MOD += [
'vendor/trezor-storage/flash_area.c',
]
SOURCE_MOD_CRYPTO += [
'vendor/trezor-crypto/aes/aes_modes.c',
'vendor/trezor-crypto/aes/aesccm.c',
'vendor/trezor-crypto/aes/aescrypt.c',
@ -75,7 +79,6 @@ SOURCE_MOD += [
'vendor/trezor-crypto/secp256k1.c',
'vendor/trezor-crypto/sha2.c',
'vendor/trezor-crypto/tls_prf.c',
'vendor/trezor-storage/flash_area.c',
]
# modtrezorui
@ -180,7 +183,7 @@ env.Replace(
env.Replace(
ALLSOURCES=SOURCE_MOD + SOURCE_PRODTEST + SOURCE_HAL,
ALLSOURCES=SOURCE_MOD + SOURCE_MOD_CRYPTO + SOURCE_PRODTEST + SOURCE_HAL,
ALLDEFS=tools.get_defs_for_cmake(env['CPPDEFINES'] + env['CPPDEFINES_IMPLICIT']))
cmake_gen = env.Command(
@ -196,6 +199,7 @@ cmake_gen = env.Command(
obj_program = []
obj_program.extend(env.Object(source=SOURCE_MOD))
obj_program.extend(env.Object(source=SOURCE_MOD_CRYPTO))
obj_program.extend(env.Object(source=SOURCE_PRODTEST))
obj_program.extend(env.Object(source=SOURCE_HAL))

View File

@ -23,6 +23,7 @@ CCFLAGS_MOD = ''
CPPPATH_MOD = []
CPPDEFINES_MOD = []
SOURCE_MOD = []
SOURCE_MOD_CRYPTO = []
CPPDEFINES_HAL = []
SOURCE_HAL = []
PATH_HAL = []
@ -49,7 +50,7 @@ CPPPATH_MOD += [
'vendor/trezor-crypto',
'vendor/trezor-storage',
]
SOURCE_MOD += [
SOURCE_MOD_CRYPTO += [
'vendor/trezor-crypto/memzero.c',
]
@ -146,7 +147,7 @@ env.Replace(
)
env.Replace(
ALLSOURCES=SOURCE_MOD + SOURCE_REFLASH + SOURCE_HAL,
ALLSOURCES=SOURCE_MOD + SOURCE_MOD_CRYPTO + SOURCE_REFLASH + SOURCE_HAL,
ALLDEFS=tools.get_defs_for_cmake(env['CPPDEFINES'] + env['CPPDEFINES_IMPLICIT']))
cmake_gen = env.Command(
@ -161,6 +162,7 @@ cmake_gen = env.Command(
obj_program = []
obj_program += env.Object(source=SOURCE_MOD)
obj_program += env.Object(source=SOURCE_MOD_CRYPTO)
obj_program += env.Object(source=SOURCE_REFLASH)
obj_program += env.Object(source=SOURCE_HAL)

View File

@ -34,6 +34,7 @@ CPPDEFINES_MOD = []
SOURCE_MOD = [
'vendor/micropython/extmod/vfs_posix_file.c',
]
SOURCE_MOD_CRYPTO = []
PYOPT = ARGUMENTS.get('PYOPT', '1')
FROZEN = ARGUMENTS.get('TREZOR_EMULATOR_FROZEN', 0)
@ -90,6 +91,8 @@ SOURCE_MOD += [
'embed/extmod/trezorobj.c',
'embed/extmod/modtrezorcrypto/crc.c',
'embed/extmod/modtrezorcrypto/modtrezorcrypto.c',
]
SOURCE_MOD_CRYPTO += [
'vendor/trezor-crypto/address.c',
'vendor/trezor-crypto/aes/aes_modes.c',
'vendor/trezor-crypto/aes/aescrypt.c',
@ -143,7 +146,7 @@ SOURCE_MOD += [
'vendor/trezor-crypto/slip39_english.c',
]
if EVERYTHING:
SOURCE_MOD += [
SOURCE_MOD_CRYPTO += [
'vendor/trezor-crypto/cardano.c',
'vendor/trezor-crypto/monero/base58.c',
'vendor/trezor-crypto/monero/serialize.c',
@ -174,7 +177,7 @@ if FEATURE_FLAGS["SECP256K1_ZKP"]:
'vendor/secp256k1-zkp/src/precomputed_ecmult.c',
'vendor/secp256k1-zkp/src/precomputed_ecmult_gen.c',
]
SOURCE_MOD += [
SOURCE_MOD_CRYPTO += [
'vendor/trezor-crypto/zkp_context.c',
'vendor/trezor-crypto/zkp_ecdsa.c',
'vendor/trezor-crypto/zkp_bip340.c',
@ -186,7 +189,7 @@ if FEATURE_FLAGS["AES_GCM"]:
'USE_AES_GCM',
'AES_VAR',
]
SOURCE_MOD += [
SOURCE_MOD_CRYPTO += [
'vendor/trezor-crypto/aes/gf128mul.c',
'vendor/trezor-crypto/aes/aesgcm.c',
]
@ -819,8 +822,9 @@ if FROZEN:
#
obj_program = []
source_files = SOURCE_MOD + SOURCE_MICROPYTHON + SOURCE_UNIX
source_files = SOURCE_MOD + SOURCE_MOD_CRYPTO + SOURCE_MICROPYTHON + SOURCE_UNIX
obj_program.extend(env.Object(source=SOURCE_MOD))
obj_program.extend(env.Object(source=SOURCE_MOD_CRYPTO))
if FEATURE_FLAGS["SECP256K1_ZKP"]:
obj_program.extend(env.Object(source=SOURCE_MOD_SECP256K1_ZKP, CCFLAGS='$CCFLAGS -Wno-unused-function'))
source_files.extend(SOURCE_MOD_SECP256K1_ZKP)