Commit ab7ae36
[PM-27230] Introduce Account Cryptographic State (#563)
## 🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-27230
https://bitwarden.atlassian.net/browse/PM-27313
<!-- Paste the link to the Jira or GitHub issue or otherwise describe /
point to where this change is coming from. -->
Client PR, fixing breaking changes:
bitwarden/clients#17488
## 📔 Objective
Account cryptographic state describes the core cryptographic objects
making up a user. For a V1 encryption user these are: The RSA Keypair.
For a V2 user these are:
- The Public-key Encryption Keypair
- The Signature Keypair
- The Signed public key (used to bind a public-key encryption key pair
to signing keypair)
- The Signed security state (used for a safe upgrade path that prevents
insecure features)
Note: The wrapped version omits the public key and verifying key for the
public-key encryption key-pair and signature key-pair, and only includes
the wrapped private / signing keys.
Not included are:
- Keys shared to the user via an organization memebership or emergency
access
- Cipher keys
which are not part of the user's cryptography, but do interact with it.
Provided is a function to generate such a cryptographic state for v2
users, and conversion to API request models. Further, this changes SDK
initialization to be based on the account cryptographic state.
## 🚨 Breaking Changes
Please note that the public API for initializing the user's account
cryptography is updated to instead take an enum. The variants for the
enum contain the private key for V1 users, and the private key, signing
key, signed public key, signed security state for V2 users.
Aside from re-packaging into an enum variant, no other changes should be
needed on the consuming side.
This both helps prevent inconsistent states from being passed in by
enforcing consistent state via type safetey, but also cleans up the
primitive obsession anti-pattern
(https://contributing.bitwarden.com/architecture/server/#avoid-primitive-obsession)
that the crypto initialization was facing and will make future changes
much easier.
Note that since so far clients did not store the signed public key, it
is optional for now, but will be made mandatory later after clients save
it for a sufficient time.
To migrate, simply repack the existing values into the corresponding
enum. Note that previously the signed public key was not passed in, now
it is passed in (optional for now, but required later on). Please ensure
it is saved to state on sync / login.
<!-- Does this PR introduce any breaking changes? If so, please describe
the impact and migration path for clients.
If you're unsure, the automated TypeScript compatibility check will run
when you open/update this PR and provide feedback.
For breaking changes:
1. Describe what changed in the client interface
2. Explain why the change was necessary
3. Provide migration steps for client developers
4. Link to any paired client PRs if needed
Otherwise, you can remove this section. -->
## ⏰ 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 1 parent 7e4b2cc commit ab7ae36
File tree
33 files changed
+1087
-532
lines changed- crates
- bitwarden-collections/src
- bitwarden-core
- src
- auth
- login
- password
- client
- key_management
- platform
- tests
- bitwarden-crypto/src
- keys
- safe
- store
- traits
- bitwarden-uniffi
- kotlin/app/src/main/java/com/bitwarden/myapplication
- swift/iOS/App
- bitwarden-vault/src
- cipher/cipher_client
- folder
- bw/src/vault
33 files changed
+1087
-532
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
| 155 | + | |
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
166 | 165 | | |
167 | 166 | | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
172 | 171 | | |
| 172 | + | |
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
116 | 115 | | |
117 | 116 | | |
| 117 | + | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
| 168 | + | |
173 | 169 | | |
174 | 170 | | |
175 | 171 | | |
| |||
240 | 236 | | |
241 | 237 | | |
242 | 238 | | |
243 | | - | |
| 239 | + | |
244 | 240 | | |
245 | | - | |
246 | | - | |
247 | 241 | | |
248 | 242 | | |
249 | 243 | | |
| |||
262 | 256 | | |
263 | 257 | | |
264 | 258 | | |
265 | | - | |
266 | | - | |
267 | | - | |
| 259 | + | |
268 | 260 | | |
269 | 261 | | |
270 | 262 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 36 | + | |
39 | 37 | | |
40 | 38 | | |
41 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
130 | | - | |
131 | | - | |
132 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 24 | + | |
28 | 25 | | |
29 | 26 | | |
30 | 27 | | |
| |||
40 | 37 | | |
41 | 38 | | |
42 | 39 | | |
| 40 | + | |
| 41 | + | |
43 | 42 | | |
44 | 43 | | |
45 | 44 | | |
| |||
48 | 47 | | |
49 | 48 | | |
50 | 49 | | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
| 50 | + | |
56 | 51 | | |
57 | 52 | | |
58 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
| 152 | + | |
157 | 153 | | |
158 | 154 | | |
159 | 155 | | |
| |||
203 | 199 | | |
204 | 200 | | |
205 | 201 | | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
| 202 | + | |
211 | 203 | | |
212 | 204 | | |
213 | 205 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
53 | 56 | | |
54 | 57 | | |
55 | 58 | | |
| |||
78 | 81 | | |
79 | 82 | | |
80 | 83 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 84 | + | |
86 | 85 | | |
87 | 86 | | |
88 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
| 8 | + | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
38 | 40 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | 41 | | |
44 | 42 | | |
45 | 43 | | |
| |||
0 commit comments