Repository navigation
Add standalone Rust native primitives under native/ - #981
Closed
Gladwin Johnson VR (gladjohn) wants to merge 1 commit into
Closed
Gladwin Johnson VR (gladjohn) wants to merge 1 commit into
Gladwin Johnson VR (gladjohn) wants to merge 1 commit into
Conversation
Host the native workspace separately from Python runtime and packaging. Clarify compatible dependency ranges without changing the lockfile. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6fe4a5cf-79f6-48f9-aa71-bd8af58c504b
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The IPv6 request-sizing bug can exceed header limits and trigger buffer reallocation that leaves authorization-token data in an unwiped old allocation.
3 open issues
What changed in this PR
Adds the pre-release Microsoft.Identity.Native.Primitives project under native/, independently of MSAL Python’s runtime, packaging, and release process.
Changes:
- Imports Rust CNG/OpenSSL primitives, bounded mTLS transport, a C ABI, and native tests and examples.
- Adds standalone Windows CI, Cargo dependency monitoring, and build tooling.
- Adapts native development, security, support, and release documentation to this repository.
| File | Description |
|---|---|
| README.md | Introduces the standalone native project. |
| native/vcpkg.json | Pins the native OpenSSL dependency baseline. |
| native/THIRD-PARTY-NOTICES.md | Documents dependency notice obligations. |
| native/tests/native/support/cng_key.h | Declares CNG test-support functions. |
| native/tests/native/cng_test_pki.c | Generates local certificates and signing requests. |
| native/tests/native/cng_provider_test.c | Tests provider signing and private-export restrictions. |
| native/tests/native/cng_mtls_test_server.c | Supplies local TLS and HTTP test scenarios. |
| native/SUPPORT.md | Defines pre-release support scope. |
| native/SECURITY.md | Documents vulnerability reporting and sensitive areas. |
| native/scripts/test.ps1 | Runs Rust and native validation matrices. |
| native/scripts/loc.ps1 | Counts production Rust source lines. |
| native/scripts/build.ps1 | Builds and stages native artifacts. |
| native/rustfmt.toml | Configures Rust formatting. |
| native/README.md | Explains native capabilities and setup. |
| native/LICENSE | Supplies the native project’s MIT license. |
| native/include/microsoft_identity_native_primitives.h | Declares the public C ABI and ownership contract. |
| native/include/cng_provider_params.h | Defines provider parameters and limits. |
| native/examples/c/mtls_request.c | Demonstrates a certificate-bound request. |
| native/docs/versioning.md | Defines product, ABI, and dependency versioning. |
| native/docs/security-review.md | Defines security-review evidence requirements. |
| native/docs/security-model.md | Describes enforced properties and trust boundaries. |
| native/docs/releasing.md | Defines independent native release requirements. |
| native/docs/development.md | Documents contributor setup and practices. |
| native/docs/building-and-testing.md | Documents builds, tests, and OpenSSL servicing. |
| native/docs/architecture.md | Explains native components and request flow. |
| native/docs/abi.md | Documents ABI ownership and error handling. |
| native/deny.toml | Configures dependency and license policy checks. |
| native/crates/rust-tests/tests/key_creation_race.rs | Tests concurrent persisted-key creation. |
| native/crates/rust-tests/src/lib.rs | Adds an ABI-version smoke test. |
| native/crates/rust-tests/src/bin/key-race-helper.rs | Supports multiprocess key-creation tests. |
| native/crates/rust-tests/src/bin/key-audit.rs | Detects leftover project test keys. |
| native/crates/rust-tests/Cargo.toml | Configures cross-crate test utilities. |
| native/crates/openssl-provider-sys/src/lib.rs | Defines OpenSSL FFI types and functions. |
| native/crates/openssl-provider-sys/Cargo.toml | Configures the OpenSSL FFI crate. |
| native/crates/mtls-bridge/src/lib.rs | Exports request execution and response cleanup. |
| native/crates/mtls-bridge/src/abi.rs | Defines Rust ABI layouts and structured errors. |
| native/crates/mtls-bridge/Cargo.toml | Configures the transport library and DLL. |
| native/crates/cng-provider/src/uri.rs | Parses bounded CNG STORE URIs. |
| native/crates/cng-provider/src/store.rs | Implements OpenSSL STORE callbacks. |
| native/crates/cng-provider/src/params.rs | Handles OpenSSL parameter conversions. |
| native/crates/cng-provider/src/lib.rs | Registers provider algorithms and callbacks. |
| native/crates/cng-provider/src/keymgmt.rs | Implements provider key-management operations. |
| native/crates/cng-provider/src/key.rs | Manages opaque keys and public parameters. |
| native/crates/cng-provider/src/error.rs | Reports bounded provider errors. |
| native/crates/cng-provider/src/allocation.rs | Supplies fallible allocation helpers. |
| native/crates/cng-provider/Cargo.toml | Configures the OpenSSL provider DLL. |
| native/crates/cng-core/Cargo.toml | Configures the Windows CNG core crate. |
| native/CONTRIBUTING.md | Adapts native contribution requirements. |
| native/CMakeLists.txt | Builds external C tests and examples. |
| native/CHANGELOG.md | Records native history and repository migration. |
| native/Cargo.toml | Defines workspace metadata and compatible dependency ranges. |
| native/Cargo.lock | Records exact native Rust dependencies. |
| native/AGENTS.md | Documents native coding and review guidance. |
| native/.gitignore | Excludes generated native outputs. |
| native/.gitattributes | Defines native text and binary handling. |
| native/.editorconfig | Defines native editing conventions. |
| .github/workflows/native-primitives.yml | Adds independent Windows validation and dependency checks. |
| .github/dependabot.yml | Adds Cargo monitoring for /native. |
Review effort: Balanced
| .checked_add(1) | ||
| .and_then(|value| value.checked_add(request.target.len())) | ||
| .and_then(|value| value.checked_add(b" HTTP/1.1\r\nHost: ".len())) | ||
| .and_then(|value| value.checked_add(request.host.len())) |
Comment on lines
+102
to
+124
| let material = if selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY != 0 { | ||
| let Some(key) = source.private_key() else { | ||
| return null_mut(); | ||
| }; | ||
| KeyMaterial::Private(key.clone()) | ||
| } else { | ||
| let Some((modulus, exponent, bits)) = source.public_parts() else { | ||
| return null_mut(); | ||
| }; | ||
| let Some(modulus) = allocation::try_copy_bytes(modulus) else { | ||
| error::raise_memory_failure(); | ||
| return null_mut(); | ||
| }; | ||
| let Some(exponent) = allocation::try_copy_bytes(exponent) else { | ||
| error::raise_memory_failure(); | ||
| return null_mut(); | ||
| }; | ||
| KeyMaterial::Public { | ||
| modulus, | ||
| exponent, | ||
| bits, | ||
| } | ||
| }; |
| $env:NATIVE_PRIMITIVES_MTLS_POP_TOKEN = '<already-acquired-token>' | ||
|
|
||
| .\artifacts\Release\microsoft_identity_native_example.exe ` | ||
| .\artifacts\Release\microsoft_identity_native_provider.dll ` |
Contributor
Author
|
Superseded by #982, using feature/native-primitives directly in the AzureAD repository rather than a fork. The implementation and validated commit are unchanged. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Summary
Host the pre-release Microsoft.Identity.Native.Primitives project under top-level
native/, separate from themsal/Python package./native.Review feedback addressed
The source review noted that hardcoded crate versions could make future updates less flexible. Workspace dependencies now show explicit lower and upper compatible bounds, matching this repository's library dependency guidance.
The original Cargo requirements were already compatible caret ranges; this is a clarification, not a widening of compatibility or an unreviewed dependency upgrade.
Cargo.lockis unchanged. All native crates continue to inherit product-version and external-dependency metadata from the workspace. The native versioning guide documents targeted updates, lockfile review, complete validation, and compatibility review before changing upper bounds.Scope and compatibility
This remains a Windows x64, pre-release native project. The existing OpenSSL 3.6.3 development baseline and documented requirement to move to a reviewed supported baseline before production release are unchanged.
Provenance
Imported from
AzureAD/microsoft.identity.native.primitivescommit8c54819f52d9d18ff12f69b3c79ee18f630569b6(the project introduced in source PR #1). Source Git history is not imported.Verified all 40 implementation, ABI, native test/example, build/test script, lockfile, CMake, and vcpkg files byte-identical to the source checkout.
Validation
Passed locally on Windows x64 with Rust 1.97.1 MSVC, Visual Studio 2022, and the pinned OpenSSL 3.6.3 baseline:
native\scripts\test.ps1Debug/Release matrix: formatting, locked workspace/all-target checks, warnings-denied Clippy, 56 Rust tests per configuration, external native provider and ABI/mTLS integration tests, and project-owned CNG test-key cleanup audit.cargo auditandcargo deny check.twine check.The native implementation and dependency set are unchanged; this PR does not claim a new production security approval or release.