Skip to content

[PM-20361] Signature keys #207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: km/cose
Choose a base branch
from
Open

[PM-20361] Signature keys #207

wants to merge 19 commits into from

Conversation

quexten
Copy link
Contributor

@quexten quexten commented Apr 5, 2025

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-20361

📔 Objective

This PR adds signing/verifying operations, and keys, including serialization to COSE for both the keys, and for the signatures. This does not use these yet. The interface is strongly domain separated.

The one implemented algorithm type is ed25519.

Keys are represented as enums such that it is easy to add other signing key types (ML-DSA for post-quantum crypto, PoC here: #216) later on.

Further, we enforce strong domain separation by adding a namespace to the protected header. This ensures not having to worry about cross-protocol attacks / swapping messages between contexts.

The signature is represented as a Cose Sign1 message (https://www.rfc-editor.org/rfc/rfc9052.html#name-signing-with-one-signer), with a detached payload. Specifically, the payload is detached because we may want to allow application level logic providing multiple signatures on an object without having to modify the entire object (two-way signed org memberships).

The namespace is separated by setting the protected header. Since this is included in the signed data, and since this is validated on verifying the signature, and since the values are unique, domain separation is enforced. We only ever want to expose the safe function outside of the crate (if we even expose it out of the crate).

Note: This does not yet add code for consuming these keys or signatures, hence there are a lot of "allow dead code" attributes.

The first use-case for this will be signing an "Account Encryption Metadata" object, proving to the user certain features of their account (icon url hash enforcement). After this, signed emergency access and signed organization memberships follow.

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation
    team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed
    issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

Copy link
Contributor

github-actions bot commented Apr 5, 2025

Logo
Checkmarx One – Scan Summary & Details9aed1dc4-4d3d-4a78-bd35-c8ffe40f38fc

Great job, no security vulnerabilities found in this Pull Request

Copy link

codecov bot commented Apr 5, 2025

Codecov Report

Attention: Patch coverage is 93.90681% with 17 lines in your changes missing coverage. Please review.

Project coverage is 67.47%. Comparing base (ae9a7da) to head (c551e7f).

Files with missing lines Patch % Lines
...es/bitwarden-crypto/src/keys/signing_crypto_key.rs 93.75% 17 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           km/cose     #207      +/-   ##
===========================================
+ Coverage    67.02%   67.47%   +0.45%     
===========================================
  Files          212      214       +2     
  Lines        16208    16487     +279     
===========================================
+ Hits         10863    11125     +262     
- Misses        5345     5362      +17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@quexten quexten changed the title Km/cose signatures [PM-20361] Signature keys Apr 17, 2025
}
}
}
let Some(signature_namespace) = signature_namespace else {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any options to represent this better? This feels highly unergonomic....

@quexten quexten requested review from Hinton and MGibson1 April 17, 2025 17:22
@quexten
Copy link
Contributor Author

quexten commented Apr 17, 2025

Adding both @MGibson1 and @Hinton to the reviews here. This is a completely new (w.r.t. bitwarden) type of cryptographic object, operation and key.

@quexten quexten marked this pull request as ready for review April 17, 2025 17:38
@quexten quexten requested a review from a team as a code owner April 17, 2025 17:38
@quexten quexten requested a review from addisonbeck April 17, 2025 17:38
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.

1 participant