Commit Graph

243 Commits

Author SHA1 Message Date
Robert Berry
588a06f5a2 Merge "Revert "Use RecoverySession object to hide session IDs"" 2018-01-18 12:24:06 +00:00
Robert Berry
9fa87627ed Revert "Use RecoverySession object to hide session IDs"
This reverts commit 988c55ce67.

Reason for revert: broke some tests

Change-Id: Ib43099aebc8ff025e052337475bab13445da74eb
2018-01-18 12:23:33 +00:00
TreeHugger Robot
c4e99794e9 Merge "Use RecoverySession object to hide session IDs" 2018-01-18 10:40:24 +00:00
TreeHugger Robot
15b0089c01 Merge "KeyStore: Remove duplicate method" 2018-01-18 10:26:44 +00:00
Robert Berry
988c55ce67 Use RecoverySession object to hide session IDs
Session IDs are an implementation detail that the framework can (and should)
abstract away.

Test: adb shell am instrument -w -e package
com.android.server.locksettings.recoverablekeystore
com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner

Change-Id: Ieba641a9b54ac9bba197a6e9749b621a07e40c67
2018-01-18 08:25:26 +00:00
Robert Berry
9e1bd362df Rename KeychainProtectionParameter to KeychainProtectionParams
Test: adb shell am instrument -w -e package
com.android.server.locksettings.recoverablekeystore
com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
Change-Id: Iab6d85d0be38e1a09ce78bb96b8f68493de65be9
2018-01-18 08:21:43 +00:00
Robert Berry
a16cd59a34 Create exception hierarchy for RecoveryController
Sets up a sensible exception hierarchy. Consolidates two error codes
that both represented some kind of internal error into a single code.
Fixed some cases where the wrong error codes were used to signal.

Test: adb shell am instrument -w -e package
com.android.server.locksettings.recoverablekeystore
com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner

Change-Id: I6b1f97715cdc28a4be79912abb6f48e6657b048b
2018-01-17 21:32:58 +00:00
Robert Berry
5f138701fe Use better names for associated classes of RecoveryManager
I will also rename RecoveryManager to RecoveryController -- in a separate CL,
as this one is already becoming too large.

Test: adb shell am instrument -w -e package
com.android.server.locksettings.recoverablekeystore
com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner

Change-Id: I2fb4e1f55fb50d95f15c230783c3d289dd71f7f3
2018-01-17 15:22:56 +00:00
Eran Messeri
eab62566ef KeyStore: Remove duplicate method
Remove the duplicate() method from KeyStore.
It is backed by dead code in the Keystore service, which (as far as I
can tell) is not doing the right thing.

Previous conversations with Keystore team members suggested this API
should not be used and it is marked for removal in the Keystore service.

Bug: 72037261
Test: That it compiles.
Change-Id: I7f8af95473c876340cbd5c73dd88c5d0282897b3
2018-01-16 16:33:22 +00:00
Dmitry Dementyev
7d8c78a2c8 Refactor KeyStore Recovery Manager.
1) Parameters -> Params
2) Use byte[] for serivice parameters.
2) Move Exception into separate class.

Bug: 66499222
Test: adb shell am instrument -w -e package \
com.android.server.locksettings.recoverablekeystore \
com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner

Change-Id: I1b9a8748830f7deb9eeb57693f5a818a49a7aabe
2018-01-12 21:06:25 -08:00
Dmitry Dementyev
ed89ea04e4 Big RecoverableKeyStoreLoader refactoring.
The change is based on API review.
1) package and class names update
2) Builders for Parcelables.
3) Use Constant for RECOVER_KEYSTORE permission defined in
android.Manifest.

Bug: 66499222
Test: adb shell am instrument -w -e package \
com.android.server.locksettings.recoverablekeystore \
com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner

Change-Id: I49f80acbb6dc0eb6d049e18e8cb0d1aa326dadb2
2018-01-11 18:39:18 -08:00
Dmitry Dementyev
e77a24b8b8 Add remove method to RecoverableKeyStoreLoader.
Bug: 66499222
Test: GTS tests will be added.
Change-Id: If352d75fbabe33e3453baed806f569931dbd8ad7
2018-01-10 14:26:26 -08:00
TreeHugger Robot
ce5ed6e6f3 Merge "Rename createSHA256Parameters to createSha256Parameters" 2018-01-10 00:37:24 +00:00
Dmitry Dementyev
b719546cad Rename createSHA256Parameters to createSha256Parameters
Fixes the following lint warning:
Warning S1: Method names with acronyms should be getMtu() instead of
getMTU()

Bug: 66499222
Test: adb shell am instrument -w -e package \
com.android.server.locksettings.recoverablekeystore \
com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner

Change-Id: If9eb03e2a2a63fe02a2da4828bd0c5c8997078b9
2018-01-09 14:28:35 -08:00
Dmitry Dementyev
07c765553d Use String instead of byte[] to represent alias in KeyEntryRecoveryData.
Bug: 66499222
Test: adb shell am instrument -w -e package \
com.android.server.locksettings.recoverablekeystore \
com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner

Change-Id: Iac74fe856b43faa602ea1c2d9172f669826f4011
2018-01-09 12:03:27 -08:00
Robert Berry
97e55583d3 Use ServiceSpecificException in RecoverableKeyStoreMgr
This is so we can better convey error codes to the client.

Test: adb shell am instrument -w -e package
com.android.server.locksettings.recoverablekeystore
com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner

Change-Id: I02d0ed07e895d3a0297f77934830e19bb6abf43e
2018-01-05 12:43:13 +00:00
Dmitry Dementyev
1429831ac8 Remove unused userId parameter from RecoverableKeyStoreManager.
Bug: 66499222
Test: adb shell am instrument -w -e package \
com.android.server.locksettings.recoverablekeystore \
com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner

Change-Id: Ibf09724839cbdbf7172462ce0368278c7e65155f
2018-01-04 17:31:50 -08:00
Bo Zhu
57e77f7c13 Fix some nits while reading the code
Test: None
Change-Id: Id231a497ad1c27de257f9e9f02f8373c5c67a68d
2018-01-03 14:53:28 -08:00
TreeHugger Robot
7b27036950 Merge changes from topics "wrapped_key_import", "keystore_seclevels"
* changes:
  Add importWrappedKey to IKeystoreService.aidl
  Keystore: Use security levels
2017-12-28 02:16:55 +00:00
Robert Berry
bd086f1963 Add storage for snapshots in KeySyncTask
Test: adb shell am instrument -w -e package com.android.server.locksettings.recoverablekeystore com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
Change-Id: I25a9d6999bec5639cc91532da1b42a8d1f911b79
2017-12-27 13:32:49 +00:00
Bo Zhu
584b923fb7 Write the integer given by setServerParameters() into SQLite DB
Change-Id: Icd8b40154560c600757d51ed4620d39fc07e494c
Test: adb shell am instrument -w -e package com.android.server.locksettings.recoverablekeystore com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
2017-12-23 00:18:00 -08:00
TreeHugger Robot
14cddc465b Merge "Implement generateAndStoreKey" 2017-12-22 19:10:24 +00:00
Janis Danisevskis
03dd82792e Add importWrappedKey to IKeystoreService.aidl
Test: pending
Bug: 63931634
Change-Id: If7fde024f9388bd85045902761d8fa7bf1c42e7d
2017-12-22 17:44:04 +00:00
Robert Berry
cfc990a49d Implement generateAndStoreKey
For now just returns raw key material. In the future we will need to
change this to use the KeyStore move api. (Once that has been
implemented.)

Test: adb shell am instrument -w -e package com.android.server.locksettings.recoverablekeystore com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
Change-Id: I8aee4da81f0f853503f570dae8d74e1d29f124cc
2017-12-22 15:54:30 +00:00
Robert Berry
bd4c43c686 Update recoverKeys to return raw material
This is a temporary solution, while the KeyStore team works on adding a
move API to KeyStore. (At which point this will be updated to instead
return 'move tokens', allowing the user to move the key from the system's
keystore to their own, without ever seeing the raw material.)

Test: adb shell am instrument -w -e package com.android.server.locksettings.recoverablekeystore com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
Change-Id: I2241a6da15d50c26a7b384d4e5b6f78366fb9300
2017-12-22 11:35:14 +00:00
Janis Danisevskis
0aadf935cb Keystore: Use security levels
In anticipation of the availability of Keymaster implementations with
multiple security levels this patch adds the additional
keystore flags FLAG_SOFTWARE and FLAG_STROGBOX.

Also, the IKeystore method addRngEntropy got a new flags parameter
for the caller to express which implementation shall be awarded the
precious entropy.

Test: Keystore CTS tests
Bug: 63931634
Change-Id: I4a4eafbdbe1290f0c7bd2bfa2ce3e5fbb06c2dd8
2017-12-22 00:02:39 +00:00
TreeHugger Robot
0be794a14c Merge "Add more methods to RecoverableKeyStoreLoader." 2017-12-21 02:01:15 +00:00
Robert Berry
e16fa98a9e Implement startRecoverySession
Test: adb shell am instrument -w -e package com.android.server.locksettings.recoverablekeystore com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
Change-Id: I25e99f6014ef5e831420367040de7e1a80f134f0
2017-12-20 21:24:38 +00:00
Dmitry Dementyev
b8b030bdbb Add more methods to RecoverableKeyStoreLoader.
1) Methods to get key status.
2) Register pending intent to get notification about new recovery
snapshots.

Test: none
Bug: 66499222
Change-Id: I4d5f8c1a6581b5e08f4589e19961d93c499689e1
2017-12-20 12:07:24 -08:00
Dmitry Dementyev
1aa96132bd Add RecoverableKeyStoreLoader implementation in LockSettingsService.
1) Updates to ILockSettings.aidl
Since we can't pass arbitrary exception using IPC, Serrvice
converts them to ServiceSpecificException with an error code.

2) Added RecoverableKeyStoreManager class which is used as interface
between RecoverableKeyStoreLoader implementation and
LockSettingsService.

Test: none
Bug: 66499222

Change-Id: I03b695bc0ced1a91ea7ca5de179e121053dfe416
2017-12-18 16:04:15 -08:00
Dmitry Dementyev
8eaf607f22 Add RecoverableKeyStoreLoader APIs.
Includes parcelables for
1) KeyDerivation
2) User Secret together with its type.
3) Application key entry
4) KeystoreRecoveryData block with all data  necessary to recover
keys later.

Test: none
Bug: 65979689
Change-Id: If59842a92ebbc0e77f95d6a2e5503943e2835062
2017-12-14 12:35:25 -08:00
Robert Berry
5397d4d574 Move recoverablekeystore package under services
As these helpers will be used by the service, these properly belong there.

Test: Unit tests.
Change-Id: I4fb4fe2ed52581790421885680473a7b9638f332
2017-12-12 13:24:35 +00:00
Robert Berry
ce50cd302a Add helpers for generating keys, wrapping them, and persisting them
As part of the RecoverableKeyStoreLoader, we need to be able to generate new
256-bit AES keys, sync them with AndroidKeyStore, and persist them, wrapped
to disk. This allows us to recover them later, using a Platform key, and
sync them with remote storage.

Test: manual for now (how do we do automated tests on Framework?)
Change-Id: I32e0beabaecc9bea9f95ca2beea851e9be833358
2017-12-08 17:47:56 +00:00
Dianne Hackborn
3accca05dd Add major version code to platform.
It turns the version code into almost a 64-bit integer, with the
new major part being the upper 32 bits.

The only tricky part about this is the backup manager, since it
stored 32-bit version codes in its backup data sets.  This is dealt
with by, when the major version code is not 0, writing MIN_INT as
the version code and following that by the full long version code,
which we can detect when reading.  Note that this makes backup sets
containing apps with major version codes incompatible with older
versions of the platform.

Bug: 64459786
Test: Added in Change-Id: Iab8a682b62103babd6c16a56b8dc1e97d7078658
Change-Id: Ibfffe235bbfcf358b3741abd3f7197fdb063d3f3
2017-12-04 13:02:10 -08:00
Dmitry Dementyev
efc4311a3f Get rid of manually created IKeystoreService.
Java/aidl side changes necessary to generate IKeystoreService.cpp
Generated C++ service currently doesn't support null parameters, so lots
of parameters were updated to pass default value instead of null.

Test: cts-tradefed run cts -m CtsKeystoreTestCases
Bug: 68389643

Change-Id: Ifaf2ab48b2bcd7b081e4b336aa279fa8ba4fbbbf
2017-11-07 10:21:08 -08:00
TreeHugger Robot
2dfd5c375e Merge "Docs: clarify WebView support for cleartext traffic" 2017-10-24 23:07:00 +00:00
Nate Fischer
6a2a541fb1 Docs: clarify WebView support for cleartext traffic
No change to logic, docs change only.

WebView added support for android:usesCleartextTraffic for apps
targeting O and above (API level 26). This CL clarifies WebView's
support in the Android documentation.

This also fixes a preexisting presubmit error in
NetworkSecurityPolicy.java (unused import).

Bug: 67714197
Test: N/A
Change-Id: If6bfd36bc65926a1b032813598c85146ccfde969
2017-10-23 18:02:41 -07:00
Chad Brubaker
fcc4633601 Change cleartext traffic permitted default for P apps
For applications targeting P and above the network security
config's cleartextTrafficPermitted will default to false instead of
the previous true.

Bug: 63931636
Test: network security config cts tests
Change-Id: Ia697358ad84e2092443c3eff518003c6a11e4630
2017-10-23 13:18:59 -07:00
Chad Brubaker
5ac2ea1b4d Make priv apps not trust user added CAs by default
Privileged applications provide core system functionality and as such a
MiTM in one can put the entire system at risk. These applications should
not be trusting user added CAs by default.

Bug: 65406503
Test: runtest --path framework/base/tests/NetworkSecurityConfigTest
Change-Id: I033258fe1c66ad245d172899df52e9cd02e9ca75
2017-10-18 12:30:30 -07:00
Chad Brubaker
5813bc2b22 Merge "Add owners for the network security config" am: 8773730cd9 am: e9d50c793a
am: 531f1af615

Change-Id: I77240a60f796c63acd640b8a43cb7054ad2a8bee
2017-08-02 17:41:21 +00:00
Chad Brubaker
e9d50c793a Merge "Add owners for the network security config"
am: 8773730cd9

Change-Id: I18b8aac4c1ac85bde3e6735e1afe6375f5c0e177
2017-08-02 17:20:16 +00:00
Chad Brubaker
1ec48fc770 Add owners for the network security config
Test: build/make/tools/checkowners.py -c -v OWNERS
Change-Id: I9bb8f5ceaae4a1af8c93f5416a6a5cea42915c62
2017-08-01 15:50:22 -07:00
Janis Danisevskis
6396ccb82e Refurbish granting mechanism
Keystore stores key blobs in with filenames that include the symbolic
name and the uid of the owner. This behaviour should have been
completely opaque to the user keystore. However, the granting mechanism,
by which an app can allow another app to use one of its keys, leaked the
internal structure in that the grantee had to specify the key name with
the granter's uid prefix in order to use the granted key. This in turn
collided with prefix handling in other parts of the framework.

This patch refurbishes the granting mechanism such that keystore can
choose a name for the grant. It uses the original symbolic key name as
prefix and appends _KEYSTOREGRANT_<grant_no> where the grant_no is
chosen as first free slot starting from 0. Each uid has its own grant_no
space.

This changes the grant call such that it now returns a string, which is
the alias name of the newly created grant. The string is empty if the
grant operation failed.

As before apps can still mask granted keys by importing a key with the
exact same name including the added suffix. But everybody deserves the
right to shoot themselves in the foot if they really want to.

Bug: 37264540
Bug: 62237038
Test: run cts-dev --module CtsDevicePolicyManagerTestCases --test
          com.android.cts.devicepolicy.DeviceOwnerTest#testKeyManagement
	  because it grants a key
Merged-In: I047512ba345c25e6e691e78f7a37fc3f97b95d32
Change-Id: I047512ba345c25e6e691e78f7a37fc3f97b95d32
2017-07-23 09:39:04 -07: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
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
Frank Salim
66925ecc64 Revert "Add new key purpose Wrap Key to KeyProperties.java and"
This reverts commit eb30e64f3f.

Reason for revert: Remove partial support for wrapped key import

Test: CTS tested
Change-Id: I8008494860534257fa983e1a5169d0ed034621f7
2017-03-02 11:16:09 -07:00
Todd Kennedy
11e4507522 Define targetSandboxVersion
The new attribute allows both ephemeral and non-ephemeral apps to
opt into a new, tighter security model.

Test: Manual; built app w/ targetSandboxVersion and verified the security domain
Change-Id: I8fcaf84e25f0519b438ba51302f79790e680e025
2017-01-30 14:47:30 -08: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
Chad Brubaker
b8feba10f4 Default to not allowing cleartext traffic for ephemeral apps
Test: NetworkSecurityPolicy.isCleartextTraffic permitted returns the
expected defaults.
Change-Id: I7d6577f8461bbf1f44eb21b4d813dba1746449fa
2016-12-07 13:17:41 -08:00