Commit Graph

734 Commits

Author SHA1 Message Date
Treehugger Robot
31952c368f Merge "Keystore 2.0 SPI: Fix installation of legacy Keystore provider" am: 5408268606 am: 3a1c6e6b9e am: 2d6247e322
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1503891

Change-Id: I144782a0ccbdfb7b78ce63db9eec8a71e058de9f
2020-11-27 01:41:49 +00:00
Janis Danisevskis
9fb5607114 Keystore 2.0 SPI: Fix installation of legacy Keystore provider
Priviously we installed the legacy keystore SPI by the name
KeyStore.AndroidKeyStore and set an alias to
KeyStore.AndroidKeyStoreLegacy. This conflicted with with the Keystore
provider which also registers as KeyStore.AndroidKeyStore.
This patch registers the old provider only by the name
KeyStore.AndroidKeyStore.

Test: CtsLibcoreTestCases:libcore.java.security.ProviderTest#test_Provider_Properties
      Also, the device boots.
Change-Id: I38a248a996839f397bdcae30fd1b03a883209df2
2020-11-23 21:59:22 -08:00
Treehugger Robot
a6c32cb0e0 Merge "Fix Broken test: libcore.java.security.ProviderTest#test_Provider_Properties" am: c778d8e747 am: 796b8b3687 am: ee01197b77 am: b6b0dee076
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1503571

Change-Id: I5607d564f17134d746431a7e0f024844030a5753
2020-11-18 22:53:50 +00:00
Treehugger Robot
c778d8e747 Merge "Fix Broken test: libcore.java.security.ProviderTest#test_Provider_Properties" 2020-11-18 21:39:54 +00:00
Janis Danisevskis
fc02edb5f5 Fix Broken test: libcore.java.security.ProviderTest#test_Provider_Properties
Test: CtsLibcoreTestCases:libcore.java.security.ProviderTest#test_Provider_Properties
Bug: 173480441
Change-Id: I188cd778a25d221991280eb461a7ec052503790c
2020-11-18 11:49:15 -08:00
Treehugger Robot
2b09184302 Merge changes from topic "ks2_with_keymint" am: ab1b8a7a20 am: 2694b808b2 am: 2eb526a1ae am: 0a9852039f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1475676

Change-Id: Ib18ef9e5fd4203f41af95d916c7e02436f44abfa
2020-11-18 17:28:18 +00:00
Janis Danisevskis
bc119dfb2b Keystore 2.0 SPI: Use KeyMint AIDL types.
We are now using KeyMint types for KeyParameter and SecurityLevel.

Test: None
Change-Id: I3db72c17a9cb999a0248df4c37588dfc2ad84f74
2020-11-17 17:45:08 -08:00
Janis Danisevskis
148e99707e resolve merge conflicts of 07bfeb3630 to master
Test: I solemnly swear I tested this conflict resolution.
Bug: None
Change-Id: Iab84b0fa8c708845aecd13dd45c242147829fd8b
2020-11-16 19:28:35 -08:00
Janis Danisevskis
4392c6977c Keystore 2.0 SPI: Install legacy Keystore provider as AndroidKeyStoreLegacy
With this patch we install the old Keystore provider as
AndroidKeyStoreLegacy when the Keystore 2.0 provider is installed as
AndroidKeyStore. This allows system components to keep using the old
keystore while we can run CTS tests against the new provider.

The tests are still mostly failing at this point. Installing the new SPI
can be enabled by setting the property
ro.android.security.keystore2.enable=true

Bug: 159476414
Test: This enables running CTS tests against Keystore 2.0.
Change-Id: I9731d9783ccf8f2705a5ca7335e00c8f4c8debba
2020-11-13 19:55:41 -08:00
Janis Danisevskis
940e05164e Keystore 2.0 SPI: Evolve the generator SPI.
We delegate the generation of self signed certificates to the KeyMint
backend. Also we use the KeyParamter AIDL type instead of
KeymasterArguments to construct parameter lists.

Bug: 159476414
Test: None
Change-Id: I441a4d4df4ef04e3da8aeaff3274c609d549c979
2020-11-13 19:55:41 -08:00
Janis Danisevskis
e6495d774b Keystore 2.0 SPI: Evolve Factory SPI
We no longer need to get the key characteristics from the Keystore
daemon to construct the KeyInfo for a key. Also we have to extract the
key info from the KeyParameter AIDL type rather than from the hand
written KeymasterArguments.

This patch also exposes the correct security level for a key through
KeyInfo.

Bug: 159476414
Test: None
Change-Id: I86a85e481e19fdadfed38a42aeac4ffe5f8b83fa
2020-11-13 19:55:40 -08:00
Janis Danisevskis
38ab78f0a0 Keystore 2.0 SPI: AndroidKeyStoreProvider loads keys from Keystore 2.0
This patch adjusts the AndroidKeyStoreProvider to register all services
with the correct packages names. And the utility functions load key
using the correct Keystore 2.0 methods.

Bug: 159476414
Test: None
Change-Id: I9268fd66d28e89e188e85991bcf90c7f19809232
2020-11-13 19:55:40 -08:00
Janis Danisevskis
4545933da5 Keystore 2.0 SPI: Evolve the Crypto SPI.
This patch evolves the Crypto SPI to use the new Keystore 2.0 shim.
The main changes are:
 * The SPI uses the AIDL defined KeyParameter instead of
   KeymasterArguments.
 * Operations are created directly from the KeystoreSecurityLevel that
   is part of the AndroidKeyStoreKey object.

Also this patch deletes the DeletatingX509Certificate class. This is no
longer needed, because public key operations are no longer performed by
Keystore 2.0. We can delegate public certificate operations simply by
wrapping such certificates into public keys that are understood by other
providers, such as BouncyCastle.

Bug: 159476414
Test: None
Change-Id: Ice874a8121d80bf788da059b4e8420c7dd799d81
2020-11-13 19:55:40 -08:00
Janis Danisevskis
4be5005c05 Keystore 2.0 SPI: KeyParameter utilities.
The wire type for key parameters is now generated from AIDL rather than
the hand written parcelable KeymasterArguments. So we need some of the
utilities for creating key parameters that the latter provided.
We also nicked some utility function from KeymasterUtils.

Bug: 159476414
Test: None
Change-Id: I12c674b6a00dd3abbed4972d80ceb766a73881e8
2020-11-13 19:55:40 -08:00
Janis Danisevskis
4ba9a09bdd Keystore 2.0 SPI: Update the chunked streamer.
This patch makes the chunked streamer observe the simplified
Keystore 2.0 operation interface. Keystore is now required to consume
all supplied data or reject data outright if too much (more than 32KiB)
is supplied in a single transaction. This allows for a simplified
streamer logic and a simplified interface. We also no longer send
entropy to Keystore. This will be handled by the Keystore 2.0 daemon.

Test: None
Bug: 159476414
Change-Id: Ie75d10fd5d5ac0da60e23e35467d0a7873230dea
2020-11-13 19:55:40 -08:00
Janis Danisevskis
27ee56c021 Keystore 2.0 SPI: KeyStoreCryptoOperationUtils
Keystore 2.0 does no longer report an error code if an operation
requires user authorization. Instead this is indicated by sending us
an operation challenge. In that case we have to check if the
authorization can possibly succeed. We changed the utility class by
adding a predicate function that checks exactly that, and we handle
other errors separately instead of having one exception handling path
that does all.

Test: None
Bug: 159476414
Change-Id: I9a373cf8f0a0b181df54c26fe314d71b6835bb97
2020-11-13 19:55:39 -08:00
Janis Danisevskis
e5795a90db Keystore 2.0 SPI: KeyStoreKeys adopt Keystore 2.0
KeyStoreKeys can now be constructed from key entry metadata and key
descriptors as defined by the new Keystore AIDL spec.
AndroidKeystorePublicKey can now create the private key proxy.
KeyStoreKeys also cache the key characteristic, which should drastically
reduce the frequency by which the SPI has to call into the Keystore 2.0
daemon.

Test: None
Bug: 159476414
Change-Id: Ia0a7841582621897760be49d39dd5442b70b3aa0
2020-11-13 19:55:39 -08:00
Janis Danisevskis
ebd964a086 Keystore 2.0: Shim around the basic functionality of Keystore 2.0
This patch adds a shim around the Keystore 2.0 AIDL spec. The new shim
is modularized like the AIDL spec into the base Keystore module
Keystore2, the security level specific interface KeystoreSecurityLevel,
and the operation specific interface KeystoreOperation.

Other system maintenance specific interfaces have yet to be added.

Bug: 159476414
Bug: 171305684
Test: None
Change-Id: I070f73739e4b37ce10568939ac666e40b14a52a8
2020-11-13 19:55:39 -08:00
Janis Danisevskis
f88d3a4b27 Keystore 2.0 SPI: Duplicate Keystore SPI to android.security.keystore2 package
This patch copies the relevant portion of the Keystore SPI to the new
package name android.security.keystore2. The purpose of this is to
illustrate the evolution from the existing Keystore SPI to the
Keystore 2.0 SPI while keeping the existing Keystore SPI intact.
Reviewers are advised to check the equivalence of this code to the
corresponding files in
    android/security/keystore (<-- no 2 here).
Subsequent patches can them be reviewed as evolution towards the new SPI
rather than completely new code.

Test: None. When the evolution is complete, Keystore CTS tests can be
used to check for regressions.
Bug: 159476414

Change-Id: I21a01a679e789868ce820b5f73221e616a456a61
2020-11-13 11:01:47 -08:00
Treehugger Robot
072951e482 Merge "Keystore 2.0 SPI: Add forEach for int arrays to ArrayUtils" am: 47e0d9e30b am: 7afe866370 am: 5427aff46d am: 0486a1aba6
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1470092

Change-Id: I507b40fa2104d85c4f0aab78fef259a7b0988468
2020-11-12 19:44:17 +00:00
Treehugger Robot
47e0d9e30b Merge "Keystore 2.0 SPI: Add forEach for int arrays to ArrayUtils" 2020-11-12 17:57:42 +00:00
Janis Danisevskis
cbab0d133b Keystore 2.0 SPI: Add forEach for int arrays to ArrayUtils
This patch adds a forEach function for int arrays to
android.security.keystore.ArrayUtils. A utility function with the
intendet use in Keystore 2.0 Key paramter handling.

Test: None
Change-Id: I2c02b300ee68fcd548c128deb0266fe603226807
2020-11-12 08:03:25 -08:00
Janis Danisevskis
94f9ea72a0 Merge "Keystore 2.0 SPI: Update KeyInfo and KeyGenParameterSpec" am: 17f24b5799 am: 7d49ae705e am: 7662e81e98 am: b90d33bd18
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1470091

Change-Id: I5728741cdd66f9b6ba6f39310c796cb8b12758e5
2020-11-12 00:55:08 +00:00
Janis Danisevskis
17f24b5799 Merge "Keystore 2.0 SPI: Update KeyInfo and KeyGenParameterSpec" 2020-11-11 23:10:13 +00:00
Janis Danisevskis
c5bdd77f1a Keystore 2.0 SPI: Update KeyInfo and KeyGenParameterSpec
This patch adds set/getSecurityLevel to KeyInfo and KeyGenParameterSpec
and it deprecates the superseded function isInSecureHardware.

It also deprecates the system API set/getUid and replaces it with the
more generic set/getNamespace.

Test: None
Change-Id: Id2f54596510954862b5077a935f3daf07211f29c
2020-11-11 07:53:54 -08:00
Mathew Inwood
f8abe13db4 Merge "Add maxTargetSdk restriction to unused APIs." 2020-11-09 14:41:20 +00:00
Treehugger Robot
9ad8254a96 Merge changes Ib3c9affb,I1dbe3d02,I88681f21 am: 1f65c6b62e am: f2abffe107 am: df8410e677 am: 15e1f8f5eb
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1451015

Change-Id: Ia0c6195e820a04d5ac0a330a0813d308d0eb0c08
2020-11-06 02:32:52 +00:00
Treehugger Robot
15e1f8f5eb Merge changes Ib3c9affb,I1dbe3d02,I88681f21 am: 1f65c6b62e am: f2abffe107 am: df8410e677
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1451015

Change-Id: I654b14fb0386d5bea6d22e37a394b00c1f66a87c
2020-11-06 02:14:41 +00:00
Janis Danisevskis
62c1d2869d Keystore 2.0: KeyProperties SignaturePadding is now public but hidden
In anticipation of the new Keystore 2.0 SPI we made this nested class
public (like its siblings) so that the new SPI which resides in a
different package may access it. It is hidden though because it does not
constitute public API surface.

Test: None
Bug: 171305684
Change-Id: I1dbe3d02c03f97f843813c26c16aaef7152ca478
2020-11-05 13:11:12 -08:00
Janis Danisevskis
d2c944bc4d Keystore SPI: Add SecurityLevelEnum to KeyProperties
This patch adds the SecurityLevelEnum to KeyProperties. This enum can be
used by the public API surface to express levels of enforcements of key
properties. And to select a designated residence for a newly generated
or imported key.

The values UNKNOWN and UNKNOWN_SECURE are used to convey to older target
APIs API levels that have not been defined when they where published.

Test: None
Change-Id: I88681f21b8a8ea9a383d32ba99f3ab7d7c8909c3
2020-11-05 13:11:12 -08:00
Mathew Inwood
5d123b6775 Add maxTargetSdk restriction to unused APIs.
These are APIs that have @UnsupportedAppUsage but for which we don't
have any evidence of them currently being used, so should be safe to
remove from the unsupported list.

Bug: 170729553
Test: Treehugger
Merged-In: I626caf7c1fe46c5ab1f39c2895b42a34319f771a
Change-Id: I54e5ecd11e76ca1de3c5893e3a98b0108e735413
2020-11-04 09:45:53 +00:00
Janis Danisevskis
a18b2db113 Merge changes I7c17ab51,I5bd4acb4,I93270f00 am: 18bbac10c1 am: 68acc834d4 am: c04b6004a3 am: 9060b67f0f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1470088

Change-Id: Iaca7385d86f44b1c1cb8625340c8e5a6033d10c7
2020-11-02 21:28:34 +00:00
Janis Danisevskis
9060b67f0f Merge changes I7c17ab51,I5bd4acb4,I93270f00 am: 18bbac10c1 am: 68acc834d4 am: c04b6004a3
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1470088

Change-Id: I59184b7d4a01b1478599b53b6f7dd1fc3b3c5465
2020-11-02 21:14:04 +00:00
Mathew Inwood
5f0edaaaf5 Add maxTargetSdk restriction to unused APIs.
These are APIs that have @UnsupportedAppUsage but for which we don't
have any evidence of them currently being used, so should be safe to
remove from the unsupported list.

Bug: 170729553
Test: Treehugger
Merged-In: I8285daa8530260251ecad6f3f38f98e263629ca7
Change-Id: I626caf7c1fe46c5ab1f39c2895b42a34319f771a
2020-11-02 10:30:09 +00:00
Mathew Inwood
8e742f928e Add maxTargetSdk restriction to unused APIs.
These are APIs that have @UnsupportedAppUsage but for which we don't
have any evidence of them currently being used, so should be safe to
remove from the unsupported list.

This is a resubmit of ag/12929664 with some APIs excluded that caused
test failures; see bugs 171886397, 171888296, 171864568.

APIs excluded:
Landroid/bluetooth/le/ScanRecord;->parseFromBytes([B)Landroid/bluetooth/le/ScanRecord;
Landroid/os/Process;->myPpid()I
Landroid/os/SharedMemory;->getFd()I
Landroid/hardware/input/InputManager;->INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH:I

Bug: 170729553
Test: Treehugger
Change-Id: I8285daa8530260251ecad6f3f38f98e263629ca7
2020-10-29 11:51:12 +00:00
Hongwei Wang
050275cd83 Revert "Add maxTargetSdk restriction to unused APIs."
This reverts commit 72f07d6a8a.

Reason for revert: Droidcop-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?testMethod=testAppZygotePreload&testClass=android.app.cts.ServiceTest&atpConfigName=suite%2Ftest-mapping-presubmit-retry_cloud-tf&testModule=CtsAppTestCases&fkbb=6936597&lkbb=6936969&lkgb=6936551&testResults=true&branch=git_master&target=cf_x86_phone-userdebug>, bug b/171886397

Bug: 171886397
Change-Id: Ibe0f0430a3451477c1ee8ef56a596e91ea1e7672
2020-10-28 20:16:22 +00:00
Janis Danisevskis
26c878fb66 Keystore SPI: Deprecate encryption flag.
The encryption-required flag is only available in already deprecated
API KeyPairGeneratorSpec and KeyStoreParameter will be ignored from
Android S. Keys are and have been encrypted by default for a long time
and if additional binding to the LSKF is desired it can be requested
by KeyGenParameterSpec.Builder#setUserAuthenticationRequired(boolean).

Test: None
Change-Id: I5bd4acb4bba276decd1930ae2e96a55f95627e10
2020-10-27 12:09:37 -07:00
Janis Danisevskis
2528438731 Keystore 2.0: Deprecate Credential prefixes.
Keystore 2.0 will no longer support free form blobs. Certificates and
certificate chains will have types fields associated with an alias.
Other free form blobs will need to be migrated to a different key value
store.

Bug: 171305684
Test: None
Change-Id: I93270f0086329229dc36c2b14c88f229351e6560
2020-10-27 12:09:37 -07:00
Mathew Inwood
72f07d6a8a Add maxTargetSdk restriction to unused APIs.
These are APIs that have @UnsupportedAppUsage but for which we don't
have any evidence of them currently being used, so should be safe to
remove from the unsupported list.

Bug: 170729553
Test: Treehugger
Change-Id: I4c8fd0006f950de9955242e93968fb0996ceb372
2020-10-27 15:46:07 +00:00
Treehugger Robot
0c4f8f2f9d Merge "Keystore SPI: Fix typos." am: 881b75d3ed am: b0421a53b2 am: c1892e8344 am: 48225d0851
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1470257

Change-Id: I1eab0c9491547010eed8c4e20298551eb0c46933
2020-10-23 21:17:45 +00:00
Rubin Xu
f12ade33a3 Apply FLAG_IMMUTABLE to KeyChain PendingIntent
Bug: 170425388
Test: make
Change-Id: I4a2914f9f91c27755ee1718048057cb52f8a5631
2020-10-23 13:59:25 +01:00
Janis Danisevskis
bb4e97ebf3 Keystore SPI: Fix typos.
Test: None
Change-Id: Iba25385b42db8059cc0811e99463e01acb98e00f
2020-10-22 21:03:32 -07:00
Anton Hansson
586a3cf229 Remove @TestApi from @SystemApi symbols
I ran these commands:
    cd frameworks/base
    grep -rl '@TestApi' --include '*.java' | xargs perl -i -p0e \
        's/\@SystemApi[\s\n]+(\@\w+[\s\n]+)?\@TestApi/\@SystemApi\1/gs'
    grep -rl '@TestApi' --include '*.java' | xargs perl -i -p0e \
        's/\@TestApi[\s\n]+(\@\w+[\s\n]+)?\@SystemApi/\1\@SystemApi/gs'

Bug: 171179806
Test: m checkapi
Change-Id: I772790b783b0a8730b8bf680c9e569a886b8d789
2020-10-20 09:04:03 +01:00
Anton Hansson
dd7d52f963 Remove @TestApi from @SystemApi symbols
I ran these commands:
    cd frameworks/base
    grep -rl '@TestApi' --include '*.java' | xargs perl -i -p0e \
        's/\@SystemApi[\s\n]+(\@\w+[\s\n]+)?\@TestApi/\@SystemApi\1/gs'
    grep -rl '@TestApi' --include '*.java' | xargs perl -i -p0e \
        's/\@TestApi[\s\n]+(\@\w+[\s\n]+)?\@SystemApi/\1\@SystemApi/gs'

Bug: 171179806
Test: m checkapi
Change-Id: I772790b783b0a8730b8bf680c9e569a886b8d789
Merged-In: I772790b783b0a8730b8bf680c9e569a886b8d789
2020-10-19 16:41:01 +01:00
Automerger Merge Worker
76e6503ea9 Merge "Merge "Remove DERInteger usages" am: 1835a24839 am: 07e62d7649 am: 96bdc2d785 am: a96a45bedf" into rvc-qpr-dev-plus-aosp am: a4eb2e220c
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1305793

Change-Id: I095ed2a27b4d483d1a64e2d1da0b5a2813e8e806
2020-07-03 12:51:32 +00:00
Daulet Zhanguzin
96bdc2d785 Merge "Remove DERInteger usages" am: 1835a24839 am: 07e62d7649
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1305793

Change-Id: I7ec9709e9f152fac13b3f56dc1f9238869502c39
2020-07-03 12:02:35 +00:00
Daulet Zhanguzin
1835a24839 Merge "Remove DERInteger usages" 2020-07-03 11:42:50 +00:00
Treehugger Robot
faa8d92090 Merge "Preserve interrupted state across waiting for future" am: 3a91c75184 am: f6574a21c2
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1340128

Change-Id: Ica523ae5269ba5e2a339653024870fefa581ad64
2020-06-17 14:53:00 +00:00
Janis Danisevskis
edcacd5374 Preserve interrupted state across waiting for future
A normal synchronous binder call would not be influenced by an
interrupted thread. With the move to asynchronous keystore IPC we wait
on a future which can throw an interrupted exception. The Java crypto
API does not expect the implementation to throw interrupted exceptions
though. So to preserve the expected behavior we wrap the Future.get()
calls in a loop that handles the interrupted exception and sets the
interrupted state after the get completed successfully.

Bug: 147398412
Bug: 155254932
Test: atest android.keystore.cts.CipherTest#testEncryptsAndDecryptsInterrupted
Change-Id: I066180e8028cc426fa1b3739fa007faa17c8c012
Merged-In: I066180e8028cc426fa1b3739fa007faa17c8c012
2020-06-16 19:54:38 -07:00
TreeHugger Robot
5f489cd753 Merge "Fixing default timeout constant" into rvc-dev am: 7697d0f3eb am: 1b701701e9 am: 587b4e8610 am: 391cd6531f
Change-Id: If4fde553a5e6a9e32a57f0ed03c45d58d3ca5184
2020-05-21 16:54:24 +00:00