Commit graph

1019 commits

Author SHA1 Message Date
Shaquille Johnson
bcab601c03 Run rustfmt on directory
Runs rustfmt on keystore2 to standardize formatting changes.

Test: Formatting change so no test needed
Change-Id: I24208f8fe91e6b15108eef0ff5264a3f086497e4
2022-09-02 13:17:54 +00:00
Treehugger Robot
ffcc8fd2ef Merge "Added HMAC key generation tests." 2022-09-02 11:14:01 +00:00
Treehugger Robot
5af917188a Merge "Adding a test to simulate OPERATION_BUSY error from keystore." 2022-09-02 10:00:04 +00:00
Rajesh Nyamagoud
01d4cde74a Adding a test to simulate OPERATION_BUSY error from keystore.
The test tries to create a race condition: It creates an operation
and starts two threads, each trying to use the operation repeatedly
until it gets  `OPERATION_BUSY`  or finishes successfully.

Bug: 194359114
Test: atest keystore2_client_test
Change-Id: Ib3549d6bcad4e24bf621960f0f399481bf2da7c7
2022-08-31 18:27:03 +00:00
Rajesh Nyamagoud
4c6193c217 Added HMAC key generation tests.
- Generate HMAC keys with digest modes [SHA1, SHA_2_224, SHA_2_256,
  SHA_2_384, SHA_2_512], should be able to create operations using
  generated keys successfully.

- Try to generate HAMC keys with key size in the range 0..513. For
  invalid key size, key generation should fail with an error code
  `UNSUPPORTED_KEY_SIZE`.

- Generate HMAC keys with min-mac-lengths in the range 0..257. For
  invalid min-mac-length, key generation should fail with an error
  code `UNSUPPORTED_MIN_MAC_LENGTH`.

- Try to generate HMAC key with multiple digest modes, key generation
  should fail with an error code `UNSUPPORTED_DIGEST`.

- Try to generate HMAC key without providing digest mode, key
  generation should fail with an error code `UNSUPPORTED_DIGEST`.

- Try to generate HMAC key with digest mode `NONE`, key
  generation should fail with an error code `UNSUPPORTED_DIGEST`.

- Generate HMAC key with min-mac-length of 128 bits and digests
  [SHA1, SHA-2-224], try to create operations with mac-len greater than
  digest lengths. Test should fail to create an operation with an error
  code `UNSUPPORTED_MAC_LENGTH`.

- Generate HMAC key with min-mac-length of 128 bits and digests
  [SHA1, SHA-2-224], try to create operations with mac-len less than
  min-mac-length. Test should fail to create an operation with an error
  code `INVALID_MAC_LENGTH`.

Bug: 194359114
Test: atest keystore2_client_test
Change-Id: I594c9718b0f6a67f2655faca4bf100abf2ced3a3
2022-08-31 18:22:08 +00:00
Ryan Prichard
9cf7f66c51 Add missing assert.h and functional includes
Bug: http://b/175635923
Test: treehugger
Change-Id: Ib062da6888e560fed3abd389dad3dfbf4cb4f3fa
2022-08-30 17:35:03 -07:00
Paul Crowley
f71fe8a1e5 Use ro.keystore.boot_level_key.strategy
Choose the strategy for generating the boot level  key from a property,
if present, instead of looking at KM versions.

Bug: 241241178
Test: set property on Cuttlefish, check logs for strategy used.
Change-Id: I2c7a6fb2c6471ab4a7cb7f650791930f41068bfa
2022-08-24 10:03:46 -07:00
Paul Crowley
e1e1723781 Refactor L0 key handling ahead of fix
Bug: 241241178
Test: treehugger
Change-Id: I3b9c6dcda0a9b8d57d6d4e8be8f9eddf59d3b89f
2022-08-24 10:03:46 -07:00
Treehugger Robot
65f8bf69c5 Merge "Added keystore2_unsafe_fuzzer" 2022-08-22 05:42:53 +00:00
Treehugger Robot
767a2e3f7f Merge "Update source for Rust 1.63.0" am: e3973b49eb
Original change: https://android-review.googlesource.com/c/platform/system/security/+/2184738

Change-Id: I1e3bc3bbb2b22475d103f8944a2fdd85363da811
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-12 19:40:58 +00:00
Treehugger Robot
e3973b49eb Merge "Update source for Rust 1.63.0" 2022-08-12 19:13:34 +00:00
Chris Wailes
263de9f8d7 Update source for Rust 1.63.0
Test: m rust
Bug: 241303140
Change-Id: I3b4d8c1c3101941258e366279bfd2a4a3ab1b948
2022-08-12 10:36:10 -07:00
Eran Messeri
f73b2d0470 Merge "Updated listEntries API response code with invalid domain field." am: 6ec53e3489
Original change: https://android-review.googlesource.com/c/platform/system/security/+/2166105

Change-Id: I85422389dfa79e167cd1258dfa4ef5fba5565104
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-12 14:09:57 +00:00
Eran Messeri
6ec53e3489 Merge "Updated listEntries API response code with invalid domain field." 2022-08-12 13:20:09 +00:00
Treehugger Robot
af75992ff6 Merge "Added tests using 3DES algorithm." am: 99fe2aeaec
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1967149

Change-Id: I1d3622e893b7f99d6aa058b6d172d461d32660e3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-12 11:34:28 +00:00
Rajesh Nyamagoud
c3523bacff Added tests using 3DES algorithm.
- Generate 3DES keys with block modes [ECB, CBC] and padding modes
  [NONE, PKCS7]. Should be able to create operations successfully
  with these generated keys.

- Try to generate a key and create an operation with invalid inputs, it
  should fail with proper error codes
  - with unsupported key size
  - with unsupported padding mode
  - with padding mode NONE and input text whose length isn't a
    multiple of the DES block size
  - with unsupported blockmode

Bug: 194359114
Test: atest keystore2_client_test
Change-Id: Ida98fd2e6f9b7ba84b8beba9ea979d5aeb2240ee
2022-08-12 02:09:46 +00:00
Rajesh Nyamagoud
16198a3ca9 Updated listEntries API response code with invalid domain field.
Updated to return `INVALID_ARGUMENT` instead of `PERMISSION_DENIED`
response code when domain is other than `APP` or `SELINUX`.

Added tests to validate `listEntries` API with valid domains `APP and
SELINUX` and invalid domains like `BLOB`.

Bug: 239719010
Test: atest CtsKeystoreTestCases; atest keystore2_client_tests;
Change-Id: I7d10c13342ca5719682e371e428fa42f992ba07d
2022-08-12 00:03:57 +00:00
Treehugger Robot
727b510c18 Merge "Restructured keystore2 client tests." am: a00741ceb6
Original change: https://android-review.googlesource.com/c/platform/system/security/+/2176242

Change-Id: Ic950a2695f904ac436817fea368779a30e14fc34
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-10 17:16:45 +00:00
Rajesh Nyamagoud
609846ad49 Restructured keystore2 client tests.
Separated out the tests based on functionalities and created a separate
modules without modifying the existing test cases.

Bug: 194359114
Test: atest keystore2_client_test
Change-Id: Ifc93b3ce69817469d1d5f01844c623f5209e2b62
2022-08-04 23:52:30 +00:00
Devendra Singhi
31863b1ab5 Added keystore2_unsafe_fuzzer
Test: ./keystore2_unsafe_fuzzer
Bug: 240524901

Change-Id: Ibb6d2c649f982bc1b5fc8d4a259087e53bac79aa
2022-08-04 14:33:29 +05:30
Treehugger Robot
3615d1fe47 Merge changes Ibf1b8460,I16843932 am: 32cf305fc5
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1941336

Change-Id: I19df4d4b5221e399010b9cab337834005e6fa5da
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-03 17:40:04 +00:00
Treehugger Robot
32cf305fc5 Merge changes Ibf1b8460,I16843932
* changes:
  Adding tests using AES algorithm.
  Adding generate key tests using RSA algorithm.
2022-08-03 17:32:48 +00:00
Rajesh Nyamagoud
4740993bf1 Adding tests using AES algorithm.
- Generate AES keys with block modes [ECB, CBC] and padding modes [NONE,
  PKCS7]. Should be able to create operations successfully with these
  generated keys.

- Generate AES keys with block modes [CTR, GCM] and padding modes [NONE,
  PKCS7]. Should be able to create operations successfully with padding
  mode NONE. With PKCS7 padding mode creation of an operation should
  fail with incompatible padding mode.

- Try to generate a key and create an operation with invalid inputs, it
  should fail with proper error codes.
  - with unsupported key size
  - with GCM block mode without providing min-mac-length
  - with multiple block modes
  - with multiple padding modes
  - with incompatible padding modes
  - with incompatible block modes
  - with missing mac-length
  - with invalid mac-length
  - with unsupported mac-length
  - With AES-CBC-PKCS7 key without `CALLER_NONCE` authorization, Try to
    set nonce while creating an operation.

Bug: 194359114
Test: atest keystore2_client_test
Change-Id: Ibf1b8460317b4c99d9060d5889c8b3778a80ca5b
2022-07-22 18:58:41 +00:00
Rajesh Nyamagoud
11912eaf78 Adding generate key tests using RSA algorithm.
- Generate RSA signing keys with combinations of digest modes [NONE,
  MD5, SHA1, SHA_2_224, SHA_2_256, SHA_2_384, SHA_2_512] and padding
  modes [NONE, RSA_PKCS1_1_5_SIGN, RSA_PSS]. Should be able to
  create operations using these keys except in below cases.
   - when padding mode is RSA_PSS and digest mode is NONE
   - when padding mode is NONE and digest is other than NONE.

- Generate RSA encrypt/decrypt keys with OAEP padding mode, combinations
  of digests [MD5, SHA1, SHA_2_224, SHA_2_256, SHA_2_384, SHA_2_512] and
  mgf-digests [MD5, SHA1, SHA_2_224, SHA_2_256, SHA_2_384, SHA_2_512].
  Should be able to create operations with these generated keys
  successfully.

- Generate RSA encrypt/decrypt keys with combinations of padding modes
  [NONE, RSA_PKCS1_1_5_ENCRYPT, RSA_OAEP], digests [NONE, MD5, SHA1,
  SHA_2_224, SHA_2_256, SHA_2_384, SHA_2_512]. Should be able to create
  operations with these generated keys successfully except in below case
   - with padding mode RSA_OAEP and digest mode NONE an error is
     expected.

- Generate RSA encrypt/decrypt keys with padding modes [NONE,
  RSA_PKCS1_1_5_ENCRYPT, RSA_OAEP] and without digests. Should be able
  to create operations with these generated keys successfully.

- Generate RSA keys without padding modes and digest modes. Creation of
  an operation should fail with unsupported padding mode error.

- Tests to validate failure of generating RSA keys with incompatible
  purpose, unsupported purpose, unsupported padding mode, unsupported
  digest and unsupported key sizes.

Bug: 194359114
Test: atest keystore2_client_test
Change-Id: I16843932cc170d0e820208f558587aacf13b9272
2022-07-22 17:54:16 +00:00
Andrew Scull
9cb85479f3 Merge "Allow virt APEX to use diced and open_dice_cbor" am: af43ae73f9
Original change: https://android-review.googlesource.com/c/platform/system/security/+/2151395

Change-Id: I6c44929e72db1bf1d65cfcfa43d9bbcd20d08f89
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-19 09:51:20 +00:00
Andrew Scull
af43ae73f9 Merge "Allow virt APEX to use diced and open_dice_cbor" 2022-07-19 09:27:41 +00:00
Vikram Gaur
6d4c60eaaa Merge "Support upgrade key for software-emulated keys." am: 65467fba1f
Original change: https://android-review.googlesource.com/c/platform/system/security/+/2155233

Change-Id: I231789a61c60244bb925a53e90bc7a82d1284135
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-18 21:32:17 +00:00
Vikram Gaur
65467fba1f Merge "Support upgrade key for software-emulated keys." 2022-07-18 21:11:36 +00:00
Eran Messeri
794cf95437 Merge "Adding tests using Domain::KEY_ID." am: 75aa039b3d
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1924617

Change-Id: I3843abf5ab1d0d0c284593486d1c0217a88618a5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-18 11:38:32 +00:00
Eran Messeri
75aa039b3d Merge "Adding tests using Domain::KEY_ID." 2022-07-18 11:11:16 +00:00
Vikram Gaur
856b1cdc9c Support upgrade key for software-emulated keys.
Currently software-emulated keys do not have any update mechanism. Any
software key that is created in previous versions cannot be used once
the device is upgraded. With this change, keys now can be upgraded and
used by the latest keystore.

Change-Id: Ic791baeedd7775df7eafca405440e645b19ec2bc
Test: TreeHugger
Fixes: 223376764
2022-07-17 23:53:20 +00:00
Rajesh Nyamagoud
54f6590f60 Adding tests using Domain::KEY_ID.
- Test to verify that Domain::KEY_ID is not allowed for generating
   a key. Try to generate a key with domain as KEY_ID and expect an
   error.

 - Test to find key entry with domain as KEY_ID.
   Generate a key and load it with domain as KEY_ID. Test should be
   able to create an operation using the key loaded with domain as
   KEY_ID.

 - Generate a key with an alias. Generate another key and bind it with
   same alias. Verify that originally generated key no longer exists
   and report an error if we try to use it.

 - Generate a key with an alias. Load the generated key with domain
   KEY_ID. Generate another key and bind it with same alias. Verify
   that originally loaded key no longer exists and report an error
   if we try to use it.

Bug: 194359114
Test: atest keystore2_client_test
Change-Id: Ibfe237181311decf5f6f00dc222d5cd124e4ac11
2022-07-15 15:00:16 +00:00
Andrew Scull
f4a6e2842d Allow virt APEX to use diced and open_dice_cbor
Microdroid payloads use diced to access their secrets and BCCs. The
open_dice_cbor then gives them safe rust bindings to open-dice to
process them. There's a dependency on ZVec which pulls in
libkeystore2_crypto.

Test: build, TH
Change-Id: I402a9a416d7b0e0eed2e268495b148e5669e5c52
2022-07-12 15:27:00 +00:00
Treehugger Robot
356277b1d0 Merge "Extend attestation key expiration buffer to 12 hours" am: b075b8e4a1
Original change: https://android-review.googlesource.com/c/platform/system/security/+/2147406

Change-Id: Ieeeabab95f50b47ce607dadeae5982833d7d3613
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-07 21:46:35 +00:00
Treehugger Robot
b075b8e4a1 Merge "Extend attestation key expiration buffer to 12 hours" 2022-07-07 21:32:38 +00:00
Seth Moore
056106fce4 Extend attestation key expiration buffer to 12 hours
This buffer time is how far into the future keystore looks to mark
a key as "old" and needing deletion.

The old buffer time was only 20 seconds, which may not even be enough
for very slow network (where round trips and retries could take
minutes).

Test: keystore2_test
Change-Id: I27869458ec66e546b42fe344bbdffd32881c84e7
2022-07-07 09:53:51 -07:00
Eran Messeri
201f14ce45 Merge "Updated to return INVALID_ARGUMENT on generateKey with invalid domain field." am: 47fce38faa
Original change: https://android-review.googlesource.com/c/platform/system/security/+/2106689

Change-Id: Ie49808093ad5f251055a8dfcb9a2bb50dddcba0e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-07 11:32:23 +00:00
Rajesh Nyamagoud
caee93eb89 Updated to return INVALID_ARGUMENT on generateKey with invalid domain field.
Bug: 211005249
Test: atest keystore2_client_tests
Change-Id: I1c2a8f66f2e3a6897d5a2bf48b65fb97bcf9903b
2022-07-06 14:43:29 +00:00
Eran Messeri
f57fec002f Merge "Adding generateKey tests with EC key algorithm." am: 28f5a40002
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1920127

Change-Id: I66bb058ce6b1fe73904305a01256caea19462045
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-05 15:47:22 +00:00
Eran Messeri
28f5a40002 Merge "Adding generateKey tests with EC key algorithm." 2022-07-05 15:23:48 +00:00
Rajesh Nyamagoud
a7766455e9 Adding generateKey tests with EC key algorithm.
Test 1: Should fail to generate a key with domain not listed
        in keystore2::Domain.
Test 2: Should fail to generate a EC key without providing curve.
Test 3: Should fail to generate a EC key with 25519 curve having
        sign and agree_key purposes.
Test 4: Generate a EC keys with `NONE, MD5, SHA1, SHA-2 224,
        SHA-2 256, SHA-2 384 and SHA-2 512` digest modes and P_224,
	P_256, P_384, P_521 ec curves combinations. Should be able
	to create operations with these keys successfully for all
	digest modes except NONE and MD5.
Test 5: Generate a EC key with curve CURVE_25519 and digest mode NONE.
	Should be able to create an operation with digest mode NONE.
Test 6: Generate a EC keys with curve CURVE_25519 and digest modes
        `MD5, SHA1, SHA-2 224, SHA-2 256, SHA-2 384 and SHA-2 512`
	combinations. Creation of an operation should fail with
	unsupported digest error.
Test 7: Should fail to create an operation with incompatible digest
        mode in key authorizations.
Test 8: Test for key owner validation. Generate a key in one user and
        try to use it in another user context where it should fail to
	load the key as it doesn't own the key generated by prior user.
Test 9: Generate a key with Domain::BLOB. Verify that key descriptor
        holds the key blob. Try to use this key to perform an operation
	successfully.

Bug: 194359114
Test: atest keystore2_client_test
Change-Id: I8b923cfdd9dbd50d1ebaab03560e9378ede7cdee
2022-07-01 16:24:41 +00:00
Treehugger Robot
30a630eaf8 Merge "Update for Rust v1.62.0" am: b304d464ef
Original change: https://android-review.googlesource.com/c/platform/system/security/+/2143072

Change-Id: I4b7feea0880ed6c3ed2c8fffcaf77fdffb713285
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-01 06:11:58 +00:00
Treehugger Robot
b304d464ef Merge "Update for Rust v1.62.0" 2022-07-01 05:53:18 +00:00
Charisee
9761d85cbb Update for Rust v1.62.0
See https://rust-lang.github.io/rust-clippy/master/index.html#is_digit_ascii_radix
Test: run test_compiler.py

Bug: 236723597
Change-Id: I98230b7584bfda1cb0119aca92e8068dfb588429
2022-07-01 01:49:12 +00:00
Eran Messeri
fcee89c861 Merge "Test keystore grant with invalid access vector values." am: 7293ffc837
Original change: https://android-review.googlesource.com/c/platform/system/security/+/2129785

Change-Id: I410731246ffcaa818bc90fb22c5fd535d79d51da
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-30 10:22:57 +00:00
Eran Messeri
7293ffc837 Merge "Test keystore grant with invalid access vector values." 2022-06-30 09:16:06 +00:00
Xin Li
ae7b082370 Merge tm-dev-plus-aosp-without-vendor@8763363
Bug: 236760014
Merged-In: Ib81fb65570a4e9eb7e7b051f9791071ee78dc02f
Change-Id: Ic18cb2c00c503dae6b663c8895106bb039a73f73
2022-06-27 23:40:17 +00:00
Charisee Chiw
593b919baa Merge "Update for Rust v1.62.0" 2022-06-27 20:37:10 +00:00
Charisee
b48992e50e Update for Rust v1.62.0
Code triggered an error. See https://rust-lang.github.io/rust-clippy/master/index.html#map_identity

Please check for correctness

Test: Ran test_compiler.py
Bug: 236723597
Change-Id: I4f4119f4d9fab5baa58b60a1de3c6e8210df1432
2022-06-27 20:35:41 +00:00
Rajesh Nyamagoud
7fe5592037 Test keystore grant with invalid access vector values.
- Test to verify grant API with invalid access vector, it is expected to
  fail with proper error code.

- Test to verify grant API with empty access vector, it is expected to
  succeed granting a key with empty access vector. In grantee context
  while trying to use this key permission denied error is expected.

- Test to verify grant API with valid access vector, it is expected to
  successfully grant a key. Grantee should be able access the key and
  use it according to granted key permissions.

Bug: 236253306
Test: atest keystore2_client_tests
Change-Id: I20dc31b0e4f888f2bf740f84e3bb7b0e97a1bb52
2022-06-27 15:25:03 +00:00
Eran Messeri
a5de861f0b Merge "Mark unused policy as such." 2022-06-24 12:34:56 +00:00
David Drysdale
66dcde13c9 Merge "Adding tests to Create forced operation with different contexts." am: ab6edec03c am: 58a553fb5c
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1915146

Change-Id: Ifa23368c3f3ad328463531e90bce2fd01b09f5db
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-22 16:24:07 +00:00
David Drysdale
ab6edec03c Merge "Adding tests to Create forced operation with different contexts." 2022-06-22 15:50:04 +00:00
Shawn Willden
c1a95385e5 Merge "Do not use RKP for DEVICE_UNIQUE_ATTESTATION." am: 053c2ad995 am: 8f9115b9c3
Original change: https://android-review.googlesource.com/c/platform/system/security/+/2131735

Change-Id: If963604991cea55349138239e0ff6e5a2b109c30
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-21 17:52:04 +00:00
Shawn Willden
053c2ad995 Merge "Do not use RKP for DEVICE_UNIQUE_ATTESTATION." 2022-06-21 17:12:43 +00:00
Max Bires
285db9f636 Do not use RKP for DEVICE_UNIQUE_ATTESTATION.
Keystore2 previously did not process the DEVICE_UNIQUE_ATTESTATION tag.
This was an unnecessary step when there was no ability to select the
attestation key provided to the backing Keymaster instance. Now,
however, Keystore2 does need to process generateKey requests for this
tag. This is because it will pass in an RKP key by default and append
those certificates to the result if RKP is present.

This change alters Keystore2 behavior during attestation key selection.
If the DEVICE_UNIQUE_ATTESTATION tag is present, it will no longer
attempt to select an RKP key and will instead pass nothing in the
attestKey argument for KM.

Bug: 234413909
Test: atest com.android.cts.devicepolicy.MixedDeviceOwnerTest#testKeyManagement
Change-Id: Ib81fb65570a4e9eb7e7b051f9791071ee78dc02f
2022-06-20 00:09:31 -07:00
Rajesh Nyamagoud
dc6fb23808 Adding tests to Create forced operation with different contexts.
Verify that the clients (for ex: clients with `vold` context) with
`req_forced_op` permission are allowed to create forced (unpruneable)
operations otherwise the creation of forced operation is denied.

Bug: 194359114
Test: atest keystore2_client_test
Change-Id: I73d85ac127274e623095e233368b0211f6738d6e
2022-06-16 15:22:09 +00:00
Eran Messeri
653932e4ff Mark unused policy as such.
The usage of unique device identifiers is enforced via Android system
permission, not SELinux policy.

Mark the USE_DEV_ID SELinux policy as unused.

Bug: 235987410
Test: atest keystore2_test
Change-Id: I89e61eaf5d1f708e3ce10a90cf33d90946009201
2022-06-16 14:42:52 +01:00
Eran Messeri
f65864873e Merge "KeystoreDB::load_access_tuple method response code updated." am: 066f33a9a6 am: a9a67a281c
Original change: https://android-review.googlesource.com/c/platform/system/security/+/2100736

Change-Id: Ic4c2748a4bf221db565690c0fdf7cc62c3711f6b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-16 09:48:47 +00:00
Eran Messeri
7753dffc13 Merge "Adding operation pruning test (DoS)" am: b243619833 am: bdf9071602
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1913620

Change-Id: Id780285218cc8908ee55f3830899fb2ead2bbf09
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-14 16:57:56 +00:00
Rajesh Nyamagoud
625e589598 KeystoreDB::load_access_tuple method response code updated.
For any Domain value other than APP, SELINUX, GRANT and KEY_ID it is
updated to return response code as ResponseCode::INVALID_ARGUMENT
instead of ResponseCode::SYSTEM_ERROR.

Bug: 232022823
Test: atest keystore2_client_test; atest CtsKeystoreTestCases
Change-Id: I48314558fb2e77636fa99f42f8326fa99f719a4f
2022-06-14 15:18:24 +00:00
Eran Messeri
b243619833 Merge "Adding operation pruning test (DoS)" 2022-06-14 10:57:00 +00:00
David Drysdale
736c9ca282 Merge "keystore2: transfer RootOfTrust from TEE to SB" am: 7fd9887f76 am: 0f76c52307
Original change: https://android-review.googlesource.com/c/platform/system/security/+/2031823

Change-Id: I5c17f1ab30aef36065421fa68f5c4fb73fa5f4ee
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-06 05:59:17 +00:00
Rajesh Nyamagoud
5a60f2f9d3 Adding operation pruning test (DoS)
Creating n number of operations from same owner. Expecting creation
of all operations should be successful without any error. Whenever all
operation slots are full older operations are expected to be pruned.

Bug: 194359114
Test: atest keystore2_client_test
Change-Id: I9d231658e77cb10f67cfd248072bde0755c1660d
2022-06-01 20:32:25 +00:00
David Drysdale
ecd403db8b keystore2: transfer RootOfTrust from TEE to SB
Bug: 219076736
Test: manual, RoT between locally modified KeyMints
Change-Id: Iad3f14afc9d853e91cc7f7810fd6e592b48cab2d
2022-05-30 15:41:56 +01:00
Vikram Gaur
593315b166 Merge "Unbind Attestation keys when freeing up namespace." am: cc15f26ecd am: 8d4fe32328
Original change: https://android-review.googlesource.com/c/platform/system/security/+/2105145

Change-Id: Ib7e8de0a26d5b55a70c748c5c1df0ca872670422
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-25 23:10:54 +00:00
Vikram Gaur
1a98f9cca9 Unbind Attestation keys when freeing up namespace.
In https://android-review.googlesource.com/c/platform/system/security/+/1698833
we added a check only for client keys. However, this means that on application
deletion only the keystore keys related to the application are unbound and the
attestation keys get orphaned.

Through this change, I am planning to unbind the attestation keys related to
the application as well.

Change-Id: I1c9d1ac6d6943cc53f5d74653e3da72cd4f2adf7
Test: atest keystore2_test
BUG: 232534682
2022-05-25 21:58:34 +00:00
David Drysdale
5fc3690ddb Merge "Adding forced operation tests" am: c28640b55e am: 2954e3ebbc
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1908978

Change-Id: Ib6ccae4f671d612d2070fa17ce0ce89d1e081dfc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-23 08:32:05 +00:00
David Drysdale
c28640b55e Merge "Adding forced operation tests" 2022-05-23 08:07:00 +00:00
Hasini Gunasinghe
64ac1f8e96 Merge "Log SecurityLevel with RkpErrorStats." 2022-05-20 18:04:02 +00:00
Treehugger Robot
95812634ba Merge "[LSC] Add LOCAL_LICENSE_KINDS to system/security" am: b8f4e7c6cc am: c73face06b
Original change: https://android-review.googlesource.com/c/platform/system/security/+/2098085

Change-Id: Ia2da489e76001fdb8d759ea9a2ab391aa820feff
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-20 16:24:16 +00:00
Rajesh Nyamagoud
fa7c0f1c41 Adding forced operation tests
- Forced operation creation with all slots filled with normal operations
- Forced operation creation with all slots filled with forced operations

Bug: 194359114
Test: atest keystore2_client_test
Change-Id: I493ea1c25d09597c44add430a20b5ca9c983e8d3
2022-05-20 15:40:03 +00:00
Bob Badour
ae667ea93c [LSC] Add LOCAL_LICENSE_KINDS to system/security
Added SPDX-license-identifier-Apache-2.0 to:
  keystore2/tests/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all
Change-Id: I816f5ba7db5e359b97f1bd0222ca43eebacfc4d1
2022-05-19 09:15:17 -07:00
Hasini Gunasinghe
1a8524bd0f Log SecurityLevel with RkpErrorStats.
Bug: 230750270
Test: Local testing with statsd TestDrive script
Merged-In: I8490e31df4a111ff6787ea67dd8a170b410566df
Change-Id: I8490e31df4a111ff6787ea67dd8a170b410566df
2022-05-18 06:26:45 +00:00
David Drysdale
636558b60f Merge changes I52f95a7c,Iabe9af74 am: dfa8b21553 am: 519482d959
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1880749

Change-Id: I943aae0c74dc34ae3a9a2dff86b74fb740582878
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-17 06:32:05 +00:00
Rajesh Nyamagoud
b881d5189c Adding test to create BACKEND_BUSY error
Creates multiple child procs and creates opearations in it and
parent proc waits for all child procs operations status, expects
one or more opearations to fail with backeend busy error.

Bug: 194359114
Test: atest keystore2_client_test
Change-Id: I52f95a7cfd031d80c88bfc2ca478a26572f40150
2022-05-13 22:30:16 +00:00
Rajesh Nyamagoud
45689e569c rust_defaults entry created for Keystore2 AIDL library.
A rust_defaults "keystore2_use_latest_aidl_rust" that includes the latest
Keystore2 AIDL library. Modules that depend on Keystore2 directly can include
this rust_defaults to avoid managing dependency versions explicitly

Test: Compile
Change-Id: Iabe9af743c4ceb787db42ff7cc619bab97ec55c4
2022-05-13 19:33:36 +00:00
Hasini Gunasinghe
5657d5fed1 Log SecurityLevel with RkpErrorStats. am: adf6692b3e
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/security/+/18350667

Change-Id: Ib67a160314b99f48ee0c5cf9e0dc07e2ea76423b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-12 21:48:04 +00:00
Hasini Gunasinghe
adf6692b3e Log SecurityLevel with RkpErrorStats.
Bug: 230750270
Test: Local testing with statsd TestDrive script
Ignore-AOSP-First: This targets T and will be cherry-picked to AOSP later.
Change-Id: I8490e31df4a111ff6787ea67dd8a170b410566df
(cherry picked from commit d675e225a7)
2022-05-12 16:58:55 +00:00
David Drysdale
e2c4f0fcf4 Merge "Drop ancient default salt value" 2022-04-22 07:12:24 +00:00
Seth Moore
dfdcb87504 Do not cache rkp_only property
To allow for testing, read the rkp_only properties every time instead
of caching the value. This allows the RemoteProvisioner tests to alter
the property, moving the device in and out of rkp-only mode.

Test: RemoteProvisionerUnitTests
Bug: 27306369
Change-Id: If9a616fd36095175f4aea07c897c67a11eb04bcf
2022-04-20 17:14:25 -07:00
Treehugger Robot
90c23a8c17 Merge "Fix lints from Rust 1.60.0" 2022-04-20 08:55:13 +00:00
Chris Wailes
20f50df906 Fix lints from Rust 1.60.0
Bug: 222737227
Test: m rust
Change-Id: I4f35c8e50a1837608ab69a7609caff9c485e8c85
2022-04-19 17:23:52 -07:00
David Drysdale
6a0ec2ca08 Drop ancient default salt value
A value for the salt is present in all code paths:

- All callers of `Password::derive_key` pass a `Some(..)` value for the
  salt.  Remove this `Some` everywhere and...
- Change the signature of `derive_key` to expect a `&[u8]` for `salt`
  rather than an `Option<&[u8]>`.
- `Password::derive_key` is the only caller of `generateKeyFromPassword`
  (via bindgen to C++-land), so...
- Make it clear that the C++ `generateKeyFromPassword()` function
  expects 16 bytes of `salt`.

Bug: 172121323
Test: compile, TreeHugger
Change-Id: I41966cce96b5371785680c13bacfc5f95969372a
2022-04-19 11:25:26 +01:00
Seth Moore
562aebb873 Ensure that "rkp only" forces checks for rkp keys
An empty key pool should not allow fallback to the batch key if the
vendor indicates the system is rkp only.

Additionally, if the system is misconfigured (e.g. marked as rkp only
and has no remotely provisioned component hal) then we should insist
on checking RKP keys anyway. This will result in the given system
always returning OUT_OF_KEYS, which will fail various tests.

Test: keystore2_test
Test: RemoteProvisionerUnitTests
Bug: 227306369
Change-Id: I027bc56ff167abf99b18be01dccf05f90dd07f2a
2022-04-18 17:03:27 -07:00
Treehugger Robot
678a6f5af4 Merge "Turn on AFDO for keystore2" 2022-04-16 05:12:02 +00:00
Seth Moore
8c06c3e872 Fix unique id attestation on devices with keymaster
The wrong tag was included in the km_compat layer filter code for
key generation tags. This prevented the INCLUDE_UNIQUE_ID tag from
being passed to keymaster, breaking unique id attestation on platforms
with keymaster (keymint functionality was correct).

Test: KeyAttestationTest
Fixes: 228851969
Change-Id: I81ef55bb92c9869102a741e64375b883c3443224
2022-04-13 15:31:02 -07:00
Bob Badour
11a8dab786 [LSC] Add LOCAL_LICENSE_KINDS to system/security
Added SPDX-license-identifier-Apache-2.0 to:
  keystore2/tests/legacy_blobs/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all
Change-Id: Ifc2e14a9b60e364323794eaa5a8c181c4f0a78ee
2022-04-07 10:44:12 -07:00
Seth Moore
bdccd287c6 Merge "Add a new permission check around unique id attestation" 2022-04-06 12:40:27 +00:00
Seth Moore
8e95c7ce03 Merge "Return OUT_OF_KEYS if system is rkp only" 2022-04-04 23:10:32 +00:00
Max Bires
65207b5f10 Return OUT_OF_KEYS if system is rkp only
This change leverages the ro.remote_provisioning.rkp_only system
property in order to determine whether or not the system has fallback
keys. If there are no fallback keys, then ks2 will now return
OUT_OF_KEYS as a ResponseCode to the caller over the binder interface.

This will allow the caller to call generateKey() on the
RemoteProvisioner AIDL interface, blocking until the call is returned.
At this point, keys will either have been provisioned, or an actionable
error can be routed back to the developer.

Bug: 227306369
Test: atest RemoteProvisionerUnitTests
Change-Id: I8f5bc5add4ab895ab95c9e4e70e6fc9fa4422da5
2022-04-04 11:20:10 -07:00
Seth Moore
66d9e908bf Add a new permission check around unique id attestation
Allow an application to either have an selinux permission or a
privileged application permission to request a unique id attestation.
Eventually, we will remove the sepolicy permission. However, until
GMSCore is updated to pick up the new permission, keep the policy
around.

Test: KeyAttestationTest
Bug: 216778747
Change-Id: I2401ca630d1599f0399b47e1fd9dd88d78318b95
2022-03-30 11:18:00 -07:00
Janis Danisevskis
005400ef16 Keystore 2.0: Add legacy blob test to TEST_MAPPINGS
Test: keystore2_legacy_blob_test
Change-Id: Ifdd50bf2d837fc9120b0f847adca18bfde2be0ff
2022-03-29 19:59:48 +00:00
Rajesh Nyamagoud
3b6427961c Adding tests to validate support for encrypted legacy blobs.
Bug: 213173772
Bug: 213172664
Bug: 203101472
Test: atest keystore2_legacy_blobs_test
Change-Id: I3c898c4447c114dd6a9481615a3366c76ad3a2bb
2022-03-29 17:48:21 +00:00
Rajesh Nyamagoud
901386c2c4 Create authorizations and key_generations test modules -
- authorizations: helper struct to create set of key authorizations
   - key_generations: helper methods to generate various keys.

Test: N/A
Change-Id: I23250838b7b6d8ad59f5ef8682861a07e856299f
2022-03-25 19:51:23 +00:00
Janis Danisevskis
5d772ef30a Keystore 2.0: Make KeyParameters serializable.
This is required to enable keystore client tests.
Test: keystore2_test

Change-Id: I6e3c81180244e45f403d8d79c86650dcd33cc21a
2022-03-24 14:34:11 -07:00
John Wu
1713e4867d Merge "Remove functionality to migrate keys across app UID" 2022-03-23 16:06:00 +00:00
Treehugger Robot
5a27d8ceac Merge "Restructred blob utilities to make them accessible in tests." 2022-03-19 00:50:48 +00:00
Treehugger Robot
13269794f6 Merge "Don't pass Tag::INCLUDE_UNIQUE_ID to attestKey" 2022-03-18 16:57:35 +00:00
Shawn Willden
bb0d0f4fea Don't pass Tag::INCLUDE_UNIQUE_ID to attestKey
Bug: 214916241
Test: Manual
Change-Id: I6237463ad9aaab76ad81ff6c438a39a703cced65
2022-03-17 10:28:17 -06:00
Rajesh Nyamagoud
69a850511b Restructred blob utilities to make them accessible in tests.
Creating a new library "libkeystore2_with_test_utils" where it includes blob utils
apis and sample test vectors based on feature flag keystore2_blob_test_utils.

Bug: 213173772
Bug: 213172664
Bug: 203101472
Test: keystore2_test
Change-Id: I869d27d1d3e8c6d28d8f5e5d6aed4305b5265816
2022-03-17 00:35:43 +00:00
Janis Danisevskis
04945eba3d Keystore2 Tests: Revisit run_as function.
This CL adds run_as_child which starts a child asynchronously and
returns a handle that allows waiting for and communicating with the
child process.

Test: keystore2_test_utils_test
Change-Id: Ibde858f249c94295b5f1c0c0cb29b8a98fb98a3a
2022-03-16 13:21:56 -07:00
John Wu
889c1ccfcf Remove functionality to migrate keys across app UID
- Remove the listEntries API in IKeystoreMaintenance
- Remove the ability to migrate keys across UIDs in the APP domain

Test: m keystore2
Bug: 220015249
Change-Id: I513e5b485b026825b9e7f8c86a1e8fb89247ab3d
2022-03-14 16:02:56 -07:00
Janis Danisevskis
c5f7b62d69 Keystore 2.0: km_compat: Fix ref counting in software keymint device.
CreateKeyMintDevice now creates a shared_ptr with correct ref counts.

Bug: 219791936
Test: atest keystore2_km_compat_test_cpp does not crash any more.
Change-Id: I3b304c0a4d55883b8f917ce0ef4c70d4bd0e9e9b
2022-03-02 11:25:10 -08:00
Charisee
a1e1c4865a Changes for the Rust 1.59.0 update
bug: 215232614
Test: TreeHugger and compiling with m rust
Change-Id: I1d25f5550f60ff1046a3a312f7bd210483bf9364
2022-02-28 21:29:32 +00:00
Matthew Maurer
f2a147a6be Merge "Send Keystore2 logs to SYSTEM rather than MAIN" 2022-02-24 18:06:01 +00:00
Treehugger Robot
4f5c70cc46 Merge "Provide alternate SE RoT provisioning path." 2022-02-23 18:13:01 +00:00
Seth Moore
79a2e42060 Merge "Add logging around export of IRemotelyProvisionedKeyPool" 2022-02-23 16:52:17 +00:00
Seth Moore
8c14710df1 Add logging around export of IRemotelyProvisionedKeyPool
If we cannot create an IRemotelyProvisionedKeyPool binder, keystore
starts up as normal. However, we were not logging _why_ the operation
failed. This change adds a bit of logging so that we can diagnose when
devices are missing the IRemotelyProvisionedKeyPool service.

Test: keystore2_test
Change-Id: I60a481dc9762d8b156c5bec9e622a7e2192d145d
2022-02-23 16:51:26 +00:00
Shawn Willden
e2fac0c976 Provide alternate SE RoT provisioning path.
On some devices it is infeasible to provision the KeyMint RoT bits in
the Android Bootloader.  This provides an alternate path to provision
them from the TEE during early boot.

Bug: 219076736
Test: VtsAidlKeyMintTargetTest
Change-Id: I8e19a1096087780f8c979f5a6b37f4100e41a975
Merged-In: I8e19a1096087780f8c979f5a6b37f4100e41a975
2022-02-22 23:50:50 -07:00
Treehugger Robot
ca744a7442 Merge changes from topic "expiration_pruning"
* changes:
  Adding additional call to delete expired keys
  Upgrade remotely provisioned keys if necessary.
2022-02-18 21:35:11 +00:00
Matthew Maurer
1f49c6e298 Send Keystore2 logs to SYSTEM rather than MAIN
Test: Boot on cuttlefish, verify log location
Bug: 215419883
Change-Id: If3cc0a5cec4db576d533c7b5d272845e3604f9d7
2022-02-17 20:33:03 +00:00
Max Bires
cd7f7417e0 Adding additional call to delete expired keys
Placing a call to delete all expired attestation keys directly in
the function responsible for retrieving them. This guarantees that any
key selected will be fresh. This also modifies
delete_expired_attestation_keys to create a time buffer so that a key
can't be milliseconds away from expiration when this call returns.

Test: atest keystore2_tests
Change-Id: I6f83eb65d02d8583d054c56ef6c572f3ee2e8e24
2022-02-16 22:12:40 -08:00
Max Bires
55620ff9a8 Upgrade remotely provisioned keys if necessary.
This change applies a key upgrade path to the RKP keys when they are
used in key generation. Without this, RKP keys will fail after a device
receives an update due to version mismatch in KeyMint.

Test: atest keystore2_test && atest RemoteProvisionerUnitTests
Change-Id: I5dddc8fa1fe7fe9d7dd559b337089d607fcc735a
2022-02-16 22:12:37 -08:00
Janis Danisevskis
779e09c9e3 Keystore 2.0: km_compat: Fix operation slot accounting.
Virtual operation slots are leaked when sofware emulation is used.
This can lead to TOO_MANY_OPERATIONS errors despite have plenty of spare
operation slots in the backend.

Also fixes not using the reserved operation slot for signing. All
signing operations during key generation are now serialized and use the
reserved operation slot.

The slot test in keystore2_km_compat_test_cpp now tests that sofware
emulated operations don't impact the virtual operation slot accounting.
It also verifies that key generation that requires an operation slot can
commence even if all virtual slots are depleted.

Bug: 219551178
Bug: 219552427
Test: atest keystore2_km_compat_test_cpp
Change-Id: I6665b06a038e4935b4c751228881d8b500a6dcd4

Slot_test

Change-Id: Ice45c9f67f0ac0aa067825c410bf3ba9257e5bee
2022-02-15 17:03:01 -08:00
Janis Danisevskis
f84d0b0520 Keystore 2.0: Teach keystore to decrypt generic blobs.
This CL addresses various gaps in legacy support.
* Encrypted legacy blobs.
* Encrypted key characteristics files (pre Android Q).
* Encrypted certificate and certificate chain entries
  (pre Android R).

To support key migration even when the corresponding user is locked,
keys can now be migrated in the legacy database by renaming files.
In order to construct a complete a key characteristics cache from old
characteristics files the information must be augmented with the
characteristics that can be extracted from the key blob by calling
KeyMintDevice::getKeyCharacteristics. For this to work, the blob
may need to be decrypted, upgraded, and reencrypted. The crypto steps
may fail with ResponseCode::LOCKED though if the user is locked.
If the key was upgraded in the process both the old and the new key
blob must be inserted into the database in order for the garbage
collector to reap and invalidate the superseded blob correctly.
At the time APPLICATION_ID and APPLICATION_DATA are usually not
available. This would cause such bound keys to fail with
ErrorCode::INVALID_KEY_BLOB. However, APPLICATION_ID/DATA were
never exposed to applications though, so this should be acceptable
for now.

Bug: 213173772
Bug: 213172664
Bug: 203101472
Test: keystore2_test
Change-Id: Id8561d3f98d53182709d9f4feeeecda3b1535077
2022-02-14 07:29:22 -08:00
David Drysdale
70bcce2dc0 Merge "Implement a back-level KeyMint compatibility wrapper" 2022-02-10 09:42:15 +00:00
Treehugger Robot
33c654fea1 Merge "Keystore 2.0: Rename legacy_migrator to importer." 2022-02-10 01:45:24 +00:00
Treehugger Robot
409283bba7 Merge "Keystore2: Fix some log messages." 2022-02-10 01:33:00 +00:00
David Drysdale
c97eb9e053 Implement a back-level KeyMint compatibility wrapper
- Implement a general back-level KeyMint wrapper, which forwards
   requests to either a back-level real device, or an up-level
   software device. Keyblobs from the latter are given a marker
   prefix and an authentication suffix.
 - Add an FFI wrapper function to allow calculation of HMAC-SHA256,
   so this can be used to give an authenticated suffix to wrapped
   keyblobs.
 - Abstract out the decision process for whether emulation is required
   to a EmulationDetector trait, and provide implementations for
   KeyMint V1 and for a km_compat-wrapped Keymaster.
 - Impose the KeyMint V1 wrapper whenever the real device is detected to
   be a V1 implementation.
 - Add support to the IKeystoreCompatService for returning a device for
   SecurityLevel::SOFTWARE. This device will always be the most recent
   KeyMint version.
 - Clarify what level of IKeyMint implementation gets returned from
   the IKeystoreCompatService for the other security levels.
 - Add an inner function to the km_compat code to allow unit tests
   to still work.

Co-authored-by: Janis Danisevskis <jdanis@google.com>
Bug: 194358913
Test: CtsKeystoreTestCases on oriole/bramble/cuttlefish
Change-Id: I297e8ad1cf00fd15cd5358b2760cd2ca88f53abb
2022-02-09 18:53:51 +00:00
Andrew Walbran
0551c46723 Update to improved system_properties API.
Bug: 217728265
Test: mm
Change-Id: I1ba1af10988f8f98318cff72488c4e600853938e
2022-02-07 12:25:55 +00:00
Janis Danisevskis
0ffb8a80bd Keystore 2.0: Rename legacy_migrator to importer.
This refactor serves the disambiguation between the import of legacy
blobs into the sqlite3 database and the migration of keys between
namespaces, which becomes more promient in the light of shared uid
migration.

Test: No new test required because no functionality was changed.
Change-Id: I0612d0731083548a196911712f6c0adbbc9a5e9a
2022-02-06 23:16:41 -08:00
Seth Moore
8099450d9e Merge changes from topic "ic-rkp"
* changes:
  Add support for RKP to credstore
  Refactor RKP key pool in keystore
2022-02-03 23:00:40 +00:00
Seth Moore
92648b6a81 Refactor RKP key pool in keystore
Split the IRemotelyProvisionedKeyPool binder implementation to its own
struct, as we cannot have two rust objects backing the same native
binder.

Test: keystore2_test
Test: keystore2_test --ignored
Bug: 194696876
Change-Id: I188bc2e2daf277f4a3543c7ec8320002d57f60ba
2022-02-02 16:17:05 -08:00
Treehugger Robot
1b1a79c68f Merge "Keystore 2.0: Sort watch dog records." 2022-02-03 00:00:31 +00:00
Janis Danisevskis
9bdc4301b6 Keystore 2.0: Sort watch dog records.
This patch makes it a little easier to interpret watch dog records, by
sorting them by the age of the youngest watch point in each thread.
The most likely  culprit will thus move to the top of the record.

Test: N/A
Change-Id: I17ef4801ed38313b85468bd14943269f881a8e2b
2022-02-02 23:59:51 +00:00
Janis Danisevskis
478a9a260d Keystore2: Fix some log messages.
Some multi line log messages were missing escape characters on their
line breaks.

Test: N/A
Change-Id: I3903b8a5ddd76d4e8ed379b3d42dc55942bbd98f
2022-02-02 10:05:57 -08:00
Andrew Scull
dba80c5445 Remove all noicu build rules
The noicu build rules were only used by microdroid which no longer has a
special variant of keystore2.

Bug: 215747811
Test: atest MicrodroidTests
Change-Id: Iefa4d22beb0074bc95e0ff20c7689ad8b62372f4
2022-01-28 18:46:02 +00:00
Andrew Scull
ec858162f2 Merge "Remove microdroid build of keystore2" 2022-01-28 13:12:53 +00:00
Treehugger Robot
9afc82a6dc Merge "-= src_available" 2022-01-27 23:45:24 +00:00
Treehugger Robot
684a9b3ba3 Merge "Keystore 2.0: Fix racy super key management." 2022-01-27 22:34:50 +00:00
Andrew Scull
214c660dad Remove microdroid build of keystore2
keystore2 has been removed from microdroid so the build variant is no
longer needed.

Bug: 215747811
Test: atest MicrodroidTests
Change-Id: I46395d04535a3084e995324445e6b52bef4d8154
2022-01-27 21:53:29 +00:00
Janis Danisevskis
0fd25a6107 Keystore 2.0: Fix racy super key management.
The super key and user state management performs concurrent lookups and
cache updates that can put keystore2 in an inconsistent state which may
lead to loss of keys. It is unlikely that this data loss was trigered,
because system server does not call keystore2 in the way required to
cause problems.

Test: keystore2_tests and CTS tests for regression testing.
Bug: 213942761
Change-Id: Ieedb4806403d3aa7175c98f2dca26532ff609cea
2022-01-27 13:05:45 -08:00
Steven Moreland
f9990f901b -= src_available
Default now. To Remove.

Bug: 215754978
Test: N/A
Change-Id: I72cfd28510da8e5794568a59b3bb248346db62ee
2022-01-25 23:46:24 +00:00
Seth Moore
682ab348ef Merge "Add new IRemotelyProvisionedKeyPool service to keystore2" 2022-01-25 13:11:35 +00:00
Seth Moore
7ee79f9f71 Add new IRemotelyProvisionedKeyPool service to keystore2
This service allows clients to request remotely provisioned attestation
keys. These blobs are only usable by applications that have the ability
to pass them to a keymint implementation for use as keys.

This API is intended as a short-term solution in Android T to enable
remote key provisioning for identity credential keys. In Android U,
the underlying service will be updated to be more flexible allowing for
IRemotelyProvisionedComponent to be implemented by things other than
keymint.

Test: keystore2_test
Test: RemoteProvisionerUnitTests
Test: VtsHalRemotelyProvisionedComponentTargetTest
Bug: 194696876
Change-Id: I5ddb1bd087b606ccea88ccf170b99d5bc1b4501d
2022-01-24 15:11:21 -08:00
Yi Kong
32701414b6 Turn on AFDO for keystore2
Enable PGO (profile guided optimisation) for better performance.

Bug: 195134194
Bug: 165018530
Test: presubmit
Change-Id: I35128221a8022095d6ef6dcef8f3baffa7b9439e
2022-01-22 02:53:12 +08:00
Treehugger Robot
ccdc21845d Merge "Revert^2 "[keystore2] Fix binder import path"" 2022-01-20 20:41:30 +00:00
Treehugger Robot
2d768e4caa Merge "Keystore 2.0: Add error string to service specific exceptions." 2022-01-20 20:29:44 +00:00
Janis Danisevskis
ea03cff987 Keystore 2.0: Add error string to service specific exceptions.
This patch adds detailed error messages to the service specific
exceptions. The error messages are formated anyhow::Errors, the same
that already get logged to logcat. Returning them to the client, allows
them to be included in java stack traces which will lead to easier
diagnosis of bugreports.

Test: N/A
Bug: 197890905
Change-Id: Ie6178292650327a1382b04f478ed5fa9e5fd7feb
2022-01-20 08:28:39 -08:00
Stephen Crane
23cf724a98 Revert^2 "[keystore2] Fix binder import path"
Import from the binder crate root instead of binder::public_api for
compatibility with the new crate structure.

Original change: Ia9695e5493bda965ca9a42989ec5a284407595ce

Test: m
Bug: 196056781

Change-Id: Ie6303a36a956cf73f317520a0e0a00ec4adbb47e
2022-01-19 09:59:17 -08:00
Treehugger Robot
23504a190e Merge "Revert "[keystore2] Fix binder import path"" 2022-01-19 02:43:02 +00:00
John Wu
f4ee093d8d Merge "keystore2 support for app UID migration" 2022-01-19 00:05:29 +00:00
Stephen Crane
a723ee2277 Revert "[keystore2] Fix binder import path"
Revert "Update Rust binder import paths"

Revert "[binder_common] Update binder import path"

Revert "[binder] Expose public Rust API at crate top level"

Revert "[libprofcollectd] Fix binder import path"

Revert submission 1797473-binder_rs-public_api

Reason for revert: Build breakage
Reverted Changes:
Ia37ec9d1e:[binder_common] Update binder import path
Ie6b4a40d7:Update Rust binder import paths
Ia9695e549:[keystore2] Fix binder import path
I811426fa7:[binder] Expose public Rust API at crate top level...
I773767a3a:[libprofcollectd] Fix binder import path

Change-Id: I7f371c61749e17c54cc83689dc8a9793286adc4c
2022-01-19 00:05:11 +00:00
Stephen Crane
eb3bd5dfb9 [keystore2] Fix binder import path
Import from the binder crate root instead of binder::public_api for
compatibility with the new crate structure.

Test: m
Bug: 196056781
Change-Id: Ia9695e5493bda965ca9a42989ec5a284407595ce
2022-01-14 09:32:21 -08:00
John Wu
16db29efdc keystore2 support for app UID migration
- Update migrate_key_namespace to accept specific UIDs for APP domain
  source and destination key descriptors
- Add new API to maintenance service to query a list of aliases for
  specified app UIDs

Test: atest SharedUserMigrationTest#testDataMigration (in internal)
Bug: 211665859
Change-Id: Ica06a8cd7c3f7b85f58d5953a22231cf7e9a1d7f
2022-01-13 15:21:43 -08:00
Treehugger Robot
d966d9e596 Merge changes Ib47e92cc,I2d218f04,If2bca458
* changes:
  Diced: Add tests for open dice rust bindings.
  Diced: Implement HAL proxy node and initialize it in diced_main.
  Diced: Add vendor library for DICE HAL implementations.
2022-01-07 22:15:17 +00:00
Janis Danisevskis
aaba4afe50 Diced: Add vendor library for DICE HAL implementations.
Bug: 198197213
Test: atest diced_vendor_test
Change-Id: If2bca4584206dc26a49ffd2fea71d7192d2678bf
2022-01-07 12:43:54 -08:00
Janis Danisevskis
11bd259e4d Keystore2: Delete all super keys.
When a user was deleted, only the per boot key was deleted, but not the
lock screen bound wrapping keys. This patch makes sure that all user
specific super keys are deleted.

Added test for the behavior of unbind_keys_for_user with respect to
super keys.

Bug: 195924790
Test: keystore2_test

Merged-In: I3741450ddf971a6b4ee184fbc946cf127e1c39f8
Change-Id: I3741450ddf971a6b4ee184fbc946cf127e1c39f8
2022-01-06 15:36:43 -08:00
Treehugger Robot
26807da820 Merge "Keystore 2.0: Add CREATION_DATETIME only for Keymint V1 and higher." 2021-12-20 23:52:02 +00:00
Janis Danisevskis
2b3c723712 Keystore 2.0: Add CREATION_DATETIME only for Keymint V1 and higher.
Adding CREATION_DATETIME unconditionally should be accepted by all
keymaster implementations. Alas, VTS tests never covered this before
Keymint V1 and so there are implementations that fail when the caller
presents the tag.

Test: CtsKeystoreTestCases for regression testing.
Bug: 210792876
Bug: 204578637
Change-Id: I3cf7e8def7a369839844ef1b3628f477d8fe6b53
2021-12-20 13:22:14 -08:00
David Drysdale
3401caf030 Merge "keystore2: cope with KeyMint AIDL V2" 2021-12-16 09:37:15 +00:00
Treehugger Robot
365184b3be Merge "Revert "Revert "Keystore 2.0: Add CREATE_DATETIME unconditionally.""" 2021-12-14 22:31:34 +00:00
Janis Danisevskis
d43c1b9db3 Revert "Revert "Keystore 2.0: Add CREATE_DATETIME unconditionally.""
This reverts commit 5b8f198fb7.

Reason for revert: Relevant vendor implementations have been fixed.

Test: CtsKeystoreTestCases ran successfully against relevant devices.
Bug: 204578637
Change-Id: I2cadd017b66f8930fd0eb26ff8f58d52cac15fd4
2021-12-14 22:29:15 +00:00
Xin Li
8c852b7d13 Merge "Merge Android 12 QPR1" 2021-12-14 20:26:07 +00:00
Hasini Gunasinghe
122786359f Merge "Set expired_by to be three days from now, when querying rkp_pool_state." 2021-12-14 18:54:34 +00:00
Hasini Gunasinghe
48e38459d4 Set expired_by to be three days from now, when querying rkp_pool_state.
When collecting metrics about RKP pool status, we currently query
the remote_provisioning module by setting expired_by = now.
But inside remote_provisioning module, all expired keys by now are
deleted before returning the pool status.
Therefore, in the metrics, we do not see the number of expiring keys
since it is always zero.

Test: statsd TestDrive script
Bug: 210162269
Ignore-AOSP-First: This will be merged to AOSP manually.
Change-Id: I7f7026b1297f297ce208b828b647f1056485128e
2021-12-14 00:59:03 +00:00
Seth Moore
49d700d521 Revert^2 "keystore2: cope with new curve25519 enum"
6c44cad429

Change-Id: Ib0c57111991221d6117cf2e5e2e9af0a13ce167e
2021-12-13 20:03:33 +00:00
Seth Moore
0400d70cec Revert^2 "Bump keystore2 AIDL API version 1->2"
6b96760c1b

Change-Id: I93fb064c0e8cd5a92b440daca0f417663fb3ed9e
2021-12-13 20:03:33 +00:00
David Drysdale
05d8d4c684 Merge changes from topic "revert-1900930-version-bump-TMGXYBHYHZ" am: 145169ac1e
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1918631

Change-Id: I20a17a23ad4911b6d76e2782c4f394890997d32e
2021-12-13 16:31:05 +00:00
David Drysdale
972ae41f5a Revert "keystore2: cope with new curve25519 enum" am: 6c44cad429
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1918630

Change-Id: I78fc8306494a581f803c1e5fe168887bd4fb0427
2021-12-13 16:31:04 +00:00
David Drysdale
6b96760c1b Revert "Bump keystore2 AIDL API version 1->2"
Revert "Advertise support of KeyMint V2"

Revert submission 1900930-version-bump

Reason for revert: Broken build on sc-qpr1-dev-plus-aosp, b/210450339
Reverted Changes:
I42a9b854f:keystore2: cope with new curve25519 enum
I167d568d6:Bump keystore2 AIDL API version 1->2
I3a16d072e:Advertise support of KeyMint V2
Ibf2325329:KeyMint HAL: add curve 25519, bump version

Change-Id: Ifc713bfb2753677e933f572d385f26cea11a3ef2
2021-12-13 16:01:21 +00:00
David Drysdale
6c44cad429 Revert "keystore2: cope with new curve25519 enum"
Revert "Advertise support of KeyMint V2"

Revert submission 1900930-version-bump

Reason for revert: Broken build on sc-qpr1-dev-plus-aosp, b/210450339
Reverted Changes:
I42a9b854f:keystore2: cope with new curve25519 enum
I167d568d6:Bump keystore2 AIDL API version 1->2
I3a16d072e:Advertise support of KeyMint V2
Ibf2325329:KeyMint HAL: add curve 25519, bump version

Change-Id: I7db3a5941e86d4e85b1e74a595137c798079f646
2021-12-13 16:01:21 +00:00
David Drysdale
25af2e5515 Merge changes from topic "version-bump" am: 469c99c285
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1907813

Change-Id: Id8416443712f3ea9963117bb680833bb34b30de8
2021-12-13 14:48:31 +00:00
David Drysdale
a6c82a916c keystore2: cope with KeyMint AIDL V2
Bug: 194358913
Test: TreeHugger
Change-Id: Ibc2d96f2cd4fd2edde4c69cf862580412af08dd7
2021-12-13 14:36:32 +00:00
David Drysdale
e36d8b7e8f keystore2: cope with new curve25519 enum
This does not yet add proper support for curve 25519, but just fills
out the places where the new enum value needs to go.

Bug: 194358913
Test: TreeHugger
Change-Id: I42a9b854ff6d3e599dbbdacf89bd140429f9f8ad
2021-12-09 18:27:27 +00:00
David Drysdale
76d52656de Bump keystore2 AIDL API version 1->2
The keystore2 AIDL definitions include types from KeyMint, so a bump in
the keymint version necessitates a bump in the keystore2 version.

Test: TreeHugger
Change-Id: I167d568d64fae5a615d1c38e32416e32348c203d
2021-12-09 17:56:49 +00:00
David Drysdale
534f73091c Merge "Use defaults to reference current keystore AIDL" am: b7d67b606c
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1906462

Change-Id: I5ce7c08e11b64da49f76e391a723e88bfda17278
2021-12-07 06:55:40 +00:00
David Drysdale
7c1df5b879 Merge "Depend on KeyMint HAL via default" am: f911d694b0
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1904134

Change-Id: I12b64ca78655288bd629102e6a161c62965d271a
2021-12-07 06:55:07 +00:00
David Drysdale
c4e0d5bed1 Use defaults to reference current keystore AIDL
The KeyMint HAL will soon be updated for a new version, which will in
turn induce a version bump for the keystore2 AIDL interface. To make
this process easier, add cc_defaults that references the "current"
version, and use this elsewhere. This should hopefully mean that a
future version bump only needs to happen in the defaults.

Test: TreeHugger
Change-Id: I8999de92443fd121a9515dccde8d76094dc93023
2021-12-02 08:19:40 +00:00
David Drysdale
bdb232db7f Depend on KeyMint HAL via default
This allows for easier bumping of the KeyMint version level.

At the moment this change should have no effect: the same dependency
is used, just reached via a default rather than explicitly.

However, when the KeyMint version increases in the near future, using
this default should mean that no change is needed here: the default
definition will change to -V2 and this will be referenced here.

Test: TreeHugger
Change-Id: I8cce78e7f56179db23b2de792764ea2cae2d3cb7
2021-12-02 08:19:33 +00:00
Treehugger Robot
1da3b66a03 Merge "Fix logic for token searching on authorize_create" am: 4f279211bf
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1905376

Change-Id: I26ad60d42440048f264c1b711f61bf03cc48c94c
2021-11-29 22:09:15 +00:00
Seth Moore
653eca5956 Fix logic for token searching on authorize_create
We only need to check that a token with a given auth type exists if
a key has a timeout bound policy. In that case, we should match that
a given token may be found with the configured authorization type.

However, if a key's parameters indicate unlocked device is required,
then any token will do. We don't care about the auth type. If the key
parameters require per-operation authentication, then the type of
authentication will be checked later, after a fresh authentication.

Test: CtsVerifier - Unloced Device Required
Test: CstKeystoreTestCases
Bug: 206762528
Change-Id: Icdffc42084854b298e8798d99312e9f829aee753
2021-11-29 12:51:19 -08:00
Matthew Maurer
33ce5f1c34 Merge "keystore2: Remove explicit dep on C DSOs" am: 03ed04fcfb
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1901124

Change-Id: Id6e71d1913b2aff2d13c7adcfb1baeb9e6c3382c
2021-11-24 21:08:51 +00:00
Matthew Maurer
03ed04fcfb Merge "keystore2: Remove explicit dep on C DSOs" 2021-11-24 20:49:11 +00:00
Max Bires
86d074b119 Merge "Replacing manual CBOR with serde-cbor" am: 8c970eba1e
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1895479

Change-Id: Ie5add3e419464be1df88dc5f9504410442a2a257
2021-11-24 17:18:15 +00:00
Max Bires
8c970eba1e Merge "Replacing manual CBOR with serde-cbor" 2021-11-24 16:59:28 +00:00
Matthew Maurer
ff1c412d48 keystore2: Remove explicit dep on C DSOs
This was previously added as a hack to work around a build system bug in
which rlib dependencies would not result in their corresponding C DSOs
being installed on the device. Now that it is fixed, we can remove this.

Bug: 187412695
Test: m installclean && m; boot AVD
Change-Id: I61f14d7a60e80034d24f0e6e4c3a8e2ea8831c96
2021-11-24 16:39:56 +00:00
Max Bires
48fc2e5a43 Replacing manual CBOR with serde-cbor
This change strips out all of the manually written CBOR parsing and
serialization code in favor of using the serde-cbor library in order to
make the code more robust and the error messages more actionable.

Fixes: 180392379
Test: atest RemoteProvisionerUnitTests
Change-Id: I1b08b26b6192763e393b061cd9b919cfd71c13c9
2021-11-22 10:46:14 -08:00
Xin Li
76bdcd2b67 Merge "Merge sc-qpr1-dev-plus-aosp-without-vendor@7810918" into stage-aosp-master 2021-11-18 21:29:05 +00:00
Ashwini Oruganti
d92cdf626b Merge "Define the MigrateAnyKey permission" 2021-11-17 17:55:13 +00:00
Ashwini Oruganti
daf73bcdaa Define the MigrateAnyKey permission
corresponding to the selinux perm `migrate_any_key`. Checked when
migrating keys for an app leaving a sharedUserId.

Bug: 179284822
Test: TH
Change-Id: I831af2f99049401855dcf4b7d23555a3473e37c6
2021-11-16 10:54:38 -08:00
Xin Li
a4f6973e38 Merge sc-qpr1-dev-plus-aosp-without-vendor@7810918
Bug: 205056467
Merged-In: Id74fb67e9adb1e75967001a67d1833d72a85bc54
Change-Id: I73d643f82a8a259625b0b33b330b4da9dcfc06ff
2021-11-10 08:06:26 +00:00
Janis Danisevskis
67b56c10e6 Keystore 2.0: Add Keystore CTS test cases to presubmit.
Run a subset of the Keystore CTS test cases on presubmit when keystore2
gets changed. Also Run the full CTS test suite as post submit.

Bug: 204906931
Test: Improves test coverage during presubmit.
Change-Id: I9b14734e4d838881e7dabf698b3df826a0ed433b
2021-11-02 13:11:05 -07:00
Treehugger Robot
2843067c5f Merge "Revert "Keystore 2.0: Add CREATE_DATETIME unconditionally."" 2021-11-02 19:19:35 +00:00
chapin
5b8f198fb7 Revert "Keystore 2.0: Add CREATE_DATETIME unconditionally."
This reverts commit 5aca5d6947.

Reason for revert: Bug: 204841659

Change-Id: I391f540e117d85146d52f984dee4127b70e544c2
2021-11-02 17:34:45 +00:00
Janis Danisevskis
46e97c8967 Keystore 2.0 Crypto: Add try_clone to ZVec.
Add the function try_clone to ZVec. Cloning may fail because mlock may
fail during the allocation of a new memory region.

Test: N/A
Change-Id: I1dc3f098d8c02d3bf9116ab86527eca6793d0bfe
2021-11-01 10:37:08 -07:00
Janis Danisevskis
a16ddf36fb Keystore 2.0 Crypto: export zvec module and provide a ZVec Error.
ZVec now has its own error rather then using the crypto library error.
This makes it easier to move ZVec out of the crypto library in the
future.

Test: N/A
Change-Id: I4788cbbc48281e30729142fb08f5cb94b2d243c2
2021-11-01 10:37:08 -07:00
Janis Danisevskis
5aca5d6947 Keystore 2.0: Add CREATE_DATETIME unconditionally.
Add CREATE_DATETIME unconditionally on generation and import.

Test: TBD
Bug: 204502660

Change-Id: I5b6eb8647d2595e575c72476010ccabf0a1a4527
2021-10-29 15:04:47 +00:00
Joel Galenson
af56d768a4 Merge "Remove custom test_config." 2021-10-27 18:11:41 +00:00
Joel Galenson
1edfbea355 Remove custom test_config.
Test: atest keystore2_test_utils_test
Change-Id: Ic88fcc5fa0eea0e8b5b03160a76d8e64fe699f06
2021-10-26 13:41:07 -07:00
Suren Baghdasaryan
3f4d774b8b Replace writepid with task_profiles command for cgroup migration
writepid command usage to join a cgroup has been deprecated in favor
of a more flexible approach using task_profiles. This way cgroup path
is not hardcoded and cgroup changes can be easily made. Replace
writepid with task_profiles command to migrate between cgroups.

Bug: 191283136
Test: build and boot
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ia136fd51d7fd39a0e1988ae3ae1aeb80ab5f3cc5
2021-10-22 00:33:43 +00:00
Treehugger Robot
22670069bf Merge changes Ib339bd0a,I4ff3ff91,I6863269e,I85d24118,Ic7ce23e2
* changes:
  Keystore 2.0: Refactor permissions. 5/5
  Keystore 2.0: Refactor permissions. 4/5
  Keystore 2.0: Refactor permissions. 3/5
  Keystore 2.0: Refactor permissions. 2/5
  Keystore 2.0: Refactor permissions. 1/5
2021-10-21 16:58:44 +00:00
Janis Danisevskis
39d57e77f8 Keystore 2.0: Refactor permissions. 5/5
Now that the implement_class! macro is generic enough, it can replace
implement_permissions_aidl! with minor tweak to the rest of the code.

Test: keystore2_test
Bug: 203555519
Change-Id: Ib339bd0ac0acc27169b9303f50999d552a1aa632
2021-10-21 08:39:57 -07:00
Janis Danisevskis
a916d9998f Keystore 2.0: Refactor permissions. 4/5
Remove obsolete constructor functions for permissions.

Test: keystore2_test
Bug: 203555519
Change-Id: I4ff3ff91d8a5dcca99db02ddbd5894c91c405389
2021-10-21 08:39:57 -07:00
Janis Danisevskis
56af03141f Keystore 2.0: Refactor permissions. 3/5
* Add trait ClassPermission and fn check_permission. This binds
  together permission names and their class name.
* Rename implement_permission! to implement_class!.
* Add #[selinux(class_name = <name>)] stanza to the syntax of
  implement_class!.

Test: keystore2_test for regressions.
Bug: 203555519

This reverts commit b8fd77fba016c4c908d371d546a5d86aff4a78d7.

Change-Id: I6863269ea4af5a6d0b36cf17e0238c81bc713d48
2021-10-21 08:39:57 -07:00
Janis Danisevskis
a2f4850e6f Keystore 2.0: Refactor permissions. 2/5
Move implement_permission macro to libkeystore2_selinux.

Test: keystore2_test
Bug: 203555519

Change-Id: I85d2411872aecaaa12876f848e9205431a8b0fa4
2021-10-21 08:14:33 -07:00
Janis Danisevskis
751d2c8e78 Keystore 2.0: Refactor permissions. 1/5
Change the input syntax of implement_permission! to something more
rust-like.

Test: keystore2_test
Bug: 203555519

Change-Id: Ic7ce23e2fecb8351b5c8c2835c7baab1d73f2616
2021-10-21 08:14:21 -07:00
Treehugger Robot
ac2be62e1c Merge "Add keystore2_microdroid" 2021-10-13 02:25:04 +00:00
Janis Danisevskis
aa0392dd14 Keystore 2.0 km_compat: Buffer incomplete updates. am: b7f303146f
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/security/+/15942712

Change-Id: I53fc86cfedf52cf0ae5ff166f8cd29f06008ff24
2021-10-06 19:48:15 +00:00
Janis Danisevskis
b7f303146f Keystore 2.0 km_compat: Buffer incomplete updates.
Older KM implementations do not consume data if in certain block modes
when too little data is presented. However, km_compat update assumes
that the backend always consumes some data. If this assumption does not
hold it can get stuck in an infinite loop.

This patch adds some buffering, allowing the km_compat to buffer
unconsumed data and make it appear to the caller that the data was
indeed consumed.

Ignore-AOSP-First: b/200041882 ASA review.

Bug: 200041882
Test: CtsKeystoreTestCases for regression testing
      keystore2_km_compat_test
Merged-In: Icae44c6bc97507f192ec44c944c3bc0a9dd60ba7
Change-Id: Icae44c6bc97507f192ec44c944c3bc0a9dd60ba7
2021-10-04 16:21:49 -07:00
Jiyong Park
975906d2c7 Add keystore2_microdroid
Instead of changing keystore2 to use libsqlite_noicu, create another
variant of keystore2 (keystore2-microdroid) which uses libsqlite_noicu,
and use it only for microdroid.

Although keystore2 doesn't actually depend on the ICU extension, doing
it for Android caused a small regression (6ms) to the boot time because
keystore2 should spend time for loading the new library
libsqlite_noicu instead of sharing text pages from libsqlite.so which
were already preloaded by zygote.

With this change, keystore2 for Android goes back to use libsqlite.so.
The use of the noicu variant is limited to Microdroid.

Bug: 201344281
Test: measure SystemServerTiming_StartLockSettingsService-total
Change-Id: I6ff123415cdc3e7494a7857864e04525322bc079
2021-10-04 22:40:53 +09:00
Janis Danisevskis
600321ad19 Revert "Keystore 2.0 km_compat: Cuttlefish does not return a vendor patch level."
This reverts commit bcb469a754.

Reason for revert: Cuttlefish's KM implementation was fixed.

Change-Id: Id16433fee1994594344f0c33d6d627bfbd144dc9
2021-09-30 16:15:25 +00:00
Janis Danisevskis
6c0cfc725c Merge "Keystore 2.0 km_compat: Cuttlefish does not return a vendor patch level." am: d644edaa37
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1836782

Change-Id: I64c7aa95b12d5ce3a2c7b4149fe5ec98fbac04e7
2021-09-27 15:19:50 +00:00
Janis Danisevskis
d644edaa37 Merge "Keystore 2.0 km_compat: Cuttlefish does not return a vendor patch level." 2021-09-27 15:05:23 +00:00
Treehugger Robot
c3b77eb41e Merge "Use sqlite with no ICU support" am: d467631919
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1824538

Change-Id: Ib38d534a132f3ee69c6c26f4c52f1ccb8133f44f
2021-09-27 02:08:26 +00:00
Treehugger Robot
d467631919 Merge "Use sqlite with no ICU support" 2021-09-27 01:53:16 +00:00
Janis Danisevskis
bcb469a754 Keystore 2.0 km_compat: Cuttlefish does not return a vendor patch level.
Stop testing for a vendor patch level in km_compat get key
characteristics test.

Bug: 189973657
Test: atest keystore2_km_compat_test
Change-Id: Id811d8fdc26fdf09e5f0ae454be7c146a7c57563
2021-09-25 08:48:02 -07:00
Treehugger Robot
e29bae2d27 Merge "Keystore 2.0: Add run_as to keystore2_test_utils" am: 70d0dd4911
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1831262

Change-Id: I7aa140cd71850c631ef1a933d145917e770f3e49
2021-09-21 22:02:35 +00:00
Janis Danisevskis
a578d3998f Keystore 2.0: Add run_as to keystore2_test_utils
The run_as function allows a test with sufficient privileges to run a
closure as different identity given by a tuple of UID, GID, and SELinux
context. This is infrastructure in preparation for the keystore2 vts
test.

Test: keystore2_test_utils_test
Bug: 182508302
Change-Id: Ic1923028e5bc4ca4b1112e34669d52687450fd14
2021-09-21 13:29:39 -07:00
Hasini Gunasinghe
140ebbc735 Merge "Fix the error message for auth token not found." am: ad0030c0a8
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1826514

Change-Id: Ie582995634c426087a2760f93c80e5c351225de1
2021-09-14 18:23:56 +00:00
Hasini Gunasinghe
ad0030c0a8 Merge "Fix the error message for auth token not found." 2021-09-14 18:09:43 +00:00
Treehugger Robot
97f18af050 Merge "Enable sqlite3 logging in keystore2" am: 0b512f0892
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1798335

Change-Id: I7397ed881d79f14cf82da8ddc13c4e6f9b39de4d
2021-09-14 16:44:14 +00:00
Treehugger Robot
0b512f0892 Merge "Enable sqlite3 logging in keystore2" 2021-09-14 16:27:41 +00:00
Hasini Gunasinghe
1ce7293eba Fix the error message for auth token not found.
This CL fixes the error message returned when an auth token is not
found for IC.

Bug: 198731997
Test: N/A

Change-Id: I4512c89f7793f2c50a61d221abe20bdfa5e87102
2021-09-14 15:52:15 +00:00
Jiyong Park
bdb6ea2e7d Use sqlite with no ICU support
keystore has used libsqlite which was built with the ICU extension [1].
The extension brings huge (> 60MB) dependency to the i18n APEX which is
too big for microdroid. Since the use of sqlite in keystore doesn't
seem to require operations like upper/lower, sorting, and regex for all
unicode strings, drop the dependency to the i18n APEX.

[1] https://www.sqlite.org/src/file?name=ext/icu/README.txt

Bug: 199674764
Test: m
Change-Id: I1e7a83283c3e79e69793a2076c97bc1bf6b9e0bf
2021-09-13 17:21:10 +09:00
Joel Galenson
3310858985 Merge "Replace keystore2_vintf's bindgen with cxx" am: 725dc606f6
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1824232

Change-Id: I3d012c00f828edf9fdee3ac850f64e9a5b743f57
2021-09-10 19:39:07 +00:00
Joel Galenson
ec7872aaf6 Replace keystore2_vintf's bindgen with cxx
This simplifies things by removing code and unsafe blocks.

Test: Boot
Test: keystore2_vintf_test
Change-Id: I5858a2a25e0ee27e42ee9846d44762da2454f706
2021-09-10 11:05:21 -07:00
Treehugger Robot
aba7edf29b Merge "android.security.*: use versions for imports (2)" 2021-09-08 14:37:57 +00:00
Treehugger Robot
358a1ecade Merge "Only fuzz if data is not empty string" am: 60298b2fac
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1812551

Change-Id: I51e5eebfed98cd12980d1bccf046f74d390322b2
2021-09-03 23:59:13 +00:00
Treehugger Robot
60298b2fac Merge "Only fuzz if data is not empty string" 2021-09-03 23:39:32 +00:00
hamzeh
bf5087184e Only fuzz if data is not empty string
Bug: b/196243054
Test: m legacy_blob_fuzzer
Change-Id: I02c2686e49df73e1a2aa4fbc95bd055fa35581ed
2021-09-03 22:03:54 +00:00
Seth Moore
e3fd587d1b Enable sqlite3 logging in keystore2
Add a trace callback and forward all log messages to the keystore2 logs
so that we catch any sqlite errors.

Test: keystore2_test, legacykeystore_test
Change-Id: I655a78153bc855678b9012b75dc522611e1ff671
2021-09-03 13:12:02 -07:00
Steven Moreland
e9daaa9dc7 android.security.*: use versions for imports (2)
This makes sure that when developers add a new version of an interface,
or when interfaces are being frozen, the runtime/buildtime situation of
clients depending on those interfaces remains the same. This is required
for AIDL to continue working at scale.

Bug: 188871598
Test: build
Change-Id: I8c6c0e279ef56b7ae06d5621a772e7abc8163a59
2021-08-31 18:23:25 -07:00
Steven Moreland
5336020be3 Merge "android.security.*: use versions for imports" 2021-08-31 16:47:14 +00:00
David Drysdale
d42054bcb9 Merge "keystore2: increase unit test timeout" am: 58fe4fe69e
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1810661

Change-Id: I42f1542791d9d261243d67f7318d06bf98e2cfef
2021-08-31 06:44:06 +00:00
Steven Moreland
538558e2a9 android.security.*: use versions for imports
This makes sure that when developers add a new version of an interface,
or when interfaces are being frozen, the runtime/buildtime situation of
clients depending on those interfaces remains the same. This is required
for AIDL to continue working at scale.

Bug: 188871598
Test: build
Change-Id: I98cf349e8501570b5bf3aed298082d0e9b9dad7e
2021-08-30 17:48:57 -07:00
David Drysdale
b9c1367a10 keystore2: increase unit test timeout
Waiting just 1ms for a callback on a different thread to be executed
is a bit swift; try 50ms instead.

Bug: 197762120
Test: keystore2_test
Change-Id: I27399b9687e21bae86a59f288c99449ca9858d6c
2021-08-27 16:28:26 +01:00
Joel Galenson
2fe1597d9f Merge "Add bindgen bindings test" am: f3d05f354e
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1806557

Change-Id: I67d93ddfaba4f456da28cc7b378b43c1da8ff1d9
2021-08-24 13:19:35 +00:00
Joel Galenson
733d1d0a8b Add bindgen bindings test
Note that some of these are currently no-op tests that do nothing.
But this makes them future proof in case we add more later.

Test: atest
Change-Id: I22914e36568d5808ab60541354e5585a1aeebd44
2021-08-23 13:47:37 -07:00
Hasini Gunasinghe
8a1a224229 Log metrics for RKP fallback event.
This CL adds metrics logging for fallback during RKP hybrid mode.

Test: atest com.android.remoteprovisioner.unittest.ServerToSystemTest#testFallback
on cuttlefish, followed by ./statsd_testdrive 10124
Bug: 194510784
Change-Id: I3d6184df02828fef1d0110688afe1ba2db10eae9
(cherry picked from commit 400b225c94)
2021-08-19 21:19:11 +00:00
Paul Crowley
93b6f681e5 Revert^2 "Add deleteAllKeys to IKeystoreMaintenance"
Revert submission 15536724-revert-15521094-vold-deleteAllKeys-GDJSMLXRVZ

Reason for revert: Underlying KM problem fixed
Reverted Changes:
I8e2621bef:Revert "Detect factory reset and deleteAllKeys"
I546b980bb:Revert "Add deleteAllKeys to IKeystoreMaintenance"...
I1ed68dd9e:Revert "Allow vold to deleteAllKeys in Keystore"

Bug: 187105270
Test: booted Cuttlefish twice
Merged-In: 46c703e6a6
Change-Id: Ib9fcf54fdc611de42a7d40b9319577e2708e226f
2021-08-13 01:43:56 +00:00
Shawn Willden
5ba41aa836 Revert "Add deleteAllKeys to IKeystoreMaintenance"
Revert "Enable deleteAllKeys from vold"

Revert "Allow vold to deleteAllKeys in Keystore"

Revert submission 15521094-vold-deleteAllKeys

Reason for revert: Causes infinite loop in Trusty KeyMint
Reverted Changes:
I9c5c54714:Detect factory reset and deleteAllKeys
I2fb0e94db:Allow vold to deleteAllKeys in Keystore
Id23f25c69:Add deleteAllKeys to IKeystoreMaintenance
Ife779307d:Enable deleteAllKeys from vold
I4312b9a11:Enable deleteAllKeys from vold

Bug: 187105270
Change-Id: I546b980bb49b064a8cbf127659f2a58748082c65
2021-08-12 01:07:25 +00:00
Paul Crowley
38cf3b17c5 Merge "Add deleteAllKeys to IKeystoreMaintenance" am: 9c52ffde95 am: 1697dd58fb
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1789628

Change-Id: Ifafeb9c94f8469064975e77894a8ba2257237ad8
2021-08-11 18:13:25 +00:00
Paul Crowley
be7cc653e6 Add deleteAllKeys to IKeystoreMaintenance
Add a method to IKeystoreMaintenance which calls deleteAllKeys on every
KM instance. This method will be called by vold when it detects a
factory reset.

Bug: 187105270
Test: booted Cuttlefish twice
Ignore-AOSP-First: no merge path to this branch from AOSP.
Merged-In: Id23f25c69a74a99bfebbf28429651d6fd647dbcd
Change-Id: Id23f25c69a74a99bfebbf28429651d6fd647dbcd
2021-08-11 10:16:42 -07:00
Paul Crowley
46c703e6a6 Add deleteAllKeys to IKeystoreMaintenance
Add a method to IKeystoreMaintenance which calls deleteAllKeys on every
KM instance. This method will be called by vold when it detects a
factory reset.

Bug: 187105270
Test: booted Cuttlefish twice
Change-Id: Id23f25c69a74a99bfebbf28429651d6fd647dbcd
2021-08-10 21:47:05 -07:00
Hasini Gunasinghe
f755af71c3 Log metrics for RKP fallback event.
This CL adds metrics logging for fallback during RKP hybrid mode.

Ignore-AOSP-First: No merge path from AOSP.
Test: atest com.android.remoteprovisioner.unittest.ServerToSystemTest#testFallback
on cuttlefish, followed by ./statsd_testdrive 10124
Bug: 194510784
Change-Id: I3d6184df02828fef1d0110688afe1ba2db10eae9
(cherry picked from commit 400b225c94)
2021-08-05 22:56:19 +00:00
Hasini Gunasinghe
ac057d3a99 Log metrics for RKP fallback event.
This CL adds metrics logging for fallback during RKP hybrid mode.

Ignore-AOSP-First: No merge path from AOSP.
Test: atest com.android.remoteprovisioner.unittest.ServerToSystemTest#testFallback
on cuttlefish, followed by ./statsd_testdrive 10124
Bug: 194510784
Merged-In: I3d6184df02828fef1d0110688afe1ba2db10eae9

Change-Id: I3d6184df02828fef1d0110688afe1ba2db10eae9
2021-08-05 20:04:01 +00:00
Joel Galenson
70b5b36981 Merge changes from topics "librustutils-cutils", "librustutils-properties" am: b7964f5b70 am: 8da8e7efed
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1782329

Change-Id: I2debca3a66cc3caa1634495152fb5c53d0f074f4
2021-08-03 14:49:42 +00:00
Joel Galenson
a435d73b12 Migrate to the librustutils system property bindings. am: 7ead3a249f am: 626ca58781
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1782328

Change-Id: Ia77ba57e0a7fe4a8828e183ed4b899e80e87a59e
2021-08-03 14:49:39 +00:00
Joel Galenson
626ca58781 Migrate to the librustutils system property bindings. am: 7ead3a249f
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1782328

Change-Id: I393bf3d75f3a5d865d4d88aa73dabab85f6bcd7a
2021-08-03 14:32:48 +00:00
Joel Galenson
b7964f5b70 Merge changes from topics "librustutils-cutils", "librustutils-properties"
* changes:
  Migrate to the librustutils cutils bindings.
  Migrate to the librustutils system property bindings.
2021-08-03 14:20:06 +00:00
Jiyong Park
1e9141c568 Merge "Remove ndk_platform backend. Use the ndk backend." am: 2624b3c19b am: 84a431d23b
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1779388

Change-Id: I165be325a3fe99b815bffbcbec4ff059ec456643
2021-08-03 12:10:47 +00:00
Jiyong Park
2624b3c19b Merge "Remove ndk_platform backend. Use the ndk backend." 2021-08-03 11:18:25 +00:00
Joel Galenson
81a50f2d93 Migrate to the librustutils cutils bindings.
Bug: 182498247
Test: Build
Change-Id: I0ab7fb092574c74b09c1b5b60e82ff776a214d53
2021-07-29 15:39:10 -07:00
Joel Galenson
7ead3a249f Migrate to the librustutils system property bindings.
Bug: 182498247
Test: Build
Change-Id: Ic16033d7f5e302a3cb7e591a0fa2ae403755fc2e
2021-07-29 15:27:34 -07:00
Treehugger Robot
f6eeafed60 Merge "Fix warnings in preparation for Rust 1.54.0" am: 8125bace85 am: d120d41334
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1780388

Change-Id: I22c41f623581fe49c9db8e8a0c75bfc04146ed90
2021-07-29 18:48:55 +00:00
Chris Wailes
d5aaaef8df Fix warnings in preparation for Rust 1.54.0
This CL fixes several new warnings generated by rustc 1.54.0.

Bug: 194812675
Test: m rust
Change-Id: I3076313ea51c6f4e74029ad9fb45d6f0b6dea460
2021-07-27 16:10:08 -07:00
Treehugger Robot
fafad035ac Merge "Fix warnings in preparation for Rust 1.53.0" am: 04f835ad2f am: 79165dc176
Original change: https://android-review.googlesource.com/c/platform/system/security/+/1779210

Change-Id: I617d86c1ef18a185e4c660575c5178e0a4ec1cab
2021-07-27 21:16:03 +00:00
Jiyong Park
0d61dd6c3a Remove ndk_platform backend. Use the ndk backend.
The ndk_platform backend will soon be deprecated because the ndk backend
can serve the same purpose. This is to eliminate the confusion about
having two variants (ndk and ndk_platform) for the same 'ndk' backend.

Bug: 161456198
Test: m
Change-Id: Ibeb4178f99857be75bb5f83a073a2d679058d921
2021-07-27 12:20:26 +09:00