Repository navigation
feat: wrap sensitive types in order to zero the memory on drop (#1240) - #1369
Conversation
kkohbrok
left a comment
There was a problem hiding this comment.
Thanks for the PR! I talked about your proposal with @franziskuskiefer and @raphaelrobert and we came to the conclusion that deriving zeroize on the level of tls_codec might be a better option. We can then change the relevant structs you highlight in this PR to use the corresponding type from tls_codec.
I filed a draft PR in tls_codec as basis for further discussion and I would suggest we wait with this PR until that discussion is settled. In case you want to chime in: RustCrypto/formats#1029
| TlsSize, | ||
| zeroize::ZeroizeOnDrop, | ||
| )] | ||
| pub(crate) struct MacValue(Vec<u8>); |
There was a problem hiding this comment.
MACs are generally considered public information. Is there a reason you want to derive ZeroizeOnDrop for them?
There was a problem hiding this comment.
I didn't know. I thought it was secret as it can be constructed from a secret.
There was a problem hiding this comment.
Fair point. In fact I just realized that we're being a bit sloppy by computing a MAC by calling HKDF extract. That works, but only as long as the HPKE ciphersuite uses an HKDF as its key derivation function. I filed #1375 to fix this (although it's functionally correct for now).
That being said, MACs are constructed in a similar way that ciphertexts are constructed from an encryption key, so I think we can do away with zeroize here.
|
With #1376 merged, you should now be able to just use |
In the types that were using |
|
Good question. I guess it's going to be functionally the same since VLBytes is just a wrapper around Vec. Then I guess if it lets us avoid depending on zeroize explicitly, just use the |
Another question. Should we also change the |
|
Good point, if we want to be thorough, the output of those functions should be covered as well. |
kkohbrok
left a comment
There was a problem hiding this comment.
Looks good! Thanks for making the additional changes.
Replace `private: Vec<u8>` with `private: SecretVLBytes` in `SignatureKeyPair`. `SecretVLBytes` from `tls_codec` derives `Zeroize` and `ZeroizeOnDrop`, ensuring Ed25519/P-256 private key bytes are zeroed when the struct is dropped. This follows the same pattern used in PR openmls#1369 for `HpkePrivateKey` and `ExporterSecret`. Closes openmls#1969
Replace `private: Vec<u8>` with `private: SecretVLBytes` in `SignatureKeyPair`. `SecretVLBytes` from `tls_codec` derives `Zeroize` and `ZeroizeOnDrop`, ensuring Ed25519/P-256 private key bytes are zeroed when the struct is dropped. This follows the same pattern used in PR openmls#1369 for `HpkePrivateKey` and `ExporterSecret`. A custom serde helper (`secret_bytes_as_vec`) preserves the original `Vec<u8>` serialization format for backward compatibility with stored key pairs — `SecretVLBytes` wraps `VLBytes { vec }` which serde would otherwise serialize as `{"vec": [...]}`. Closes openmls#1969
Replace `private: Vec<u8>` with `private: SecretVLBytes` in `SignatureKeyPair`. `SecretVLBytes` from `tls_codec` derives `Zeroize` and `ZeroizeOnDrop`, ensuring Ed25519/P-256 private key bytes are zeroed when the struct is dropped. This follows the same pattern used in PR openmls#1369 for `HpkePrivateKey` and `ExporterSecret`. Additional hardening: - Ed25519: use `as_bytes()` instead of `to_bytes()` to avoid an unzeroed 32-byte stack copy of the private key - P-256: explicitly zeroize the `FieldBytes` temporary after copying into `SecretVLBytes` - Serde: custom `secret_bytes_as_vec` helper preserves the original `Vec<u8>` serialization format for backward compatibility with stored key pairs Closes openmls#1969
…1973) ## Summary Replaces `private: Vec<u8>` with `private: SecretVLBytes` in `SignatureKeyPair`, ensuring Ed25519/P-256 private key bytes are automatically zeroed when the struct is dropped. This follows the same pattern established in #1369 for `HpkePrivateKey` and `ExporterSecret`. ## Changes - `basic_credential/src/lib.rs`: `private` field type changed from `Vec<u8>` to `SecretVLBytes` - Construction sites updated to use `From<&[u8]>` / `From<Vec<u8>>` conversions - `private()` test-utils accessor updated to use `as_slice()` - No API changes — `from_raw()` still accepts `Vec<u8>` (converted internally) ## Testing - `cargo check -p openmls -p openmls_basic_credential -p openmls_rust_crypto --features test-utils` — clean - `cargo test -p openmls --lib --features test-utils` — 1732 passed, 0 failed Closes #1969
* chore: prepare v0.7.1 release (#1850) * prepare v0.7.1 release * Improve changelogs * Use -rc. instead of -pre. --------- Co-authored-by: Konrad Kohbrok <[email protected]> * follow up on v0.7.1 (#1852) * release v0.7.1 (#1853) * doc: Book corrections and fixes, prettier fmt *.md files (#1817) * Add Swap Members API (#1855) * readd api A simple re-add API that allows removing and adding the same members. This may help with recovering from bad group states. * address PR feedback * readd fixes * clippy * clippy tests * rename to swap_members * Apply suggestions from code review Co-authored-by: raphaelrobert <[email protected]> * fmt --------- Co-authored-by: Jan Winkelmann (keks) <[email protected]> Co-authored-by: Jan Winkelmann <[email protected]> Co-authored-by: raphaelrobert <[email protected]> * extend changelog from #1855 (#1857) * chore: allow deprecated warnings in rustcrypto for now (#1858) * Update validation for extension types of leaf node extensions (#1831) * test adding an ApplicationIdExtension to the leaf node extensions * check leaf node extensions with `is_valid_in_leaf_node()` * improve comments * update doc comment * update comment * validate extensions on `LeafNodeParametersBuilder` * validate leaf node extension types * update test * add tests * move validation logic to method * add note to `LeafNode::validate_locally()` about extension type validation * improve comment * remove unneeded flag * improve comment * improve comment * fix link * add validation check references and update comment * update note about extension type validation * improve comment * Fix references to validation dashboard for some tests (#1861) * update test names * add references to validation checks * chore: psk validation when processing welcome messages (#1862) Fixes parts of #1122. - Only reinit and branch resumption PSKs in Welcomes - Only one reinit or branch resumption PSK in Welcomes - Check PSK nonce length in Welcomes * feat: add sqlx based storage provider (#1854) * chore: update PSK validation id comments (#1863) * feat: add from_components method to avoid allocations in TreeNode (#1864) * doc: correct RFC section reference in key schedule documentation (#1865) * fix: store application export tree after group creation (#1871) * chore: fix PPRF tests (#1870) * feat: add `extensions-draft-08` support to sqlx storage provider (#1872) * Implement AppEphemeral proposal and update AppAck implementation (#1868) * docs: add docsrs cfg feature and document features * update dependabot * For `extensions-draft-08` flag, selectively enable optional storage provider dependencies (#1876) * in `extensions-draft-08` feature, selectively enable optional dependency features * add `extensions-draft-08` feature to libcrux crypto provider * chore(deps): update criterion requirement from ^0.5 to ^0.7 Updates the requirements on [criterion](https://github.com/bheisler/criterion.rs) to permit the latest version. - [Changelog](https://github.com/bheisler/criterion.rs/blob/master/CHANGELOG.md) - [Commits](bheisler/criterion.rs@0.5.0...0.7.0) --- updated-dependencies: - dependency-name: criterion dependency-version: 0.7.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> * chore(deps): update rstest requirement from 0.24 to 0.26 Updates the requirements on [rstest](https://github.com/la10736/rstest) to permit the latest version. - [Release notes](https://github.com/la10736/rstest/releases) - [Changelog](https://github.com/la10736/rstest/blob/master/CHANGELOG.md) - [Commits](la10736/rstest@v0.24.0...v0.26.1) --- updated-dependencies: - dependency-name: rstest dependency-version: 0.26.1 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> * chore(deps): update refinery requirement from 0.8 to 0.9 Updates the requirements on [refinery](https://github.com/rust-db/refinery) to permit the latest version. - [Release notes](https://github.com/rust-db/refinery/releases) - [Changelog](https://github.com/rust-db/refinery/blob/main/CHANGELOG.md) - [Commits](rust-db/refinery@0.8.4...v0.9.0) --- updated-dependencies: - dependency-name: refinery dependency-version: 0.9.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> * [CI] Build workspace with `extensions-draft-08` feature flag, and simplify `openmls` crate feature build combinations (#1894) * group all developer options in `cargo hack` command * test `extensions-draft-08` feature in workspace * chore(deps): bump actions/checkout from 4 to 5 Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v4...v5) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * Add AES-GCM support to libcrux provider, and update libcrux dependencies (#1874) * update libcrux dependencies * use `libcrux-aead` APIs for chacha20poly1305 * add AES-GCM support * update changelogs * add provider aead test * use git dependency for `hpke-rs` * chore(deps): update indicatif requirement from 0.17.8 to 0.18.3 Updates the requirements on [indicatif](https://github.com/console-rs/indicatif) to permit the latest version. - [Release notes](https://github.com/console-rs/indicatif/releases) - [Commits](console-rs/indicatif@0.17.8...0.18.3) --- updated-dependencies: - dependency-name: indicatif dependency-version: 0.18.3 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> * chore(deps): bump actions/checkout from 5 to 6 Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v5...v6) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * feat: optimize Signable to reuse serialized payload * chore(deps): update thiserror requirement from 1.0 to 2.0 --- updated-dependencies: - dependency-name: thiserror dependency-version: 2.0.17 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> * book: remove multilingual config * ci: remove crypto-subtle feature from cargo hack * Implement HPKE safe encrypt/decrypt with label (MLS Extensions Draft) (#1898) * implement safe encrypt and decrypt * add component module * fixup: rustdoc links * Remove nightly-only cargo fmt config settings * correction in tree operations KAT * bump hpke to 0.4 (#1911) * Improve the error return types in TreeSync * chore: update hpke-rs to 0.5.0 * add from_bytes wasm bindings for KeyPackage/RatchetTree * ci: update tests * Add injection and handling for GREASE values * Always add grease * Enhance GREASE support by adding convenience methods for injecting random GREASE values into capabilities. Update documentation to clarify GREASE handling and ensure users opt-in for GREASE value inclusion. Adjust tests to reflect changes in GREASE injection behavior. * Formatting fix * Update CHANGELOG and user manual to reflect GREASE enhancements and clarify usage. Added details on RFC-defined vs. custom GREASE values, and emphasized the purpose of GREASE in implementation. * Fix typo in test comment for own messages (#1917) Co-authored-by: raphaelrobert <[email protected]> * chore(deps): update reqwest requirement from 0.12 to 0.13 (#1922) Updates the requirements on [reqwest](https://github.com/seanmonstar/reqwest) to permit the latest version. - [Release notes](https://github.com/seanmonstar/reqwest/releases) - [Changelog](https://github.com/seanmonstar/reqwest/blob/master/CHANGELOG.md) - [Commits](seanmonstar/reqwest@v0.12.0...v0.13.1) --- updated-dependencies: - dependency-name: reqwest dependency-version: 0.13.1 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: raphaelrobert <[email protected]> * Update openmls-wasm/src/lib.rs Co-authored-by: Jan Winkelmann <[email protected]> * Update openmls-wasm/src/lib.rs Co-authored-by: Jan Winkelmann <[email protected]> * add comments for RatchetTree wasm functions * chore(deps): update criterion requirement from ^0.7 to ^0.8 (#1912) Updates the requirements on [criterion](https://github.com/criterion-rs/criterion.rs) to permit the latest version. - [Release notes](https://github.com/criterion-rs/criterion.rs/releases) - [Changelog](https://github.com/criterion-rs/criterion.rs/blob/master/CHANGELOG.md) - [Commits](criterion-rs/criterion.rs@criterion-plot-v0.7.0...criterion-v0.8.0) --- updated-dependencies: - dependency-name: criterion dependency-version: 0.8.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Franziskus Kiefer <[email protected]> Co-authored-by: raphaelrobert <[email protected]> * feat: make JoinBuilder::new API public (#1924) This allows to create JoinBuilder from a processed welcome exposing a more flexible API when converting it into a staged welcome. * update `rand` dependency for tests * update `rand` dependency in `ds-lib` * update rustflags and getrandom dependency for tests * reorganize flags for getrandom backend and update workflows * update `getrandom` and remove `RUSTFLAGS` that are no longer required as of that version * remove `libcrux-provider-js` feature flag * update changelog * feat: store pending proposals feat: expand example to show how to send messages and handling adding 3rd person * fix: check for duplicate PSK IDs in commits (#1928) * Add AppData mechanisms from the extensions draft (#1930) This commit adds an implementation of the AppDataDictionary (and related) structs, as well as the AppDataUpdate proposal (and handling) as defined in the extensions draft. Since the proposals contain diffs in an appplication-defined format, processing of these proposals requires extra work from the application. While working on this we also found a missing validation check that we added. Co-authored-by: wysiwys <[email protected]> Co-authored-by: Konrad Kohbrok <[email protected]> * add AAD getter to `PrivateMessageIn` (#1934) * Enforce allowed extension types using Rust types (#1927) Closes #1830 Extends PR #1834 by integrating @keks’s work on extension validation. * Don't use git dependencies for hpke-rs, update tonic in interop_client (#1941) * don't use git dependencies for hpke-rs * update tonic in interop client * fix: skip removed members in capabilities check (#1943) * fix: correctly access credentials from past epochs (#1944) * update libcrux and hpke deps (#1945) * feat: don't replace groups by default (#1929) This PR changes `MlsGroup` constructors (both for fresh groups, as well as groups created from a `Welcome`) s.t. they don't replace pre-existing groups with the same `GroupId`. If the application would like to replace an existing group, it can either just delete the group manually before recreating it, or call the `replace_old_group` on the `MlsGroupBuilder` or the `JoinBuilder`. This PR also changes the semantics on the `store` functions of the `sqlx_storage` and the `sqlite_storage` from `INSERT` to `INSERT OR REPLACE`. * Add APIs to access information about the next epoch from a StagedCommit (#1936) * Allow accessing info about next epoch from StagedCommit * add tests * fix clippy * fmt * add better error handling * update changelog (#1948) * Add and document more validation checks (#1933) Co-authored-by: Konrad Kohbrok <[email protected]> * feat: derive serde Serialize and Deserialize for MlsMessageOut (#1950) * Merge commit from fork * prep release * chore: bump memory provider version to 0.5.0 (#1953) * relax wasm size limit (#1949) * update ciphersuites in book (#1954) * TreeSync: expose full_leaves/parents; make full_leaves provide LeafNodeIndex (#1955) * update libcrux and hpke-rs depdencenies (#1962) * update libcrux and hpke-rs depdencenies * drop unused wasm ci job * chore: prepare 0.8.1 release (#1964) * Expose TreeSync for MlsGroup and PublicGroup (#1959) * expose TreeSync for MlsGroup and PublicGroup * expose TreeSync struct * add missing import * clippy * add integration test * publish ParentNodeIndex::32 and add check to test * expose API to get blank nodes and a test that accesses it * expose ParentNodeIndex * Derive TlsSerializeBytes for SignatureScheme (#1965) * Add API to export secret from staged welcome (#1961) * Expose epoch in private and public messages and public group getter (#1970) * update hpke and libcrux dependencies (#1975) * feat(basic_credential): zeroize SignatureKeyPair private key on drop (#1973) ## Summary Replaces `private: Vec<u8>` with `private: SecretVLBytes` in `SignatureKeyPair`, ensuring Ed25519/P-256 private key bytes are automatically zeroed when the struct is dropped. This follows the same pattern established in #1369 for `HpkePrivateKey` and `ExporterSecret`. ## Changes - `basic_credential/src/lib.rs`: `private` field type changed from `Vec<u8>` to `SecretVLBytes` - Construction sites updated to use `From<&[u8]>` / `From<Vec<u8>>` conversions - `private()` test-utils accessor updated to use `as_slice()` - No API changes — `from_raw()` still accepts `Vec<u8>` (converted internally) ## Testing - `cargo check -p openmls -p openmls_basic_credential -p openmls_rust_crypto --features test-utils` — clean - `cargo test -p openmls --lib --features test-utils` — 1732 passed, 0 failed Closes #1969 * Add APIs for time-based deletion of past epoch secrets (#1972) * add new APIs * improve documentation * Minor refactor and add optional `max_past_epochs` to new APIs Includes a small refactor of how the `MessageSecrets` struct is stored alongside its timestamp. * add new tests and update existing tests * improve documentation * update documentation * update tests to ensure start time is always before epoch timestamps * make timestamp optional * implement compatible deserialization and add tests * use policies for past epoch deletion * documentation * alias for previous name of storage field * add test data * remove unused API and make timestamp optional * reorganize tests * ensure compatible deserialization of policy * fix documentation * fix argument * use correct argument name * wip * simplify past epoch secret deletion APIs * add book page and update book text * add book code anchors and reorganize test * simplify past epoch deletion policy enum * update all new APIs to take policy as argument * update documentation * update tests and documentation * more info on the epoch secret deletion APIs and policy * remove duplicate markdown file * clean up tests and documentation * documentation * update docs and add documentation TODOs * formatting * reorganize tests * clear the past secrets if no time filter provided * clean up tests and documentation * clean up comments/TODOs * configure test methods for `test` only * simplify `cfg` * use past epoch deletion policy in group builder in `MlsGroup::reboot()` * fix lints * use RustCrypto provider in storage compat test * disable sqlite storage test for wasm32 * fix typo Co-authored-by: Franziskus Kiefer <[email protected]> * remove out of date docs * add note about deprecation * update docs Co-authored-by: Franziskus Kiefer <[email protected]> * move `max_past_epochs` logic to `if` clause * delete past epoch secrets from storage * handle a mixture of `Some` and `None` timestamps and add initial tests * check persistence of deletion in tests * check loaded group * add API to group for setting policy, and add test * documentation updates * add doc comments * load testing SQL statements from file at runtime * more documentation of `PastEpochDeletionPolicy` * address doc TODOs * cleaner retrieval of matching index * API for deleting all past secrets without timestamps * add comment * remove TODO * more documentation * rename method to resize store * set and persist the join config * add API to get a group's past epoch deletion policy * update tests to ensure policy is updated * update phrasing * update changelog * add test for policy persistence on group --------- Co-authored-by: Franziskus Kiefer <[email protected]> * feat: allow app data dictionary extension in key packages (#1979) According to [draft-ietf-mls-extensions-09], section 4.6, key packages can contain an application data dictionary extension. Also fix missing error handling in `apply_app_data_update_proposals`. * feat: clean up lifetime validation and errors (#1980) * update the `rusqlite` version used in `openmls_sqlite_storage` (#1982) --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: raphaelrobert <[email protected]> Co-authored-by: Konrad Kohbrok <[email protected]> Co-authored-by: Nuke 🌄 <[email protected]> Co-authored-by: Franziskus Kiefer <[email protected]> Co-authored-by: Jan Winkelmann (keks) <[email protected]> Co-authored-by: Jan Winkelmann <[email protected]> Co-authored-by: clara <[email protected]> Co-authored-by: WaterWhisperer <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jeff Gardner <[email protected]> Co-authored-by: raphaelrobert <[email protected]> Co-authored-by: Mayel de Borniol <[email protected]> Co-authored-by: Stanley Sebastian <[email protected]> Co-authored-by: Mayel de Borniol <[email protected]> Co-authored-by: wysiwys <[email protected]> Co-authored-by: Adam Sparks <[email protected]> Co-authored-by: tbehner <[email protected]> Co-authored-by: Alec Marcus <[email protected]>
Closes #1240
This wraps sensitve variables into new types that will implement
Zeroizeand will zero the memory on drop. Unfortunately we can't use theVLBytesin that case and I had to switch to the regularVec<u8>.I've moved the
HpkePrivateKeystruct to thetraitscrate and since for testingPartialEqandEqare required I had to introduce thetest-utilsfeature in it.