Skip to content
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

Implement parsing for all EncString ciphers #213

Merged
merged 8 commits into from
Sep 4, 2023

Conversation

dani-garcia
Copy link
Member

Type of change

- [ ] Bug fix
- [x] New feature development
- [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc)
- [ ] Build/deploy pipeline (DevOps)
- [ ] Other

Objective

Implement converting an EncString to and from a base64 encoded string and a buffer for all the ciphers we support. Added support for legacy EncStrings without a type header, just like the rest of the clients.
Marked RSA with HMAC as deprecated like the other clients. Also removed their mac fields, the other clients don't check them either.

@dani-garcia dani-garcia requested a review from Hinton September 1, 2023 13:57
@bitwarden-bot
Copy link

bitwarden-bot commented Sep 1, 2023

Logo
Checkmarx One – Scan Summary & Detailsc8d67d67-96b7-478a-8cc9-bed7de0c11a2

No New Or Fixed Issues Found

# Conflicts:
#	crates/bitwarden/src/crypto/enc_string.rs
Comment on lines 107 to 113
("5" | "6", 1) => {
let data = from_b64_vec(parts[0])?;
if enc_type == "5" {
Ok(EncString::Rsa2048_OaepSha256_HmacSha256_B64 { data })
} else {
Ok(EncString::Rsa2048_OaepSha1_HmacSha256_B64 { data })
}
Copy link
Member

@Hinton Hinton Sep 4, 2023

Choose a reason for hiding this comment

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

Is this cleaner than just writing?

("5", 1) => {
  Ok(EncString::Rsa2048_OaepSha256_HmacSha256_B64 { data: from_b64_vec(parts[0])? })
}
("6", 1) => {
  Ok(EncString::Rsa2048_OaepSha1_HmacSha256_B64 { data: from_b64_vec(parts[0])? })
}

(Same also applies for ("3" | "4", 1))

Copy link
Member Author

Choose a reason for hiding this comment

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

I kept it like it was previoulsy, but it's definitely not very useful now that most of the match branches are very short with the from_b64_vec. We could even split ("1" | "2", 3) as well, as it's only three lines now.

@dani-garcia dani-garcia requested a review from Hinton September 4, 2023 14:01
Hinton
Hinton previously approved these changes Sep 4, 2023
@dani-garcia dani-garcia merged commit 2dc124d into master Sep 4, 2023
36 of 37 checks passed
@dani-garcia dani-garcia deleted the ps/more-encstring-ciphers branch September 4, 2023 15:54
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