Repository navigation
[Objective-C] Add encrypted compiled EPContext inference coverage - #33223
Gopalakrishnan Nallasamy (GopalakrishnanN) wants to merge 8 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ture Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The tamper control modifies the HMAC tag rather than ciphertext, so the stated altered-ciphertext case is not covered.
2 open findings
What changed in this PR
Adds Objective-C end-to-end coverage for encrypted compiled EPContext model restoration and inference, building on #33216.
Changes:
- Adds an executable Mul EPContext fixture and generated model.
- Adds encrypted Objective-C compilation, restoration, negative, and inference tests.
- Provisions the plugin/model for macOS XCTest and documents the workflow.
| File | Description |
|---|---|
.gitignore |
Tracks the generated ONNX fixture. |
cmake/onnxruntime_objectivec.cmake |
Links Security.framework and provisions test assets/plugin. |
docs/design/Compiled_Model_Encryption.md |
Documents binding workflows and Objective-C coverage. |
objectivec/test/ort_encrypted_ep_context_test.mm |
Implements encrypted EPContext integration testing. |
onnxruntime/test/autoep/library/example_plugin_ep/ep.cc |
Serializes and restores executable Mul context. |
onnxruntime/test/autoep/library/example_plugin_ep/ep.h |
Adds restored-kernel state and configuration. |
onnxruntime/test/autoep/library/example_plugin_ep/ep_factory.cc |
Parses the execution-test option. |
onnxruntime/test/testdata/encrypted_ep_context_mul.py |
Generates the two-input Mul model. |
onnxruntime/test/testdata/encrypted_ep_context_mul.onnx |
Provides the bundled source-model fixture. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use the existing unordered-map overload explicitly so GCC and Clang do not have to choose between the map and parallel-vector options overloads. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Match NSUInteger operands to avoid Clang -Werror=sign-compare failures in the macOS Debug matrix. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Fixed both macOS Debug -Werror=sign-compare errors by making expected XCTest counts NSUInteger, plus the shared Linux fixture overload ambiguity. Pushed 8de1640. Corrected C++ fixture call passed MSVC C++17 /W4 /WX syntax validation; Apple XCTest compilation requires the newly triggered macOS CI. No old-head runs were manually retriggered. |
|
Retried only the confirmed DNS-failed current-head iPhone simulator job after the macOS workflow completed. Original setup error: getaddrinfo ENOTFOUND github.com while downloading CMake. No stale-head or green jobs were retriggered. |
Tianlei Wu (tianleiwu)
left a comment
There was a problem hiding this comment.
The Objective-C XCTest (ort_encrypted_ep_context_test.mm) and CMake wiring are well structured, with a clean AES-256-CBC + encrypt-then-HMAC-SHA256 construction and thorough negative controls.
Requesting changes for one blocking compile issue on Apple Clang: objectivec/test/ort_encrypted_ep_context_test.mm line 147 still calls native.AppendExecutionProvider_V2(nativeEnv, {*device}, {}) with {} as the third argument, which is ambiguous on Clang (the same issue fixed for test_execution.cc in fcdaaa40eb).
Move plugin-dependent tests outside the Swift package source tree into a separate macOS XCTest target. Confine native setup to a fixture adapter, disambiguate provider options, and verify plaintext cleanup after an unregister exception. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>


Description
Add a standalone macOS Objective-C XCTest target for the complete compiled-model/context workflow:
objectivec/tree copied to the Swift package repository. The separateonnxruntime_objc_encryption_testtarget owns its plugin dependency, Security framework, model resource, and CTest environment; ordinary Objective-C tests have none of those extra dependencies.testCleanupRemovesPlaintextWhenUnregisterThrowsto cover that failure path.The public Objective-C session constructor is path-only. Decrypted compiled ONNX is temporarily persisted during loading and removed during cleanup; external context plaintext remains in memory. This does not establish no-plaintext-at-any-time coverage.
Dependency: #33216. This branch contains the identical shared fixture prerequisite commit so it can receive normal PR CI against main. Merge #33216 first; its changes should then disappear from this PR's diff.
Validation
clang-format --dry-run --Werror onnxruntime\test\platform\apple\ort_encrypted_ep_context_test.mm onnxruntime\test\platform\apple\ort_ep_context_fixture.h onnxruntime\test\platform\apple\ort_ep_context_fixture.mm: passed.git diff --check: passed.ctest --test-dir <Apple build directory> -C Release -R '^XCTest.onnxruntime_objc_encryption_test$' --output-on-failure. Both the encrypted-inference test and unregister-failure cleanup regression must execute successfully. The target fails rather than skips if its required plugin path is missing.Existing macOS full-build CTest execution discovers the separate target automatically. No encrypted-workflow execution is claimed for ordinary XCTest runs, iOS, or the Swift package.
Motivation and Context
Follow up the APIs from #32265 and merged Objective-C binding #32309 with real compiled-state transport and numerical inference coverage. Ordinary model loads and callback-only tests do not prove restored external EPContext execution.
The isolation addresses the Swift package synchronization constraint without adding new public APIs or requiring the copied Objective-C test suite to depend on ORT's example plugin target.