Commit 2541bf6
authored
Replace Deprecated Keystore API for Android 28+, Fixes AB#3110184 (#2558)
Issue :
https://portal.microsofticm.com/imp/v5/incidents/details/540463066/summary
Keystore operation "unwrap" is failing on Pixel 5 Android 14 devices. It
is still not clear why the operation would fail specifically on Pixel 5
devices but it could be some bug on google side which is fixed for all
other devices through a patch. Updates for Pixel 5 are stopped hence it
may not have the google fix.
However, the getSpecForKeyStoreKey method used while wrapping the key
was using a deprecated API (KeyPairGeneratorSpec). It was deprecated in
Android 23. Updating it to latest one has somehow resolved the issue for
1 customer (Since there are no updates from other customers, we assumed
that it is the fix).
Exception : [YPC] 2024-11-14 17:34:29.29 [25795][917] ERROR
[AndroidKeyStoreUtil:unwrap] [2024-11-14 12:04:29 - thread_id: 911,
correlation_id: UNSET - Android 34] invalid_key
java.security.InvalidKeyException: Keystore operation failed
at
android.security.keystore2.KeyStoreCryptoOperationUtils.getInvalidKeyException(KeyStoreCryptoOperationUtils.java:128)
at
android.security.keystore2.KeyStoreCryptoOperationUtils.getExceptionForCipherInit(KeyStoreCryptoOperationUtils.java:152)
at
android.security.keystore2.AndroidKeyStoreCipherSpiBase.ensureKeystoreOperationInitialized(AndroidKeyStoreCipherSpiBase.java:354)
Fix : Removed the deprecated API KeyPairGeneratorSpec and using the new
one KeyGenParameterSpec which lets us set the purpose as
PURPOSE_WRAP_KEY
Testing : Ran the pipeline to confirm if the instrumented and UI tests
are running as expected
https://identitydivision.visualstudio.com/Engineering/_build/results?buildId=1401690&view=ms.vss-test-web.build-test-results-tab&runId=4352544&resultId=100000&paneView=debug
and
https://identitydivision.visualstudio.com/Engineering/_build/results?buildId=1401664&view=logs&s=60296c01-192d-58d3-82b8-da4d468e44bd
Fixes
[AB#3110184](https://identitydivision.visualstudio.com/fac9d424-53d2-45c0-91b5-ef6ba7a6bf26/_workitems/edit/3110184)1 parent e77bcfc commit 2541bf6
File tree
2 files changed
+35
-1
lines changed- common/src/main/java/com/microsoft/identity/common/crypto
2 files changed
+35
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
Lines changed: 34 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
| |||
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
| 49 | + | |
47 | 50 | | |
| 51 | + | |
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
| |||
269 | 273 | | |
270 | 274 | | |
271 | 275 | | |
| 276 | + | |
272 | 277 | | |
273 | 278 | | |
274 | 279 | | |
275 | 280 | | |
276 | 281 | | |
277 | | - | |
| 282 | + | |
278 | 283 | | |
279 | 284 | | |
280 | 285 | | |
| |||
295 | 300 | | |
296 | 301 | | |
297 | 302 | | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
298 | 331 | | |
299 | 332 | | |
300 | 333 | | |
| |||
0 commit comments