539 Commits

Author SHA1 Message Date
Rob Barnes
73e9640194 Merge "Added listUidsForAuthBoundKeys to KeyStore" 2018-11-15 17:32:31 +00:00
Rob Barnes
f1a678e0fe Added listUidsForAuthBoundKeys to KeyStore
listUidsForAuthBoundKeys was added to IKeyStoreService.
This CL exposes this method in KeyStore for system apps.
This method will be hidden for non system apps.

Bug: b/112321280
Test: listUidsForAuthBoundKeys in IKeyStoreService has its own tests
Test: This method cannot be tested directly from CTS
Change-Id: Iac9e863079a1367ddb3a599bc3825baea96a1c31
2018-11-14 13:14:35 -07:00
Janis Danisevskis
b0358e72be Multi-threaded keystore
This patch makes the framework use the asynchronous keystore api model.

Bug: 111443219
Test: Ran full keystore cts test suite
Change-Id: I8d1fdc70cb9eb501d3f22a97d1221904c2ef8f9a
2018-11-14 09:59:16 -08:00
Janis Danisevskis
d257538507 Add return code KEY_ALREADY exists
In preparation to the async keystore interface we change the semantics
form unconditionally overwriting existing keys to reporting that the key
exists. For compatibility we reimplement the same semantic in the
calling code.

Bug: 111443219
Test: KeyStore CTS test
Change-Id: I1fa5428fa7ada97d5068778cd4590593c992554d
2018-11-08 12:53:57 -08:00
Janis Danisevskis
1864c95616 Remove legacy functions form IKeystoreService.aidl
In preparation for making the keystore service asynchronous we remove
redundant legacy functionality from the protocol.

This patch removes the functions get_pubkey, sign, verify, generate,
and import_key. Which have long been superseded by exportKey
(get_pubkey), begin/update/finish (sign, verify), generateKey
(generate), and importKey (import_key).

This patch also removes isOperationAuthorized.

Test: KeyStore CTS tests
Bug: 111443219
Change-Id: Ib3bd6f40b4e948e5ad6b2ef5278b18ff46201d71
2018-11-08 12:53:57 -08:00
Mathew Inwood
e2a6ad99ae Merge "Add @UnsupportedAppUsage annotations"
am: d9381f5e56

Change-Id: I3940d669bb1f4fedc8a7fbbcdb8de2ef954674a8
2018-08-17 02:13:11 -07:00
Mathew Inwood
4dbdcf43ad Add @UnsupportedAppUsage annotations
For packages:
  android.security.net.config
  android.security.keystore
  android.security.keymaster
  android.security

This is an automatically generated CL. See go/UnsupportedAppUsage
for more details.

Exempted-From-Owner-Approval: Mechanical changes to the codebase
which have been approved by Android API council and announced on
android-eng@

Bug: 110868826
Test: m
Change-Id: Ifed4da56531195f64fd53d84f14b4e8298843b2c
Merged-In: I7762dd647bede8abc9be2c538af3a3a99a25a73e
2018-08-16 18:49:37 +01:00
Mathew Inwood
842e882507 Merge "Code reformatting for upcoming annotations." am: 60c8cfdd0f
am: 02763a1c3e

Change-Id: Icdbef4bd0e71876a3ddb296ca38a243209f2eaf9
2018-08-01 16:35:28 -07:00
Mathew Inwood
02763a1c3e Merge "Code reformatting for upcoming annotations."
am: 60c8cfdd0f

Change-Id: I4fcf520f53dddd6e70edf0d59fd13ae218c336a5
2018-08-01 16:01:52 -07:00
Mathew Inwood
efb481646e Code reformatting for upcoming annotations.
@UnsupportedAppUsage annotations are added automatically, but this does
not work when there are multiple definitions on the same line.

Test: m
Bug: 110868826
Change-Id: I2c26c136cdfa557e45cf1ee0b39dab9c17abde56
2018-08-01 10:24:49 +01:00
Eran Messeri
5a5c6e0e44 Correctly preserve key generation parameters
Due to an oversight, some of the key generation parameters that are set
in KeyGenParameterSpec were not preserved when parceling the object
(they should have been added to ParcelableKeyGenParameterSpec but were
not).

This means these parameters will be ignored when generating keys using
the DevicePolicyManager.generateKeyPair method, leading to an
inconsistent key generation behaviour between the DevicePolicyManager
and KeyStore.

In particular, this would prevent callers from using StrongBox when
generating keys for use in the KeyChain.

Fix the issue by simply persisting these parameters in
ParcelableKeyGenParameterSpec and making sure that the Builder copies
them too from the source KeyGenParameterSpec.

Left to do is put in place an automated measure to find out
discrepancies between the two classes.

Bug: 110915980
Bug: 110882855
Bug: 109953656
Test: atest KeystoreTests
Change-Id: Ic64bd2921b6dfc97ea34ecba55f532312963ffcb
2018-06-28 17:20:01 +01:00
Shawn Willden
fe6d4769a8 Correct the keystore alias used for secure imports
An Android-O timeframe refactor removed all use of keystore "skey"
aliases.  Creating one not only partially reverses that refactor, but
it also results in a key alias which cannot be deleted in some cases,
causing AndroidKeyStoreTest failures during the second run of CTS.

Bug: 80228327
Test: CTS tests ImportWrappedKeyTest and AndroidKeyStoreTest, in that order
Change-Id: I348ba421f29cdf6c65fc98be3a25d19938d559c1
2018-06-26 12:35:03 +00:00
Eran Messeri
0bc50f9442 Improve KeyChain documentation
Improve the choosePrivateKeyAlias documentation by:
(1) removing reference to host+port when a URI is being passed in.
(2) Clearing up the language about what a DPC can do.

Test: N/A
Bug: 81522642
Change-Id: I12fbf675536ea5d843dd2eec4f0379daad764bb6
2018-06-04 17:12:41 +01:00
Frank Salim
4b9fee5331 Make ImportWrappedKey work with real hardware:
Get unwrapping params from WrappedKeyEntry

Add @hide API for StrongBox-backed imported keys (as opposed to wrapped or generated)
Enable 3DES conditionally based on a system property.

Bug: b/79986479
Bug: b/79986680
Test: CTS
Change-Id: If6beedc203337027576ecd3555d11ed2874f9768
2018-05-18 18:25:33 +00:00
Mike Harris
cd0eb716c5 Use the @Nullable annotations for choosePrivateKeyAlias.
Both the code and docstring support this, but the parameters weren't
annotated.

Test: it builds locally

Change-Id: I16beddcd74a86047ce9aaf37007d96f3e8e0d4e0
Merged-In: I16beddcd74a86047ce9aaf37007d96f3e8e0d4e0
Fix: 78868934
(cherry picked from commit b7c5eddc53c3872b661222ae30270d95cfe63b4e)
2018-04-30 09:27:31 +00:00
Eran Messeri
ec6268c514 Merge "AttestationUtils: Request MEID explicitly" into pi-dev 2018-04-13 10:07:36 +00:00
Eran Messeri
52dcedca37 AttestationUtils: Request MEID explicitly
Rather than rely on getDeviceId to provide the MEID, explicitly use
getMeid to get it.

For MEID attestation to work, the right identifier needs to be passed in
for attestation by Keymaster.
AttestationUtils currently gets this identifier by calling getDeviceId.
This would only yield the MEID if the device does not have an IMEI
provisioned, which means it'll get the IMEI for devices that have both
(like Pixel 2).

According to bartfab@ that is the correct way (see b/77584730#13).

Bug: 77584730
Bug: 73284024
Test: runtest --path cts/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java
Change-Id: I98f6c2e2a9835bf2fd681cfb4ff74fc3984c3a8e
2018-04-12 17:20:35 +01:00
Allen Webb
9b5853d304 keystore: Add documentation for user presence required.
Test: make -j50 docs
Bug: 77600728
Change-Id: I6334bc0fc7a7d4faced6b03522c350ce74303443
Signed-off-by: Allen Webb <allenwebb@google.com>
2018-04-11 19:23:30 +00:00
Shawn Willden
13e230f5d6 Mark CTS-tested APIs as @TestApi
Bug: 77596526
Test: Keystore CTS
Change-Id: Ic4280db3d9ff093138f0a361ac6a52ca69187cca
2018-04-10 18:15:22 -06:00
Brian C. Young
1c5ee613be Allow CTS tests to access more from KeyProtection
Add @TestApi to allow CTS tests to use that call.
Encryption and decryption are reversed in some documentation.

Test: CtsKeystoreTestCases
Bug: 77596526
Change-Id: Ifaf8b3fa0e231eef256451a2514219fff1b16699
2018-04-10 17:05:39 -06:00
TreeHugger Robot
aa5c335a60 Merge "keystore: Change superclass of UserPresenceUnavailableException." into pi-dev 2018-04-05 00:58:18 +00:00
TreeHugger Robot
084f9aee9a Merge ""Unlocked device required" javadoc clarification" into pi-dev 2018-04-02 21:40:34 +00:00
TreeHugger Robot
840c29eb0b Merge "Rename trustedUserPresenceRequired." into pi-dev 2018-04-02 20:36:34 +00:00
Brian C. Young
6f8fa9ac83 "Unlocked device required" javadoc clarification
Wording changes on the public API functions for these keys.

Test: CTS
Bug: 67752510
Change-Id: Iaf620e8c0e06d436d09f50d308268653bec196ce
2018-04-02 12:40:58 -07:00
Shawn Willden
3c1830bd7f Rename trustedUserPresenceRequired.
The existing name is misleading, because it can be read as requiring
that a trusted user be present, rather than the intended meaning of
requiring trusted proof of user presence.  Since this is all about
TEE/SE-based keys, the "trusted" part is implied, so the simple
"userPresenceRequired" name makes more sense.

Bug: 77151288
Test: Keystore CTS tests
Change-Id: If8b533b9f34a1875eaf35cdd1bb8f3709da9761b
2018-04-02 13:03:14 -06:00
TreeHugger Robot
50228a6471 Merge "Revise secure key import API after review" into pi-dev 2018-04-02 18:45:35 +00:00
Brian C. Young
f5f6bb2d88 Remove getCurrentUser call to find an alternative
The call the framework uses to get the current user ID requires the
INTERACT_ACROSS_USERS permission, which not a lot of apps will have.
Find a better way to do that.

Bug: 76430246

Test: CtsKeystoreTestCases
Change-Id: I8a0637d351fff9cfbf40e02946325f90466b68c5
2018-03-30 21:37:48 +00:00
TreeHugger Robot
1e0a9b0b1b Merge "Enable "Unlocked device required" API" into pi-dev 2018-03-30 18:54:39 +00:00
Frank Salim
b631503200 Revise secure key import API after review
• WrappedKeyEntry: add doc (based on IKeymasterDevice.hal comments)
• StrongBoxUnavailableException: add public ctors, match superclass
• SecureKeyImportUnavailableException: new first class exception
• ORIGIN_SECURELY_IMPORTED: elaborated on properties

Test: make doc & review output
Bug: b/74218267
Change-Id: Ice9adc60ede618870e57bb58ca66fd0218cd2bf7
2018-03-30 10:25:22 -07:00
Allen Webb
be10891cab keystore: Change superclass of UserPresenceUnavailableException.
Also add additional comments to isTrustedUserPresenceRequired().

Test: m -j KeystoreTests && adb install -r
out/target/product/${TARGET_PRODUCT}/data/app/KeystoreTests/KeystoreTests.apk
    adb shell am instrument

Bug: 73392697
Bug: 76462141
Change-Id: Iabcc331adda53e2a5cad5ead6002dfbc29188da2
Signed-off-by: Allen Webb <allenwebb@google.com>
2018-03-30 10:02:46 -07:00
Brian Young
0186b42f2a Merge changes from topics "niap-asym-write-pi-dev", "niap-asym-write-api-pi-dev" into pi-dev
* changes:
  Restore "Add "Unlocked device required" parameter to keys"
  Add "Unlocked device required" key API
2018-03-30 14:21:19 +00:00
Brian C. Young
9e87490580 Enable "Unlocked device required" API
Remove the @hide annotations so the SDP asymmetric-write functionality
is included in the public API.

Test: CtsKeystoreTestCases

Bug: 63928827
Change-Id: I8f462b0ebe4d9a7b96b48fa1672dd2ab9140c505
2018-03-29 10:25:33 -07:00
Brian Young
9272dab49e Restore "Add "Unlocked device required" parameter to keys"
Add a keymaster parameter for keys that should be inaccessible when
the device screen is locked. "Locked" here is a state where the device
can be used or accessed without any further trust factor such as a
PIN, password, fingerprint, or trusted face or voice.

This parameter is added to the Java keystore interface for key
creation and import, as well as enums specified by and for the native
keystore process.

This reverts commit da82e2cb7193032867f86b996467bcd117545616.

Test: CTS tests in I8a5affd1eaed176756175158e3057e44934fffed

Bug: 67752510

Merged-In: Ia162f1db81d050f64995d0360f714e79033ea8a5
Change-Id: Ia162f1db81d050f64995d0360f714e79033ea8a5
(cherry picked from d7c961ee914192e09ec10727da6d31a6b597bf51)
2018-03-29 10:24:18 -07:00
Eran Messeri
6169239b94 Utilize verbose KeyChain errors
As KeyChain reports detailed error codes about failure to generate keys
or attestation records for them, log these detailed errors and throw an
exception if the hardware does not support Device ID attestation.

Bug: 72642093
Bug: 73448533
Test: cts-tradefed run commandAndExit  cts-dev -s 127.0.0.1:50487 -a x86_64 -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.DeviceOwnerTest#testKeyManagement -l DEBUG
Change-Id: Ib12efcf48c158373e1fc28cc51d67e70282d029e
2018-03-29 10:58:20 +01:00
Brian Young
36716eb470 Add "Unlocked device required" key API
This adds the API methods and values for keyguard-bound keys, but
contains none of the actual functionality.

Test: CTS tests in CtsKeystoreTestCases

Bug: 67752510

Merged-In: Iccd7dafd77258d903d11353e02ba3ab956050c40
Change-Id: Iccd7dafd77258d903d11353e02ba3ab956050c40
(cherry picked from commit fd75c7232aebc8690f004de3486b3b9a44f3e0b0)
2018-03-28 08:38:56 -07:00
TreeHugger Robot
56e9c026b3 Merge "Refactor AddUserAuthArgs for extensibility" into pi-dev 2018-03-27 22:13:37 +00:00
Dmitry Dementyev
4b4a0539b6 Add missing @NonNull annotation to AndroidKeyStoreProvider method.
Bug: 73959762
Test: none
Change-Id: I2298c8fe0893032f374629a5af128474ba0f679c
2018-03-23 17:46:52 -07:00
Brian Young
5437b81696 Refactor AddUserAuthArgs for extensibility
Create an interface that encapsulates the common arguments to
AddUserAuthArgs, add that interface to KeyProtection and
KeyGenParameterSpec, and refactor AddUserAuthArgs to accept an
instance of that interface.

Test: CTS Module CtsKeystoreTestCases

Bug: 74017618

Merged-In: I591e34e5d08421ea1c022bbb6e955ee3c01eb435
Change-Id: I591e34e5d08421ea1c022bbb6e955ee3c01eb435
(cherry picked from commit df16c56fbf05908e03f3a95a8a3d981bbc2fdb91)
2018-03-22 16:10:40 -07:00
David Zeuthen
bbb7f65a23 ConfirmationDialog: Pass accessibility options and implement isSupported().
Bug: 63928580
Test: Manually tested.
Change-Id: I6a06d10a4cb924c3e57c8e212ba4626cad00f4a1
2018-02-26 11:08:00 -05:00
Brian Young
da82e2cb71 Revert "Add "Unlocked device required" parameter to keys"
This reverts commit efc3f16be7870c84227b79f73f0ad7cab72a260f.

Reason for revert: Regression in creating auth-bound keys

Bug: 73773914

Bug: 67752510

Change-Id: Ic3886ceb3c3c0c4274682ed9f5f2bfbf8fdd71b9
2018-02-23 01:31:49 +00:00
Brian C. Young
efc3f16be7 Add "Unlocked device required" parameter to keys
Add a keymaster parameter for keys that should be inaccessible when
the device screen is locked. "Locked" here is a state where the device
can be used or accessed without any further trust factor such as a
PIN, password, fingerprint, or trusted face or voice.

This parameter is added to the Java keystore interface for key
creation and import, as well as enums specified by and for the native
keystore process.

Test: CTS tests in I8a5affd1eaed176756175158e3057e44934fffed

Bug: 67752510

Change-Id: I314b848f6971d1849a7a6347d52e41d9604639ae
2018-02-14 12:19:13 -08:00
David Zeuthen
a8e8b659d0 Add Confirmation API.
This CL adds new Framework APIs that can be used for the secure
confirmations. This includes support for configuring a key such that
it can only sign data returned by the confirmation APIs.

Bug: 63928580
Test: Manually tested.
Change-Id: I94c1fc532376bd555b3dc37fc4709469450cfde6
2018-01-30 17:33:21 -05:00
Brian Young
3a28570b28 Revert "Add "Unlocked device required" parameter to keys"
This reverts commit 55fff3a89d96d0d0f8b8cb161bb0dda170c21ccb.

Reason for revert: Build breakages on elfin, gce_x86_phone.

Bug: 67752510

Bug: 72679761
Change-Id: Ia495e9cb158b64fcf015e37b170554a7ed6810a7
2018-01-30 15:31:42 +00:00
Brian C. Young
55fff3a89d Add "Unlocked device required" parameter to keys
Add a keymaster parameter for keys that should be inaccessible when
the device screen is locked. "Locked" here is a state where the device
can be used or accessed without any further trust factor such as a
PIN, password, fingerprint, or trusted face or voice.

This parameter is added to the Java keystore interface for key
creation and import, as well as enums specified by and for the native
keystore process.

Test: go/asym-write-test-plan

Bug: 67752510

Change-Id: I8b88ff8fceeafe14e7613776c9cf5427752d9172
2018-01-29 10:16:02 -08:00
TreeHugger Robot
4dadff8be0 Merge "Add confirmation UI protocol to Keystore AIDL definition" 2018-01-25 17:31:38 +00:00
TreeHugger Robot
7f1e49f2ff Merge "Generating StrongBox backed keys" 2018-01-25 17:24:17 +00:00
Allen Webb
fcd05a94ef keystore: Add Trusted User Presence (TUP) APIs.
Test: m -j KeystoreTests && adb install -r
out/target/product/crosshatch/data/app/KeystoreTests/KeystoreTests.apk
    adb shell am instrument
    'android.security.tests/android.support.test.runner.AndroidJUnitRunner'
Bug: 72476834

Change-Id: I61ee4326a5e31f1cefacd47470b53634fa94c2ef
2018-01-24 23:06:35 -08:00
Frank Salim
ea5e038bc1 Generating StrongBox backed keys
•Add FLAG_STRONGBOX when the generator spec requires it.
•Throw StrongBoxUnavailableException when the request
fails due to HARDWARE_UNAVAILABLE.
•Add PackageManager.FEATURE_STRONGBOX_KEYSTORE

Test: KeyStore CTS tests under development on an emulator
Bug: 63931634
Change-Id: I42d32b22981e43e504d30e5657d21ac555c71ebe
2018-01-24 23:45:54 +00:00
Janis Danisevskis
7dacad8dc8 Add confirmation UI protocol to Keystore AIDL definition
Test: Manually tested
Bug: 63928580
Change-Id: Ief1cdb9a64737d5aac08aa1c48ff60c34218d5ba
2018-01-24 15:45:08 -08:00
Frank Salim
21d9c1d44a Keystore APIs for Import Wrapped Key, Strongbox, 3DES
Import Wrapped Key:
Applications can import keys in a wrapped, encrypted format. Wrapped keys are
unwrapped inside of a Keymaster device.

Strongbox:
Applications can import and generate keys in secure hardware.

3DES:
Add KeyProperties and KeymasterDefs
Add AndroidKeyStore3DESCipherSpi and provider registrations

Bug: 63931634
Test: Keystore CTS tests in progress

Change-Id: I80b6db865b517fa108f14aced7402336212c441b
2018-01-23 00:29:11 -08:00