461 Commits

Author SHA1 Message Date
phweiss
7eeab2cdd9 Implement CACert queries in SecurityController
Cherry-pick note:
testCACertLoader() was flaky, so this cherry-pick contains
two attempted fixes and a CL that disables the test. The original commit
messages of the squashed CLs are below.
Merged-In: I3b9cc3d85c9f49d0a892613b63d1fba184ab647e

Implement CACert queries in SecurityController

Queries are run (on a AsyncTask) when user is switched and when
ACTION_TRUST_STORE_CHANGED is broadcasted. Otherwise, the result is cached
in the SecurityController.

Bug: 37535489
Test: runtest --path frameworks/base/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SecurityControllerTest.java
Change-Id: I3b9cc3d85c9f49d0a892613b63d1fba184ab647e

Increase timeout for flaky testCACertLoader()

Bug: 37535489
Bug: 38045871
Test: runtest --path frameworks/base/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SecurityControllerTest.java
Change-Id: I5778082973af7c6d4d719b83e334fec552b0a89e

Fix flaky SecurityControllerTest.testCaCertLoader

Fixes: 38108698
Test: runtest -c .statusbar.policy.SecurityControllerTest systemui
Change-Id: I6029a09984b72599622f0df57187a20aba4dab30

Disable flaky test

Test: treehugger
Bug: 38118260
Change-Id: I05c6504acee6a787e1cc5071bed0118388963212

(cherry picked from commit e375fc441cc889890d1cff5bc771039bb65f08ef)
2017-05-09 15:35:30 +02:00
Bartosz Fabianowski
237f4b369b Add device ID attestation method to keymaster
Device ID attestation consists of three steps:
* Generate a temporary key
* Attest the key and desired device IDs
* Delete the temporary key

Rather than being spread over three keymaster APIs, these operations
should happen automatically in a single keymaster method.

Bug: 34734938
Test: GTS com.google.android.gts.security.DeviceIdAttestationHostTest

Change-Id: Ifabb5163b9e4d12cb309a6b0ca8e5f2f92d212f4
2017-04-26 17:40:44 +02:00
Jeff Sharkey
a00c7c0a99 Merge "Fix some issues found by new doclava linter." into oc-dev 2017-04-25 22:11:01 +00:00
Jeff Sharkey
0f3f60b576 Fix some issues found by new doclava linter.
Add missing API annotations for permissions and SdkConstants, and
invoke doclava with new "-android" flag.

Test: make -j32 offline-sdk-docs
Bug: 37526420
Change-Id: I970bb2655eb568fd25004636f134c794663a6c33
2017-04-25 13:12:45 -06:00
Rubin Xu
12b644d275 Introduce KEYSTORE_FLAG_CRITICAL_TO_DEVICE_ENCRYPTION
This flag is used by system server to mark keys used during the
synthetic password auth flow. keys marked with this flag will not
be super encrypted because super encryption requires knowledge of
the synthetic password, causing a chicken-and-egg problem.

Bug: 35849499
Bug: 34600579
Test: cts-tradefed run cts-dev -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.MixedProfileOwnerTest#testResetPasswordWithToken

Change-Id: I474822f2e026f24ce6f6de1aa58b5012922f7b13
2017-04-24 20:04:50 +01:00
Jeff Sharkey
910e081216 More auto-doc work.
Add support for AnyThread, CallSuper, and UiThread.

Another related CL started documenting @RequiresPermission, so remove
duplicated information in existing APIs.

Suppress auto-doc on a handful of classes that are already
well-documented.

Test: make -j32 offline-sdk-docs
Bug: 37526420
Change-Id: I791437dccec0f11d5349a23b982ba098cb551af8
2017-04-21 16:35:08 -06:00
Chad Brubaker
8b651bf7d5 Fix ACTION_STORAGE_CHANGED doc
The deprecation note was not quite correct.

Change-Id: I15231881bbf1ee1ee4d342bff74280d7e9807ac0
Fixes: 36493384
Test: builds
2017-03-23 09:26:09 -07:00
Bartosz Fabianowski
ad60c0615f Add manufacturer and model to device ID attestation
Discussions have shown that in addition to brand, device and product,
we should also allow devices to attest their manufacturer and model.

Bug: 36433192
Test: GTS com.google.android.gts.security.DeviceIdAttestationHostTest

Change-Id: Idd48929d6a0c9fe6656c6d2656e2c3f6f370a21e
2017-03-20 14:00:25 +01:00
Bartosz Fabianowski
05dc9f764c Add API for checking which CA certs were installed by the DO/PO
With this API, the system can determine whether a CA cert was
installed by the user or the user's DO/PO.

Bug: 32692748
Test: unit tests (see DevicePolicyManagerTest.java for invocation)
Test: cts-tradefed run cts-dev --module CtsDevicePolicyManagerTestCases

Change-Id: I3bcae5ac18ec2b110154184fc515df804fd73da6
2017-03-03 19:42:51 +01:00
Frank Salim
66925ecc64 Revert "Add new key purpose Wrap Key to KeyProperties.java and"
This reverts commit eb30e64f3fac192404a6ae3c162a0770201a7dc2.

Reason for revert: Remove partial support for wrapped key import

Test: CTS tested
Change-Id: I8008494860534257fa983e1a5169d0ed034621f7
2017-03-02 11:16:09 -07:00
TreeHugger Robot
a7aaae881c Merge "Delete ParcelableString, add StringParceledListSlice" 2017-02-28 22:09:06 +00:00
Robin Lee
abaa0695c5 Delete ParcelableString, add StringParceledListSlice
Both inherit from package private BaseParceledListSlice.

This is still bad, but it's not as bad. The existing code that uses
this can just do Foo.bar().getList() now instead of having to marshal
to and from an oddball type at either end as well.

In the longer term ParceledListSlice<> should be eliminated, but it's
not clear how far into the future that is going to happen.

Test: runtest -x services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
Test: runtest -x core/tests/coretests/src/android/content/pm/ParceledListSliceTest.java
Change-Id: Ie69b96b5215d6e04990f6d31345772cdfee21d78
2017-02-28 18:07:08 +00:00
Robin Lee
3e7cf168a5 Make IKeyChainAliasCallback oneway
So it can be sent from devicepolicymanager (system_server) to keychain
(a system_app) without waiting on the response and having to do
everything in a background thread.

Side-effect: the regular keychain => app callback is slightly more
efficient now too. in case anyone particularly needs blazing fast
private key user selections.

Fix: 35675253
Test: cts-tradefed run cts --abi=arm64-v8a --skip-device-info --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.DeviceOwnerTest#testKeyManagement' </dev/null 2>&1
Change-Id: I6e9d96ca3c42e6489d879d8cfb0507eb94838bf1
2017-02-25 01:32:54 +00:00
TreeHugger Robot
2c92e9daa4 Merge "Reject HMAC keys smaller than 64 bits." 2017-02-14 15:58:31 +00:00
Robin Lee
7f5c91c6bc MonitoringCertTask no longer relies on software.device_admin
Added a test to validate that it still works the way it should before
and after the change.

Bug: 33258404
Bug: 35196414
Fix: 35129745
Test: runtest -x services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
Test: also manual, instructions:
Test: (1) Disable software.device_admin from tablet_core_hardware, rebuild.
Test: (2) Install CA cert. Notification should appear.
Test: (3) Reboot. Notification should still be there.
Change-Id: Id992725c1844a2fffbde4d8acaba531e99f853ad
2017-02-14 13:29:31 +00:00
Rubin Xu
59ced28f0f Add hidden KeyProtection API to specify SID
Allows the caller to specify which SID the given key
should be bound to, overriding the default rule of
binding to the current root/fingerprint SID.

This is a prerequsite for introducing synthetic password
based authentication flow.

Test: cts-tradefed run cts -m CtsKeystoreTestCases
Bug: 33126414
Change-Id: Ide03c0f4fd33ecca7a169ea763c3d4d0b173d1dd
2017-02-02 17:53:32 +00:00
Bartosz Fabianowski
92e8cfd21d Add device id attestation
This adds a new public API for attesting the device's hardware ids
(e.g. serial number and IMEI).

Bug: 34597337
Test: CTS CtsKeystoreTestCases and GTS DeviceIdAttestationHostTest

Change-Id: I2e9c1b4f8eb24afa4a09c71c137ce33a6b87eb27
2017-01-25 04:47:15 +01:00
Crystal Qin
eb30e64f3f Add new key purpose Wrap Key to KeyProperties.java and
KeymasterDefs.java.

Test: There will be a CTS test CL submitted together.
Change-Id: Ic60c3efc451cd7cbb04689b3d7bf9d607fae6c1f
2017-01-19 21:02:10 -08:00
Shawn Willden
7c3b65e9b1 Reject HMAC keys smaller than 64 bits.
Test: CTS test has been updated to verify this.
Change-Id: I6389d9fa2ff75d08a2223c789e5437190c4b82c6
2017-01-17 05:05:56 -07:00
Shawn Willden
dea6614603 Test for null context in getPrivateKey
In N, passing a null context to getPrivateKey provoked a
NullPointerException, which is validated by a CTS test. In commit
28d68b1 this behavior was changed (inadvertently, I believe) causing
getPrivateKey to wrap the NPE in a KeyChainException. This CL restores
the previous behavior, fixing the test and avoiding breaking any apps
that were catching the NPE.

Test: Fixing broken test
Change-Id: Icb0c75b03efc478b7310998cf3e7108a2c419107
2016-11-16 06:06:36 -07:00
Jeff Sharkey
0a17db1cc5 Detect non-oneway calls leaving system_server.
To protect system stability, any Binder calls leaving the
system_server must carefully be performed using FLAG_ONEWAY (or
the 'oneway' verb in AIDL) which prevents the call from blocking
indefinitely on the remote process.

In this CL, the system_server uses the new Binder.setWarnOnBlocking()
method to enable detection by default for all remote Binder
interfaces.  It can also use Binder.allowBlocking() to allow
blocking calls on certain remote interfaces that have been
determined to be safe.

This CL adds the 'oneway' verb to several interfaces and methods
where it should have been added, and marks a handful of system
ContentProviders as being safe to call into.  Also, we assume that
any services obtained from ServiceManager are part of the core
OS, and are okay to make blocking calls to.

Test: builds, boots, runs with minimal logs triggered
Bug: 32715088
Change-Id: Ide476e120cb40436a94b7faf7615c943d691f4c0
2016-11-07 17:03:37 -07:00
Tucker Sylvestro
7f99db4e63 Add the onDeviceOffBody API method to KeyStore am: b32aae2a46
am: 8f75adc624

Change-Id: Ib8d7bc19a167999894b90b45e7eb1cadb2a85d24
2016-10-06 16:20:19 +00:00
Tucker Sylvestro
8f75adc624 Add the onDeviceOffBody API method to KeyStore
am: b32aae2a46

Change-Id: Idbf7f1d505b1d446a3d648dcf1b0f334a629110a
2016-10-06 16:13:48 +00:00
Kevin Hufnagle
c8d45456bd docs: Fixed broken link to Android KeyStore facility am: c0c4ac5e35 am: 507a5c03da
am: f4ac919849

Change-Id: I20e5abdffd9ac4fd8b4164ef56c1b3bafb58ad2b
2016-09-27 02:06:09 +00:00
Kevin Hufnagle
f4ac919849 docs: Fixed broken link to Android KeyStore facility am: c0c4ac5e35
am: 507a5c03da

Change-Id: Iec80ad1c7127efb7e257be0625988ef1b2588b0f
2016-09-26 23:47:39 +00:00
Tucker Sylvestro
b32aae2a46 Add the onDeviceOffBody API method to KeyStore
This is necessary for allowing the KeyStore to lock keys that remain
authorized as long as the device is on-body.

Bug 28911985

Change-Id: If50bc84d5a1cb23f9b01b1950c3676d1519cc4f5
2016-09-23 15:11:42 -04:00
Kevin Hufnagle
c0c4ac5e35 docs: Fixed broken link to Android KeyStore facility
Bug: 13663279
Change-Id: I859b3c9a35f9e6c63cb0c29260f4aa1aa33ab15c
2016-09-19 11:31:08 -07:00
Rubin Xu
8910bf2ca0 Merge "Handle null packageName in PendingIntentRecord" into nyc-mr1-dev am: 6acd5e7361 am: 2f6eecbed0
am: f38514ccd6

Change-Id: I1071a92b4ff74a57bf94c9b6aad9df4fb3852072
2016-08-23 22:29:15 +00:00
Robin Lee
c378aabdda Documentation warning against short-lived Contexts
am: da23618043

Change-Id: Ie6e4c05d8d9a273f0f529c2be79f3df4a856fedb
2016-08-23 16:09:41 +00:00
Robin Lee
4f7d56a706 Force application context for KeyChain bindings
am: f04a663d6a

Change-Id: I16c31a9c31527a79addbd2b44003f8fe56cb652f
2016-08-23 16:06:39 +00:00
Robin Lee
da23618043 Documentation warning against short-lived Contexts
It's better to use an Application Context rather than hoping the
activity won't be destroyed in another thread (because it will).

Change-Id: I9bf842d0d7dbedcc509a4a314d23a9a6cfca4d48
Fix: 29873669
2016-08-23 12:47:54 +00:00
Shawn Willden
e5d71c4cfa Fix @link tags in keystore doc am: 3f0526ea09
am: 9e8b4ad9c9

Change-Id: Iadb16bd13d4bb525805dd0266aea046c4c472309
2016-08-09 19:38:00 +00:00
Shawn Willden
3f0526ea09 Fix @link tags in keystore doc
Bug: 30258412
Change-Id: I370a53ebad29ff0471e4b7776cd76b2530efe760
(cherry picked from commit 9739d48a2101e49b0936096d69c29006f9acdeb5)
2016-08-02 16:45:06 +00:00
TreeHugger Robot
1c23ed9601 Merge "Fix @link tags in keystore doc" 2016-08-01 23:49:53 +00:00
Robin Lee
28d68b1456 Unbind from KeyChainService before RPCing to keystore
This leaves the binder connection open for far too long, which keeps
the keychain app alive longer than necessary.

Bug: 29873669
Change-Id: I037c2b91400202ba6a474819867df16b6342ec0d
2016-07-27 11:11:13 +01:00
TreeHugger Robot
bea9e036f5 Merge "Fix incorrect @link in ACTION_STORAGE_CHANGED comment" 2016-07-25 23:08:57 +00:00
Chad Brubaker
dbf01c12d0 Fix incorrect @link in ACTION_STORAGE_CHANGED comment
Change-Id: Ibfca8651a55e32e9caed96b04e5a40dc6ebc3019
2016-07-25 14:54:39 -07:00
Robin Lee
f04a663d6a Force application context for KeyChain bindings
Bug: 29873669
Change-Id: I68c11ab19a169498045bbc23bc8fe6a2f46be031
(cherry picked from commit 43e235c0d55fce8ff845c0249a414a1b2daa5b10)
2016-07-25 17:35:12 +00:00
Robin Lee
43e235c0d5 Force application context for KeyChain bindings
Bug: 29873669
Change-Id: I68c11ab19a169498045bbc23bc8fe6a2f46be031
2016-07-25 16:09:22 +01:00
Shawn Willden
9739d48a21 Fix @link tags in keystore doc
Bug: 30258412
Change-Id: I370a53ebad29ff0471e4b7776cd76b2530efe760
2016-07-21 10:11:09 -06:00
ewol
cde8c47be6 Merge \\"Fix a broken case of AndroidKeyStoreProvider error logging\\" into nyc-mr1-dev am: 45b8216d33
am: 4beff1fc13

Change-Id: I0e547655e9a10572be341db50976c66ae493d021
2016-07-19 18:01:29 +00:00
Erik Wolsheimer
292d291fa7 Fix a broken case of AndroidKeyStoreProvider error logging
BUG: 30117950
Change-Id: Ib9985493a08d721021d777e0e4a4d67511f190a5
2016-07-15 11:22:25 -07:00
Chad Brubaker
721afae8f1 Mention target API limits for ACTION_STORAGE_CHANGED
Bug: 28450538
Change-Id: I9c69f9d0bdda5b69aec2dc3014a612d84082dc64
2016-07-08 11:06:09 -07:00
Chad Brubaker
4de59ef323 Deprecate ACTION_STORAGE_CHANGED
ACTION_STORAGE_CHANGED is too noisy and fires on too many events. It has
been split into ACTION_KEYCHAIN_CHANGED for
addition/modification/removal of user certificates and keys,
ACTION_TRUST_STORE_CHANGED for changes the the user added and system CA
stores on the device and ACTION_KEY_ACCESS_CHANGED for changes to key
grants.

ACTION_STORAGE_CHANGED will only be sent to applications targeting N
and below. Applications targeting future releases should use the new
broadcasts.

Bug:28450538
Change-Id: I34ff838e9858db65f7308ca2b0f7d652c48fae17
2016-06-30 09:23:15 -07:00
Amith Yamasani
d04aaa323c More thorough cleansing of expired users
If any /data/system_[c|d]e folders were not erased
when the user was removed (maybe due to a reboot),
make sure they're cleaned up on restart as well
as when the userId is recycled later.

Mark the users' system folders with the correct
serial number for later verification.

AccountManager shouldn't be querying accounts of
partially created/destroyed users.

Change-Id: I4313756b7464f34cd5ce4fb296d61daa50b41fcb
Fixes: 29285673
2016-06-15 11:32:16 -07:00
Shawn Willden
26e8d553e5 Update semantics of on-body Keystore API.
Architectural changes from the Wear team have required changes to the
semantics of the Keystore on-body feature. Although no devices will
actually implement this feature until the release of new Wear devices
with the necessary sensors, we need to get the API documentation right
now.

Bug: 29369151
Change-Id: I857e00928f994a1337313123eae7e00534c53c3c
2016-06-14 17:29:54 -06:00
Shawn Willden
5e018c04a6 Unbreak Javadoc on getAttestationChallenge()
Bug: 28844154
Change-Id: I8402a39f366291cd2b5d646536cd2c2bab8556d2
2016-06-14 17:00:25 -06:00
Trevor Johns
682c24e228 Resolve merge conflicts of a5060ee to nyc-dev
This undoes the automerger skip which occured in
commit e740c84dc32180214a7fd157105d6c18d30408ee and
replays it as a standard (NOT -s ours) merge.

Change-Id: If5a47be26f73d6a0735c425cd66310a3e2a89086
2016-04-19 02:03:59 -07:00
Rubin Xu
b436591708 Add DevicePolicyManager API to install a client cert chain.
When installing a keypair the caller will have the option to specify a
certificate chain which will later be returned to whoever requests access
to the keypair via KeyChain.

Bug: 18239590
Change-Id: Id21ef026e31537db38d891cb9b712dd4fe7159c7
2016-03-30 11:57:58 +01:00
Kenny Root
f78cae3cb4 Use canonical name for SHA1withECDSA
The Standard Names documentation says that "ECDSA" should not be used
due to its ambiguity. Bouncycastle has switched from "ECDSA" to
"SHA1withECDSA" so therefore we should switch this "workaround" Provider
to use the same name to keep it functioning correctly.

(cherry picked from commit 8a6c191094b3d1f74dbb71a7f262496377596ba8)

Bug: 27753949
Change-Id: I5acfca9d89c85bf005902a2f06cb5d7b1ef9dff2
2016-03-23 14:29:33 -07:00