Commit graph

1784 commits

Author SHA1 Message Date
Roshan Pius
286c4b0532 keystore: Allow network_stack uid to use AID_WIFI
The wifi stack will be running inside the network_stack process for
devices which will accept wifi mainline module in R. So, add a effective
uid entry to allow calls from wifi stack inside network_stack to use
keystore blobs stored by wifi uid.

Bug: 142298627
Test: Compiles, will verify failing tests.
Change-Id: Iff19bcad134a3531934215ea4b7d975433da787d
2019-10-08 19:45:43 -07:00
Treehugger Robot
a5273d9a57 Merge "Fix memory leak in keystore" 2019-10-04 21:16:34 +00:00
Janis Danisevskis
8c4c1d6efb Fix memory leak in keystore
The operation device map needs to be cleand up on finish regardless of
whether the operations succeeds of fails. The operation lifecycle ends
in any case.

Bug: 141317862
Test: Generate key and perform repeated operations.
      Watch memory consumptoin not raise with using:
      adb shell dumpsys meminfo keystore

Change-Id: I3a25aa67f121832640848a38398c523e20a2c6df
2019-10-04 11:01:54 -07:00
Treehugger Robot
946f1d11c0 Merge "Fix handling of user password changes." 2019-10-03 17:56:12 +00:00
Treehugger Robot
a28f0d8c63 Merge "Rewrite fsverity_init in C++ and load keys from keystore" 2019-10-02 16:17:47 +00:00
Treehugger Robot
e7dc464319 Merge "New APIs for a keystore client to list and get keys" 2019-10-02 16:17:47 +00:00
Shawn Willden
17b8709c67 Fix handling of user password changes.
A bug introduced in a patch intended to upgrade keystore master keys
to use AES-256 and SHA-256 instead of AES-128 and SHA1 causes the
newly-updated master key to fail to be retrievable ever again.  Making
this worse, after five successive failures, keystore decided that all
the data is bad and wipes the user's keystore.  This problem happens
on every password change if the master key is 128 bits.  Luckily,
since the introduction of synthetic passwords to support escrow
tokens, the password presented to keystore is the synthetic password,
which never changes.  So this problem only crops up in devices that
did not have synthetic passwords (launched with Android N or earlier),
were not upgraded to O DR1 (when synthetic passwords were enabled by
default), were never factory reset or had their password removed and
re-added during all of that time and were then upgraded to P or Q,
when the master key upgrade code was present.

This CL fixes the upgrade process so that updated master keys can be
used.  It doesn't change the key size, the keys stay 128 bits, but now
they're readable and usable.  Factory resetting allows an entirely
new master key to be generated, which will be AES-256.

Note that the keystore master key is not really essential to the
security of Keystore keys.  They're also encrypted by the secure
world (TEE or SE), which is their primary protection.  The master key
just provides a cryptographic dependency on the user's password, so
that in the event of a secure world break the attacker still has to
brute force the user's password to recover the key material, or use of
the protected keys.

Bug: 129970023
Test: Manual
Change-Id: I8ce2bb2359cf822039c137bb6bb1fc225da47c29
2019-10-01 17:43:43 -06:00
Colin Cross
c20dc9444e Merge "Use libcrypto_static instead of libcrypto" 2019-09-26 14:32:33 +00:00
Victor Hsieh
d0a4b202a4 Rewrite fsverity_init in C++ and load keys from keystore
Test: still see keys loaded from /product appears in /proc/keys
Test: Add X.509 DER cert files to keystore, see the key in
      /proc/keys after reboot
Bug: 112038744
Change-Id: I08006d8befa69e4bf416a2bed9e1813725877147
2019-09-25 09:52:19 -07:00
Victor Hsieh
8b3b6fc1f7 New APIs for a keystore client to list and get keys
Test: client is able to list and get keys given sepolicy
Bug: 112038744
Change-Id: Ib7e2e9cc7cff6bdf4e4aba2499b9bf16a6db1d4f
2019-09-25 09:32:55 -07:00
Wenhao Wang
b48208f2c9 Merge "Fix memory leak in keystore" 2019-09-19 22:27:40 +00:00
Colin Cross
aebf66398a Use libcrypto_static instead of libcrypto
Replace libcrypto with libcrypto_static, which can be protected through
visibility to ensure only modules that don't affect FIPS certification
can use it.

Bug: 141248879
Test: m checkbuild
Change-Id: I4e0e287fab5d8968359dd98ad84b0a0713d93b41
2019-09-18 11:12:36 -07:00
Treehugger Robot
aad4f6ed19 Merge "Allow system and root to access fsverity keys" 2019-09-17 20:22:57 +00:00
Treehugger Robot
5386377bfb Merge "Don't fail attestation on missing app ID" 2019-09-12 18:40:40 +00:00
Shawn Willden
6f7d27c6c0 Don't fail attestation on missing app ID
As identified by Droidguard, a non-trivial percentage of attestations
fail with a missing attestation app ID.  It's better to produce an
attestation with missing app ID than to fail, because not all
consumers of attestations care about the app ID.

Test: Keystore CTS tests.
Change-Id: I1a8d8a6873edab27771bff4ce9262f4fbe533e56
2019-09-11 22:51:46 -06:00
Treehugger Robot
ce605a225a Merge "Remove libhwbinder/libhidltransport deps" 2019-09-06 19:43:51 +00:00
Victor Hsieh
58c10acfe8 Allow system and root to access fsverity keys
Test: can add a key from Settings/CertInstaller
Test: see the key loaded from an init script in /proc/keys
Bug: 112038744
Change-Id: I72b643d88ca4c0afce8a4e3bc64fef606daf8364
2019-09-05 16:21:21 -07:00
Steven Moreland
de99a52dc4 Remove libhwbinder/libhidltransport deps
Since these were combined into libhidlbase.

Bug: 135686713
Test: build only (libhwbinder/libhidltransport are empty)
Change-Id: I940228446b6f5b747399b408ad9af652ac618fda
2019-09-05 14:18:17 -07:00
Xin Li
1ba438c4ac Merge "DO NOT MERGE - Merge Android 10 into master" 2019-09-05 16:53:28 +00:00
Treehugger Robot
04b8903804 Merge "Make keystore a core service" 2019-09-04 23:56:29 +00:00
Xin Li
c908dbe5dd DO NOT MERGE - Merge Android 10 into master
Bug: 139893257
Change-Id: I73abd798446b0a6a87bd6bf1107612395ad8cda4
2019-09-04 13:35:28 -07:00
Janis Danisevskis
bec89993a9 Fix memory leak in keystore
When operations are aborted by an app or an app dies, tokens are not
removed from the device token map. This patch moves the this map from
key_store_service to KeyStore so that it can be accessed by the
keymaster workers. It also adds calls to removeOperationDevice to the
binderDied hook of the keymaster workers as well as to keystore service
abort.

Add a call to removeOperationDevice() inside pruneOperation() function on
keystore/keymaster_worker.cpp

Bug: 139383076
Test: atest keystore_unit_tests (passed)

Change-Id: I90d4dc9d4510f4ac250022c89240a742b9e8d4b4
2019-09-03 20:34:08 +00:00
Victor Hsieh
7fd8e853e9 Make keystore a core service
Keystore is originally a main service, but can be started earlier.
Making it a core service achieve our goal, while still keeps the
dependencies satisfied.

Specifically, the boot sequence in late-init looks like:

on late-init
  ...
  trigger late-fs       # starts early_hal class, e.g. keymaster-4-0
  trigger post-fs-data  # mounts /data
  ...
  trigger boot          # starts core class

Test: keystore still runs
Bug: 112038744
Change-Id: Ifd2192b927006b1c30d8e17be7c23e1459515d2c
2019-08-26 11:09:28 -07:00
Wenhao Wang
523a912137 Merge "Check correct err variable on wifi keystore HAL"
am: 81f35573c7

Change-Id: I9e2644beb1f421e04c59f123636943dded81ae1b
2019-08-22 15:04:05 -07:00
Wenhao Wang
81f35573c7 Merge "Check correct err variable on wifi keystore HAL" 2019-08-22 21:38:50 +00:00
Wenhao Wang
0ff2568e38 Check correct err variable on wifi keystore HAL
Test: rebuild source code and flash it to phone (Pixel 3a), which works.
Change-Id: I152470dd9f6f5a8a7793eefd0cfb2f8d8d483205
2019-08-21 09:43:39 -07:00
David Benjamin
e2d3e0b584 Merge "Replace custom BoringSSL scopers with bssl::UniquePtr."
am: 147f3df5c3

Change-Id: Ieb0bb08b000fe2eada74c8884fc4845beadc9d0f
2019-08-19 16:54:11 -07:00
Treehugger Robot
147f3df5c3 Merge "Replace custom BoringSSL scopers with bssl::UniquePtr." 2019-08-19 23:33:54 +00:00
David Benjamin
dc4d142303 Replace custom BoringSSL scopers with bssl::UniquePtr.
BoringSSL already provides C++ scopers.

Test: mma
Change-Id: I34d4ec36fc0b51750560be0886768a83fe69fbf5
2019-08-08 13:13:54 -04:00
Janis Danisevskis
277e536d5c Merge "Keystore should be developed in AOSP."
am: 52f822d6ae

Change-Id: I5c728903e615650946940d39f9bf3b2a7033b11d
2019-07-31 15:19:50 -07:00
Treehugger Robot
52f822d6ae Merge "Keystore should be developed in AOSP." 2019-07-31 21:14:43 +00:00
Janis Danisevskis
4eea9764a4 Merge "Fixed unchecked key blob access in attestKey"
am: 4e3f697233

Change-Id: If4a382525807b5d7663682f1a927b0d9c2607441
2019-07-31 12:32:36 -07:00
Treehugger Robot
4e3f697233 Merge "Fixed unchecked key blob access in attestKey" 2019-07-31 18:54:32 +00:00
Janis Danisevskis
791956e492 Keystore should be developed in AOSP.
Test: N/A
Bug: 118491737
Change-Id: I0a25be18e82172ff7cbceaf8d543fbdd27f2d8df
2019-07-31 10:50:04 -07:00
Janis Danisevskis
9dff56c52b Fixed unchecked key blob access in attestKey
In attestKey we did not check a return value after retrieving a key
blob. This results in a segfault if an attestation is requested on a non
existent or corrupted key.

Bug: 135907940
Merged-In: I1e84d334bb93ac878b63e15a59c35631f9e6e397
Change-Id: I1e84d334bb93ac878b63e15a59c35631f9e6e397
2019-07-31 10:21:27 -07:00
Xin Li
f955b4ac05 [automerger skipped] Merge "DO NOT MERGE - Merge pie-platform-release (PPRL.190705.004) into master"
am: 9f22467a12 -s ours
am skip reason: subject contains skip directive

Change-Id: Icec27349c6e80c14c69a566e0ebf2f7c45526fd9
2019-07-10 21:53:44 -07:00
Xin Li
4058a5ac0d [automerger skipped] DO NOT MERGE - Merge pie-platform-release (PPRL.190705.004) into master
am: fefc1997a5 -s ours
am skip reason: subject contains skip directive

Change-Id: I7965419205f6a448599049ea95f3397ff8e25d8e
2019-07-10 21:23:01 -07:00
Treehugger Robot
9f22467a12 Merge "DO NOT MERGE - Merge pie-platform-release (PPRL.190705.004) into master" 2019-07-11 03:52:58 +00:00
Xin Li
fefc1997a5 DO NOT MERGE - Merge pie-platform-release (PPRL.190705.004) into master
Bug: 136196576
Change-Id: I63f1465fcd85a1cd09d850bd7882b950cee2012b
2019-07-09 17:18:51 -07:00
android-build-team Robot
de927dd8d5 Snap for 5622519 from c77e4768f5 to pi-platform-release
Change-Id: Ieaa8427c189fe9429c9f4d5ff71dd1e03215a0eb
2019-07-08 23:30:32 +00:00
android-build-team Robot
4a5cb0be76 Snap for 5600800 from 3a827b0a88 to pi-platform-release
Change-Id: I507fd16c59236a9fd0f69db82876c3cb4f623f4c
2019-07-08 18:21:48 +00:00
Xin Li
76206993e4 DO NOT MERGE - Merge qt-dev-plus-aosp-without-vendor (5699924) into stage-aosp-master
Bug: 134405016
Change-Id: I7b2848c7eff8a193adc998d4d2dfea0ec05b7b73
2019-07-01 21:00:30 +00:00
Steven Moreland
173d152ddf Merge "listByInterface -> listManifestByInterface" am: 40983e6ab7
am: 2fa525797f

Change-Id: I0b46cd63ec70f6c7eea7bf3ac72c9f1a4fa70fa7
2019-05-17 15:19:02 -07:00
Steven Moreland
2fa525797f Merge "listByInterface -> listManifestByInterface"
am: 40983e6ab7

Change-Id: I0d9773723b086130e99c2eb7708ba70a841e5cdd
2019-05-17 14:35:44 -07:00
Treehugger Robot
40983e6ab7 Merge "listByInterface -> listManifestByInterface" 2019-05-17 20:55:42 +00:00
Xin Li
7c79e5e2fa [automerger skipped] DO NOT MERGE - Skip pi-platform-release (PPRL.190505.001) in stage-aosp-master
am: 9017c9f0c5 -s ours
am skip reason: subject contains skip directive

Change-Id: I0ef0eebbb25a61634d13813e511edfb582cb74a9
2019-05-15 17:45:00 -07:00
android-build-team Robot
c77e4768f5 Merge cherrypicks of [7513497, 7518418, 7517880, 7517881, 7517882, 7517883, 7517884, 7517885, 7517886, 7517956, 7517957, 7518438, 7518102, 7517887, 7518141, 7518142, 7518143, 7518144, 7517888, 7517889, 7517890, 7517891, 7518439, 7518440, 7518441, 7518442, 7518443, 7518029, 7518104, 7517892, 7517893, 7518061, 7518444, 7517894, 7517895, 7518030, 7518031, 7518445, 7517896, 7517969, 7517897, 7518105, 7518145, 7518146, 7518446] into pi-qpr3-b-release
Change-Id: I9ac6516f25ce3a313fe7e888f9a0544316d28275
2019-05-15 05:36:18 +00:00
Janis Danisevskis
3cdf309d9d Fix keystore wifi concurrency issue.
Keystore was conceptually single threaded. Even with the introduction of
Keymaster workers it was always assumed that the service dispatcher
thread was single threaded. The wifi keystore service, however, calls
into the keystore service concurrently.

This patch adds a lock around all keystore service entry points to make
sure all dispatcher executions are serialised despite being called from
both the binder and hwbinder service thread.

Bug: 128810613
Bug: 129145334
Bug: 128774635
Bug: 130045583
Bug: 131622568
Test: Regressions tested with Keystore CTS test suite.
Merged-In: I8c5602d2c2cb1dd9423df713037e99b247cee71f
Change-Id: I8c5602d2c2cb1dd9423df713037e99b247cee71f
(cherry picked from commit 4ea6d7a447)
2019-05-15 05:35:01 +00:00
Xin Li
9017c9f0c5 DO NOT MERGE - Skip pi-platform-release (PPRL.190505.001) in stage-aosp-master
Bug: 132622481
Change-Id: Idfa9f62edf772ef641d5b6832c150451b174904e
2019-05-14 12:13:17 -07:00
android-build-team Robot
3a827b0a88 Merge cherrypicks of [7496339, 7495273, 7495624, 7496340, 7496341, 7496342, 7496343, 7495658, 7494789, 7494790, 7494791, 7496344, 7496345, 7496346, 7496347, 7496574, 7496348, 7496575, 7496576, 7496260, 7496349, 7496350, 7496440, 7496577, 7496578, 7496261, 7495625, 7496442, 7496351] into pi-qpr3-release
Change-Id: I43c7060e9f4c6d51851bf394418734b09c8c6403
2019-05-14 05:00:02 +00:00