Commit Graph

818 Commits

Author SHA1 Message Date
Paul Crowley
336b5db809 Tell keystore which SIDs can unlock this user
If biometric unlock is enabled, we tell keystore at lock time so that
a key can be set up in KM which unlocks UNLOCKED_DEVICE_REQUIRED keys
based on auth tokens carrying those SIDs. This also has the effect that
if there is no biometric unlock, UNLOCKED_DEVICE_REQUIRED keys have
full cryptographic protection, per NIAP requirements.

Test: aosp/1686345
Bug: 163866361
Change-Id: Ia4d01faa998c76b2b33ad3520730466ac59e6d8d
2021-04-27 10:34:33 -07:00
Treehugger Robot
06df6d84eb Merge "Keystore 2.0 SPI: Fix engineDoFinal with null input." 2021-04-23 17:53:34 +00:00
Janis Danisevskis
70cf430ede Keystore 2.0 SPI: Fix engineDoFinal with null input.
AndroidKeyStoreCipherSpiBase.engineDoFinal may get called with a null
input argument. In the case where we forward the operation to the
default provider doFinal() needs to be called instead of
doFinal(byte[], int, int).

Bug: 183913233
Test: atest android.keystore.cts.CipherTest#testEncryptsAndDecryptsUsingCipherStreams
Change-Id: Ia3afaf281be7c8e5493ac8e4155a7aa02d1d37f0
2021-04-22 14:55:45 +00:00
Nikita Iashchenko
c931f43bcd Merge "Remove usage of Math.randomLongInternal" 2021-04-22 09:10:52 +00:00
Treehugger Robot
6bcd65c99e Merge "Keystore 2.0: Add namespace locksettings." 2021-04-21 15:53:32 +00:00
Rubin Xu
d42f1be8eb Merge "Keystore 2.0: Add key migration API." 2021-04-21 15:52:17 +00:00
Nikita Iashchenko
1bc8a1f886 Remove usage of Math.randomLongInternal
As a part of internal libcore API cleanup some of the functions
previously exposed are getting removed from public surface.
Math#randomLongInternal is a wrapper around java.util.Random and has no
specific implications so its usages are get refactored.

Bug: 154796679
Test: m droid
Change-Id: I29e0e9307fbaf9c1ac018b83014efb2d3dd74479
2021-04-21 14:10:43 +00:00
Janis Danisevskis
52e19940b1 Keystore 2.0: Add namespace locksettings.
This namespace is required by LocksettingsService to protect the
synthetic password key from removal when the user removes the
credentials or wipes AID_SYSTEM app data.

Bug: 184664830
Test: N/A
Change-Id: Ie752a75d2cb2ebf1f4e5814bc2cbc807cc754c21
2021-04-20 15:32:56 +00:00
Janis Danisevskis
8c97d4fe79 Fix operation auth bound keys.
CryptoObject still called the legacy AndroidKeystoreProvider which did
not return the correct operation handle for per operation auth bound
keys.

Bug: 184804041
Bug: 185181377
Test: CtsVerifier->Security->Biometric Tests->2a Strong Biometrics +
      Crypto
Merged-In: I0bceff0425e7ef32c394f33deda3c78f729c0c6c
Change-Id: I0bceff0425e7ef32c394f33deda3c78f729c0c6c
2021-04-16 12:55:33 -07:00
Janis Danisevskis
cbe7e963ab Keystore 2.0: Add key migration API.
The key migration API is required by locksettingsservice to move the
synthetic password key out of AID_SYSTEM to protect it from deletion
when the user removes credentials from AID_SYSTEM.

Bug: 184664830
Test: N/A
Change-Id: I8d0ffb79870affc8ac055574b6f808a984aa5e52
2021-04-16 14:21:40 +01:00
Janis Danisevskis
464e6c415f Keystore 2.0 SPI: Make getAttestationIds return an empty array.
getAttestationIds shall return an empty array instead of null.

Bug: 184026478
Test: N/A
Change-Id: I6c6233fa50a83cf7d6354d2783525704a3b39d0d
2021-04-07 14:38:57 -07:00
Max Bires
caa4617084 Merge "Fixing array cast." 2021-04-06 01:17:24 +00:00
Janis Danisevskis
a6dcf091f5 Keystore 2.0: Remove Keystore 1.0 SPI with all remaining references
Bug: 171305684
Test: CtsKeystoreTestCases
Change-Id: I337515dadc9e45b909bff058d4e13371b4fa843c
2021-04-01 17:06:41 -07:00
Steven Moreland
5fdf93fc9d Merge "Keystore 2.0: Update to canonical service name." 2021-03-29 17:02:31 +00:00
Max Bires
e7f48b9926 Merge "Adding AIDL and functions for talking to RemoteProvisioner" 2021-03-25 00:03:09 +00:00
Janis Danisevskis
11c25156a2 Merge "Keystore 2.0: Disable BackendBusyException." 2021-03-24 19:02:46 +00:00
Janis Danisevskis
e36f515441 Merge "Keystore 2.0: Add onDeviceOffBody to AndroidKeyStoreMaintenance." 2021-03-24 18:32:35 +00:00
Janis Danisevskis
5d1c590723 Keystore 2.0: Disable BackendBusyException.
This disables throwing BackendBusyException in Android S. Instead we
keep the legacy behavior of spinning until an operation can be created.

Bug: 180133780
Test: N/A
Change-Id: I802148c59338b91e751498607fa903e156e40aa6
2021-03-24 09:22:56 -07:00
Max Bires
7fd458dc44 Adding AIDL and functions for talking to RemoteProvisioner
This change adds an AIDL interface which the RemoteProvisioner app
implements that allows the keystore SPI to inform the app when an
attestation key may have been used, and when the underlying attestation
key pool is totally empty. The former is a non-blocking call, and the
latter blocks until completion.

Since the latter involves network, there are timeouts involved on the
app side to ensure that the blocking call doesn't hang indefinitely if
there's no network.

Test: atest CtsKeystoreTestCases && atest RemoteProvisionerUnitTests

Change-Id: Ie49e37659c96ce5c1626d1b99a4a7ccc62028156
2021-03-24 01:13:10 -07:00
Janis Danisevskis
fd5cba4483 Keystore 2.0: Add onDeviceOffBody to AndroidKeyStoreMaintenance.
Also have KeyStore.onDeviceOffBody call
AndroidKeyStoreMaintenance.onDeviceOffBody.

Test: N/A
Bug: 171305684
Change-Id: I0b01764bfc4c5828d17ccfffb4f8dad5f3bcea6d
2021-03-23 19:18:55 -07:00
Max Bires
68ebc12979 Fixing array cast.
This fix properly casts the Certificate[] returned by KeyStore to an
X509Certificate.

Bug: 182825370
Test: atest GtsGmscoreHostTestCases
Change-Id: If1e7cbbe612217b92067f76f8d13d1a0002e1579
2021-03-23 09:15:31 -07:00
Janis Danisevskis
68570cc5a7 Keystore 2.0: Add @IntDef for Keystore namespaces.
Bug: 182914789
Test: N/A
Change-Id: Ibdfd2a4a37d7200317ef449ef857f34401625237
2021-03-22 17:43:32 -07:00
Janis Danisevskis
f3064ba0b3 Keystore 2.0: Update to canonical service name.
Bug: 179907868
Test: N/A
Change-Id: I74adab04bd84f120bc547011151ea77769b6bda9
2021-03-22 14:57:28 -07:00
Janis Danisevskis
8875f872de Keystore: Fix Device ID attestation test.
Test: atest android.keystore.cts.KeyAttestationTest#testDeviceIdAttestation
Bug: 182606921
Change-Id: Ie8dbc4a2829fb7f70188c5d903e748060c5869ce
2021-03-20 21:29:21 -07:00
Janis Danisevskis
8758b2ceaf Keystore 2.0: Fix infinit recursion.
Fix endless recursion when Cipher is initialized with
AndroidKeyStorePrivateKey.

Fixes: 183167349
Test: atest android.keystore.cts.AndroidKeyStoreTest#testKeyStore_Encrypting_RSA_NONE_NOPADDING
Change-Id: I5b4166fb1a4e298072f7156ba61a64966e86dc53
2021-03-19 08:09:34 +00:00
Treehugger Robot
be1b1d5550 Merge "Keystore 2.0: Fix diagnosing invalid key in CipherSpiBase." 2021-03-18 23:46:37 +00:00
Janis Danisevskis
0b66a19bdd Keystore 2.0: No longer install the legacy provider.
The legacy provider is obsolete now that all calling code has
been fixed.

Bug: 183100147
Bug: 183093711
Bug: 171305684
Test: N/A
Merged-In: I0d71d3c9cdd586a508827eb26120c872cb8643ea
Change-Id: I0d71d3c9cdd586a508827eb26120c872cb8643ea
2021-03-18 20:24:39 +00:00
Janis Danisevskis
0b858aef63 Keystore 2.0: Fix diagnosing invalid key in CipherSpiBase.
Bug: 183101158
Test: atest CtsLibcoreTestCases:com.android.org.conscrypt.javax.crypto.CipherBasicsTest#testAeadEncryption

Merged-In: Idc9c7dc2614a47818227a06fe76078f72c0c1f57
Change-Id: Idc9c7dc2614a47818227a06fe76078f72c0c1f57
2021-03-18 19:41:56 +00:00
Janis Danisevskis
53ed9207a7 Keystore 2.0: Remove hidden Keystore API from locksettings tests.
Test: N/A
Bug: 171305684
Change-Id: I6fd90c29dd1fb077c25f1bd428fb8adf9782330e
2021-03-15 18:33:46 -07:00
Hasini Gunasinghe
e92adf724b Keystore2: Integrate getState method of IKeystoreMaintenance AIDL.
Bug: 176123105
Test: TBD
Change-Id: I8bc6bf219f7c4bb3722c310debcc8a276d14ed98
2021-03-12 00:07:44 +00:00
Treehugger Robot
721f75ec5a Merge "Keystore 2.0: Rename KeystoreUserManagement KeystoreMaintenance" 2021-03-11 11:20:11 +00:00
Janis Danisevskis
7a46c3c1fd Merge "Modify AttestationUtils to use public Keystore API" 2021-03-11 06:47:41 +00:00
Janis Danisevskis
274a93e953 Keystore 2.0: Fix TODOs in public doc comments.
Bug: 174580379
Test: N/A
Change-Id: If893c408156b2481a22730de22f1a7ba391d88eb
2021-03-10 11:22:22 -08:00
Janis Danisevskis
7160506468 Keystore 2.0: Rename KeystoreUserManagement KeystoreMaintenance
Test: N/A
Change-Id: I252f75fc6d918029ef682c20edb3fb667ebaf8db
2021-03-08 09:27:41 -08:00
Shawn Willden
0306b1ced8 Modify AttestationUtils to use public Keystore API
AttestationUtils calls directly into keystore1 to generate ID
attesations.  This needs to change prior to keystore2 being enabled
and keystore1 deleted.  This CL changes the AttestationUtils to use
the public API (and one SystemAPI method) to generate ID attestations,
allowing the lower layers to handle the transition between keystore1
and keystore2.

Test: CtsKeystoreTestCases
Change-Id: I64a230b9983cc90767a60d6e7cf2abcf5dfb0108
2021-03-08 09:52:33 -07:00
Treehugger Robot
492ab3dd2c Merge "Keystore 2.0: Silence common error on operation abort." 2021-03-08 14:10:27 +00:00
Janis Danisevskis
421c5739ea Merge "Keystore 2.0: Make VPN Keystore 2.0 ready." 2021-03-05 02:57:34 +00:00
Janis Danisevskis
051d7668f7 Keystore 2.0: Silence common error on operation abort.
Test: N/A
Change-Id: I7c85ae881165bc77d836624bfe20251b971d4479
2021-03-04 15:48:12 -08:00
Shawn Willden
c7de4a237a Fix subject in self-signed certificates.
Bug: 180620122
Test: atest -c CtsKeystoreTestCases:android.keystore.cts.KeyPairGeneratorTest#testGenerate_EC_ModernSpec_Defaults
Change-Id: Ib74a3f0cea81faf741d49d868739cbedda77e8df
2021-03-04 12:21:17 -07:00
Janis Danisevskis
8cd7953577 Keystore 2.0: Make VPN Keystore 2.0 ready.
* Use public stable API to load certificates from keystore.
* Also use grants to allow racoon to use keystore keys without
  special exceptions in keystore.
* Use LegacyProfileStore instead of Keystore for storing VPN profiles.

Bug: 175068876
Bug: 171305607
Test: atest android.net.cts.Ikev2VpnTest
      atest android.net.cts.IpSecManagerTest
      atest com.android.server.connectivity.VpnTest
      atest com.android.server.ConnectivityServiceTest
Merged-In: I27975113896ea137260a9f94a34fb1c3ca173fe3
Change-Id: I27975113896ea137260a9f94a34fb1c3ca173fe3
2021-03-03 22:14:41 -08:00
Dmitry Dementyev
dbf8a7c1bd Merge "Migrate recoverablekeystore to KeyStore V2." 2021-02-26 06:13:35 +00:00
Janis Danisevskis
a51a74a8c5 Merge "Keystore 2.0: Clear Uid/Namesapce" 2021-02-26 03:04:30 +00:00
Dmitry Dementyev
16491e1316 Migrate recoverablekeystore to KeyStore V2.
Test: manual
Bug: 171305545
Change-Id: Id415be48cab6852df155b5b2dbaf941ef54cd5a4
2021-02-25 16:42:15 -08:00
Janis Danisevskis
d5dd5ebaed Keystore 2.0: Clear Uid/Namesapce
Implement uid/namespace clearing for Keystore 2.0.

Test: Verified that keys get deleted when an app gets uninstalled.
Change-Id: I1b0b65e977177a6e34c500b00b5070ec18be2671
2021-02-25 09:30:44 -08:00
Janis Danisevskis
7e06904734 Keystore 2.0: Add keystore engine grant string convenience functions.
This patch adds function for and end decoding grant identfiers as
understood by the keystore boringssl engine.

Test: N/A
Change-Id: I619d8f460163e6270e41da81ca549efb71138113
2021-02-23 14:42:13 -08:00
Janis Danisevskis
0cdf262ee5 Keystore 2.0: Remove attestKey from KeyChain.
KeyChain supports device id attestation through KeyGenParameterSpec now.
No need to call attest key individually. Also calling attest key
individually is no longer supported by Keystore 2.0 and KeyMint.

Also isBoundKeyAlgorithm returns true.

Test: atest FrameworksServicesTests:DevicePolicyManagerTest
Bug: 171305387
Merged-In: I759fe245b48fe435153fded2c74c9ae99634c146
Change-Id: I759fe245b48fe435153fded2c74c9ae99634c146
2021-02-23 14:41:49 -08:00
Treehugger Robot
75025c5b62 Merge "Keystore 2.0: Fix correct handling of Uid/Namespace" 2021-02-22 23:35:21 +00:00
Janis Danisevskis
fa1a21957c Keystore 2.0: Fix correct handling of Uid/Namespace
AndroidKeyStoreKeyPairGeneratorSpi used the Uid as namespace which is
wrong, and ParcelableKeyGenParameterSpec inadvertently used the Uid as
namespace specifier during conversion.

Bug: 160623310
Test: com.android.keychain.tests.BasicKeyChainServiceTest#testGenerateKeyPairErrorsOnBadUid
Change-Id: I84b4c69c639e42922449e00a3708cef89b82f63e
2021-02-22 12:55:35 -08:00
Treehugger Robot
08bf2e8f49 Merge "Keystore 2.0: Revisite Authorization.java" 2021-02-20 19:26:58 +00:00
Hasini Gunasinghe
13dd61336f Integrate IKeystoreUserManager aidl with LockSettingsService.
This CL introduces the client side for IKeystoreUserManager aidl and
integrates it with the LockSettingsService.

Bug: 171305115
Test: TBD
Change-Id: I7560e98f95aaec6b85cdcfc01ba83aea0ccc52ae
2021-02-19 15:34:10 -08:00