-
Notifications
You must be signed in to change notification settings - Fork 10
[PM-20614] Cose Content Type #203
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
quexten
wants to merge
43
commits into
main
Choose a base branch
from
km/cose-content-format
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
bc5900b
Implement cose content format
quexten 2e905c4
Cargo fmt
quexten b41f5ef
Fix docs
quexten eb70dfc
Fix formatting
quexten 1e2e95c
Merge main
quexten 68be6e6
Fix formatting
quexten d6a18a4
Fix comment
quexten 6e9e526
Cleanup
quexten 50d8f70
Switch from pass by ref to pass by value for enum
quexten e5bd251
Add CompositeEncryptable trait
quexten b92010b
Cleanup
quexten 9635098
Merge branch 'main' into km/cose-content-format
quexten b8056c2
Fix typo
quexten 9440825
Typed encryptable
quexten f8cb804
Apply cargo fmt
quexten e6939e6
Fix build
quexten 2a202c1
Remove unused imports
quexten ba9e2c3
Rename to primitiveencryptablewithcontenttype
quexten a42b1e7
Set correct content type for pkcs8
quexten 5447cbb
Add cose keywrap
quexten 66c345f
Fix keywrap
quexten 9b2f6c9
Run cargo fmt
quexten 88b96b7
Fix encryptable
quexten 7e69b7b
Run cargo fmt
quexten b7d2bc8
Cleanup
quexten acb6d12
Rename to PrimitiveEncryptableWithoutContentFormat
quexten 723ec63
Rename to PrimitiveEncryptable
quexten 36d8de9
Merge branch 'main' into km/cose-content-format
quexten 33da07b
Add documentation for the encryptable traits
quexten 2861a9a
Merge branch 'km/cose-content-format' of github.com:bitwarden/sdk-intโฆ
quexten 1681df9
Fix clippy errors
quexten 0cd85fa
Fix docs
quexten f91f0b8
Cargo fmt
quexten 34ee00e
Fix docs
quexten 485b6d8
Fix docs
quexten f122ff0
Fix docs
quexten f22531c
Update crates/bitwarden-crypto/src/keys/utils.rs
quexten ba10631
Update crates/bitwarden-crypto/src/keys/utils.rs
quexten 69d8c57
Update crates/bitwarden-crypto/src/keys/utils.rs
quexten 8833146
Merge branch 'main' into km/cose-content-format
quexten 47ced5a
Merge branch 'main' into km/cose-content-format
quexten 42dccb0
Add docs
quexten 9d0ea55
Merge branch 'km/cose-content-format' of github.com:bitwarden/sdk-intโฆ
quexten File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opinion question: Are we fine with OctetStream for old bitwarden keys? Should we make a custom content format - "BitwardenLegacyKey"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems reasonable to me to create our own custom content format. Attachments and file sends would probably also use the same content type, and there maybe be some others as well, like the FIDO2 private key (or is that just a base64 string?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, so for FIDO2, the private key seems to be a PKCS8 DER, B64 encoded (but without the typical PEM header/footer) before encrypting. So we cannot give it the pkcs8 content type, as that refers to PKCS8 DER without B64, but string/our padded string seems reasonable. (Or, I guess we could skip the b64 encoding step when encrypting with a COSE key, and mark it as PKCS8? I'm not sure whether that is worth the effort to ensure correctness with old encryption in all places...)
I'm not sure about files (attachments/send attachments); they seem like just byte buffers, so octetstream seems fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're going with a
BitwardenLegacyKey
, is there a reason not to use this enum to precisely define content of anything that encrypted?That definitely has value to me from a type safety perspective, but I don't know if a format flag is the right place to do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK with using a custom content format here.
Some things to keep in mind: Custom content formats - in contrast to standardized ones - are defined using strings. The standardized ones sadly don't offer a privateuse category:
(This is also the case with encstrings, that contain padded utf8 text, which are much more common right now).
The second: So far I've introduced content formats only where they are required to distinguish. (PKCS8 / CoseKey, Utf8/Octetstream CoseKey/OctetStream[or BitwardenLegacyKey].). OctetStream should be unique here, but BitwardenLegacyKey makes this much clearer.
Both of these are not a big deal, and don't hinder using it, and I'm happy to change to it. Given the context, should I change it?