Skip to content

Commit 17866c0

Browse files
authored
[PM-22844] Fix enrollment of signing keys (#320)
## 🎟️ Tracking https://bitwarden.atlassian.net/browse/PM-22844 ## 📔 Objective Enrollment of signing keys used the user state's signature keypair to create a signed public key. However, this is not available at the time of enrolling into signing keys yet, and thus creation fails. This PR fixes this by setting the just-created signature key to the local context, and using this local key. ## ⏰ 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 <!-- Suggested interactions but feel free to use (or not) as you desire! --> - 👍 (`:+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
1 parent c9bd7f9 commit 17866c0

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

crates/bitwarden-core/src/key_management/crypto.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,9 +595,12 @@ pub fn make_user_signing_keys_for_enrollment(
595595

596596
// Make new keypair and sign the public key with it
597597
let signature_keypair = SigningKey::make(SignatureAlgorithm::Ed25519);
598+
let temporary_signature_keypair_id = SigningKeyId::Local("temporary_key_for_rotation");
599+
#[allow(deprecated)]
600+
ctx.set_signing_key(temporary_signature_keypair_id, signature_keypair.clone())?;
598601
let signed_public_key = ctx.make_signed_public_key(
599602
AsymmetricKeyId::UserPrivateKey,
600-
SigningKeyId::UserSigningKey,
603+
temporary_signature_keypair_id,
601604
)?;
602605

603606
Ok(MakeUserSigningKeysResponse {

crates/bitwarden-core/src/key_management/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ key_ids! {
3434
#[signing]
3535
pub enum SigningKeyId {
3636
UserSigningKey,
37+
#[local]
38+
Local(&'static str),
3739
}
3840

3941
pub KeyIds => SymmetricKeyId, AsymmetricKeyId, SigningKeyId;

0 commit comments

Comments
 (0)