-
Notifications
You must be signed in to change notification settings - Fork 995
wolfCrypt on TI C2000 C28x (LAUNCHXL-F28P55X) #10724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
dgarske
wants to merge
4
commits into
wolfSSL:master
Choose a base branch
from
dgarske:ti_c25
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5e898d7
wolfcrypt: support CHAR_BIT != 8 (WOLFSSL_WIDE_BYTE) targets - infra,…
dgarske 5522b65
mldsa: correct ML-DSA on CHAR_BIT!=8 + add WOLFSSL_MLDSA_VERIFY_SMALL…
dgarske 12a3dce
test/bench/ci: CHAR_BIT!=8 test vectors, NO_MALLOC bench, TI C2000 co…
dgarske 20e4053
dilithium: faster Montgomery q^-1 via 64-bit-widened multiply on 16-b…
dgarske File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| name: TI C2000 (C28x) compile-only | ||
|
|
||
| # Compile-guard for the TI C2000 C28x port (CHAR_BIT == 16). It builds the | ||
| # wolfCrypt subset that carries the CHAR_BIT != 8 gated fixes with the TI cl2000 | ||
| # code generation tools - no linking, no C2000Ware, no hardware. Purpose: catch | ||
| # compile regressions in the octet/SP/ML-DSA gated paths. On-target run-tests | ||
| # live on a hardware-in-the-loop runner (there is no public C28x simulator). | ||
|
|
||
| # START OF COMMON SECTION | ||
| on: | ||
| # Only build when something that can affect the C28x compile changes, so the | ||
| # job (and the CGT it pulls) does not burn runner minutes on unrelated PRs. | ||
| push: | ||
| branches: [ 'master', 'main', 'release/**' ] | ||
| paths: | ||
| - 'wolfcrypt/src/**' | ||
| - 'wolfssl/wolfcrypt/**' | ||
| - 'scripts/ti-c2000/**' | ||
| - '.github/workflows/ti-c2000-compile.yml' | ||
| pull_request: | ||
| types: [opened, synchronize, reopened, ready_for_review] | ||
| branches: [ '*' ] | ||
| paths: | ||
| - 'wolfcrypt/src/**' | ||
| - 'wolfssl/wolfcrypt/**' | ||
| - 'scripts/ti-c2000/**' | ||
| - '.github/workflows/ti-c2000-compile.yml' | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
| # END OF COMMON SECTION | ||
|
|
||
| jobs: | ||
| ti_c2000_compile: | ||
| name: cl2000 compile-only | ||
| if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }} | ||
| runs-on: ubuntu-22.04 | ||
| timeout-minutes: 20 | ||
| env: | ||
| # TI C2000 code generation tools. The CGT is a free download from TI. | ||
| # Update CGT_VER / CGT_URL when bumping the toolchain. If the TI URL | ||
| # starts requiring a click-through, host the installer as a repo/org | ||
| # cache artifact and point CGT_URL at it (the cache step below makes the | ||
| # download a once-per-version cost). | ||
| CGT_VER: "22.6.2.LTS" | ||
| CGT_URL: "https://dr-download.ti.com/software-development/ide-configuration-compiler-or-debugger/MD-LP0nQ4O8eX/22.6.2.LTS/ti_cgt_c2000_22.6.2.LTS_linux-x64_installer.bin" | ||
| CGT_DIR: "${{ github.workspace }}/ti-cgt-c2000" | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| name: Checkout wolfSSL | ||
|
|
||
| - name: Cache TI C2000 CGT | ||
| id: cgt-cache | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ${{ env.CGT_DIR }} | ||
| key: ti-cgt-c2000-${{ env.CGT_VER }} | ||
|
|
||
| - name: Download + install TI C2000 CGT | ||
| if: steps.cgt-cache.outputs.cache-hit != 'true' | ||
| run: | | ||
| set -e | ||
| curl -fsSL "$CGT_URL" -o /tmp/cgt.bin | ||
| chmod +x /tmp/cgt.bin | ||
| /tmp/cgt.bin --mode unattended --prefix "$CGT_DIR" | ||
|
|
||
| - name: Locate cl2000 | ||
| id: find-cl | ||
| run: | | ||
| CL=$(find "$CGT_DIR" -type f -name cl2000 | head -1) | ||
| test -n "$CL" || { echo "cl2000 not found under $CGT_DIR"; exit 1; } | ||
| echo "cgt_root=$(dirname "$(dirname "$CL")")" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Compile-only guard | ||
| run: | | ||
| CGT_ROOT="${{ steps.find-cl.outputs.cgt_root }}" \ | ||
| scripts/ti-c2000/compile.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| #!/bin/sh | ||
| # compile.sh - compile-only guard for the TI C2000 (C28x, CHAR_BIT==16) port. | ||
| # | ||
| # Builds the wolfCrypt subset that compiles under CHAR_BIT==16 with the TI cl2000 | ||
| # code generation tools, using scripts/ti-c2000/user_settings.h. No linking, no | ||
| # C2000Ware, no hardware: this only catches compile regressions in the | ||
| # CHAR_BIT != 8 gated code paths (SHA-2/3/SHAKE, ML-DSA-87 verify, SP-ECC). | ||
| # | ||
| # Usage: | ||
| # CGT_ROOT=/path/to/ti-cgt-c2000_xx.y.z scripts/ti-c2000/compile.sh | ||
| # | ||
| # CGT_ROOT must point at a TI C2000 codegen install (the dir containing | ||
| # bin/cl2000). The CGT is a free download from TI; in CI it is fetched/cached | ||
| # by .github/workflows/ti-c2000-compile.yml. | ||
|
|
||
| set -e | ||
|
|
||
| : "${CGT_ROOT:?set CGT_ROOT to the ti-cgt-c2000 install (dir with bin/cl2000)}" | ||
|
|
||
| # Repo root = two levels up from this script. | ||
| SELF_DIR=$(cd "$(dirname "$0")" && pwd) | ||
| WOLFROOT=$(cd "$SELF_DIR/../.." && pwd) | ||
| CL="$CGT_ROOT/bin/cl2000" | ||
|
|
||
| if [ ! -x "$CL" ]; then | ||
| echo "ERROR: cl2000 not found/executable at $CL" >&2 | ||
| exit 2 | ||
| fi | ||
|
|
||
| OUT=$(mktemp -d) | ||
| trap 'rm -rf "$OUT"' EXIT | ||
|
|
||
| INCS="-I$CGT_ROOT/include -I$WOLFROOT -I$SELF_DIR" | ||
| CFLAGS="-v28 --abi=eabi --float_support=fpu32 --tmu_support=tmu1 -O2 \ | ||
| --define=WOLFSSL_USER_SETTINGS --display_error_number --diag_warning=225" | ||
|
|
||
| # wolfCrypt sources to compile-guard under CHAR_BIT==16. This is the set that | ||
| # carries the CHAR_BIT != 8 gated fixes (plus their direct deps) - the | ||
| # regression surface for this port. hash.c (an unmodified dispatch wrapper) is | ||
| # intentionally omitted: its wc_OidGetHash() OID switch needs the fuller ASN/OID | ||
| # config of a real build to avoid a 16-bit-int case-label fold, and it is | ||
| # covered by the on-target example build, not by this minimal guard. | ||
| SRCS="error wc_port memory logging misc coding \ | ||
| sha256 sha512 sha3 wc_mldsa random ecc sp_int sp_c32" | ||
|
|
||
| rc=0 | ||
| for s in $SRCS; do | ||
| printf 'CC %s.c ... ' "$s" | ||
| if "$CL" $CFLAGS $INCS --compile_only --skip_assembler \ | ||
| --asm_directory="$OUT" --obj_directory="$OUT" \ | ||
| "$WOLFROOT/wolfcrypt/src/$s.c" > "$OUT/$s.log" 2>&1; then | ||
| echo "ok" | ||
| else | ||
| echo "FAIL" | ||
| cat "$OUT/$s.log" | ||
| rc=1 | ||
| fi | ||
| done | ||
|
|
||
| if [ "$rc" -eq 0 ]; then | ||
| echo "TI C2000 compile-only guard: PASS" | ||
| else | ||
| echo "TI C2000 compile-only guard: FAIL" >&2 | ||
| fi | ||
| exit "$rc" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| /* user_settings.h - minimal wolfCrypt config for the TI C2000 (C28x, | ||
| * CHAR_BIT==16) compile-only CI guard. | ||
| * | ||
| * This is NOT a board config: it has no BSP/device dependencies. Its only job | ||
| * is to enable the subset of wolfCrypt that exercises the CHAR_BIT != 8 gated | ||
| * code paths (SHA-2/3/SHAKE, ML-DSA-87 verify, ECDSA/ECDH P-256 via SP math) | ||
| * so that scripts/ti-c2000/compile.sh can compile them with cl2000 and catch | ||
| * regressions. cl2000 predefines __TMS320C28XX__, so types.h auto-enables | ||
| * WOLFSSL_WIDE_BYTE; we do not set it here. | ||
| */ | ||
| #ifndef TI_C2000_CI_USER_SETTINGS_H | ||
| #define TI_C2000_CI_USER_SETTINGS_H | ||
|
|
||
| #define WOLFCRYPT_ONLY /* crypto only - no TLS (no MD5/SHA1 dep) */ | ||
| #define WOLFSSL_GENERAL_ALIGNMENT 2 | ||
| #define HAVE_LIMITS_H | ||
| #define WOLFSSL_NO_ASM | ||
| #define NO_INLINE | ||
| #define SINGLE_THREADED | ||
| #define NO_FILESYSTEM | ||
| #define NO_WOLFSSL_DIR | ||
| #define NO_MAIN_DRIVER | ||
| #define NO_DEV_RANDOM | ||
| #define WOLFSSL_IGNORE_FILE_WARN | ||
| #define BENCH_EMBEDDED | ||
| #define NO_WOLFSSL_MEMORY | ||
| #define WOLFSSL_GENSEED_FORTEST /* dev-only seed; no TRNG on this part */ | ||
|
|
||
| /* Hashes */ | ||
| #define WOLFSSL_SHA512 | ||
| #define WOLFSSL_SHA384 | ||
| #define WOLFSSL_SHA3 | ||
| #define WOLFSSL_SHAKE128 | ||
| #define WOLFSSL_SHAKE256 | ||
|
|
||
| /* ML-DSA-87 verify (smallest-mem streaming verifier) */ | ||
| #define WOLFSSL_HAVE_MLDSA | ||
| #define WOLFSSL_NO_ML_DSA_44 | ||
| #define WOLFSSL_NO_ML_DSA_65 | ||
| #define WOLFSSL_MLDSA_NO_ASN1 | ||
| #define WOLFSSL_MLDSA_VERIFY_ONLY | ||
| #define WOLFSSL_MLDSA_VERIFY_SMALL_MEM | ||
| #define WOLFSSL_MLDSA_VERIFY_NO_MALLOC | ||
| #define WOLFSSL_MLDSA_VERIFY_SMALLEST_MEM | ||
| #undef WOLFSSL_MLDSA_ALIGNMENT | ||
| #define WOLFSSL_MLDSA_ALIGNMENT 16 | ||
| #define WOLFSSL_SMALL_STACK | ||
|
|
||
| /* ECDSA / ECDH P-256 via SP single-precision math (sp_c32.c) */ | ||
| #define HAVE_ECC | ||
| #define ECC_USER_CURVES | ||
| #define HAVE_ECC256 | ||
| #define HAVE_ECC_VERIFY | ||
| #define HAVE_ECC_SIGN | ||
| #define HAVE_ECC_DHE | ||
| #define ECC_TIMING_RESISTANT | ||
| #define WOLFSSL_SP_MATH | ||
| #define WOLFSSL_HAVE_SP_ECC | ||
| #define WOLFSSL_SP_NO_MALLOC | ||
| #define WOLFSSL_SP_SMALL | ||
| #define SP_WORD_SIZE 32 | ||
| #define WOLFSSL_SP_ALLOW_16BIT_CPU | ||
|
|
||
| /* Off: anything that pulls in big-int/ASN/symmetric not under test here. */ | ||
| #define NO_RSA | ||
| #define NO_DH | ||
| #define NO_DSA | ||
| #define NO_ASN | ||
| #define NO_CERTS | ||
| #define NO_PWDBASED | ||
| #define NO_PKCS7 | ||
| #define NO_PKCS12 | ||
| #define NO_SIG_WRAPPER | ||
| #define NO_AES | ||
| #define NO_DES3 | ||
| #define NO_RC4 | ||
| #define NO_MD4 | ||
| #define NO_MD5 | ||
| #define NO_SHA | ||
| #define NO_HMAC | ||
| #define NO_ASN_TIME | ||
| #define WOLFSSL_USER_CURRTIME | ||
|
|
||
| #endif /* TI_C2000_CI_USER_SETTINGS_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.