Skip to content

Latest commit

 

History

History
227 lines (196 loc) · 17.9 KB

File metadata and controls

227 lines (196 loc) · 17.9 KB

Verification

3.0.0 footprint integration

  • sizeof(mcrypt_sha256_t)=120, sizeof(mcrypt_hmac_sha256_t)=192, and sizeof(mcrypt_aes128_t)=184 on the measured 64-bit ABI; HMAC context storage changed from 320 B to 192 B.
  • GCC 13.3.0 -O2 -fstack-usage: SHA transform stack changed from 384 B on the 2.1 cleanup baseline to 192 B using the cleared 16-word schedule. SHA final remained 256 B; HMAC init/final measured 224 B/240 B.
  • SHA-256 and HMAC-SHA256 OpenSSL differential soaks each passed 100,000 deterministic boundary-biased cases. The GCC suite also passed the 50,000 case OpenSSL GCM soak.
  • GCC/Clang, i386, s390x QEMU, Cortex-M4, ASan+UBSan, GCM-disabled, hash-pinned NIST GCMVS (750/750), hash-pinned Wycheproof (67/67), relocatable consumer, and static-only BUILD_SHARED_LIBS=ON checks passed.
  • The prior local GCC benchmark found SHA reductions of 13.0% to 15.5% and HMAC reductions of 7.2% to 17.4%, depending on message size; this is the documented RAM/stack versus throughput tradeoff.

2.1.0 release-cleanup rerun

  • Hash-pinned NIST GCMVS archive (f9fc479e...f26a023) rerun: 375 encrypt, 179 valid decrypt, and 196 invalid decrypt cases passed; no unexpected accepts, crypto failures, or parser errors.
  • Hash-pinned Wycheproof revision b61843a9a5115bb758134b6a1f5d5e502d445342 (aes_gcm_test.json, SHA-256 985e5ecc...dc97dfe7) rerun: 67/67 selected cases passed (40 valid, 27 invalid).
  • Strict GCC and Clang suites, ASan+UBSan, i386 runtime, s390x QEMU runtime, Cortex-M4 compile, GCM-disabled build, static-only BUILD_SHARED_LIBS=ON, and a relocatable installed-package consumer test passed.

SHA-256 / HMAC-SHA256 footprint optimization

  • GCC 13.3.0 -O2 -fstack-usage: SHA transform stack changed from 368 to 192 bytes after replacing the 64-word schedule with a cleared 16-word ring buffer. SHA final remained 240 bytes. The GCC object .text size changed from 14,581 to 14,517 bytes.
  • mcrypt_hmac_sha256_t changed from 320 to 192 bytes on the measured 64-bit ABI. The 128-byte reduction removes stored normalized-key and inner pad data; only the outer pad remains until HMAC finalization. This public layout change is ABI-breaking.
  • OpenSSL differential verification: 100,000 deterministic SHA-256 cases (0..8192 bytes, boundary-biased) and 100,000 deterministic HMAC-SHA256 cases (keys 0..512 bytes, messages 0..8192 bytes, boundary-biased) passed.
  • Clang ASan+UBSan full self-test passed with a 1,000-case deterministic differential subset; the separately run full GCC/OpenSSL soak above used the default 100,000 cases for each primitive.
  • Strict GCC 13.3.0 i386 runtime self-test and strict s390x GCC/QEMU big-endian runtime self-test passed. Cortex-M4 strict C99 compile passed.
  • The ring schedule trades throughput for stack: the local GCC benchmark saw SHA changes of -13.0% (64 B), -14.9% (1 KiB), -15.2% (64 KiB), and -15.5% (1 MiB); HMAC changes were -7.2%, -11.7%, -17.4%, and -16.6% respectively.

AES-128-GCM verification

  • cmake -S . -B build-gcm-gcc-debug -G Ninja -DMICROCRYPT_BUILD_TESTS=ON -DMICROCRYPT_BUILD_DIFFERENTIAL_TESTS=ON -DMICROCRYPT_STRICT_WARNINGS=ON -DMICROCRYPT_ENABLE_AES_GCM=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=gcc
    • Result: WSL Ubuntu GCC 13.3.0 configured with OpenSSL differential oracle support.
  • cmake --build build-gcm-gcc-debug --parallel and ctest --test-dir build-gcm-gcc-debug --output-on-failure
    • Result: strict Debug build passed; 1/1 CTest tests passed.
  • cmake -S . -B build-gcm-sanitize -G Ninja -DMICROCRYPT_BUILD_TESTS=ON -DMICROCRYPT_BUILD_DIFFERENTIAL_TESTS=ON -DMICROCRYPT_STRICT_WARNINGS=ON -DMICROCRYPT_ENABLE_AES_GCM=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang -DCMAKE_C_FLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer"
    • Result: WSL Ubuntu Clang 18.1.3 configured with OpenSSL differential oracle support.
  • cmake --build build-gcm-sanitize --parallel, ctest --test-dir build-gcm-sanitize --output-on-failure, and ./build-gcm-sanitize/test_microcrypt
    • Result: ASan and UBSan run passed; 1/1 CTest tests passed; 20 tests, 179371 assertions, 0 failures.
  • cmake -S . -B build-gcm-disabled -G Ninja -DMICROCRYPT_BUILD_TESTS=ON -DMICROCRYPT_BUILD_DIFFERENTIAL_TESTS=OFF -DMICROCRYPT_STRICT_WARNINGS=ON -DMICROCRYPT_ENABLE_AES_GCM=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=gcc
    • Result: configured successfully.
  • cmake --build build-gcm-disabled --parallel and ctest --test-dir build-gcm-disabled --output-on-failure
    • Result: strict GCM-disabled build passed; 1/1 CTest tests passed.
  • arm-none-eabi-gcc -std=c99 -mcpu=cortex-m4 -mthumb -specs=nosys.specs -DMICROCRYPT_ENABLE_AES_GCM=1 -Iinclude -c src/mcrypt.c -o /tmp/mcrypt_gcm_arm.o
    • Result: Cortex-M4 compile smoke passed.
  • NIST AES-GCM vectors covered: empty plaintext, one zero block, and the published non-empty AAD/multi-block/partial-block vector.
  • The OpenSSL GCM differential oracle ran 512 deterministic random cases, including successful decrypt and corrupted-tag rejection.

AES-128-GCM destructive verification

  • A regression test found and fixed order-dependent AES-GCM encryption when AAD overlapped the payload output. The API now rejects metadata/payload aliasing with MCRYPT_ERR_OVERLAP; exact payload in-place operation remains supported.
  • WSL Ubuntu GCC 13.3.0, strict C99, -O3: OpenSSL-backed exhaustive matrix of 33,540 cases (plaintext_len=0..257, aad_len=0..129) and a 50,000-case boundary-biased deterministic soak both passed.
  • WSL Ubuntu Clang 18.1.3, ASan+UBSan: the exhaustive matrix and a 5,000-case deterministic soak passed without sanitizer findings.
  • Stack usage measured with GCC -O2 -fstack-usage: GCM encrypt 96 bytes dynamic/bounded, GCM decrypt 144 bytes dynamic/bounded; tag helper 176 bytes static; CTR helper 144 bytes static. CBC encrypt/decrypt measured 128/160 bytes static.
  • GCC -O2 object size: GCM enabled .text 14,581 bytes; disabled .text 11,021 bytes; delta 3,560 bytes. .data and .bss were zero for both objects.

AES-128-GCM external corpus and portability follow-up

  • NIST GCMVS vectors:
    • Source: https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Algorithm-Validation-Program/documents/mac/gcmtestvectors.zip
    • Archive: gcmtestvectors.zip; SHA-256: f9fc479e134cde2980b3bb7cddbcb567b2cd96fd753835243ed067699f26a023.
    • tests/gcm_external_runner.py --parser-selftest passed before corpus execution. It checks valid encrypt/decrypt records, decrypt FAIL, missing PT/CT/tag fields, incompatible IV/tag/key sizes, and an unsupported response-file type.
    • Compatible known-answer response records: encrypt 375/375 passed; decrypt-valid 179/179 passed; decrypt-invalid 196/196 correctly rejected; unexpected accepts 0; crypto failures 0; parser errors 0.
    • Skipped 46,500: response files outside the selected known-answer response-file types or records outside AES-128/96-bit-IV/128-bit-tag API profile. Incomplete compatible records: 0.
    • These are official published test vectors only; using them does not constitute CAVP or FIPS validation/certification of this project.
  • Project Wycheproof AES-GCM vectors:
    • Upstream: https://github.com/C2SP/wycheproof, commit b61843a9a5115bb758134b6a1f5d5e502d445342.
    • File: testvectors_v1/aes_gcm_test.json; SHA-256: 985e5ecc172e181eaf49e89508b9470dcf478002eb7e8559c707eb42dc97dfe7.
    • API-compatible cases: 67; valid 40/40 passed; invalid 27/27 rejected; acceptable 0; failures 0; skipped 249 for AES key, IV, or tag length outside the supported profile.
    • Wycheproof vectors are test material and are not a formal security audit.
  • 32-bit attempt, WSL Ubuntu GCC 13.3.0, gcc -m32:
    • A 32-bit object compiled when the -Wtype-limits diagnostic was not promoted (ELF 32-bit). No runtime was available.
    • The fully strict attempt stopped on gcm_lengths_valid: on a 32-bit size_t, casts of aad_len and payload_len to uint64_t can never exceed UINT64_MAX / 8. This is a redundant guard on that target, not a demonstrated arithmetic/runtime defect; production code was not changed.

AES-128-GCM big-endian runtime verification

  • Architecture: s390x (runtime confirmed big-endian: BIG_ENDIAN_CONFIRMED: YES).
  • Compiler: s390x-linux-gnu-gcc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0; target binary identified as ELF 64-bit MSB, IBM S/390.
  • QEMU: qemu-s390x version 8.2.2 (Debian 1:8.2.2+ds-0ubuntu1.18).
  • Strict C99 build passed with -Wall -Wextra -Wpedantic -Werror -Wconversion -Wsign-conversion -Wshadow -Wformat=2 -Wundef -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wvla.
  • BIG_ENDIAN_RUNTIME_HARNESS: PASS: AES block encrypt/decrypt KAT; empty and one-block GCM NIST vectors; NIST AAD/multi-block/partial-block vector; authentication failures for changed tag, ciphertext, AAD, nonce, and key, including out-of-place zeroisation and in-place preservation; and an OpenSSL-generated 88-case boundary corpus (11 payload lengths x 8 AAD lengths). Total checks 198, failures 0.
  • FULL_BIG_ENDIAN_SELF_TEST: PASS: cross-compiled tests/test_all.c ran under QEMU with 21 tests, 6,334 assertions, and 0 failures. The OpenSSL differential branch was unavailable on the target and reported NOT VERIFIED, not a passing differential test.
  • A first temporary harness run failed only because its manually transcribed NIST key used 8a where the project NIST vector uses 8f; after correcting the temporary test input, all checks passed. This was a harness transcription error, not a production-code defect.

AES-128-GCM 32-bit strict portability fix

  • gcm_lengths_valid formerly compared 32-bit size_t values, after conversion to uint64_t, with UINT64_MAX / 8. GCC correctly diagnosed both comparisons as always false on i386.
  • The bit-length overflow guard is now compiled only where SIZE_MAX > UINT64_MAX / 8; the 32-bit path does not compile impossible comparisons. This is a strict-warning portability fix only: no GCM algorithm, limit, or public API changed.
  • WSL Ubuntu GCC 13.3.0 i386: the required unsuppressed gcc -m32 strict source compile passed and produced an ELF 32-bit object. A full -m32 CMake build and ctest self-test run also passed (1/1).
  • The large-length validation regression covers UINT64_MAX / 8, the next value, and SIZE_MAX on platforms where those values fit in size_t; it uses small buffers and validation rejects before payload processing. On 32-bit, the corresponding fake ranges are rejected by overlap validation because their bit lengths themselves are representable.

Current Release Closure

MSYS2 UCRT64

  • cmake -S . -B build-msys2-gcc-debug -G Ninja -DMICROCRYPT_BUILD_TESTS=ON -DMICROCRYPT_BUILD_DIFFERENTIAL_TESTS=ON -DMICROCRYPT_STRICT_WARNINGS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=gcc
    • Result: configured with GNU 16.1.0; OpenSSL found
  • cmake --build build-msys2-gcc-debug --parallel
    • Result: built libmicrocrypt.a and test_microcrypt.exe
  • ctest --test-dir build-msys2-gcc-debug --output-on-failure
    • Result: 1/1 tests passed
  • ./build-msys2-gcc-debug/test_microcrypt.exe
    • Result: Suites: 1 Tests: 18 Assertions: 26332 Failures: 0
    • Result: no NOT VERIFIED: OpenSSL oracle unavailable line
  • cmake -S . -B build-msys2-gcc-release -G Ninja -DMICROCRYPT_BUILD_TESTS=ON -DMICROCRYPT_BUILD_DIFFERENTIAL_TESTS=ON -DMICROCRYPT_STRICT_WARNINGS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc
    • Result: configured with GNU 16.1.0; OpenSSL found
  • cmake --build build-msys2-gcc-release --parallel
    • Result: built libmicrocrypt.a and test_microcrypt.exe
  • ctest --test-dir build-msys2-gcc-release --output-on-failure
    • Result: 1/1 tests passed
  • cmake -S . -B build-msys2-clang-debug -G Ninja -DMICROCRYPT_BUILD_TESTS=ON -DMICROCRYPT_BUILD_DIFFERENTIAL_TESTS=ON -DMICROCRYPT_STRICT_WARNINGS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang
    • Result: configured with Clang 22.1.7 and MinGW target auto-detection; OpenSSL found
  • cmake --build build-msys2-clang-debug --parallel
    • Result: built libmicrocrypt.a and test_microcrypt.exe
    • Result: warnings about unused --gcc-toolchain argument remained non-fatal
  • ctest --test-dir build-msys2-clang-debug --output-on-failure
    • Result: 1/1 tests passed
  • cmake -S . -B build-msys2-clang-release -G Ninja -DMICROCRYPT_BUILD_TESTS=ON -DMICROCRYPT_BUILD_DIFFERENTIAL_TESTS=ON -DMICROCRYPT_STRICT_WARNINGS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang
    • Result: configured with Clang 22.1.7 and MinGW target auto-detection; OpenSSL found
  • cmake --build build-msys2-clang-release --parallel
    • Result: built libmicrocrypt.a and test_microcrypt.exe
    • Result: warnings about unused --gcc-toolchain argument remained non-fatal
  • ctest --test-dir build-msys2-clang-release --output-on-failure
    • Result: 1/1 tests passed
  • cmake -S . -B build-msys2-gcc-lto -G Ninja -DMICROCRYPT_BUILD_TESTS=ON -DMICROCRYPT_BUILD_DIFFERENTIAL_TESTS=ON -DMICROCRYPT_STRICT_WARNINGS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON
    • Result: configured with GNU 16.1.0; OpenSSL found and IPO enabled
  • cmake --build build-msys2-gcc-lto --parallel
    • Result: built libmicrocrypt.a and test_microcrypt.exe
  • ctest --test-dir build-msys2-gcc-lto --output-on-failure
    • Result: 1/1 tests passed

Makefile Path

  • cd tests && make clean && make
    • Result: built and ran test_all
    • Result: Suites: 1 Tests: 18 Assertions: 26332 Failures: 0
    • Result: no NOT VERIFIED: OpenSSL oracle unavailable line

MSVC Release

  • cmake -S . -B build-msvc-release-ninja2 -G Ninja -DCMAKE_MAKE_PROGRAM=C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe -DMICROCRYPT_BUILD_TESTS=ON -DMICROCRYPT_BUILD_DIFFERENTIAL_TESTS=ON -DMICROCRYPT_STRICT_WARNINGS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=cl
    • Result: configured with MSVC 19.42.34444.0; OpenSSL found
  • cmake --build build-msvc-release-ninja2 --parallel
    • Result: built microcrypt.lib and test_microcrypt.exe
  • ctest --test-dir build-msvc-release-ninja2 --output-on-failure
    • Result: 1/1 tests passed

Install / Consumer

  • cmake --install build-msvc-release-ninja2 --config Release --prefix C:/Users/vande/Desktop/github/microcrypt/microcrypt/stage-install-msvc
    • Result: installed microcrypt.lib, mcrypt.h, and CMake package files
  • cmake -S tests/consumer -B build-consumer-msvc-install -G Ninja -DCMAKE_MAKE_PROGRAM=C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe -DCMAKE_PREFIX_PATH=C:/Users/vande/Desktop/github/microcrypt/microcrypt/stage-install-msvc -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=cl
    • Result: configured against the install tree package
  • cmake --build build-consumer-msvc-install --parallel
    • Result: built consumer.exe
  • build-consumer-msvc-install/consumer.exe
    • Result: ba7816bf

ARM Smoke

  • arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -specs=nosys.specs -Iinclude -c arm_smoke.c -o arm_smoke.o
    • Result: compiled successfully
  • arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -specs=nosys.specs -Iinclude -c src/mcrypt.c -o mcrypt_arm.o
    • Result: compiled successfully
  • arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -specs=nosys.specs arm_smoke.o mcrypt_arm.o -o microcrypt-arm.elf
    • Result: linked successfully with nosys warnings for _close, _lseek, _read, and _write

Analysis

  • cppcheck --project=build-analysis/compile_commands.json --enable=warning,style,performance,portability --inline-suppr --suppress=missingIncludeSystem
    • Result: no warnings after the current source cleanup
  • clang-tidy -p build-analysis src/mcrypt.c tests/test_all.c --checks=clang-analyzer-core.*,-clang-analyzer-security.insecureAPI.*,-clang-analyzer-deadcode.*
    • Result: completed with no diagnostics

WSL Ubuntu

  • C:\Windows\System32\wsl.exe -d Ubuntu-24.04 -- bash -lc "cd /mnt/c/Users/vande/Desktop/github/microcrypt/microcrypt && pwd && uname -a && gcc --version && clang --version && cmake --version && ninja --version && openssl version"
    • Result: /mnt/c/Users/vande/Desktop/github/microcrypt/microcrypt
    • Result: Linux Vanderhell 6.6.87.2-microsoft-standard-WSL2
    • Result: gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
    • Result: Ubuntu clang version 18.1.3
    • Result: cmake version 3.28.3
    • Result: 1.11.1
    • Result: OpenSSL 3.0.13 30 Jan 2024
  • C:\Windows\System32\wsl.exe -d Ubuntu-24.04 -- bash -lc "cd /mnt/c/Users/vande/Desktop/github/microcrypt/microcrypt && rm -rf build-wsl-sanitize && cmake -S . -B build-wsl-sanitize -G Ninja -DMICROCRYPT_BUILD_TESTS=ON -DMICROCRYPT_BUILD_DIFFERENTIAL_TESTS=ON -DMICROCRYPT_STRICT_WARNINGS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang -DCMAKE_C_FLAGS='-fsanitize=address,undefined -fno-omit-frame-pointer'"
    • Result: configured successfully with Clang 18.1.3
    • Result: OpenSSL found: differential oracle support available
    • Result: build files written to build-wsl-sanitize
  • C:\Windows\System32\wsl.exe -d Ubuntu-24.04 -- bash -lc "cd /mnt/c/Users/vande/Desktop/github/microcrypt/microcrypt && cmake --build build-wsl-sanitize --parallel"
    • Result: build passed
    • Result: linked test_microcrypt
  • C:\Windows\System32\wsl.exe -d Ubuntu-24.04 -- bash -lc "cd /mnt/c/Users/vande/Desktop/github/microcrypt/microcrypt && ctest --test-dir build-wsl-sanitize --output-on-failure"
    • Result: 1/1 tests passed
    • Result: 0 tests failed
    • Result: total test time 0.38 sec
  • C:\Windows\System32\wsl.exe -d Ubuntu-24.04 -- bash -lc "cd /mnt/c/Users/vande/Desktop/github/microcrypt/microcrypt && ./build-wsl-sanitize/test_microcrypt"
    • Result: Suites: 1 Tests: 18 Assertions: 26332 Failures: 0
    • Result: test_differential_oracle_or_skip passed
    • Result: no NOT VERIFIED: OpenSSL oracle unavailable line

Notes

  • OpenSSL-backed differential tests are enabled when libcrypto is found.
  • The test binary no longer prints NOT VERIFIED: OpenSSL oracle unavailable when OpenSSL is available.