444 Commits

Author SHA1 Message Date
Bartosz Fabianowski
92e8cfd21d Add device id attestation
This adds a new public API for attesting the device's hardware ids
(e.g. serial number and IMEI).

Bug: 34597337
Test: CTS CtsKeystoreTestCases and GTS DeviceIdAttestationHostTest

Change-Id: I2e9c1b4f8eb24afa4a09c71c137ce33a6b87eb27
2017-01-25 04:47:15 +01:00
Crystal Qin
eb30e64f3f Add new key purpose Wrap Key to KeyProperties.java and
KeymasterDefs.java.

Test: There will be a CTS test CL submitted together.
Change-Id: Ic60c3efc451cd7cbb04689b3d7bf9d607fae6c1f
2017-01-19 21:02:10 -08:00
Shawn Willden
dea6614603 Test for null context in getPrivateKey
In N, passing a null context to getPrivateKey provoked a
NullPointerException, which is validated by a CTS test. In commit
28d68b1 this behavior was changed (inadvertently, I believe) causing
getPrivateKey to wrap the NPE in a KeyChainException. This CL restores
the previous behavior, fixing the test and avoiding breaking any apps
that were catching the NPE.

Test: Fixing broken test
Change-Id: Icb0c75b03efc478b7310998cf3e7108a2c419107
2016-11-16 06:06:36 -07:00
Jeff Sharkey
0a17db1cc5 Detect non-oneway calls leaving system_server.
To protect system stability, any Binder calls leaving the
system_server must carefully be performed using FLAG_ONEWAY (or
the 'oneway' verb in AIDL) which prevents the call from blocking
indefinitely on the remote process.

In this CL, the system_server uses the new Binder.setWarnOnBlocking()
method to enable detection by default for all remote Binder
interfaces.  It can also use Binder.allowBlocking() to allow
blocking calls on certain remote interfaces that have been
determined to be safe.

This CL adds the 'oneway' verb to several interfaces and methods
where it should have been added, and marks a handful of system
ContentProviders as being safe to call into.  Also, we assume that
any services obtained from ServiceManager are part of the core
OS, and are okay to make blocking calls to.

Test: builds, boots, runs with minimal logs triggered
Bug: 32715088
Change-Id: Ide476e120cb40436a94b7faf7615c943d691f4c0
2016-11-07 17:03:37 -07:00
Tucker Sylvestro
7f99db4e63 Add the onDeviceOffBody API method to KeyStore am: b32aae2a46
am: 8f75adc624

Change-Id: Ib8d7bc19a167999894b90b45e7eb1cadb2a85d24
2016-10-06 16:20:19 +00:00
Tucker Sylvestro
8f75adc624 Add the onDeviceOffBody API method to KeyStore
am: b32aae2a46

Change-Id: Idbf7f1d505b1d446a3d648dcf1b0f334a629110a
2016-10-06 16:13:48 +00:00
Kevin Hufnagle
c8d45456bd docs: Fixed broken link to Android KeyStore facility am: c0c4ac5e35 am: 507a5c03da
am: f4ac919849

Change-Id: I20e5abdffd9ac4fd8b4164ef56c1b3bafb58ad2b
2016-09-27 02:06:09 +00:00
Kevin Hufnagle
f4ac919849 docs: Fixed broken link to Android KeyStore facility am: c0c4ac5e35
am: 507a5c03da

Change-Id: Iec80ad1c7127efb7e257be0625988ef1b2588b0f
2016-09-26 23:47:39 +00:00
Tucker Sylvestro
b32aae2a46 Add the onDeviceOffBody API method to KeyStore
This is necessary for allowing the KeyStore to lock keys that remain
authorized as long as the device is on-body.

Bug 28911985

Change-Id: If50bc84d5a1cb23f9b01b1950c3676d1519cc4f5
2016-09-23 15:11:42 -04:00
Kevin Hufnagle
c0c4ac5e35 docs: Fixed broken link to Android KeyStore facility
Bug: 13663279
Change-Id: I859b3c9a35f9e6c63cb0c29260f4aa1aa33ab15c
2016-09-19 11:31:08 -07:00
Rubin Xu
8910bf2ca0 Merge "Handle null packageName in PendingIntentRecord" into nyc-mr1-dev am: 6acd5e7361 am: 2f6eecbed0
am: f38514ccd6

Change-Id: I1071a92b4ff74a57bf94c9b6aad9df4fb3852072
2016-08-23 22:29:15 +00:00
Robin Lee
c378aabdda Documentation warning against short-lived Contexts
am: da23618043

Change-Id: Ie6e4c05d8d9a273f0f529c2be79f3df4a856fedb
2016-08-23 16:09:41 +00:00
Robin Lee
4f7d56a706 Force application context for KeyChain bindings
am: f04a663d6a

Change-Id: I16c31a9c31527a79addbd2b44003f8fe56cb652f
2016-08-23 16:06:39 +00:00
Robin Lee
da23618043 Documentation warning against short-lived Contexts
It's better to use an Application Context rather than hoping the
activity won't be destroyed in another thread (because it will).

Change-Id: I9bf842d0d7dbedcc509a4a314d23a9a6cfca4d48
Fix: 29873669
2016-08-23 12:47:54 +00:00
Shawn Willden
e5d71c4cfa Fix @link tags in keystore doc am: 3f0526ea09
am: 9e8b4ad9c9

Change-Id: Iadb16bd13d4bb525805dd0266aea046c4c472309
2016-08-09 19:38:00 +00:00
Shawn Willden
3f0526ea09 Fix @link tags in keystore doc
Bug: 30258412
Change-Id: I370a53ebad29ff0471e4b7776cd76b2530efe760
(cherry picked from commit 9739d48a2101e49b0936096d69c29006f9acdeb5)
2016-08-02 16:45:06 +00:00
TreeHugger Robot
1c23ed9601 Merge "Fix @link tags in keystore doc" 2016-08-01 23:49:53 +00:00
Robin Lee
28d68b1456 Unbind from KeyChainService before RPCing to keystore
This leaves the binder connection open for far too long, which keeps
the keychain app alive longer than necessary.

Bug: 29873669
Change-Id: I037c2b91400202ba6a474819867df16b6342ec0d
2016-07-27 11:11:13 +01:00
TreeHugger Robot
bea9e036f5 Merge "Fix incorrect @link in ACTION_STORAGE_CHANGED comment" 2016-07-25 23:08:57 +00:00
Chad Brubaker
dbf01c12d0 Fix incorrect @link in ACTION_STORAGE_CHANGED comment
Change-Id: Ibfca8651a55e32e9caed96b04e5a40dc6ebc3019
2016-07-25 14:54:39 -07:00
Robin Lee
f04a663d6a Force application context for KeyChain bindings
Bug: 29873669
Change-Id: I68c11ab19a169498045bbc23bc8fe6a2f46be031
(cherry picked from commit 43e235c0d55fce8ff845c0249a414a1b2daa5b10)
2016-07-25 17:35:12 +00:00
Robin Lee
43e235c0d5 Force application context for KeyChain bindings
Bug: 29873669
Change-Id: I68c11ab19a169498045bbc23bc8fe6a2f46be031
2016-07-25 16:09:22 +01:00
Shawn Willden
9739d48a21 Fix @link tags in keystore doc
Bug: 30258412
Change-Id: I370a53ebad29ff0471e4b7776cd76b2530efe760
2016-07-21 10:11:09 -06:00
ewol
cde8c47be6 Merge \\"Fix a broken case of AndroidKeyStoreProvider error logging\\" into nyc-mr1-dev am: 45b8216d33
am: 4beff1fc13

Change-Id: I0e547655e9a10572be341db50976c66ae493d021
2016-07-19 18:01:29 +00:00
Erik Wolsheimer
292d291fa7 Fix a broken case of AndroidKeyStoreProvider error logging
BUG: 30117950
Change-Id: Ib9985493a08d721021d777e0e4a4d67511f190a5
2016-07-15 11:22:25 -07:00
Chad Brubaker
721afae8f1 Mention target API limits for ACTION_STORAGE_CHANGED
Bug: 28450538
Change-Id: I9c69f9d0bdda5b69aec2dc3014a612d84082dc64
2016-07-08 11:06:09 -07:00
Chad Brubaker
4de59ef323 Deprecate ACTION_STORAGE_CHANGED
ACTION_STORAGE_CHANGED is too noisy and fires on too many events. It has
been split into ACTION_KEYCHAIN_CHANGED for
addition/modification/removal of user certificates and keys,
ACTION_TRUST_STORE_CHANGED for changes the the user added and system CA
stores on the device and ACTION_KEY_ACCESS_CHANGED for changes to key
grants.

ACTION_STORAGE_CHANGED will only be sent to applications targeting N
and below. Applications targeting future releases should use the new
broadcasts.

Bug:28450538
Change-Id: I34ff838e9858db65f7308ca2b0f7d652c48fae17
2016-06-30 09:23:15 -07:00
Amith Yamasani
d04aaa323c More thorough cleansing of expired users
If any /data/system_[c|d]e folders were not erased
when the user was removed (maybe due to a reboot),
make sure they're cleaned up on restart as well
as when the userId is recycled later.

Mark the users' system folders with the correct
serial number for later verification.

AccountManager shouldn't be querying accounts of
partially created/destroyed users.

Change-Id: I4313756b7464f34cd5ce4fb296d61daa50b41fcb
Fixes: 29285673
2016-06-15 11:32:16 -07:00
Shawn Willden
26e8d553e5 Update semantics of on-body Keystore API.
Architectural changes from the Wear team have required changes to the
semantics of the Keystore on-body feature. Although no devices will
actually implement this feature until the release of new Wear devices
with the necessary sensors, we need to get the API documentation right
now.

Bug: 29369151
Change-Id: I857e00928f994a1337313123eae7e00534c53c3c
2016-06-14 17:29:54 -06:00
Shawn Willden
5e018c04a6 Unbreak Javadoc on getAttestationChallenge()
Bug: 28844154
Change-Id: I8402a39f366291cd2b5d646536cd2c2bab8556d2
2016-06-14 17:00:25 -06:00
Trevor Johns
682c24e228 Resolve merge conflicts of a5060ee to nyc-dev
This undoes the automerger skip which occured in
commit e740c84dc32180214a7fd157105d6c18d30408ee and
replays it as a standard (NOT -s ours) merge.

Change-Id: If5a47be26f73d6a0735c425cd66310a3e2a89086
2016-04-19 02:03:59 -07:00
Rubin Xu
b436591708 Add DevicePolicyManager API to install a client cert chain.
When installing a keypair the caller will have the option to specify a
certificate chain which will later be returned to whoever requests access
to the keypair via KeyChain.

Bug: 18239590
Change-Id: Id21ef026e31537db38d891cb9b712dd4fe7159c7
2016-03-30 11:57:58 +01:00
Kenny Root
f78cae3cb4 Use canonical name for SHA1withECDSA
The Standard Names documentation says that "ECDSA" should not be used
due to its ambiguity. Bouncycastle has switched from "ECDSA" to
"SHA1withECDSA" so therefore we should switch this "workaround" Provider
to use the same name to keep it functioning correctly.

(cherry picked from commit 8a6c191094b3d1f74dbb71a7f262496377596ba8)

Bug: 27753949
Change-Id: I5acfca9d89c85bf005902a2f06cb5d7b1ef9dff2
2016-03-23 14:29:33 -07:00
Robin Lee
7854d58392 Merge "Guard against null component when binding KeyChain" into nyc-dev 2016-03-03 19:11:37 +00:00
Robin Lee
21bcbc54dd Guard against null component when binding KeyChain
If keychain is removed from a device, there will be no sensible
resolution and client apps will bind to whatever is available.

Doesn't affect system apps which are forcibly prevented from wildcard
binding.

Bug: 27475655
Change-Id: Ide1aab3778e12f0b9a96662deb297a76d2f4997f
2016-03-03 18:57:32 +00:00
Robin Lee
e4487ea288 More sensible return code for Credentials.deleteAll
Was: result = True iff nDeleted != 0
Now: result = True iff nDeleted == nExisted

The most common reason you'd want to delete all credentials under an
alias is to be sure they no longer exist. The new contract gives a
way to do this without multiple IPCs to the same service.

Bug: 27335182
Change-Id: I8762b9b4fcc48037387dd805dbd0dbbe141d5b24
2016-03-01 18:56:14 +00:00
Shawn Willden
c38eae5229 Revert "Revert "Add option to allow key validity after fingerprint enrollment.""
This reverts commit 512c132f49fc6e8e4fc119f4cf167d33b2393509.

Change-Id: Iac381dfebcfe42f0468569eb2395ebeb97a95887
2016-02-22 20:38:00 -07:00
Shawn Willden
512c132f49 Revert "Add option to allow key validity after fingerprint enrollment."
This reverts commit ada0fc1b05902b11401094b15480377d1b6c5a35.

Change-Id: I934b6e6af49ab680af726c544f0193dfcb80054e
2016-02-22 22:59:34 +00:00
Shawn Willden
ada0fc1b05 Add option to allow key validity after fingerprint enrollment.
Bug: 21563854
Change-Id: I4f601e59fbfcd601e6a80ddcbc7b83ced6cc18c8
2016-02-18 15:13:50 -07:00
Shawn Willden
adef49640d Add support for extending key validity while on body.
Bug: 21563854
Change-Id: I3b622d2af77ec4ac3ba42407fc391112c153ef0f
2016-02-18 05:50:21 -07:00
Shawn Willden
8d8c747774 Add attestation API to Android KeyStore.
Bug: 22914603
Change-Id: I7c6162dc7a390aa48a2542494780959b01c23bd4
2016-02-08 19:29:54 +00:00
Alex Klyubin
bd0d4265bb Merge "Fix typo in KeyInfo Javadoc." am: e8fbc20e12
am: b21416e287

* commit 'b21416e2875973706d8b922428225194d9625875':
  Fix typo in KeyInfo Javadoc.
2016-02-05 22:37:31 +00:00
Alex Klyubin
d9dded5a46 Fix typo in KeyInfo Javadoc.
Change-Id: I801005a93aee71b93b3d6cf3f7c38361493ff203
2016-02-05 14:18:19 -08:00
Neil Fuller
9498e8a8d2 Fix @code escapes
The body of {@code} must not be HTML escaped. This is one of
several changes that fix the source in conjunction with a
doclava fix.

Bug: 25757239
(cherry-picked from commit 71fbb81b14958b80fe55738607740c6630e4e9da)

Change-Id: I19dafddc6501be6fee362c396ac5bbdc934ae39d
2016-01-15 16:14:57 +00:00
Robin Lee
3a435f0390 Return null on getPrivateKey failure not exception
According to documentation:

Returns the {@code PrivateKey} for the requested alias, or null if
there is no result.

@throws KeyChainException if the alias was valid but there was some
problem accessing it.

@throws IllegalStateException if called from the main thread.

In this case the alias doesn't exist or isn't visible to the caller so
they should get null back instead of KeyChainException.

Change-Id: Ied5603ac6aefbcef79050f24c2aa7ee8f386be0b
2015-12-21 12:09:20 +00:00
Robin Lee
fbc65644b9 DevicePolicy API to remove an installed KeyPair
The keypair is specified by alias and removed via a call to the
KeyChainService, which will have installed the pair in the first place.

Bug: 22541933
Change-Id: I37317e7c22e89816156e6e9a7abf4c5a59e8440a
2015-12-08 16:40:56 +00:00
Neil Fuller
71fbb81b14 Fix @code escapes
The body of {@code} must not be HTML escaped. This is one of
several changes that fix the source in conjunction with a
doclava fix.

Bug: 25757239
Change-Id: Ib38a0fa2dd2a3d68e467f78a812071e763d7e881
2015-12-02 14:24:11 +00:00
Alex Klyubin
7b0b9a1351 Merge "Custom engineUpdate/engineDoFinal(ByteBuffer, ByteBuffer)." am: e766e399c5 am: 4bc1904119
am: 0540e1b127

* commit '0540e1b127e03ecc97c32719ac79769d69c16aec':
  Custom engineUpdate/engineDoFinal(ByteBuffer, ByteBuffer).
2015-11-25 19:23:55 +00:00
Alex Klyubin
d976c5a4ee Custom engineUpdate/engineDoFinal(ByteBuffer, ByteBuffer).
This makes Android Keystore's Cipher implementation use a custom
implementation of engineUpdate(ByteBuffer, ByteBuffer) and
engineDoFinal(ByteBuffer, ByteBuffer). The implementation is
explicitly designed around the fact that Android Keystore transmits
input and receives output via Binder and thus there's no need to
attempt any optimizations to avoid copying input and output.

Bug: 25863382
Change-Id: I311072891f02f5e7a283628b51b8d6058b55231c
2015-11-24 17:22:27 -08:00
Alex Klyubin
8f49178b8f Merge "Insert Android Keystore JCA Provider at the correct position." am: 887d348d7e am: 5995579f5f
am: 00245ffce4

* commit '00245ffce4d08fbb6aeaeba62b8a30ce234862fa':
  Insert Android Keystore JCA Provider at the correct position.
2015-11-17 23:14:38 +00:00