Commit Graph

204 Commits

Author SHA1 Message Date
Chad Brubaker
5813bc2b22 Merge "Add owners for the network security config" am: 8773730cd9 am: e9d50c793a
am: 531f1af615

Change-Id: I77240a60f796c63acd640b8a43cb7054ad2a8bee
2017-08-02 17:41:21 +00:00
Chad Brubaker
e9d50c793a Merge "Add owners for the network security config"
am: 8773730cd9

Change-Id: I18b8aac4c1ac85bde3e6735e1afe6375f5c0e177
2017-08-02 17:20:16 +00:00
Chad Brubaker
1ec48fc770 Add owners for the network security config
Test: build/make/tools/checkowners.py -c -v OWNERS
Change-Id: I9bb8f5ceaae4a1af8c93f5416a6a5cea42915c62
2017-08-01 15:50:22 -07:00
Janis Danisevskis
6396ccb82e Refurbish granting mechanism
Keystore stores key blobs in with filenames that include the symbolic
name and the uid of the owner. This behaviour should have been
completely opaque to the user keystore. However, the granting mechanism,
by which an app can allow another app to use one of its keys, leaked the
internal structure in that the grantee had to specify the key name with
the granter's uid prefix in order to use the granted key. This in turn
collided with prefix handling in other parts of the framework.

This patch refurbishes the granting mechanism such that keystore can
choose a name for the grant. It uses the original symbolic key name as
prefix and appends _KEYSTOREGRANT_<grant_no> where the grant_no is
chosen as first free slot starting from 0. Each uid has its own grant_no
space.

This changes the grant call such that it now returns a string, which is
the alias name of the newly created grant. The string is empty if the
grant operation failed.

As before apps can still mask granted keys by importing a key with the
exact same name including the added suffix. But everybody deserves the
right to shoot themselves in the foot if they really want to.

Bug: 37264540
Bug: 62237038
Test: run cts-dev --module CtsDevicePolicyManagerTestCases --test
          com.android.cts.devicepolicy.DeviceOwnerTest#testKeyManagement
	  because it grants a key
Merged-In: I047512ba345c25e6e691e78f7a37fc3f97b95d32
Change-Id: I047512ba345c25e6e691e78f7a37fc3f97b95d32
2017-07-23 09:39:04 -07:00
Bartosz Fabianowski
237f4b369b Add device ID attestation method to keymaster
Device ID attestation consists of three steps:
* Generate a temporary key
* Attest the key and desired device IDs
* Delete the temporary key

Rather than being spread over three keymaster APIs, these operations
should happen automatically in a single keymaster method.

Bug: 34734938
Test: GTS com.google.android.gts.security.DeviceIdAttestationHostTest

Change-Id: Ifabb5163b9e4d12cb309a6b0ca8e5f2f92d212f4
2017-04-26 17:40:44 +02:00
Bartosz Fabianowski
ad60c0615f Add manufacturer and model to device ID attestation
Discussions have shown that in addition to brand, device and product,
we should also allow devices to attest their manufacturer and model.

Bug: 36433192
Test: GTS com.google.android.gts.security.DeviceIdAttestationHostTest

Change-Id: Idd48929d6a0c9fe6656c6d2656e2c3f6f370a21e
2017-03-20 14:00:25 +01:00
Frank Salim
66925ecc64 Revert "Add new key purpose Wrap Key to KeyProperties.java and"
This reverts commit eb30e64f3f.

Reason for revert: Remove partial support for wrapped key import

Test: CTS tested
Change-Id: I8008494860534257fa983e1a5169d0ed034621f7
2017-03-02 11:16:09 -07:00
Todd Kennedy
11e4507522 Define targetSandboxVersion
The new attribute allows both ephemeral and non-ephemeral apps to
opt into a new, tighter security model.

Test: Manual; built app w/ targetSandboxVersion and verified the security domain
Change-Id: I8fcaf84e25f0519b438ba51302f79790e680e025
2017-01-30 14:47:30 -08:00
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
Chad Brubaker
b8feba10f4 Default to not allowing cleartext traffic for ephemeral apps
Test: NetworkSecurityPolicy.isCleartextTraffic permitted returns the
expected defaults.
Change-Id: I7d6577f8461bbf1f44eb21b4d813dba1746449fa
2016-12-07 13:17:41 -08: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
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
Chad Brubaker
d2b2968e1d Avoid NPE on certificates that cannot be read am: 01e9682cab am: 92a534325d
am: 94c395549a

Change-Id: Ifc5c8aa90255b46564225c1cfbc2d96f640ce2f7
2016-09-06 21:49:40 +00:00
Chad Brubaker
94c395549a Avoid NPE on certificates that cannot be read am: 01e9682cab
am: 92a534325d

Change-Id: Ie650d94e36498c78ca7c2e49d75510966c351b16
2016-09-06 21:44:54 +00:00
Chad Brubaker
01e9682cab Avoid NPE on certificates that cannot be read
Skip certificates in a DirectoryCertificateSource that cannot be read to
due IOExceptions or CertificateExceptions, this prevents a NPE but
connections will still fail due to the certificate being unusable and no
valid trust-anchor existing.

This also logs the error since this really shouldn't happen.
Bug: 29997695

Change-Id: I9f7327efc302a259fb951f1f61f7fc4d647821fa
2016-09-02 13:15:39 -07:00
Janis Danisevskis
8ff1e193ac Add KeyAttestationApplicationIdProviderService to SystemServer
Add getKeyAttestationApplicationId and the Parcelables
KeyAttestationPackageInfo and KeyAttestationApplicationId,
needed by keystore.

Bug: 22914603
Change-Id: I89a88cd9cd80e9b132ca67fc452e9cae8b8ad241
2016-08-19 13:50:55 +01:00
Chad Brubaker
495f3f5d99 Merge "Add stub isCTVerificationRequired methods" am: 5b63231a31 am: 6e1f860c6a am: 10943c69a2
am: 46c354f75c

Change-Id: If5da76eebffea8c0be8995422d62694f622a337a
2016-08-09 20:10:01 +00:00
Chad Brubaker
6e1f860c6a Merge "Add stub isCTVerificationRequired methods"
am: 5b63231a31

Change-Id: Ica40dc0da1821aa47825e615f0f3b629e0358568
2016-08-09 19:43:50 +00:00
Chad Brubaker
bd62098a54 Add stub isCTVerificationRequired methods
Bug: 28746284
Change-Id: Iebeecba7356ac57fedb06d71de63aa9900f2ccd8
2016-08-02 07:57:16 -07:00
Chad Brubaker
c72875b01e Update trusted certificates when the trust store is changed
This CL flushes the trusted cert cache of all active Network Security
Configs and their TrustManagers. Previously CA addition mostly worked
however removed CAs would remain cached in the X509TrustManager causing
the removed CA to still be trusted.

Change-Id: I0f5fd39932f8f8ed3ec5dfd088a82e982b366c43
2016-06-30 09:23:23 -07:00
Chad Brubaker
9f779ab4af Add getApplicationConfigForPackage
getApplicationConfigForPackage will be used by system components that
need to make connections for apps, e.g. DownloadManager, so that their
secure connections have the same configuration as those from the app
itself.

Bug: 29505888
Change-Id: Idf1cac6307431911eda34529d3fd50f9ca0da314
2016-06-20 12:40:20 -07:00
TreeHugger Robot
c738e48ed6 Merge "Use NoPreloadHolder for certificate sources" into nyc-dev 2016-06-14 00:35:49 +00:00
Chad Brubaker
319f9fe102 Use NoPreloadHolder for certificate sources
The static instances of SystemCertificateSource and
UserCertificateSource depend on the current user, avoid triggering their
static initializer when preloaded.

Bug: 29258379
Change-Id: I5088366ae67145b8bc928d6c04118529c82a7fc3
2016-06-13 15:51:40 -07:00
Chad Brubaker
c3a6c78fed Don't depend directly on AppplicationInfo
ApplicationInfo is mutable and unfortunately some apps do actually
modify the flags. Due to the lazy loading nature of the network security
config this may lead to issues. Instead cache the needed flags and
resources at application startup.

Bug: 29063413

(cherry picked from commit 276ee969be)

Change-Id: If638a716fd903b4e9dbabcbecb38bd4e26fef08c
2016-06-08 21:48:45 -07:00
Chad Brubaker
c845b2a21c Use an attribute for the network security config resource
Originally we went with the meta-data approach to make unbundling
easier, however with the amount of platform changes that the config
ended up relying on it would be better to focus on exposing it through
the platform.

Bug:28763009
Change-Id: Iaf80001b1980220cd2e1e05faf2dc86af41700e1
2016-05-19 17:25:41 -07:00
Chad Brubaker
d4b6c696e1 Support TrustedCertificateStore.findAllIssuers
(cherry-picked from commit aa6c3c3e25)
Change-Id: I176ec42c9907e50ee218e4fb352b530ca797be46
2016-05-12 11:15:47 -07:00
Chad Brubaker
00a4e29969 Fix isUserAddedCertificate
Check if the CA is in the user store directly instead of delegating to
the TrustManager. This removes one more reflection dependency between
X509TrustManagerExtensions and the default X509TrustManager.

Bug: 28138736
Change-Id: I16c17bf6230becdc0a1948b1d184212f83ee25f0
2016-04-13 10:20:08 -07:00
Chad Brubaker
5116ac0d22 Add implemention for isSameTrustConfiguration
Bug: 27672565
Change-Id: Id5291a4a5f2ca75fdf84db4d51363735f1a76845
2016-04-12 13:04:43 -07:00
Chad Brubaker
0f5d386a76 Use X509ExtendedTrustManagers
Move the X509TrustManagers for the Network Security Config from
X509TrustManagers to X509ExtendedTrustManagers.

Bug: 27271561
Change-Id: I084a6c6022fe69730192d2bdcbabaf58e8f92f04
2016-03-28 10:48:41 -07:00
Chad Brubaker
bf9a82a643 Add handleTrustStorageUpdate
This pruns all the stored trusted issuers so that changes to the system
or user CA store are detected. Currently this is only exposed as a
TestApi, but it can be hooked up to the trusted storage change event
in a future commit.

Bug: 27526668
Change-Id: Ic426254babab9a3177c968bc05b45e95eaac1fdd
2016-03-25 14:48:44 -07:00
Chad Brubaker
7cc736da82 Properly handle whitespace in domain entries
Domain entries can contain whitespace (or newlines) which should be
ignored to avoid unexpectedly failing to match a domain.

Bug: 27816377
Change-Id: I3691aa4abd409e7be97ad0cf1eb0195725e1b0ab
2016-03-23 15:28:41 -07:00
Chad Brubaker
567f6f2474 Allow debug-overrides to be specified in an extra resource
An application can specify its debug-overrides in an extra resource with
the same name suffixed with "_debug" (e.g. res/xml/security_config.xml and
res/xml/security_config_debug.xml).

By specifying the debug-overrides in an extra file release builds can
strip out the file (and any certificate resources that the
debug-overrides depend on) to prevent including testing configuration
information in the release build of an application.

Bug: 27418003
Change-Id: Ibfebc376360ca474fc0f9f2fd565faa0cffd9549
2016-03-01 12:42:54 -08:00
Chad Brubaker
c1b0236d70 Merge "Dont trust the user added CA store by default for apps targeting N" into nyc-dev 2016-02-25 00:02:37 +00:00
Chad Brubaker
32d2a1024f Dont trust the user added CA store by default for apps targeting N
Android's security model is such that the applications data is secure by
default unless the application specifically grants access to it.
Application data in transit should have similar security properties.

Bug: 27301579
Change-Id: I72f106aefecccd6edfcc1d3ae10131ad2f69a559
2016-02-24 10:36:27 -08:00
Chad Brubaker
62df07eee1 Merge "Use provided context directly" into nyc-dev 2016-02-22 19:11:51 +00:00
Chad Brubaker
7879b8f4ab Use provided context directly
getApplicationContext may return null so use the provided context
instead.

Bug:27293859
Change-Id: Ic3b218bf5b0c23982c75a793f0374870bd8e9da1
2016-02-22 11:08:59 -08:00
Shawn Willden
0f900c02d9 Merge "Add support for extending key validity while on body." into nyc-dev 2016-02-18 12:51:50 +00: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
Chad Brubaker
da449afbfe Merge "Fix getAcceptedIssuers" into nyc-dev 2016-02-17 22:20:36 +00:00
Chad Brubaker
efb4f91bdb Fix getAcceptedIssuers
Delegating to the TrustManagerImpl doesn't work correctly with
getAcceptedIssuers, do it in NetworkSecurityTrustManager instead.

Bug: 27124116
Change-Id: Ie527d63aaa115e6137396e07c7d134b1c42bfe87
2016-02-17 10:31:14 -08:00
Shawn Willden
8d8c747774 Add attestation API to Android KeyStore.
Bug: 22914603
Change-Id: I7c6162dc7a390aa48a2542494780959b01c23bd4
2016-02-08 19:29:54 +00:00
Chad Brubaker
05dd853526 Merge "Support TrustedCertificateStore.findAllIssuers" 2016-01-26 23:49:00 +00:00
Chad Brubaker
d321954f72 Merge "Add getApplicationConfigForPackage" am: 7519dce8c2
am: 8500093a35

* commit '8500093a351c40fdd2077fcd724396f72b51d3ba':
  Add getApplicationConfigForPackage
2016-01-25 18:18:39 +00:00
Chad Brubaker
056e8b5a5a Add getApplicationConfigForPackage
This allows services which make network connections on behalf of
applications to honor the application's network security policy.

Change-Id: I562b7bd0eb20f2f8c9f8342c211166d4e3397780
2016-01-22 22:04:20 -08:00
Chad Brubaker
aa6c3c3e25 Support TrustedCertificateStore.findAllIssuers
Change-Id: I176ec42c9907e50ee218e4fb352b530ca797be46
2016-01-13 15:19:45 -08:00
Chad Brubaker
25e34339ba Unhide hostname aware isCleartextTrafficPermitted
Change-Id: Id2bde5889d963ca2820fdecce1628dce022b510b
2016-01-05 11:36:43 -08:00
Chad Brubaker
d8844613a3 Merge "Add ConfigNetworkSecurityPolicy" am: 2786002bd5
am: a35d617cce

* commit 'a35d617cce6c9b1b1cba7e7c786849d21ea42d3e':
  Add ConfigNetworkSecurityPolicy
2016-01-04 20:54:00 +00:00
Chad Brubaker
2786002bd5 Merge "Add ConfigNetworkSecurityPolicy" 2016-01-04 20:26:56 +00:00