Commit Graph

227 Commits

Author SHA1 Message Date
Max Bires
1cfd95ec0c Fixing how SIDs are added to keys during generation time
SIDs were not being properly applied to key parameters under the new
authentication rework. Now that biometric/credential unlocks are valid
for either auth-per-op or timeout auth bound keys, the SIDs need to be
tacked on appropriately in each authentication flow.

Bug: 148425329
Test: CtsVerifier
Change-Id: I73733b00d2da5ac78db6d77c53de144f4473bb54
2020-03-17 02:57:36 +00:00
Max Bires
a811787a96 Fixing default behavior for keys requiring auth
The default timeout and authentication type is being updated to offer a
correct default that matches the old behavior.

Bug: 148425329
Bug: 149931201
Test: CtsVerifier
Test: atest KeyguardLockedTests

Change-Id: Id20097b04ce881e7028609d2ba1c30c26ba3c8cf
2020-03-11 13:43:52 -07:00
TreeHugger Robot
0ffc3165a3 Merge "Do not allow -1 duration in setUserAuthenticationParameters" into rvc-dev 2020-03-05 21:39:57 +00:00
Kevin Chyn
9f49e8df2a Do not allow -1 duration in setUserAuthenticationParameters
This is a completely new API so callers can follow the new pattern of
using 0 to require auth for every use of the key.

Supporting both -1 and 0 to require auth for every use of the key
increases CtsVerifier complexity exponentially (strongbox,
invalidated by enrollment, etc).

Fixes: 150823346
Test: builds
Change-Id: Ieef53a8b50f5119c5e52656e930bf16b1e8e3d89
2020-03-05 11:17:22 -08:00
Kenny Root
291718cdb7 Merge "Revert "Fixing default behavior for keys requiring auth"" into rvc-dev 2020-03-05 17:10:53 +00:00
Kenny Root
382e724714 Revert "Fixing default behavior for keys requiring auth"
This reverts commit e5b6686b49.

Reason for revert: Droidcop-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?testMethod=testDismissKeyguard&testClass=android.server.wm.KeyguardLockedTests&atpConfigName=cts%2Fframework%2Fgce-presubmit-wm-cloud-tf-2&testModule=CtsWindowManagerDeviceTestCases&fkbb=6265187&lkbb=6266200&lkgb=6265150&testResults=true&badBuildCount=32&branch=git_rvc-dev-plus-aosp&target=aosp_cf_x86_phone-userdebug, bug b/150847441

Bug: 150847441
Change-Id: I1e648e1174172f8077cea1dd175c4167830adcb6
2020-03-05 16:57:39 +00:00
Kevin Chyn
8586645527 Merge "Fixing default behavior for keys requiring auth" into rvc-dev 2020-03-05 04:06:22 +00:00
Max Bires
e5b6686b49 Fixing default behavior for keys requiring auth
The default timeout and authentication type is being updated to offer a
correct default that matches the old behavior.

Bug: 149931201
Test: CtsVerifier
Change-Id: I3f3d4f8d5b02455c285a882933fd6c37739ee44a
2020-03-04 17:31:06 -08:00
Eran Messeri
3f9578be3e Fix copy-pasted documentation.
Fix the documentation  for USE_INDIVIDUAL_ATTESTATION which was
copy-pasted from another attestation ID type.

Bug: 149475774
Test: That it compiles.
Change-Id: I9366870c8875997321c93fe1db216e91f374b1db
2020-02-28 11:32:33 +00:00
Kevin Chyn
7d07c89235 Clean up biometric system server
1) BiometricService / AuthService always need to be started, since on
   Android 11 and later, the public credential auth API comes through this
   path.

2) Consolidate getAuthenticatorId() and expose via AuthService. This is
   used only by the platform during key generation. Instead of asking
   each individual service, AuthService will return a list of IDs for
   sensors which are enrolled and meet the required strength.

Test: atest com.android.server.biometrics
Test: fingerprint device, CtsVerifier biometric section
Test: face unlock device, CtsVerifier biometric section
Test: remove biometrics from device, CtsVerifier biometric section

Bug: 148419762
Bug: 149795050

Change-Id: I2c5385b1cd4f343fabb0010e1fe6fb1ea8283391
2020-02-20 11:12:51 -08:00
Max Bires
04b682d394 Changing op per auth keys to allow password
Previously, auth per operation keystore keys could only be authorized
with biometrics. There is no reason to restrict this functionality to
biometrics. This change slightly refactors the key parameter builder
interface to allow the caller to specify which authentication types
should be allowed for an auth per op key.

Bug: 147693375
Bug: 140256692
Test: atest keystore
Change-Id: I5cbf3d4e3f0e84d577dbf6b4cb356b1010100925
2020-02-06 11:17:26 -08:00
Rubin Xu
b3a13e1e2c Add KeyGenParameterSpec.setCriticalToDeviceEncryption
Mirror KeyProtection.setCriticalToDeviceEncryption so
the flag can also be set on keys generated by keystore.

Bug: 72178550
Test: atest android.security.keystore.KeyGenParameterSpecTest
Test: atest android.security.ParcelableKeyGenParameterSpecTest
Change-Id: I7f102c82e60f211028c694d499ffd2838b89bb2b
2020-01-14 17:10:18 +00:00
Automerger Merge Worker
509eee80fa Merge "Make KeyStoreCryptoOperationChunkedStreamer lazy." am: c13f012cc5 am: bb8ecaef09 am: ecb9c6f041
Change-Id: Icbcec2ae8ea5c907d7ce37558b0db0b634643a56
2020-01-06 16:29:26 +00:00
Artur Satayev
53fe96661b Use new UnsupportedAppUsage annotation.
Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library.

Bug: 145132366
Test: m && diff unsupportedappusage_index.csv
Change-Id: I4bc8c9482e4bb1af21363f951affff7ee3fefeab
2019-12-18 15:42:06 +00:00
Eran Messeri
c54507664b Wire individual attestation
Properly define the constant for requesting the use of device individual
attestation certificate and use it in AttestationUtils.

This lets callers to DevicePolicyManager.generateKeyPair request the use
of device-unique attestation certificate, on Keymaster implementations
that support this.

Bug: 140193672
Bug: 136494773
Test: atest com.android.cts.devicepolicy.MixedDeviceOwnerTest#testKeyManagement
Change-Id: I74de89e4c121a27b0495dcb99b0775445c3d4eaf
2019-12-13 10:58:57 +00:00
Rob Barnes
73ea6195ac Make KeyStoreCryptoOperationChunkedStreamer lazy.
Only send updates when a configurable threshold is met.
For some scenarios this results in a significant performance
improvement. Specifically sign operations should be 10-40% faster.

Bug: 139891753
Test: atest CtsKeystoreTestCases
Change-Id: I233679d4f8582eeaaa6f21e3102cce08110f0482
2019-12-04 11:38:13 -07:00
TreeHugger Robot
2f6c5fe32f Merge changes from topic "broadcast_multiple_perm"
* changes:
  AndroidKeyStoreProvider: Add @throws documentation
  RemoteException: Add @throws documentation
  Context: Rename Context.sendBroadcastMultiplePermissions
2019-11-21 06:28:10 +00:00
Roshan Pius
4241a2866c AndroidKeyStoreProvider: Add @throws documentation
Bug: 144791977
Test: Compiles
Change-Id: I9f19e30d58b1b7d504f9e8f7e79dd71a38f81357
2019-11-20 14:48:34 -08:00
Max Bires
7de99c2f1a Merge "Updating accepted HMAC key sizes" am: 1cf90f78f1 am: 7f813b80d3
am: 432cb5d523

Change-Id: I1308b205762df42ed5fdc23da00f84a8cc31d45e
2019-11-19 19:57:30 -08:00
Rob Barnes
c00713055b Merge "Allow for input_data on finish." am: 4a83b14ada am: 02c287a628
am: 51e842e43c

Change-Id: I3ed4477e925a203ae8a7b1dde9744ade4a32e93c
2019-11-19 19:50:18 -08:00
Treehugger Robot
1cf90f78f1 Merge "Updating accepted HMAC key sizes" 2019-11-19 23:59:32 +00:00
Rob Barnes
92743aeb44 Allow for input_data on finish.
This additional input will be unused for now, but future changes are
expected to utilize it.

Test: Keystore CTS Tests
Change-Id: I5c388032e3710e3825bdb06b26443a5ae2c034a3
2019-11-14 16:19:20 -07:00
TreeHugger Robot
bc7671b9fb Merge "Add @UnsupportedAppUsage to test apis that are known to be used by apps." 2019-11-13 15:46:27 +00:00
Artur Satayev
5a525851a8 Add @UnsupportedAppUsage to test apis that are known to be used by apps.
go/testapi-enforcement

Bug: 133832325
Test: m
Change-Id: Ifc8db120640a1554dcbf1722e61e09c7ddc65dd6
Merged-In: Ifc8db120640a1554dcbf1722e61e09c7ddc65dd6
2019-11-13 15:05:56 +00:00
Roshan Pius
780d117268 keystore: Expose @SystemApi's to wifi mainline module
Two @SystemApi's being added to allow wifi mainline module to access
formal API's:
a) KeyGenParameterSpec.Builder.setUid() to allow wifi to create/store keys
with WIFI_UID.
b) AndroidKeyStoreProvider.getKeyStoreForUid() to allow wifi to get/put
any keys stored with WIFI_UID.

Both of these API's are already permission protected in the lower
layers. There is a map of euid's stored in the native keystore which
limits which uid is allowed to access which other uid's data.

Bug: 142089671
Test: make system-api-stubs-docs-update-current-api
Change-Id: I39b92d2293bcdc26bb0a4a48a1d1e4cc0b20ad0b
2019-11-13 06:08:13 -08:00
Artur Satayev
f0b7d0ba51 Add @UnsupportedAppUsage to test apis that are known to be used by apps.
go/testapi-enforcement

Bug: 133832325
Test: m
Change-Id: Ifc8db120640a1554dcbf1722e61e09c7ddc65dd6
Merged-In: Ifc8db120640a1554dcbf1722e61e09c7ddc65dd6
2019-11-13 12:58:29 +00:00
Max Bires
ca0d4d8f42 Updating accepted HMAC key sizes
In order to keep conformity across the ecosystem, keystore will enforce
that HMAC key sizes coming in through the framework must be limited to
the range of 64-512 bits, inclusive. This will be the case for both TEE
and StrongBox Keymaster implementations.

Bug: 143404829
Test: atest CtsKeystoreTestCases
Change-Id: I2ea867392060f4478b5a01bd747a4345e1fded4c
2019-11-12 13:42:58 -08:00
Eran Messeri
da05c80d6b API for individual attestation
Introduce a new API to request use of individual attestation
certificate for attesting keys generated by the
DevicePolicyManager.generateKeyPair method.

It builds on existing device ID attestation capabilities in two ways:
(1) Eligibility check: Assuming similar privacy requirements for the use
    of individual attestation certificates, enforce the same conditions
    for using them as the conditions for requesting device identifiers
    in the attestation record.
(2) Keymaster interaction: Passing the right Keymaster tag to the
    attestKey call, which is easily done in AttestationUtils.

Bug: 136494773
Test: CTS test to be added.
Change-Id: Idb5cee66d986a521c17e1955532d0bfae66c035d
2019-09-24 18:14:05 +01:00
Shawn Willden
d8283a81f3 Fix encryption/decryption of large blocks.
There's a long-standing bug (since ~Marshmallow) that causes
AndroidKeyStore to truncate large (>64 KiB) blocks of data.  This can
be avoided by callers by processing data in smaller chunks, and
smaller chunks are more memory-efficient while not being much (if any)
more time-efficient.  But, Keystore should handle large blocks
correctly.  This CL adds a test to all block cipher tests that
attempts to encrypt and then decrypt a 100 KiB block.

Bug: 123391046
Test:  CtsKeystoreTestCases
Change-Id: I0c0286fd5360d4fe62cbd8130aa0c17f97318801
2019-05-24 09:39:50 -06:00
Kevin Chyn
1e50792d72 Check PackageManager for feature before getting system service
Fixes: 130756217

Test: See comment #3 in the bug above
Change-Id: I0008f2b2958c9ac0df4e1f8ce4f5edcd9aac4292
2019-04-18 13:39:09 -07:00
Kevin Chyn
9374c9f839 Update documentation for fingerprint -> biometric
Fixes: 129909360

Test: Builds
Change-Id: I8e419e4c2b5ca2c1f0fc9d988100ceb41f193a42
2019-04-05 00:49:59 +00:00
Max Bires
f5276800d8 Merge "Fixing engineGetCertificateChain exception" am: 09e3d8c3eb am: 53187655d0
am: efb8468705

Change-Id: I8157345ed59352152c5035467f94836c0c4f216e
2019-03-18 20:45:55 -07:00
Treehugger Robot
09e3d8c3eb Merge "Fixing engineGetCertificateChain exception" 2019-03-19 03:02:31 +00:00
Max Bires
18e0781d3d Merge "Adding KEY_PERMANENTLY_INVALIDATED int" 2019-03-08 17:53:05 +00:00
Max Bires
beae8c67dc Fixing engineGetCertificateChain exception
If a certificate is self signed, then currently KeyStore will still
attempt to find the CA certificate. When it obviously fails to find it,
a key not found exception is propagated up and thrown. This CL
suppresses that exception, as it seems to exclusively be thrown in this
condition, which is WAI. Having the stack trace show up can be very
misleading to developers.

Test: atest cts/tests/tests/keystore/src/android/keystore/cts
Change-Id: I192f54d3d8355c183e830ab09314932e8800f7ed
2019-03-07 18:19:29 +00:00
Eran Messeri
842d883f05 Device ID Attestation: Fix API review
Mark the c'tor parameters as nullable to comply with Exception's
behaviour.

Bug: 126702366
Test: That it compiles
Change-Id: I96a7c03cb79e7180872de02bee143b67f7a408ec
2019-03-05 22:34:29 +00:00
Jeff Sharkey
9e8f83db6d All Parcelable CREATOR fields are @NonNull.
If they were null, then the Parcelable would fail to work.

Bug: 126726802
Test: manual
Change-Id: I7929ffa2f20e5de1c8e68e8263cca99496e9d014
Exempt-From-Owner-Approval: Trivial API annotations
2019-02-28 23:29:04 -07:00
Max Bires
6b850fb4ef Merge "Adding KEY_PERMANENTLY_INVALIDATED int" 2019-02-20 17:21:22 +00:00
Max Bires
b2cc3dc227 Adding KEY_PERMANENTLY_INVALIDATED int
This is to keep it in sync with response codes in keystore.h.

This commit also adds the KeyPermanentlyInvalidatedException to all the
methods that could receive this error code out of KeyStore.

Bug: 118883532
Test: atest cts/hostsidetests/appsecurity/src/android/appsecurity/cts/AuthBoundKeyTest.java
Change-Id: I878a628824e2eeb639ec5678b1a5d3d10428a918
Merged-In: I878a628824e2eeb639ec5678b1a5d3d10428a918
2019-02-18 21:11:48 +00:00
Max Bires
13f98ce5aa Adding KEY_PERMANENTLY_INVALIDATED int
This is to keep it in sync with response codes in keystore.h.

This commit also adds the KeyPermanentlyInvalidatedException to all the
methods that could receive this error code out of KeyStore.

Bug: 118883532
Test: atest cts/hostsidetests/appsecurity/src/android/appsecurity/cts/AuthBoundKeyTest.java
Change-Id: I878a628824e2eeb639ec5678b1a5d3d10428a918
2019-02-18 20:45:46 +00:00
Max Bires
68a6071f71 Merge "Adding framework check for 3DES key size" am: a24d025212 am: a68009941a
am: 67046659a4

Change-Id: Ibe2259a6eec6115c3bbabfd387e585ec39389a0b
2019-02-15 13:55:45 -08:00
Max Bires
20fa0e7c2e Adding framework check for 3DES key size
Previously the framework would accept any key size that was a multiple
of 8 for the KeyGenerator.

Bug: 117509689
Bug: 122274787
Test: atest cts/tests/tests/keystore/src/android/keystore/cts/KeyGeneratorTest.java
Change-Id: I60b52f6062a41ae52486bae0ae36616f4b532b37
2019-02-13 15:10:29 -08:00
Max Bires
21ffe60b70 Merge "Adding check for HMAC/EC key size for StrongBox" am: ffee7d8ce0 am: f5992f894a
am: 717fca1d59

Change-Id: I15c12c940722bb6a810f86b039d9a3d2f0eadac4
2018-12-26 18:44:14 -08:00
Treehugger Robot
ffee7d8ce0 Merge "Adding check for HMAC/EC key size for StrongBox" 2018-12-27 01:58:05 +00:00
Max Bires
d255a2136f Adding check for HMAC/EC key size for StrongBox
engineInit() for AndroidKeyStoreKeyGeneratorSpi does not make a call
into the backing Keymaster implementation until generate is called on it
to actually create the key. If a disallowed spec for StrongBox is passed
in, the backing StrongBox implementation won't be able to revoke it
until engineGenerateKey() is called, which will create different
behaviors between TEE backed implementations (which support a wider
range of algorithm spec parameters) and StrongBox implementations from a
public API perspective. This change will make sure HMAC is the same for
StrongBox.

This is also being done for EC keys in
AndroidKeyStoreKeyPairGeneratorSpi.java

Bug: 113525261
Bug: 114487149
Test: atest cts/tests/tests/keystore/src/android/keystore/cts/KeyGeneratorTest.java
Test: atest
cts/tests/tests/keystore/src/android/keystore/cts/KeyPairGeneratorTest.java
Change-Id: I728bb5222c9bf0ad84cdf2b8c0b78a4dd99f7186
2018-12-19 14:35:55 -08:00
Xin Li
15b123ef45 DO NOT MERGE - Merge pie-platform-release (PPRL.181205.001) into master
Bug: 120502534
Change-Id: Idc8bfb6d97a869b76cfb87ca1a494201baf9e8bd
2018-12-11 14:13:44 -08:00
Adrian Roos
27432dba6b API: Make implicit APIs from type usage explicit
API stubs generation implicitly made any types used by an API also part
of that API. This has caused DeviceIdAttestationException and
ImsFeature.Capabilities to become implicit APIs, so they are added to
the API files.

After this, using non-API types in APIs will become an error to prevent
implicit APIs occuring in the future.

Bug: 119556446
Test: METALAVA_PREPEND_ARGS="--error ReferencesHidden" make
Exempt-From-Owner-Approval: Identical CL has been approved on other branch
Change-Id: I5fe4f20502b8d4e287b28e9f07139456d4191e22
Merged-In: I5fe4f20502b8d4e287b28e9f07139456d4191e22
(cherry picked from commit 8f91e5fde8)
2018-11-22 15:22:09 +00:00
TreeHugger Robot
271339ffdf Merge "API: Make implicit APIs from type usage explicit" 2018-11-19 17:21:27 +00:00
TreeHugger Robot
278913ae62 Merge "Update KeyStore for new biometric modalities" 2018-11-16 22:52:30 +00:00
Adrian Roos
8f91e5fde8 API: Make implicit APIs from type usage explicit
API stubs generation implicitly made any types used by an API also part
of that API. This has caused DeviceIdAttestationException and
ImsFeature.Capabilities to become implicit APIs, so they are added to
the API files.

After this, using non-API types in APIs will become an error to prevent
implicit APIs occuring in the future.

Bug: 119556446
Test: METALAVA_PREPEND_ARGS="--error ReferencesHidden" make
Change-Id: I5fe4f20502b8d4e287b28e9f07139456d4191e22
2018-11-15 07:14:49 -08:00