Commit Graph

699 Commits

Author SHA1 Message Date
Max Bires
7de99c2f1a Merge "Updating accepted HMAC key sizes" am: 1cf90f78f1 am: 7f813b80d3
am: 432cb5d523

Change-Id: I1308b205762df42ed5fdc23da00f84a8cc31d45e
2019-11-19 19:57:30 -08:00
Rob Barnes
c00713055b Merge "Allow for input_data on finish." am: 4a83b14ada am: 02c287a628
am: 51e842e43c

Change-Id: I3ed4477e925a203ae8a7b1dde9744ade4a32e93c
2019-11-19 19:50:18 -08:00
Treehugger Robot
1cf90f78f1 Merge "Updating accepted HMAC key sizes" 2019-11-19 23:59:32 +00:00
Rob Barnes
92743aeb44 Allow for input_data on finish.
This additional input will be unused for now, but future changes are
expected to utilize it.

Test: Keystore CTS Tests
Change-Id: I5c388032e3710e3825bdb06b26443a5ae2c034a3
2019-11-14 16:19:20 -07:00
Robert Horvath
3bb0b61820 Merge "Fix NPE when KeyChain binding dies" 2019-11-14 14:10:36 +00:00
Robert Horvath
54c94398bf Fix NPE when KeyChain binding dies
BlockingQueue does not accept null values, change to CountDownLatch for
synchronization.

Bug: 144477553
Test: Enable multiple managed profiles, and run
      `atest UserLifecycleTests#managedProfileStopped`
Change-Id: I1a003568896ce7983a5ac14a710944d914c86bac
2019-11-14 14:01:46 +01:00
TreeHugger Robot
bc7671b9fb Merge "Add @UnsupportedAppUsage to test apis that are known to be used by apps." 2019-11-13 15:46:27 +00:00
Artur Satayev
5a525851a8 Add @UnsupportedAppUsage to test apis that are known to be used by apps.
go/testapi-enforcement

Bug: 133832325
Test: m
Change-Id: Ifc8db120640a1554dcbf1722e61e09c7ddc65dd6
Merged-In: Ifc8db120640a1554dcbf1722e61e09c7ddc65dd6
2019-11-13 15:05:56 +00:00
Roshan Pius
780d117268 keystore: Expose @SystemApi's to wifi mainline module
Two @SystemApi's being added to allow wifi mainline module to access
formal API's:
a) KeyGenParameterSpec.Builder.setUid() to allow wifi to create/store keys
with WIFI_UID.
b) AndroidKeyStoreProvider.getKeyStoreForUid() to allow wifi to get/put
any keys stored with WIFI_UID.

Both of these API's are already permission protected in the lower
layers. There is a map of euid's stored in the native keystore which
limits which uid is allowed to access which other uid's data.

Bug: 142089671
Test: make system-api-stubs-docs-update-current-api
Change-Id: I39b92d2293bcdc26bb0a4a48a1d1e4cc0b20ad0b
2019-11-13 06:08:13 -08:00
Artur Satayev
f0b7d0ba51 Add @UnsupportedAppUsage to test apis that are known to be used by apps.
go/testapi-enforcement

Bug: 133832325
Test: m
Change-Id: Ifc8db120640a1554dcbf1722e61e09c7ddc65dd6
Merged-In: Ifc8db120640a1554dcbf1722e61e09c7ddc65dd6
2019-11-13 12:58:29 +00:00
Max Bires
ca0d4d8f42 Updating accepted HMAC key sizes
In order to keep conformity across the ecosystem, keystore will enforce
that HMAC key sizes coming in through the framework must be limited to
the range of 64-512 bits, inclusive. This will be the case for both TEE
and StrongBox Keymaster implementations.

Bug: 143404829
Test: atest CtsKeystoreTestCases
Change-Id: I2ea867392060f4478b5a01bd747a4345e1fded4c
2019-11-12 13:42:58 -08:00
Rubin Xu
c398627e5e Update keyguard locked state from TrustManagerService
TrustManagerService holds the ground truth about whether a user is
locked or not, so update keystore using the information there,
instead of doing it from KeyguardStateMonitor. This fixes the issue
of work profile locked state not being correctly pushed to keystore.

Note: since this change is likely to be backported as a security
patch, I'm refraining from doing major refactoring right now.

Bug: 141329041
Test: manually with KeyPairSampleApp
Change-Id: I3472ece73d573a775345ebcceeeb2cc460374c9b
2019-11-08 13:40:42 +00:00
Rubin Xu
3bf1ccc1cf Merge "Handle the case when KeyChain binding fails" 2019-10-28 22:29:59 +00:00
Alex Johnston
fde28690ff Added functionality to select type of certificate to be installed from the Settings app
This is part of the changes to improve the UX and language for installing certificates.
Previously, the different types of certificate used the same installation flow. This CL
introduces a new settings page, where the type of certificate to be installed can be selected.

Bug: 139173976
Test: Atest com.android.settings.security
      manual testing from Settings by selecting the certificate type
	preference and ensuring the installation flow still worked as expected.

Change-Id: I6e0606b00c5f684571ffbd903b9cf55c6911fd0f
2019-10-24 10:32:55 +01:00
Rubin Xu
7629a4b45e Handle the case when KeyChain binding fails
Binding to keychain can fail, for example when the target user
is being removed. Handle this case gracefully and do not block
the system server.

Bug: 139554671
Test: none
Change-Id: Ib68c873e367428b82f3cb2a81cafe1a59776336c
2019-10-23 15:36:17 +01:00
Polina Bondarenko
ecc2cde45b Fix KeyChain.KEY_ALIAS_SELECTION_DENIED
Remove the UUID suffix from the constant to make it less confusing.

Bug: 142347719
Test: compile
Change-Id: I6e73f1ef71c30c5b4388931abc8e431eaede6ece
2019-10-16 13:40:31 +02:00
TreeHugger Robot
8e73c69e91 Merge "Add KeyChain.KEY_ALIAS_SELECTION_DENIED constant." 2019-10-07 14:57:42 +00:00
Polina Bondarenko
a75bf0ca59 Add KeyChain.KEY_ALIAS_SELECTION_DENIED constant.
Add KEY_ALIAS_SELECTION_DENIED contant to flag that no private key alias has
been chosen in onChoosePrivateKeyAlias, but no KeyChainActivity selection dialog
should be presented to the user.

Bug: 136649900
Test: run cts --test MixedManagedProfileOwnerTest#testDelegationCertSelection
Change-Id: I9aeea7be0c2a6172ca054f91d49183c843ecfa6e
2019-10-07 15:05:39 +02:00
Eran Messeri
da05c80d6b API for individual attestation
Introduce a new API to request use of individual attestation
certificate for attesting keys generated by the
DevicePolicyManager.generateKeyPair method.

It builds on existing device ID attestation capabilities in two ways:
(1) Eligibility check: Assuming similar privacy requirements for the use
    of individual attestation certificates, enforce the same conditions
    for using them as the conditions for requesting device identifiers
    in the attestation record.
(2) Keymaster interaction: Passing the right Keymaster tag to the
    attestKey call, which is easily done in AttestationUtils.

Bug: 136494773
Test: CTS test to be added.
Change-Id: Idb5cee66d986a521c17e1955532d0bfae66c035d
2019-09-24 18:14:05 +01:00
Eran Messeri
d6ee4aae9b KeyChain: Unify manual and programmatic key installation flows
Unify the manual certificate installation flow (via "Install from
storage" in the Settings app) with the programmatic one (using
DevicePolicyManager.installKeyPair).

The unification is achieved by extending the KeyChainService API to take
in the UID for which the key is designated (so WiFi keys can be
installed with the unified flow), and making the CredentialStorage
activity call the KeyChainService rather than poke into Keystore
directly.

Framework-related changes to support this:
* Add new constant for specifying the key alias as an extra to the
  install activity, and remove obsolete constants from the Credentials
  class.
* Make KeyChainService definition include key destination UID.
* Make the call to KeyChainService.installKeyPair from the
  DevicePolicyManagerService specify the "self" UID.

Test: Manual CtsVerifier tests: KeyChain Storage Test, CA Cert Notification Test
Test: cts-tradefed run commandAndExit cts-dev -m CtsDevicePolicyManagerTestCases -t  com.android.cts.devicepolicy.MixedDeviceOwnerTest#testKeyManagement
Bug: 138375478
Change-Id: Ib317f85fa6719c70ee3b1da4255c44754fbfa789
2019-09-12 16:02:36 +01:00
Eran Messeri
e7a65b65e5 AttestedKeyPair: Address API review comments
Make AttestedKeyPair c'tor accept a List<Certificate> rather than
Certificate[] to match the getter method on this class.

To make it easier to use this class from other framework code I've
re-instantiated the c'tor with a certificate array which will
convert the array to a list.

Bug: 139092002
Test: cts-tradefed run commandAndExit cts-dev -m CtsDevicePolicyManagerTestCases -t  com.android.cts.devicepolicy.MixedDeviceOwnerTest#testKeyManagement
Change-Id: Ie80dcb28f112efa89d3cc6fdceb1b9e5e26c58b1
2019-08-23 15:33:16 +01:00
Eran Messeri
390539d11b Make AttestedKeyPair constructable
Make the constructor for AttestedKeyPair public so instances of it can
be created for testing.

Bug: 138409426
Test: That it compiles
Change-Id: Iab8fbf1ad2293a91347701eb67631a8f3a3bd3fa
2019-08-06 15:55:17 +01:00
Solomon Kinard
2bd792f3de Spelling fix in KeyStore.java
Test: none
Change-Id: I37c535a358b0b157f0e04978658816036c52ebab
2019-07-03 16:37:03 -07:00
Shawn Willden
d8283a81f3 Fix encryption/decryption of large blocks.
There's a long-standing bug (since ~Marshmallow) that causes
AndroidKeyStore to truncate large (>64 KiB) blocks of data.  This can
be avoided by callers by processing data in smaller chunks, and
smaller chunks are more memory-efficient while not being much (if any)
more time-efficient.  But, Keystore should handle large blocks
correctly.  This CL adds a test to all block cipher tests that
attempts to encrypt and then decrypt a 100 KiB block.

Bug: 123391046
Test:  CtsKeystoreTestCases
Change-Id: I0c0286fd5360d4fe62cbd8130aa0c17f97318801
2019-05-24 09:39:50 -06:00
Kevin Chyn
5e052537b7 Merge "Check PackageManager for feature before getting system service" into qt-dev 2019-04-20 02:26:16 +00:00
Kevin Chyn
1e50792d72 Check PackageManager for feature before getting system service
Fixes: 130756217

Test: See comment #3 in the bug above
Change-Id: I0008f2b2958c9ac0df4e1f8ce4f5edcd9aac4292
2019-04-18 13:39:09 -07:00
Janis Danisevskis
f924b7e25d Fix refactoring glitch in KeyStore.java
Bug: 129974578
Test: atest android.keystore.cts
Change-Id: I3ba732e15e522bd31e7eb813677d3ea884328cb6
2019-04-17 14:10:28 -07:00
Kevin Chyn
9374c9f839 Update documentation for fingerprint -> biometric
Fixes: 129909360

Test: Builds
Change-Id: I8e419e4c2b5ca2c1f0fc9d988100ceb41f193a42
2019-04-05 00:49:59 +00:00
Janis Danisevskis
eff37cca16 Merge "Keystore.java: Make apps tolerant to keystore crashes" 2019-04-02 16:13:15 +00:00
Janis Danisevskis
c9277ffd42 Keystore.java: Make apps tolerant to keystore crashes
Since keystore accepts asynchronous requests it may be that apps wait
forever if keystore dies. This patch adds a death recipient to all
keystore promises so that Keystore.java gets notified when keystore
dies.

Test: atest android.keystore.cts
Bug: 111443219
Bug: 128991260
Change-Id: Ie6e4a4f371287f83a2cdf4069d5686c67d8aebc1
2019-04-02 16:13:01 +00:00
Sasha Smundak
b61bab6a58 Convert Android.mk file to Android.bp
Files failing automerge from AOSP.
See build/soong/README.md for more information.

Bug: 122332340
Test: treehugger
Change-Id: I92f7584aeaf502336f67e04fbc22634784c9305d
2019-03-26 15:18:41 -07:00
Max Bires
f5276800d8 Merge "Fixing engineGetCertificateChain exception" am: 09e3d8c3eb am: 53187655d0
am: efb8468705

Change-Id: I8157345ed59352152c5035467f94836c0c4f216e
2019-03-18 20:45:55 -07:00
Treehugger Robot
09e3d8c3eb Merge "Fixing engineGetCertificateChain exception" 2019-03-19 03:02:31 +00:00
Treehugger Robot
f070b51670 Merge "Add Keystore get option that supresses caught exceptions warnings." 2019-03-08 21:58:46 +00:00
Max Bires
18e0781d3d Merge "Adding KEY_PERMANENTLY_INVALIDATED int" 2019-03-08 17:53:05 +00:00
Irina Dumitrescu
203bd1b113 Add Keystore get option that supresses caught exceptions warnings.
This is useful when the caught exceptions are not informative and they
act as a red herring in the adb logs.

Bug:109791294
Test: call this method in the VpnSettings and manually navigate to
adding a new VPN by searching for VPN in settings and then pressing '+'.

Change-Id: I4bc86e3ea5b11027090fd3a27dc7455557cf66ab
Merged-In: I4bc86e3ea5b11027090fd3a27dc7455557cf66ab
2019-03-07 20:42:22 +00:00
Max Bires
beae8c67dc Fixing engineGetCertificateChain exception
If a certificate is self signed, then currently KeyStore will still
attempt to find the CA certificate. When it obviously fails to find it,
a key not found exception is propagated up and thrown. This CL
suppresses that exception, as it seems to exclusively be thrown in this
condition, which is WAI. Having the stack trace show up can be very
misleading to developers.

Test: atest cts/tests/tests/keystore/src/android/keystore/cts
Change-Id: I192f54d3d8355c183e830ab09314932e8800f7ed
2019-03-07 18:19:29 +00:00
Eran Messeri
842d883f05 Device ID Attestation: Fix API review
Mark the c'tor parameters as nullable to comply with Exception's
behaviour.

Bug: 126702366
Test: That it compiles
Change-Id: I96a7c03cb79e7180872de02bee143b67f7a408ec
2019-03-05 22:34:29 +00:00
Brett Chabot
502ec7ae4b Migrate remainder of frameworks/base to androidx.test
See go/jetpack-test-android-migration

Exempt-From-Owner-Approval: automated package name refactoring

Test: m  m -j BroadcastRadioTests KeystoreTests mediaframeworktest ActivityManagerPerfTests AppLaunch AppLaunchWear BackgroundDexOptServiceIntegrationTests AppCompatibilityTest DynamicCodeLoggerIntegrationTests FlickerLibTest InternalTests PackageWatchdogTest RcsTests RollbackTestAppAv1 RollbackTestAppAv2 RollbackTestAppACrashingV2 RollbackTestAppBv1 RollbackTestAppBv2 RollbackTestAppASplitV1 RollbackTestAppASplitV2 RollbackTest ServiceCrashTest UsageStatsPerfTests UsbTests WindowAnimationJank
Change-Id: I32fe3297656eec6060da6c7e24582bcd5315fb16
2019-03-02 00:35:17 +00:00
Jeff Sharkey
9e8f83db6d All Parcelable CREATOR fields are @NonNull.
If they were null, then the Parcelable would fail to work.

Bug: 126726802
Test: manual
Change-Id: I7929ffa2f20e5de1c8e68e8263cca99496e9d014
Exempt-From-Owner-Approval: Trivial API annotations
2019-02-28 23:29:04 -07:00
Andrei Onea
ffeefd3cd3 Add @UnsupportedAppUsage annotations
For packages:
  android.security
  android.service.dreams
  android.service.euicc
  android.service.vr
  android.service.wallpaper

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
Merged-In: I1c8ae08f8d3b4b2f5bf365468f22155f8def09fe
Change-Id: I09850a52193a28b0f884cfa01b564c29d25d41ed
2019-02-28 13:46:06 +00:00
Andrei Onea
4aa2a2015b Add @UnsupportedAppUsage annotations
For packages:
  android.security
  android-service.dreams
  android.service.euicc
  android.service.vr
  android.service.wallpaper

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: I1c8ae08f8d3b4b2f5bf365468f22155f8def09fe
2019-02-27 16:28:07 +00:00
Max Bires
6b850fb4ef Merge "Adding KEY_PERMANENTLY_INVALIDATED int" 2019-02-20 17:21:22 +00:00
Max Bires
b2cc3dc227 Adding KEY_PERMANENTLY_INVALIDATED int
This is to keep it in sync with response codes in keystore.h.

This commit also adds the KeyPermanentlyInvalidatedException to all the
methods that could receive this error code out of KeyStore.

Bug: 118883532
Test: atest cts/hostsidetests/appsecurity/src/android/appsecurity/cts/AuthBoundKeyTest.java
Change-Id: I878a628824e2eeb639ec5678b1a5d3d10428a918
Merged-In: I878a628824e2eeb639ec5678b1a5d3d10428a918
2019-02-18 21:11:48 +00:00
Max Bires
13f98ce5aa Adding KEY_PERMANENTLY_INVALIDATED int
This is to keep it in sync with response codes in keystore.h.

This commit also adds the KeyPermanentlyInvalidatedException to all the
methods that could receive this error code out of KeyStore.

Bug: 118883532
Test: atest cts/hostsidetests/appsecurity/src/android/appsecurity/cts/AuthBoundKeyTest.java
Change-Id: I878a628824e2eeb639ec5678b1a5d3d10428a918
2019-02-18 20:45:46 +00:00
Max Bires
68a6071f71 Merge "Adding framework check for 3DES key size" am: a24d025212 am: a68009941a
am: 67046659a4

Change-Id: Ibe2259a6eec6115c3bbabfd387e585ec39389a0b
2019-02-15 13:55:45 -08:00
Treehugger Robot
a24d025212 Merge "Adding framework check for 3DES key size" 2019-02-15 21:12:29 +00:00
Max Bires
20fa0e7c2e Adding framework check for 3DES key size
Previously the framework would accept any key size that was a multiple
of 8 for the KeyGenerator.

Bug: 117509689
Bug: 122274787
Test: atest cts/tests/tests/keystore/src/android/keystore/cts/KeyGeneratorTest.java
Change-Id: I60b52f6062a41ae52486bae0ae36616f4b532b37
2019-02-13 15:10:29 -08:00
Eran Messeri
55b8d082ba KeyChain: Improve key override documentation.
Improve the documentation on the case of key override: When a new key is
generated/installed using an alias that already exists.

In particular, clarify that grants are lost and that a new call to
KeyChain.choosePrivateKeyAlias must be issued in this case.

Bug: 123563258
Test: that it builds.
Change-Id: I055e95f57b9576883736ca0cfa6a998dec08a6c2
2019-02-07 23:45:44 +00:00
Eran Messeri
71864b4790 Merge "Add owners for KeyChain code" am: 0f9319ed1b am: d7fd57224d
am: 4cfb943d9b

Change-Id: I8d5ab0f2e7778c34fa0171f8b85276281ebbd6af
2019-02-01 05:23:03 -08:00