Converts the Path A pipeline from stubs to a working implementation for A5-A11 devices, adds real certificate extraction via lockdownd and ECDSA P-256 signing, and introduces a comprehensive mock-based test suite. Activation - cert_extract: lockdownd-backed DeviceCertificate, AccountTokenCertificate, UniqueDeviceCertificate with base64 decode and CertificateChain array fallback. - signer: OpenSSL EVP ECDSA P-256 sign/verify with DER-encoded signatures plus a test keypair generator. - record.c: 3 of 6 cert fields now populate from live device data. AccountTokenSignature signs when TR4MPASS_SIGNING_KEY is set. FairPlayKeyData, RKCData, SepNonce remain documented stubs (SEP-blocked per 26.3-vulnerability.md). Path A bypass - path_a_ramdisk: iBSS/iBEC/devicetree/trustcache/ramdisk upload via libirecovery, reconnect handling between DFU and recovery stages, iBoot go/bootx commands, SSH readiness poll. - path_a_ssh: libssh2 + SCP. Mounts rootfs rw (apfs then hfs), runs AMFI patcher, backs up and replaces /usr/libexec/mobileactivationd with a user-supplied patched binary, verifies mode. Build, CLI, config - Makefile: add libssh2 dependency, split test targets into hw-independent (make test) and full mock (make test-mocks). - env_config + cli_flags: 12 new --flags for ramdisk, SSH, signing paths; flags map to TR4MPASS_* env vars. --verbose prints summary. - start.sh slimmed; helpers extracted to start-helpers.sh. Test suite (20 to 248 tests) - Mock framework under tests/mocks/ intercepts libimobiledevice, libirecovery, libusb, libssh2, libcurl, plus mobileactivation and afc. Staging API in mock_control.h. - Unit tests per module: cert_extract, signer, ramdisk, SSH jailbreak, env_config. - Integration tests in tests/integration/: 6 Path A E2E scenarios (happy path, exploit fail, reconnect timeout, SSH auth fail, SCP fail, missing env) and 3 Path B scenarios (identity manipulation works, nonce barrier rejection is handled cleanly, signal detection). Path B tests verify the tool reports the SEP barrier failure rather than misclaiming success. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
58 lines
1.9 KiB
C
58 lines
1.9 KiB
C
/*
|
|
* test_framework.h -- Assertion macros and counters for tr4mpass unit tests.
|
|
*
|
|
* Shared by every test_*.c file. The counters live in test_main.c.
|
|
* Include this header from each test translation unit; do not duplicate
|
|
* the `extern int g_passes` in the .c files.
|
|
*/
|
|
|
|
#ifndef TR4MPASS_TEST_FRAMEWORK_H
|
|
#define TR4MPASS_TEST_FRAMEWORK_H
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
/* Pass/fail counters defined in tests/test_main.c. */
|
|
extern int g_passes;
|
|
extern int g_failures;
|
|
|
|
#define ASSERT(expr) do { \
|
|
if (!(expr)) { \
|
|
fprintf(stderr, "FAIL %s:%d %s\n", __FILE__, __LINE__, #expr); \
|
|
g_failures++; \
|
|
} else { \
|
|
g_passes++; \
|
|
} \
|
|
} while (0)
|
|
|
|
#define ASSERT_EQ(a, b) ASSERT((a) == (b))
|
|
#define ASSERT_NEQ(a, b) ASSERT((a) != (b))
|
|
#define ASSERT_NULL(p) ASSERT((p) == NULL)
|
|
#define ASSERT_NOTNULL(p) ASSERT((p) != NULL)
|
|
#define ASSERT_STREQ(a, b) ASSERT((a) && (b) && strcmp((a), (b)) == 0)
|
|
#define ASSERT_STRSTR(h, n) ASSERT((h) && (n) && strstr((h), (n)) != NULL)
|
|
#define ASSERT_MEM_EQ(a, b, n) ASSERT((a) && (b) && memcmp((a), (b), (n)) == 0)
|
|
#define ASSERT_LT(a, b) ASSERT((a) < (b))
|
|
#define ASSERT_GT(a, b) ASSERT((a) > (b))
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
/* Section entry points */
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
/* Existing hardware-independent tests */
|
|
void run_serial_parse_tests(void);
|
|
void run_chip_db_tests(void);
|
|
void run_bypass_probe_tests(void);
|
|
void run_constant_tests(void);
|
|
|
|
/* Phase 2 placeholders (filled in by other agents) */
|
|
void run_cert_extract_tests(void);
|
|
void run_signer_tests(void);
|
|
void run_ramdisk_tests(void);
|
|
void run_ssh_jailbreak_tests(void);
|
|
|
|
/* Phase 3 integration sections (mock-only) */
|
|
void run_path_a_integration_tests(void);
|
|
void run_path_b_integration_tests(void);
|
|
|
|
#endif /* TR4MPASS_TEST_FRAMEWORK_H */
|