635 Commits

Author SHA1 Message Date
Janis Danisevskis
a258be6742 Merge "Fix deleting legacy key blobs" am: c24a4b5f44 am: b3c61fac5f
am: 4d8a0decdb

Change-Id: I74ba06e7371696806a8ab1adbd7e65d806e208c4
2018-11-21 15:15:17 -08:00
Janis Danisevskis
4d8a0decdb Merge "Fix deleting legacy key blobs" am: c24a4b5f44
am: b3c61fac5f

Change-Id: I90950d0ecd4b5995ae513ed343f4d8b250183ff5
2018-11-21 15:06:01 -08:00
Janis Danisevskis
906147cdb3 Fix deleting legacy key blobs
Since the keystore alias prefix USERSKEY was deprecated
Credentials.deleteUserKeyTypeForAlias tried to delete key the
remaining prefix first and if that failed tried to delete the
legacy prefix.
However, KeyStore.delete returns true if the key was deleted or
did not exist. So the first call to delete would return true
whether the key existed or not and the legacy alias would never be
deleted.

This patch introduces a new flavor of KeyStore.delete, that returns an
error code instead of a boolean. The caller can now distinguish
the nature of the failure. Credentials.deleteUserKeyTypeForAlias now
checks this return code and attempts to delete the legacy variant if
KEY_NOT_FOUND was returned.

Bug: 117818447
Change-Id: Ifae1f3dbb07d85d94f430ead2cdd3e39d22436a4
2018-11-21 18:42:17 +00:00
TreeHugger Robot
271339ffdf Merge "API: Make implicit APIs from type usage explicit" 2018-11-19 17:21:27 +00:00
Janis Danisevskis
e299490621 Merge "Fix IllegalArgumentException in KeyChain" am: 932f96b27f am: e73f8e8827
am: 28b8cd58ca

Change-Id: I327e931490d3d81b824b134795a57add7c257c74
2018-11-16 15:18:16 -08:00
Janis Danisevskis
28b8cd58ca Merge "Fix IllegalArgumentException in KeyChain" am: 932f96b27f
am: e73f8e8827

Change-Id: I3b779c5456525d4980284baa532eafb415695b47
2018-11-16 14:55:26 -08:00
TreeHugger Robot
278913ae62 Merge "Update KeyStore for new biometric modalities" 2018-11-16 22:52:30 +00:00
Janis Danisevskis
2b106adaf5 Fix IllegalArgumentException in KeyChain
The legacy support importKey method uses the wrong method to add date
fields to the import keymaster arguments.

Bug: 119549023
Change-Id: Iff841086f6616303b365ad28aae429ccae1f3406
2018-11-15 14:58:03 -08:00
Rob Barnes
bf5c28da56 Merge "Added listUidsForAuthBoundKeys to KeyStore" am: 73e9640194 am: 3090f045a7
am: 919f2169e7

Change-Id: I3ed8dcb49baffac2215b0a32e25241bcbd74e9c8
2018-11-15 10:12:38 -08:00
Rob Barnes
919f2169e7 Merge "Added listUidsForAuthBoundKeys to KeyStore" am: 73e9640194
am: 3090f045a7

Change-Id: I10ebfdc276a6af84b32b116c6d93f488ad0c97b8
2018-11-15 10:01:53 -08:00
Rob Barnes
73e9640194 Merge "Added listUidsForAuthBoundKeys to KeyStore" 2018-11-15 17:32:31 +00:00
Adrian Roos
8f91e5fde8 API: Make implicit APIs from type usage explicit
API stubs generation implicitly made any types used by an API also part
of that API. This has caused DeviceIdAttestationException and
ImsFeature.Capabilities to become implicit APIs, so they are added to
the API files.

After this, using non-API types in APIs will become an error to prevent
implicit APIs occuring in the future.

Bug: 119556446
Test: METALAVA_PREPEND_ARGS="--error ReferencesHidden" make
Change-Id: I5fe4f20502b8d4e287b28e9f07139456d4191e22
2018-11-15 07:14:49 -08:00
Janis Danisevskis
463e2b0d3c Merge "Multi-threaded keystore" am: 9f248989bf am: cbd890315e
am: 444162a57c

Change-Id: I2c09961a74c7de92d85f3d2045dd065c94bc6fac
2018-11-15 06:39:39 -08:00
Janis Danisevskis
444162a57c Merge "Multi-threaded keystore" am: 9f248989bf
am: cbd890315e

Change-Id: Ie394840ac3e0bd571b9dfb6654c28d8a4032617f
2018-11-14 17:56:37 -08:00
Rob Barnes
f1a678e0fe Added listUidsForAuthBoundKeys to KeyStore
listUidsForAuthBoundKeys was added to IKeyStoreService.
This CL exposes this method in KeyStore for system apps.
This method will be hidden for non system apps.

Bug: b/112321280
Test: listUidsForAuthBoundKeys in IKeyStoreService has its own tests
Test: This method cannot be tested directly from CTS
Change-Id: Iac9e863079a1367ddb3a599bc3825baea96a1c31
2018-11-14 13:14:35 -07:00
Janis Danisevskis
b0358e72be Multi-threaded keystore
This patch makes the framework use the asynchronous keystore api model.

Bug: 111443219
Test: Ran full keystore cts test suite
Change-Id: I8d1fdc70cb9eb501d3f22a97d1221904c2ef8f9a
2018-11-14 09:59:16 -08:00
Janis Danisevskis
3a33ccca7d Merge changes from topic "async_keystore" am: e8c144fe17 am: 07b06e1bdb
am: d46d33cf25

Change-Id: Id9fcb7d5bac0a24de8ca64e79d50131a5930b8ed
2018-11-09 13:28:56 -08:00
Janis Danisevskis
3a72e2b08e Remove legacy functions form IKeystoreService.aidl am: 1864c95616 am: 036229c8df
am: 5c5fe83c4d

Change-Id: Id2fa59fcbe111a968abef088b76fb97dbe2e369e
2018-11-09 13:21:46 -08:00
Janis Danisevskis
d46d33cf25 Merge changes from topic "async_keystore" am: e8c144fe17
am: 07b06e1bdb

Change-Id: Ie2326ec19b82bf3977e490617fb9935b07dd818a
2018-11-08 15:38:43 -08:00
Janis Danisevskis
5c5fe83c4d Remove legacy functions form IKeystoreService.aidl am: 1864c95616
am: 036229c8df

Change-Id: I7475f8bd936147efaf4344ba625e50875534b8b8
2018-11-08 15:33:21 -08:00
Janis Danisevskis
1864c95616 Remove legacy functions form IKeystoreService.aidl
In preparation for making the keystore service asynchronous we remove
redundant legacy functionality from the protocol.

This patch removes the functions get_pubkey, sign, verify, generate,
and import_key. Which have long been superseded by exportKey
(get_pubkey), begin/update/finish (sign, verify), generateKey
(generate), and importKey (import_key).

This patch also removes isOperationAuthorized.

Test: KeyStore CTS tests
Bug: 111443219
Change-Id: Ib3bd6f40b4e948e5ad6b2ef5278b18ff46201d71
2018-11-08 12:53:57 -08:00
Janis Danisevskis
d257538507 Add return code KEY_ALREADY exists
In preparation to the async keystore interface we change the semantics
form unconditionally overwriting existing keys to reporting that the key
exists. For compatibility we reimplement the same semantic in the
calling code.

Bug: 111443219
Test: KeyStore CTS test
Change-Id: I1fa5428fa7ada97d5068778cd4590593c992554d
2018-11-08 12:53:57 -08:00
Kevin Chyn
057b743fe9 Update KeyStore for new biometric modalities
Biometrics are now generic from KeyStore point of view

Bug: 113624536

Test: Unable to create keys when no templates enrolled
Test: Able to create keys when templates are enrolled
Test: No regression in Fingerprint
      Keys are invalidated after enrolling another FP

Change-Id: I6bdc20eb58c8a0c10a986519d4ba9e1843ebc89d
2018-11-02 18:09:25 -07:00
Janis Danisevskis
2780525ad9 Merge changes I7070326d,I8346e53c am: 546073a5b6 am: 11e9a86034
am: b8037c2c25

Change-Id: I9deb135fedf45c6a7e00a5bd07a73c9fecbdfb47
2018-10-11 14:07:01 -07:00
Janis Danisevskis
b8037c2c25 Merge changes I7070326d,I8346e53c am: 546073a5b6
am: 11e9a86034

Change-Id: I51ea833a23e0f511291c261c8741792c3dbc911a
2018-10-11 13:51:49 -07:00
Janis Danisevskis
11e9a86034 Merge changes I7070326d,I8346e53c
am: 546073a5b6

Change-Id: I4ca0a1ebf9240d81dbbf966fd2ceae3c2bd39a2c
2018-10-11 13:36:49 -07:00
Janis Danisevskis
569055dd60 Add OWNERS file to AndroidKeystoreSPI implementation
Change-Id: I7070326d680c6bff00839d847f8fadbbe2b16fa7
2018-10-11 09:19:58 -07:00
Eran Messeri
9ccec4d2d4 Handle issuer and key type restrictions.
The caller to KeyChain.choosePrivateKeyAlias can restrict the set of
aliases that are displayed to the user to select from by specifying the
issuers that the associated certificates should be issued by or the key
types that these certificates should contain.

Until now this functionality was not implemented. This was mostly
affecting Chrome
(https://bugs.chromium.org/p/chromium/issues/detail?id=753756).

Support this functionality by passing the issuers and key types into the
KeyChainActivity (from KeyChain) and, prior to displaying the aliases
associated with the certificates, check if each certificate adheres to
the criteria (key type, issues) specified.

Bug: 62910781
Test: m -j RunKeyChainRoboTests
Change-Id: I75e071545699891cfbd77d4f706fc5ef35b85516
2018-09-05 13:58:32 +01:00
Eva Bertels
f1bbe75ede Minor changes to check for misprovisioned Pixel 2 devices
Check for brand parameter specified in config file. Implementing suggestion that was added to the original CL (ag/4791307) after it was submitted.

Bug: 69471841
Test: atest com.android.cts.devicepolicy.MixedDeviceOwnerTest#testKeyManagement
Change-Id: I9b257f406d5b47265db4dbf022df75865f496cdd
2018-08-28 17:19:51 +01:00
Eva Bertels
eeedc9e276 Merge "Added check for misprovisioned Pixel 2 device." into pi-dev
am: ec94be1526

Change-Id: I443bd4a96e616616e4608f1e9a8c5d8554647e56
2018-08-24 11:21:06 -07:00
Eva Bertels
e238d589f1 Added check for misprovisioned Pixel 2 device.
Some Pixel devices had a wrong brand value provisioned into keymaster.
Due to this misprovisioning those devices fail device ID attestation because it includes a check for the correct brand value.
This is now solved by re-trying Device ID attestation if we are running on a potentially misprovisioned device, allowing for the known incorrect brand value.

Bug: 69471841
Test: atest com.android.cts.devicepolicy.MixedDeviceOwnerTest#testKeyManagement
Change-Id: Ia0da5478d6092c1927d26600a6893ae8ce53da51
2018-08-24 13:43:47 +01:00
Eva Bertels
3f821a8e17 Added check for misprovisioned Pixel 2 device.
Some Pixel devices had a wrong brand value provisioned into keymaster.
Due to this misprovisioning those devices fail device ID attestation because it includes a check for the correct brand value.
This is now solved by re-trying Device ID attestation if we are running on a potentially misprovisioned device, allowing for the known incorrect brand value.

Bug: 69471841
Test: atest com.android.cts.devicepolicy.MixedDeviceOwnerTest#testKeyManagement
Change-Id: If715ebdd4ab6d7fcfffab60b40fd2dc8fa1fda44
Merged-In: Ia0da5478d6092c1927d26600a6893ae8ce53da51
2018-08-24 11:39:20 +00:00
Treehugger Robot
fcb597e1f5 Merge "Correct the keystore alias used for secure imports" 2018-08-17 13:48:56 +00:00
Shawn Willden
281b7cf7d9 Correct the keystore alias used for secure imports
An Android-O timeframe refactor removed all use of keystore "skey"
aliases.  Creating one not only partially reverses that refactor, but
it also results in a key alias which cannot be deleted in some cases,
causing AndroidKeyStoreTest failures during the second run of CTS.

Bug: 80228327
Test: CTS tests ImportWrappedKeyTest and AndroidKeyStoreTest, in that order
Change-Id: I348ba421f29cdf6c65fc98be3a25d19938d559c1
2018-08-17 06:39:01 -06:00
Mathew Inwood
29779732e6 Merge "Add @UnsupportedAppUsage annotations" am: d9381f5e56
am: e2a6ad99ae

Change-Id: I3a0236e8388f7f5448a10873a3e0f0ca502fa625
2018-08-17 03:16:13 -07:00
Mathew Inwood
e2a6ad99ae Merge "Add @UnsupportedAppUsage annotations"
am: d9381f5e56

Change-Id: I3940d669bb1f4fedc8a7fbbcdb8de2ef954674a8
2018-08-17 02:13:11 -07:00
Mathew Inwood
4dbdcf43ad Add @UnsupportedAppUsage annotations
For packages:
  android.security.net.config
  android.security.keystore
  android.security.keymaster
  android.security

This is an automatically generated CL. See go/UnsupportedAppUsage
for more details.

Exempted-From-Owner-Approval: Mechanical changes to the codebase
which have been approved by Android API council and announced on
android-eng@

Bug: 110868826
Test: m
Change-Id: Ifed4da56531195f64fd53d84f14b4e8298843b2c
Merged-In: I7762dd647bede8abc9be2c538af3a3a99a25a73e
2018-08-16 18:49:37 +01:00
Mathew Inwood
e420f8b5fb Add @UnsupportedAppUsage annotations
For packages:
  android.security.net.config
  android.security.keystore
  android.security.keymaster
  android.security

This is an automatically generated CL. See go/UnsupportedAppUsage
for more details.

Exempted-From-Owner-Approval: Mechanical changes to the codebase
which have been approved by Android API council and announced on
android-eng@

Bug: 110868826
Test: m
Change-Id: I7762dd647bede8abc9be2c538af3a3a99a25a73e
2018-08-16 18:40:47 +01:00
Janis Danisevskis
dbb6114d96 Merge "Fix symmetric key generation in strongbox" into pi-dev
am: 0e43e2ef96

Change-Id: I154ab21e8f0d804225f993d187e2aad66a5cdeac
2018-08-15 12:10:17 -07:00
TreeHugger Robot
0e43e2ef96 Merge "Fix symmetric key generation in strongbox" into pi-dev 2018-08-15 18:53:16 +00:00
TreeHugger Robot
cb71d0b2fc Merge "Fix symmetric key generation in strongbox" 2018-08-15 16:10:30 +00:00
Mathew Inwood
8f29903747 Merge "Code reformatting for upcoming annotations." am: 60c8cfdd0f am: 02763a1c3e am: 842e882507
am: e377a769bd

Change-Id: I67465690c2addbbfbe53472e5b45783821990567
2018-08-01 18:08:20 -07:00
Mathew Inwood
842e882507 Merge "Code reformatting for upcoming annotations." am: 60c8cfdd0f
am: 02763a1c3e

Change-Id: Icdbef4bd0e71876a3ddb296ca38a243209f2eaf9
2018-08-01 16:35:28 -07:00
Mathew Inwood
02763a1c3e Merge "Code reformatting for upcoming annotations."
am: 60c8cfdd0f

Change-Id: I4fcf520f53dddd6e70edf0d59fd13ae218c336a5
2018-08-01 16:01:52 -07:00
Mathew Inwood
efb481646e Code reformatting for upcoming annotations.
@UnsupportedAppUsage annotations are added automatically, but this does
not work when there are multiple definitions on the same line.

Test: m
Bug: 110868826
Change-Id: I2c26c136cdfa557e45cf1ee0b39dab9c17abde56
2018-08-01 10:24:49 +01:00
Janis Danisevskis
6064a17fa4 Fix symmetric key generation in strongbox
The strongbox flag was not passed to keystore by
AndroidKeyStoreKeyGeneratorSpi. As a result keys, that were supposed to
be generated in strongbox would silently be generated in TEE.

Test: There is no reliable way to test this other than instrumenting or
      debugging the strongbox implementation. This was done by the
      author of this patch.
Bug: 109769728
Change-Id: I8a08838440030fab7b774762c3d6af0d3b6a4ad8
Merged-In: I8a08838440030fab7b774762c3d6af0d3b6a4ad8
2018-07-31 18:19:03 +00:00
Janis Danisevskis
7aa04ef24d Fix symmetric key generation in strongbox
The strongbox flag was not passed to keystore by
AndroidKeyStoreKeyGeneratorSpi. As a result keys, that were supposed to
be generated in strongbox would silently be generated in TEE.

Test: There is no reliable way to test this other than instrumenting or
      debugging the strongbox implementation. This was done by the
      author of this patch.
Bug: 109769728
Change-Id: I8a08838440030fab7b774762c3d6af0d3b6a4ad8
2018-07-31 15:48:17 +00:00
Eran Messeri
607a995691 DPM: Propagate StrongBox-related exception
When the caller attempts to generate a key via DevicePolicyManager
(using DevicePolicyManager.generateKeyPair), and specifies that
StrongBox should be used, throw the right exception indicating
StrongBox unavailability - the same one that is thrown if the same
parameters were passed to the KeyStore's key generation method.

This is achieved by catching the StrongBoxUnavailableException in
KeyChain, returning an error code indicating this particular failure
to the DevicePolicyManagerService, which then propagates it by
throwing a service-specific exception with a value indicating
StrongBox unavailability.
The DevicePolicyManager then raises StrongBoxUnavailableException.

Prior to this change the exception propagated from KeyChain would be
a generic failure so the caller would simply get a null result.

Bug: 110882855
Bug: 111183576
Bug: 111322478
Test: atest CtsDevicePolicyManagerTestCases:com.android.cts.devicepolicy.MixedDeviceOwnerTest#testKeyManagement
Change-Id: I9abe3f449b48eb5a960fafbc15c59b9b4ce7a966
2018-07-17 12:58:13 +01:00
Eran Messeri
84c8b0fe47 Merge "Correctly preserve key generation parameters" into pi-dev am: 6f7cfb0627
am: e323fcbe98

Change-Id: I8cdbb82cd6fee604775764519dc8bf835a9c3738
2018-07-03 12:07:59 -07:00
Eran Messeri
5a5c6e0e44 Correctly preserve key generation parameters
Due to an oversight, some of the key generation parameters that are set
in KeyGenParameterSpec were not preserved when parceling the object
(they should have been added to ParcelableKeyGenParameterSpec but were
not).

This means these parameters will be ignored when generating keys using
the DevicePolicyManager.generateKeyPair method, leading to an
inconsistent key generation behaviour between the DevicePolicyManager
and KeyStore.

In particular, this would prevent callers from using StrongBox when
generating keys for use in the KeyChain.

Fix the issue by simply persisting these parameters in
ParcelableKeyGenParameterSpec and making sure that the Builder copies
them too from the source KeyGenParameterSpec.

Left to do is put in place an automated measure to find out
discrepancies between the two classes.

Bug: 110915980
Bug: 110882855
Bug: 109953656
Test: atest KeystoreTests
Change-Id: Ic64bd2921b6dfc97ea34ecba55f532312963ffcb
2018-06-28 17:20:01 +01:00