Skip to content

Cot updates v2#2

Merged
seqre merged 5 commits into
mainfrom
cot-updates2
May 21, 2026
Merged

Cot updates v2#2
seqre merged 5 commits into
mainfrom
cot-updates2

Conversation

@seqre
Copy link
Copy Markdown
Member

@seqre seqre commented Apr 13, 2026

Another approach to #1

@seqre seqre requested a review from m4tx April 13, 2026 16:38
@seqre seqre self-assigned this Apr 13, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates secure-string to better integrate with cot-rs by switching equality to subtle::ConstantTimeEq, removing the previous pre-based contracts, and simplifying dependency/test setup.

Changes:

  • Implement constant-time equality for SecureVec, SecureArray, and SecureBox using subtle::ConstantTimeEq, and adjust tests accordingly.
  • Remove pre and serde_cbor dev-dependencies/tests; keep JSON-only serde tests.
  • Clean up CI and introduce shared test helpers (src/test_utils.rs) for padding/packed equality cases.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/test_utils.rs Adds test-only helper types/constants for constant-time equality and padding/packed layout tests.
src/serde.rs Removes CBOR tests; keeps JSON test coverage for serde support.
src/secure_utils.rs Adds SAFETY comments around mlock/munlock calls.
src/secure_types/vec.rs Adds ConstantTimeEq + conditional PartialEq/Eq for SecureVec; updates tests and removes pre annotations.
src/secure_types/string.rs Replaces pre contracts with inline SAFETY comments; restores Eq impl explicitly.
src/secure_types/boxed.rs Adds ConstantTimeEq + conditional PartialEq/Eq; refactors internal accessors and expands tests for padding/packed structs.
src/secure_types/array.rs Adds ConstantTimeEq + conditional PartialEq/Eq; updates multibyte-related test.
src/lib.rs Adds test-only module export and re-exports subtle::ConstantTimeEq.
Cargo.toml Adds subtle, loosens dependency versions, and removes pre/serde_cbor dev-deps.
Cargo.lock Updates lockfile to reflect dependency changes.
.woodpecker.yml Removes Woodpecker CI configuration.
.vscode/settings.json Removes editor-specific feature configuration.
.github/workflows/ci.yml Minor formatting/cleanup and keeps GitHub Actions CI as the primary pipeline.
Comments suppressed due to low confidence (2)

src/secure_types/vec.rs:257

  • The SAFETY comment says an all-zero bit pattern is valid for u32, but this test is operating on SecureVec<char>. Please update the comment to match the actual element type / invariant being relied on (that zeroed bytes correspond to valid char values, i.e., \0).
        // `zero_out` sets the `len` to 0, here we reset it to check that the bytes were zeroed
        // SAFETY: capacity is still >= 8 (zero_out does not shrink), and all bytes were
        // zeroed, which is a valid bit pattern for `u32`.
        unsafe {

src/secure_types/vec.rs:105

  • These trait impls mean SecureVec<T> only supports ==/!= when T: subtle::ConstantTimeEq (and the earlier derived Hash/Ord impls were removed). That’s a public API/semver change for generic SecureVec<T> users (e.g., types like char will no longer be comparable, and SecureVec<T> can’t be used as a map/set key). If this is intended, it would help to document it prominently (and/or consider providing specialized impls for common byte/key types so typical uses don’t need wrapper newtypes).
impl<T: Copy + Zeroize + ConstantTimeEq> PartialEq for SecureVec<T> {
    fn eq(&self, other: &Self) -> bool {
        self.ct_eq(other).into()
    }
}

impl<T: Copy + Zeroize + ConstantTimeEq> Eq for SecureVec<T> {}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/secure_types/vec.rs
Comment thread src/secure_types/vec.rs
Comment thread src/secure_types/boxed.rs
Comment thread src/serde.rs
@m4tx m4tx mentioned this pull request May 21, 2026
Copy link
Copy Markdown
Member

@m4tx m4tx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the comments, I think we should also adopt more config from our other repos, such as the CI pipeline, pre-commit config, rustfmt, etc.

Otherwise, it looks like a step in a good direction.

Comment thread src/secure_types/array.rs Outdated
Comment thread src/secure_types/boxed.rs Outdated
Comment thread src/secure_utils.rs Outdated
Comment thread src/secure_types/string.rs Outdated
Comment thread src/secure_types/string.rs Outdated
Comment thread .github/workflows/ci.yml
Comment thread src/secure_types/vec.rs Outdated
reason = "they were initialized to `0` by the call to `zero_out`"
)
)]
// SAFETY: capacity is still >= 5 (zero_out does not shrink), and all 5 bytes were
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A safety comment inside a unit test is arguably not very much needed, but it's fine to keep it, too.

Comment thread src/secure_types/vec.rs Outdated
@seqre seqre requested a review from m4tx May 21, 2026 10:28
@seqre seqre merged commit 380cd4a into main May 21, 2026
9 of 10 checks passed
@seqre seqre deleted the cot-updates2 branch May 21, 2026 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants