Commit 19fa711
committed
Fix user logout issue during V11→V13 app upgrades caused by failed OAEP re-encryption
**Issue:**
After upgrading from SDK V11 to V13, users were unexpectedly logged out when
restarting the app a second time. The failure sequence was:
1. **V11 behavior**: Stored unique ID encrypted with PKCS1 using PKCS1-only keys
2. **V13 first run after upgrade**:
- Attempts OAEP decryption (fails - stored with PKCS1)
- Falls back to PKCS1 decryption (succeeds - gets unique ID)
- Attempts to re-encrypt and store with OAEP for future use
- OAEP encryption fails silently because V11 keys don't support OAEP padding
3. **V13 second run** (app restart):
- Attempts OAEP decryption (fails - OAEP storage failed in step 2)
- Falls back to PKCS1 decryption (fails - old PKCS1 version overwritten)
- Unique ID becomes unreadable → refresh tokens can't be decrypted → user logout
**Root Cause:**
V13's upgrade logic assumed all keys support OAEP padding, but V11 keys were
created with `ENCRYPTION_PADDING_RSA_PKCS1` only. The failed OAEP re-encryption
corrupted the stored unique ID, breaking access to all encrypted user data.
**Solution:**
- Added `keySupportsOAEPPadding()` method to inspect key capabilities via KeyInfo
- Enhanced SalesforceKeyGenerator to detect legacy keys and recreate them with
full OAEP support BEFORE attempting OAEP operations
- Added test coverage for legacy vs modern key detection
**Impact:**
- Eliminates unexpected user logouts during V11→V13 upgrades
- Ensures seamless session preservation across app versions
- Users maintain access to their encrypted data without re-authentication
- All upgraded apps automatically transition to modern OAEP encryption
**Files Modified:**
- KeyStoreWrapper.java: Added keySupportsOAEPPadding() method
- SalesforceKeyGenerator.java: Added proactive key upgrade logic
- KeyStoreWrapperTest.java: Added test for key capability detection1 parent a99d2c9 commit 19fa711
3 files changed
Lines changed: 59 additions & 0 deletions
File tree
- libs
- SalesforceSDK/src/com/salesforce/androidsdk/security
- test/SalesforceSDKTest/src/com/salesforce/androidsdk/security
Lines changed: 30 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| |||
253 | 255 | | |
254 | 256 | | |
255 | 257 | | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
256 | 286 | | |
257 | 287 | | |
258 | 288 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
179 | 185 | | |
180 | 186 | | |
181 | 187 | | |
| |||
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| 76 | + | |
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
| |||
198 | 200 | | |
199 | 201 | | |
200 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
201 | 224 | | |
202 | 225 | | |
203 | 226 | | |
| |||
0 commit comments