Commit graph

2377 commits

Author SHA1 Message Date
Joel Galenson
17f180c317 Add .gitignore.
Test: Don't see these files in git.
Change-Id: I78fe68d1e39a05ab4897315b8738faaaa84cff49
2020-11-24 09:59:17 -08:00
Treehugger Robot
8e019fa90d Merge "Make Keystore2's crypto operations their own crate" 2020-11-24 01:04:31 +00:00
Joel Galenson
46d6fd0ffa Make Keystore2's crypto operations their own crate
This cleanly separates out the underlying C++ code and allows clients
to depend only on the safe wrapper.

Test: keystore2_crypto_test
Test: keystore2_crypto_test_rust
Change-Id: I730ebe22ac66287a5650a36b7aeb61c69172e0f8
2020-11-19 18:00:02 -08:00
Treehugger Robot
9d46224ed0 Merge "Fix broken test" 2020-11-19 20:17:37 +00:00
Joel Galenson
7fa5c41dc5 Fix broken test
Test: keystore2_test
Change-Id: I62e2281635e44b7d495b02c9f5c23cd3bbd71d89
2020-11-19 10:57:12 -08:00
Treehugger Robot
de5e40df83 Merge "Use std::optional instead of std::unique_ptr" 2020-11-19 11:43:28 +00:00
Treehugger Robot
70761c104f Merge "Keystore 2.0: Make key blob upgrade atomic." 2020-11-18 20:46:50 +00:00
Treehugger Robot
7178b8999b Merge changes from topic "ks2_with_keymint"
* changes:
  Keystore 2.0: Add back dependency on KeyMint AIDL spec.
  Keystore 2.0: Revisited pruning strategy
  Keystore 2.0: Store key parameters
  Keystore 2.0: Use generated KeyMint AIDL bindingis.
2020-11-18 15:59:01 +00:00
Jooyung Han
1eec75aaa7 Use std::optional instead of std::unique_ptr
Since Android R, Parcel provides read/write methods for "@nullable"
values using std::optional.

Bug: 149784838
Test: m
Change-Id: I343841e690ed2d00548bb2ad623e07fa26823214
2020-11-18 15:02:52 +09:00
Janis Danisevskis
aec1459ec2 Keystore 2.0: Make key blob upgrade atomic.
This patch adds a key id lock. load_key_entry now returns a key id
guard, and database operations, that manipulate key entries require
a valid guard. This is mainly used to make upgrading the key blob
atomic.
This patch also adds key upgrade to wrapped key import and adds a helper
function, that hides the upgrade-required-retry logic.

Test: keystore2_test
Change-Id: I3f816817c731b89acb651b7d9a5fcacdd46c567f
2020-11-17 12:20:51 -08:00
Janis Danisevskis
a53c9cf798 Keystore 2.0: Add back dependency on KeyMint AIDL spec.
We are using SecurityLevel, KeyParameter, and HardwareAuthenticatorType
from the KeyMint spec now, instead of defining our own versions of these
types.

Test: keystore2_test
Change-Id: I0080382cb3619f7153ea3a6e49bb7b5f4b23f15b
2020-11-17 12:17:10 -08:00
Janis Danisevskis
45c5c97665 Keystore 2.0: Revisited pruning strategy
There was a bug by which we could end up spinning in an endless loop in
the case where finalized operations were still considered for pruning.
We try to check the outcome of an operation and refrain from considering
it for pruning if it is confirmed finalized and awaiting garbage
collection.

We also made a tweak to the pruning strategy, that allows clients to
cannibalize their own operations if no other slot can be found. This is
catering to the Java Keystore SPI which has no synchronous way of
aborting an operation. The CTS test actually spawns many operations that
it does not intend to finalize. It simply drops the corresponding crypto
object, which then might linger until the garbage collector decides to
clean up.

Test: Cts test passes without throwing backend busy exceptions.
Change-Id: I05ee231d22877a166107e5d02c88501d0fb6bf13
2020-11-17 12:17:10 -08:00
Janis Danisevskis
04b0283254 Keystore 2.0: Store key parameters
We now store key parameters in the database and returns sets of
authorizations to the keystore client's.

We also switched to mostly using the SecurityLevel type from the KeyMint
AIDL spec, rather then the temporary one from the Keystore 2.0 AIDL
spec.

Test: This enables some of the CTS test e.g. from
      atest android.keystore.cts.CipherTest
Change-Id: I0a13063b397a5ad835fecea0e6b44a98845c05be
2020-11-17 12:17:10 -08:00
Janis Danisevskis
85d4793fe8 Keystore 2.0: Use generated KeyMint AIDL bindingis.
This patch adjusts keystore2 to use rust bindings generated from the
KeyMint AIDL spec instead of using pregenerated bindings.

Bug: 160623310
Test: keystore2_test
Change-Id: I77bb0426991381535f9dbe4f32e7e137a8eb7df3
2020-11-16 22:35:45 -08:00
Treehugger Robot
a58771971b Merge "Add certificate utils to keystore2 crypto" 2020-11-17 00:55:02 +00:00
Janis Danisevskis
a7c72dbad7 Add certificate utils to keystore2 crypto
This patch adds code for certificate generation with boringssl.
This is required for the Keymaster to KeyMint legacy wrapper.

Bug: 171351607
Test: keystore2_crypto_test
Change-Id: Id2d35be04cb5ab8c4e6b0597f5a970150ab9e69b
2020-11-16 14:30:12 -08:00
Treehugger Robot
3b37aa5e43 Merge "Rename module for pregenerated keymint bindings." 2020-11-16 21:55:02 +00:00
Janis Danisevskis
1ea682ee86 Rename module for pregenerated keymint bindings.
This module uses a name that conflicts with the about
to land keymint AIDL spec. This patch renames this
temporary module to allow the keymint spec to land.

Test: Still compiles.
Change-Id: I4aa9a2fb125b2111f778e0182615ab29d2c9fe85
2020-11-16 12:54:24 -08:00
Janis Danisevskis
245453e0ea Merge "Keystore 2.0: Observe revision of the Keystore 2.0 AIDL interface." 2020-11-13 18:23:21 +00:00
Janis Danisevskis
2c7f962f8b Keystore 2.0: Observe revision of the Keystore 2.0 AIDL interface.
Remove output parameters by moving them into designated output
structures.

Test: see VTS test
Change-Id: If629f206b4bb69a798e63be37062bf507338d0f5
2020-11-12 20:48:01 -08:00
Wedson Almeida Filho
8a8ea67e55 Merge "Add provisioner CLI and its interface." 2020-11-12 16:47:31 +00:00
Wedson Almeida Filho
ba42dac790 Add provisioner CLI and its interface.
Change-Id: If7682c037232844568ba88a0ed38e26924e1c10e
2020-11-12 15:21:12 +00:00
Steven Moreland
26668f5bc2 Merge "Add @SensitiveData to Keystore service and callback" 2020-11-11 16:17:19 +00:00
Branden Archer
2f0c3976e3 Add @SensitiveData to Keystore service and callback
Bug: 171501998
Test: Builds and manual evaluation
Change-Id: Ie2f88994afca298df34020bc62659e7c51060e6e
2020-11-04 13:26:46 -08:00
Treehugger Robot
68ed7fcc63 Merge "Add crypto libraries" 2020-11-03 14:49:37 +00:00
Joel Galenson
ca0efb1f27 Add crypto libraries
Add C++ versions of the BoringSSL crypto functions we need (copied
from keystore) and create Rust wrappers for them.

Test: atest keystore2_test
Change-Id: I21ff8630df26ca73ae36395c5303270e96a6deb6
2020-11-02 07:21:11 -08:00
Treehugger Robot
552c0ca443 Merge "Add maxTargetSdk restriction to unused APIs." 2020-10-27 13:25:59 +00:00
Mathew Inwood
271f57b52c 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: I54fce50d3fb9d3ba02eae312c478bac419a46ede
2020-10-26 11:21:01 +00:00
Treehugger Robot
e0b6606138 Merge "Keystore 2.0: Start keystore2 daemon conditionally." 2020-10-25 20:49:53 +00:00
Janis Danisevskis
9402f2775b Keystore 2.0: Start keystore2 daemon conditionally.
This patch makes the keystore2 daemon start conditionally based on the
platform property ro.android.system.keystore2.enable.
This is patch can be reverted when the Keystore 2.0 migration is
complete. b/171563717

Bug: 171563717
Bug: 171305684
Test: The keystore2 daemon is running if the property
      ro.android.system.keystore2.enable is set and true
      and not running otherwise.
Change-Id: I2b3d6c70f45f3dafb9edb6f2f6960be94e13ed20
2020-10-23 11:14:52 -07:00
Treehugger Robot
68ec103cb2 Merge "Add Keystore 2.0 service." am: 0078542aa1
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1395708

Change-Id: I8b30f67ee5943ce28ac55928906bb9e93c657e04
2020-10-16 02:55:23 +00:00
Treehugger Robot
0078542aa1 Merge "Add Keystore 2.0 service." 2020-10-16 02:36:44 +00:00
Janis Danisevskis
1af9126a1f Add Keystore 2.0 service.
This patch adds a boilerplate Keystore 2.0 service. It is configured to
run on the device but does not provide any useful service yet.
It provides basic functionality for generating, importing and using
keys, but it still lacks full Keystore functionality.

Test: VtsKeystore2V1_0TargetTest (in followup CL)
Bug: 160623310
Bug: 160930114
Bug: 160930117
Bug: 160930331
Bug: 159465122
Change-Id: I7dfa2f2f63f4da3af620aff2ec99c0cba3bda6fd
2020-10-15 16:11:09 -07:00
Xin Li
d5a79419b8 Skip ab/6749736 in stage.
Merged-In: I3c023063eff938812d7001d621d027b81572f4c8
Change-Id: Ied5cd2adff15c89a895bf751cecb047267931ce4
2020-10-08 17:24:04 -07:00
Treehugger Robot
c0f98114f7 Merge changes from topic "ks2_aidl_autogen" am: c79a95510f
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1454000

Change-Id: I5b8f42ad16476257feacaa105023e8192ac313f6
2020-10-08 17:59:18 +00:00
Treehugger Robot
c79a95510f Merge changes from topic "ks2_aidl_autogen"
* changes:
  Keystore 2.0: Add globals.rs and utils.rs
  Update prebuilt keymint interface.
  Keystore 2.0: Adopt associated const enum variants.
  Keystore 2.0: Switch to autogenerated AIDL bindings.
2020-10-08 17:41:00 +00:00
Janis Danisevskis
a75e208d30 Keystore 2.0: Add globals.rs and utils.rs
These two files add some utility functions and a thread local reference
to a database connection.

Test: None
Change-Id: I34fdf977deb233571b9a0c6d50da20e47593d6a5
2020-10-08 08:22:34 -07:00
Janis Danisevskis
c5b5cb6f08 Update prebuilt keymint interface.
Change-Id: I2af01ffdcd22bd2389b193bab90a5c9ceb79da64
2020-10-07 17:52:43 -07:00
Janis Danisevskis
c5b210b62b Keystore 2.0: Adopt associated const enum variants.
The aidl to rust generator now generates tuple structs with associated
constants as variants. This patch adjusts the existing Keystore 2.0
codebase to this change.

In the process one more variant was added to the
implement_key_parameter_conversion_to_from_wire! macro and the
indentation was fixed.

Test: keystore2_test
Change-Id: I2639c76d4da7401f6799180e1bfcb3e420341628
2020-10-07 17:52:32 -07:00
Janis Danisevskis
71dc30de9c Keystore 2.0: Switch to autogenerated AIDL bindings.
Remove pregenerated file android_security_keystore2.rs and
reconfigure the build to use the generated target
android.security.keystore2-rust instead.

Test: keystore2_test
Change-Id: Iad24cab05ef35ccc766f7342225d4b79e8051ada
2020-10-06 19:31:05 -07:00
Hasini Gunasinghe
eb4a5a5d70 Merge "Pass default values for the optional fields in attestation logs" am: 6214d7d3ad
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1448835

Change-Id: I6289f63a9188f87c48f33127c9bcd931919e491e
2020-10-06 21:54:08 +00:00
Hasini Gunasinghe
6214d7d3ad Merge "Pass default values for the optional fields in attestation logs" 2020-10-06 21:34:36 +00:00
Hasini Gunasinghe
2481b9deb7 Pass default values for the optional fields in attestation logs
This CL provides the fix for the issue reported in b/169959923.

Bug: 169959923
Test: tested using statsd_testdrive script.
Change-Id: I3fe42e85abd0976782795ad4fa13a804702624d6
2020-10-05 12:46:42 +00:00
Janis Danisevskis
a5562fae1d [automerger skipped] Merge "Keystore 2.0: Remove list permission from keystore2_key security class." am: d55f6ceacc -s ours
am skip reason: Change-Id Ie0a29d8b08c53977ae2ed04d042868044d2c34c5 with SHA-1 3d72aad0bc is in history

Original change: https://android-review.googlesource.com/c/platform/system/security/+/1434719

Change-Id: I3475e3e4a7ede8e810ef8a2b6e4b2a5b307dc825
2020-10-01 17:10:10 +00:00
Janis Danisevskis
d55f6ceacc Merge "Keystore 2.0: Remove list permission from keystore2_key security class." 2020-10-01 16:49:33 +00:00
Janis Danisevskis
3d72aad0bc Keystore 2.0: Remove list permission from keystore2_key security class.
The list permission is special keystore2 permission that allows
callers to list arbitrary namespaces. It is not a key or namespace
specific permission.

Ignore-AOSP-First: This needs to land in googleplex first to updated
                   prebuilt vendor images. Otherwise it breaks
		   aosp-with-phone builds.
Test: N/A
Change-Id: Ie0a29d8b08c53977ae2ed04d042868044d2c34c5
2020-10-01 05:33:29 +00:00
Janis Danisevskis
ee10b5fab0 Keystore 2.0: Remove list permission from keystore2_key security class.
The list permission is special keystore2 permission that allows
callers to list arbitrary namespaces. It is not a key or namespace
specific permission.

Test: N/A
Merged-In: Ie0a29d8b08c53977ae2ed04d042868044d2c34c5
Change-Id: Ie0a29d8b08c53977ae2ed04d042868044d2c34c5
2020-09-30 12:20:56 -07:00
Hasini Gunasinghe
f6121aedfe Merge "Convert KeyParameter to wire type." am: 29c9edd2d5
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1414588

Change-Id: Ic80ba5f9d6a51c2c0af48dd6d8543f404d6ad767
2020-09-16 00:37:51 +00:00
Hasini Gunasinghe
29c9edd2d5 Merge "Convert KeyParameter to wire type." 2020-09-16 00:00:15 +00:00
Hasini Gunasinghe
3eb77c275c Convert KeyParameter to wire type.
For communicating with keymint and SPI.
This CL also moves all test modules to the bottom of the file.

Bug: 167744352
Test: Unit tests
Change-Id: I085dbe68076ba361c4d89f63de87c3b2f05627bc
2020-09-15 14:47:56 +00:00