Skip to content

Update libtomcrypt and libtommath to latest upstream versions#2510

Draft
PatrickvL wants to merge 10 commits into
masterfrom
libtom-update
Draft

Update libtomcrypt and libtommath to latest upstream versions#2510
PatrickvL wants to merge 10 commits into
masterfrom
libtom-update

Conversation

@PatrickvL
Copy link
Copy Markdown
Member

This pull request updates the imported libtomcrypt and libtommath submodules, modernizes build integration for these libraries, and updates cryptographic code to use their latest APIs. The changes improve maintainability, compatibility with upstream, and ensure the project uses the most up-to-date cryptographic primitives and interfaces.

Library Updates:

  • Updated import/libtomcrypt and import/libtommath submodules to newer commits, bringing in upstream changes and improvements. [1] [2]

Build System Improvements:

  • Simplified and modernized CMake integration for libtommath by using glob patterns for headers and sources (*.h, *.c), replacing long explicit file lists.
  • Added MSVC-specific compile options to suppress warnings and ensure dead code elimination works in Debug builds, preventing linker errors. [1] [2]
  • Enabled new libtomcrypt features (LTC_HMAC, LTC_HASH_HELPERS) in MSVC builds for both cxbx and cxbxr-emu. [1] [2]

Cryptographic Source Integration:

  • Updated source file list to match new libtomcrypt structure: replaced, removed, or renamed several source files to align with upstream changes (e.g., replaced pk_get_oid.c with pk_get.c, removed Katja and some DER sequence files, updated RSA/ECC files). [1] [2] [3] [4]

Code Modernization:

  • Updated EmuRsa.cpp to use new libtommath APIs: replaced deprecated init_LTM() with crypt_mp_init("ltm"), and switched from mp_import/mp_export to the new mp_unpack/mp_pack functions for big integer handling. [1] [2]

libtomcrypt: 7e7eb69 → 3223b87 (develop branch, +424 commits)
libtommath:  08549ad → 652d70a (v1.3.0-351, +603 commits)

Required for updated API (crypt_mp_init, mp_unpack/mp_pack) and
source file renames (rsa_free→rsa_key, katja removal, etc.).
The libtommath submodule uses mp_*.c naming (v1.3.x) but the build
file listed old bn_*.c names (v1.1.x), resulting in an empty library.
Replace the explicit file list with *.c / *.h globs so it works with
any version of the submodule.
- Replace deprecated init_LTM() with crypt_mp_init("ltm")
- Replace removed mp_import() with mp_unpack()
- Replace removed mp_export() with mp_pack()
Reflects upstream renames: pk_get_oid.c→pk_get.c, rsa_free.c→rsa_key.c,
ltc_ecc_is_valid_idx.c→ltc_ecc_is_point*.c. Removes deleted files:
katja sources, ecc_test.c, subject_public_key_info encoders.
MSVC /Od (Debug) disables all optimization including dead code elimination.
s_mp_rand_platform.c has forward declarations for Unix-only random source
functions (s_read_arc4random, s_read_getrandom, s_read_urandom) guarded by
MP_HAS() which relies on DCE. Enable /O1 for this file in Debug builds.
Strip /RTC1 from Debug flags for libtommath so the per-file /O1 on
s_mp_rand_platform.c doesn't conflict. Runtime checks aren't useful
for this external math library.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cmake cmake modules submodules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant