Commit Graph

983 Commits

Author SHA1 Message Date
Eran Messeri
ee3c80f288 Merge "Keystore: Surface service error message" am: af771eb908 am: b3612e019f am: e53fd593b5 am: a2b165989b
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1969819

Change-Id: I0f3d9721af9aa47bf7f7ae6a419d79ec3547210b
2022-02-08 19:50:28 +00:00
Eran Messeri
5eedf5a373 Keystore: Surface service error message
Surface the service-specific error message. To avoid API changes, the
error message is surfaced in the toString / getMessage methods.

Test: atest android.security.keystore.KeyStoreExceptionTest
Bug: 217593122
Change-Id: Id4090564b46db9b3b10ea390390f6683f7314463
2022-02-08 13:26:57 +00:00
Eran Messeri
a31689bc37 KeyStore: Verbose error reporting
Report KeyStore/KeyMint error messages via public API.

This lets developers find out:
* Whether an error is transient or not.
* Whether a failure is due to a system error
(system configuration/state/capabilities), or a key-related error.
* Whether user authentication is required to use the key.

Test: atest CtsKeystorePerformanceTestCases CtsKeystoreTestCases
Bug: 197890905
Merged-In: I776d9e9cc01a9dc3542a63000ee0709847760963
Change-Id: Ica0c93fdd4b89255ee0a03a9b9b948202777d4d4
2022-02-02 22:11:44 +00:00
John Wu
14ce8bc120 Framework support for AndroidKeyStore migration
- Add a new boolean attribute `inheritKeyStoreKeys` to allow apps to
  indicate whether they want keys to be transferred to the updated app
- Call the appropriate KeyStore method to migrate keys from the old
  namespace to the new one
- Clear keys owned by the previous app ID if it is removed

Test: atest SharedUserMigrationTest#testKeyMigration
Test: atest AndroidPackageTest
Bug: 179284822
Change-Id: I321b85b88c150f17709a2270c0cbaf368ca035cc
2022-01-21 01:36:43 +00:00
John Wu
1c632f80e8 Merge "Update AndroidKeyStoreMaintenance framework API" am: 8c34efd29a am: be201a0ed5 am: 7d7010dcf8 am: 253c91192f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1950401

Change-Id: I8b3f892d829decc104ef2a732af5fbbfa3e08fa8
2022-01-19 01:13:31 +00:00
John Wu
bb5c49e510 Update AndroidKeyStoreMaintenance framework API
Update the Java framework accordingly with the underlying keystore2
changes for key migration.

Test: atest SharedUserMigrationTest#testDataMigration (in internal)
Bug: 211665859
Change-Id: I26c817dffdf2e50a43373114a63242644ee7e712
2022-01-14 15:35:07 -08:00
Seth Moore
ea9d0dd167 Merge "Add missing </pre> to Javadoc" am: 076fb5e987 am: d084c0202a am: 33e0b830dc am: a665f6bd93
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1905490

Change-Id: I5965b31cb15b2cf30596939d4c5cb70e51b332b9
2022-01-07 17:34:34 +00:00
Seth Moore
076fb5e987 Merge "Add missing </pre> to Javadoc" 2022-01-07 16:40:32 +00:00
Eran Messeri
5da05ee3ed KeyStore: Verbose error reporting
Report KeyStore/KeyMint error messages via public API.

This lets developers find out:
* Whether an error is transient or not.
* Whether a failure is due to a system error
(system configuration/state/capabilities), or a key-related error.
* Whether user authentication is required to use the key.

Test: atest CtsKeystorePerformanceTestCases CtsKeystoreTestCases
Bug: 197890905
Change-Id: I776d9e9cc01a9dc3542a63000ee0709847760963
2021-12-14 15:22:35 +00:00
Seth Moore
c78e369c4c Fix incorrect SID matching for bio prompts
The default value for canUnlockViaBiometrics, which determines if we
are able to show a bio prompt, is true. However, if there are 0
biometric authenticator IDs, then it's impossible for the user to
satisfy a bio prompt. In this case, we should set canUnlockViaBiometrics
to false.

The loop that is normally expected to invert canUnlockViaBiometrics was
never run in the case of 0 bio authenticator ids, so we mistakenly
let the crypto init operation succeed when we should have blocked it.

Bug: 188864794
Test: Manual, using sample app that displays a biometric prompt.
Change-Id: Ib95b0564aa098157718b8d4a45b11baa69dad71b
2021-12-01 14:59:24 -08:00
Shawn Willden
f3aac252f7 Add missing </pre> to Javadoc
Change-Id: Iedf0f7f85fecbc2ee274a108887c77add62dcb31
2021-11-29 19:20:19 +00:00
Treehugger Robot
70e7dd44b4 Merge changes Ic6e60752,I2b8b7e74
* changes:
  Test for contract between AndroidKeyStoreKey hash and equals.
  Keystore 2.0 SPI: Fix contract between equals and hashCode 2
2021-10-08 15:31:03 +00:00
Janis Danisevskis
2eef723ced Merge "Keystore 2.0 SPI: Fix NullPointerException in setKeyEntry." 2021-10-08 14:57:47 +00:00
Janis Danisevskis
5fe5f2def0 Test for contract between AndroidKeyStoreKey hash and equals.
Test: atest KeystoreTests
Bug: 196118021

Merged-In: Ic6e60752faa986debe3d325f54242cffaa03b336
Change-Id: Ic6e60752faa986debe3d325f54242cffaa03b336
2021-10-07 16:39:39 -07:00
Janis Danisevskis
e36fe6bf46 Keystore 2.0 SPI: Fix contract between equals and hashCode 2
This fixes the contract between equals and hashCode in
AndroidKeystorePublicKey. The previous fix made only a reference
comparisson between certificate blobs. In this patch java.util.Arrays is
used to compare and compute the hash of the array.

Bug: 196118021
Test: See following CL.
Change-Id: I2b8b7e740fb377de39fd21f763e15cb00024b2fc
2021-10-07 16:24:46 -07:00
Janis Danisevskis
4ff6274fa7 Keystore 2.0 SPI: Fix NullPointerException in setKeyEntry.
Fix a NullPointerException when trying to insert SecretKey that already
exists.

Bug: 202146009
Test: atest android.keystore.cts.AndroidKeyStoreTest#testKeyStore_SetKeyEntry_ReplacedWithSameGeneratedSecretKey
Change-Id: If3a4bd6677ab3173c5c1a7c921ba567b7981662b
2021-10-07 08:24:42 -07:00
Treehugger Robot
6939d8d665 Merge "Fix key alias string comparison" am: 15d1ab2fdd
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1802873

Change-Id: I20bb1006d93233dfe7dd73c12a0eaadee229e3d5
2021-08-24 17:52:12 +00:00
Seth Moore
11cce949b6 Fix key alias string comparison
The code was doing a reference compare, not object value comparison,
resulting in failures in the KeyStore setEntry API.

Test: CtsKeystoreTestCases:android.keystore.cts.AndroidKeyStoreTest
Fixes: 197138784
Change-Id: I2c5e47283eed5694951869e9ea3853364ddef9d1
2021-08-19 12:44:08 -07:00
Max Bires
f5e0c3e257 Merge "Fixing a condition that can cause deadlock" am: 773a378390
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1797475

Change-Id: Id20947de8b039d4a468127a446266c30fbbd1659
2021-08-18 02:06:57 +00:00
Max Bires
773a378390 Merge "Fixing a condition that can cause deadlock" 2021-08-18 01:45:15 +00:00
Max Bires
c9be198afe Fixing a condition that can cause deadlock
Callbacks on ServiceConnection happen on the main UI thread for an
application. Since the thread that calls bindService then immediately
blocks to wait for the service to be connected, this will cause a
deadlock if key operations are happening on the main UI thread.

This bug has likely not been detected yet since key operations are not
supposed to be performed on the main UI thread, however it was uncovered
in a similar application during other testing. This fix ensures the
ServiceConnection object's callbacks will be triggered from a separate
thread from the calling thread.

Bug: 196571032
Test: Apps that run key operations on the UI thread don't hang.
Change-Id: I630a0ef2560a8ebd962de54c65e3d6277133a1cb
Merged-In: I630a0ef2560a8ebd962de54c65e3d6277133a1cb
2021-08-17 06:43:46 +00:00
Xin Li
773a9dfba7 Merge sc-dev-plus-aosp-without-vendor@7634622
Merged-In: I661f5fb6b1f3f6ce4322fab8fa84a7ab364c65b1
Change-Id: I16482b494ff4821016aabbb646e495d616c630ac
2021-08-14 07:23:27 +00:00
Janis Danisevskis
7bdc12d5f3 Keystore 2.0 SPI: Fix contract between equals and hashCode
This fixes the contract between equals and hashCode in
AndroidKeystoreKey and AndroidKeystorePublicKey.

Bug: 196118021
Test: N/A
Change-Id: I3f7e6d72d53c7051c13daeb5aa6ce1abf4eb0cc5
2021-08-12 12:29:02 -07:00
Janis Danisevskis
f5985b0838 Keystore 2.0 SPI: Add EC_CURVE tag on key generation.
The KeyMint spec requires the specification of the EC_CURVE tag when
generating an EC key. This patch adds the correct curve tag parameter to
the parameter list.

Test: CtsVerifier Protected confirmation test.
Bug: 192908276
Merged-In: I2e7dd4868abda85d244e73592ff12d688f5c21fc
Change-Id: I2e7dd4868abda85d244e73592ff12d688f5c21fc
2021-07-08 10:00:22 -07:00
TreeHugger Robot
7f85119309 Merge "Keystore 2.0 SPI: Add EC_CURVE tag on key generation." into sc-dev am: 214d129500
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15225383

Change-Id: I8a65bc5a7724830ecb5a0df28c35c4f1fa806a0d
2021-07-08 16:32:51 +00:00
Janis Danisevskis
5a3c880534 Keystore 2.0 SPI: Add EC_CURVE tag on key generation.
The KeyMint spec requires the specification of the EC_CURVE tag when
generating an EC key. This patch adds the correct curve tag parameter to
the parameter list.

Test: CtsVerifier Protected confirmation test.
Bug: 192908276
Change-Id: I2e7dd4868abda85d244e73592ff12d688f5c21fc
2021-07-08 08:48:46 -07:00
Max Bires
40f4b669c1 Merge "Fixing the race condition in GenerateRkpKey" am: 5023e1fb96 am: 7fc084200f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1736160

Change-Id: I274163d45ee758a5a520c78dd82d0babba9a7d1d
2021-07-01 14:57:34 +00:00
Max Bires
5023e1fb96 Merge "Fixing the race condition in GenerateRkpKey" 2021-07-01 14:20:37 +00:00
Janis Danisevskis
84e082d3da Keystore 2.0: Renaming the vpnstore interface.
Renaming the vpnstore interface to legacykeystore.

Bug: 190229655
Test: TBD
Merged-In: Icd304ef621f0de52d6ebc415a0628d63f827fbcd
Change-Id: Icd304ef621f0de52d6ebc415a0628d63f827fbcd
2021-06-30 12:29:29 -07:00
Janis Danisevskis
191b206410 Keystore 2.0: Renaming the vpnstore interface.
Renaming the vpnstore interface to legacykeystore.

Bug: 191373871
Test: TBD
Change-Id: Icd304ef621f0de52d6ebc415a0628d63f827fbcd
2021-06-30 09:45:54 -07:00
Victor Chang
49a5bb208c Update the java doc of AndroidKeyStoreProvider#getKeyStoreOperationHandle to support Signature object
Bug: 191661889
Test: m droid
Merged-In: Ie65dcfe96f3bb00cc9af4d49e4e1d1f57bde438a
Change-Id: Ie65dcfe96f3bb00cc9af4d49e4e1d1f57bde438a
(cherry picked from commit 507a653a6e)
2021-06-21 17:38:21 +01:00
Victor Chang
507a653a6e Update the java doc of AndroidKeyStoreProvider#getKeyStoreOperationHandle to support Signature object
Test: m droid
Change-Id: Ie65dcfe96f3bb00cc9af4d49e4e1d1f57bde438a
2021-06-16 15:57:44 +01:00
Max Bires
5e43390b9b Fixing the race condition in GenerateRkpKey
This file was written on the assumption that bindService was
synchronous, which it isn't. This change adds a CountDownLatch to force
the class to wait for the binding to finish. If the relevant key
generation service is not present on the system, then this
functionality will just silently be skipped over.

Bug: 190222116
Test: atest RemoteProvisionerUnitTests
Change-Id: Ie34997a08aa743642c66a20c4b756cd47bff4af1
Merged-In: Ie34997a08aa743642c66a20c4b756cd47bff4af1
2021-06-13 21:50:36 +00:00
Max Bires
17f9f3e8b5 Merge "Revert "Fixing the race condition in GenerateRkpKey"" 2021-06-09 20:35:23 +00:00
Max Bires
b2a11d35e5 Revert "Fixing the race condition in GenerateRkpKey"
This reverts commit 0f62195535.

Reason for revert: Breaks non-RKP systems

Bug: 190222116
Change-Id: I7e31a3045caa7b8bb0e34c8d1e266c104a627324
Merged-In: I7e31a3045caa7b8bb0e34c8d1e266c104a627324
2021-06-09 20:21:41 +00:00
Max Bires
8092f01ce1 Merge "Revert "Fixing the race condition in GenerateRkpKey"" into sc-dev 2021-06-09 20:21:15 +00:00
Max Bires
56318a568f Revert "Fixing the race condition in GenerateRkpKey"
This reverts commit d05498b9d8.

Reason for revert: Bugged on non-RKP systems.

Bug: 190222116
Change-Id: Ie7d17d4251c381c1bae6a76cd9b0246c551f8042
2021-06-09 19:54:48 +00:00
Max Bires
d1de4cc6e4 Merge "Fixing the race condition in GenerateRkpKey" 2021-06-09 17:48:32 +00:00
TreeHugger Robot
825d39e0f1 Merge "Fixing the race condition in GenerateRkpKey" into sc-dev 2021-06-08 20:28:28 +00:00
Max Bires
d05498b9d8 Fixing the race condition in GenerateRkpKey
This file was written on the assumption that bindService was
synchronous, which it isn't. This change adds a CountDownLatch to force
the class to wait for the binding to finish.

Bug: 190222116
Test: atest RemoteProvisionerUnitTests
Change-Id: I917a61da612f21f9a0f783bea5d24270d4e1db42
2021-06-08 20:28:06 +00:00
Seth Moore
d57dabcc94 Check for invalid device attestation parameters
Previous releases explicitly check for invalid inputs. These checks
were removed with the move to keystore2 -- add them back.

Remove old prepareAttestationArguments* methods, as they are no
longer referenced.

Bug: 188741672
Test: com.google.android.gts.security.DeviceIdAttestationHostTest
Change-Id: I4eeec8367ebdfad527395206ab9e89b409e02631
Merged-In: I4eeec8367ebdfad527395206ab9e89b409e02631
2021-06-08 12:40:38 -07:00
Seth Moore
c0133d7c47 Check for invalid device attestation parameters
Previous releases explicitly check for invalid inputs. These checks
were removed with the move to keystore2 -- add them back.

Remove old prepareAttestationArguments* methods, as they are no
longer referenced.

Fixes: 188741672
Test: com.google.android.gts.security.DeviceIdAttestationHostTest
Change-Id: I4eeec8367ebdfad527395206ab9e89b409e02631
2021-06-07 16:44:06 -07:00
Max Bires
0f62195535 Fixing the race condition in GenerateRkpKey
This file was written on the assumption that bindService was
synchronous, which it isn't. This change adds a CountDownLatch to force
the class to wait for the binding to finish.

Bug: 190222116
Test: atest RemoteProvisionerUnitTests
Change-Id: I917a61da612f21f9a0f783bea5d24270d4e1db42
Merged-In: I917a61da612f21f9a0f783bea5d24270d4e1db42
2021-06-07 18:30:51 +00:00
Joshua Duong
d10df9336a Merge "Use keymasterSwEnforcedUserAuthenticators if keymasterHwEnforcedUserAuthenticators is zero." am: 3b2decbb34 am: bc9360ea4e am: 791f088436
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1705645

Change-Id: Ieea062bd379150daf14406376e2e26b9499832fe
2021-05-13 20:57:24 +00:00
Joshua Duong
3b2decbb34 Merge "Use keymasterSwEnforcedUserAuthenticators if keymasterHwEnforcedUserAuthenticators is zero." 2021-05-13 20:16:08 +00:00
Treehugger Robot
29d875d690 Merge changes If663677b,I387d90ea am: ea4a93a946 am: da769ac79d am: 574db828e3
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1706425

Change-Id: I261fe4c6a0d926486052fdd2a812f709c419f78f
2021-05-13 15:23:50 +00:00
Treehugger Robot
ea4a93a946 Merge changes If663677b,I387d90ea
* changes:
  Fixed KeyGenParameterSpecTest
  Keystore 2.0 SPI: Fix NPE in getUniqueAliases.
2021-05-13 14:20:44 +00:00
Treehugger Robot
5ac4488fec Merge "Keystore 2.0 SPI: Silence warning about blocking calls to Keystore." am: fa8d51d5a6 am: ad73e362f0 am: 41d04381e9
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1706447

Change-Id: I3247db1b8db8691705a3a7856d696a84f0fd1413
2021-05-13 03:00:40 +00:00
Janis Danisevskis
738e422b00 Keystore 2.0 SPI: Fix NPE in getUniqueAliases.
getUniqueAliases may return a null if an error occurred. This would lead
to a NPE in engineAliases.

This patch makes getUniqueAliases return an empty HashSet instead.

Test: atest KeystoreTests

Change-Id: I387d90ea851a8b9c18bb2b20d1a0bfc1ab76c99f
2021-05-12 17:29:26 -07:00
Janis Danisevskis
04d5622233 Keystore 2.0 SPI: Silence warning about blocking calls to Keystore.
Test: N/A
Bug: 184108046
Change-Id: I7401b88e5055cb781113656021f3ec274d1951a4
2021-05-12 16:53:14 -07:00