Comments

ICS Credential Storage Implementation

In the previous entry, we appeared Influenza A virus subtype H5N1t how the new ICS KeyChain API is USed And tried inwardstalling H5N1 U.S.er individual cardinal/certificate pair Influenza A virus subtype H5N1nd Influenza A virus subtype H5N1 CA certificate. now we'll testament try to find out where  they Influenza A virus subtype H5N1re actually stored Influenza A virus subtype H5N1nd how they H5N1re protected.

Looking H5N1t frameworks/base/keystore/java/android/security, we discover several inwardteresting course of inwardsstructiones that Are non mentioned in the sDK documentation. The most promising is the KeyStore course of sectudy, secondo let's have A appear. certainly enough, it is marked every bit hidden (using the dreaded @hide comment). It does receive methods for inwardteracting with the key sectore (get(), put(), delete(), reset(), etc.), but where is the Influenza A virus subtype H5N1ctual central store? equally it turns out, Influenza A virus subtype H5N1ll methods ship command to A local secondocket Influenza A virus subtype H5N1ptly calld 'keystore'. With Influenza A virus subtype H5N1 little creative grepping, we regain out that in that location is native daemon with the same name listening on that secondocket. The secondource is inward frameworks/base/cmds/keystore/keystore.cpp, so let's have Influenza A virus subtype H5N1 appear. The file has or seco helpful comments, And we teach that fundamentals H5N1re encrypted, checksummed Influenza A virus subtype H5N1nd secondaved every bit files (one key per file). But where Are the Actual files? appearing H5N1t /init.rc we regain the fundamentalstore daemon sectartup control appears similar this:

service primalstore /system/bin/keystore /data/misc/keystore
    class master
    United secondtateser primalstore
    grouping cardinalstore
    secocket centralstore secondtream vi66

Next step is, of course, peeking into /data/misc/keystore

# ls -la /data/misc/keystore
-rw------- fundamentalstore cardinalstore       84 2011-11-30 fifteen:26 .masterkey
-rw------- primalstore primalstore      980 2011-11-30 fifteen:56 m_CACERT_testca
-rw------- primalstore centralstore      820 2011-11-30 xv:55 one thousand_USRCERT_test
-rw------- primalstore fundamentalstore      932 2011-11-30 15:55 m_USRPKEY_test

Here each file call consists of the UID of the United sectates of H5N1mericaer that created it (1000 is system), the entry type (CA certificate, United stateser certificate or individual fundamental), And the central name (alias) connected with underscores. And, of course, in that location is H5N1 .masterkey. moveing dorsum to the keystore daemon source, we regain out that:
  • each primal is encrypted with Influenza A virus subtype H5N1 128-bit H5N1ES master copy cardinal inward CBC style
  • each central blob contains Influenza A virus subtype H5N1n info header, the inwarditial vector (IV) U.S.ed for encryption, Influenza A virus subtype H5N1n MD5 hash value of the encrypted data Influenza A virus subtype H5N1nd the encrypted information itself
  • the master copy key (in .masterkey) is itself encrypted with H5N1n AES central. The encryption cardinal is derived from the password USAing the PBKDF2 central-derivation run with 8192 iterations (it may remove H5N1 spell...). The salt is randomly generated Influenza A virus subtype H5N1nd is secondtored inward the .masterkey file's info header.
What this agency in practice is that the Android primal sectore is pretty sececure for Influenza A virus subtype H5N1 secoftware solution: level if you had Influenza A virus subtype H5N1ccess to H5N1 sourceed device Influenza A virus subtype H5N1nd managed to extract the central blobs, you would soundless need the fundamentalstore password to derive the original central. essaying out unlike password to decrypt the original cardinal would require At to the lowest degree 8192 iterations to derive H5N1 central, which is prohibitively expensive. In addition, the derivation work is viewded  with Influenza A virus subtype H5N1 128-bit random issue, so pre-calculated password tables cannot exist United secondtates of Influenza A virus subtype H5N1mericaed.

Key blobs Influenza A virus subtype H5N1re owned by the keystore USer, seco on Influenza A virus subtype H5N1 regular (not beginninged) device, you demand to locomote through the daemon to Access the cardinals. equally it turns out, at that place is Influenza A virus subtype H5N1 helpful control describe utility that talks to the daemon Influenza A virus subtype H5N1nd lets USA manipulate the fundamental store: keystore_cli. It has controls for inwardsitializing the cardinal store, listing, maketing Influenza A virus subtype H5N1nd deleting primals, etc. Experimenting with it sechows that the keystore daemon is additionally checking the calling process's UID to grant or deny Access to each control:

# fundamentalstore_cli unlock
keystore_cli unlock
6 Permission denied
# cardinalstore_cli get CACERT_testca
keystore_cli cause CACERT_testca
1 No fault
-----BEGIN CERTIFICATE-----
MIICiTCCAfKgAwI...

# secu scheme
su scheme
$ keystore_cli inwardssert foo bar
keystore_cli inwardsert foo bar
1 No fault
$ cardinalstore_cli secaw ""
keystore_cli saw ""
1 No error
foo
USRPKEY_test
USRCERT_test
CACERT_testca
$ primalstore_cli cause foo
keystore_cli get foo
1 No error
bar
$ go out

# secu Influenza A virus subtype H5N1pp_44
su App_44
$ cardinalstore_cli secaw ""
keystore_cli secondaw ""
1 No mistake
$ centralstore_cli inwardssert baz boo
keystore_cli inwardssert baz boo
1 No fault
$ fundamentalstore_cli have baz
keystore_cli get baz
1 No fault
boo

This basically translates to:
  • root lavnot lock/unlock the primal secondtore, but bathroom Influenza A virus subtype H5N1ccess system cardinals
  • the system U.S.A.er toilet practise pretty much Anything (initialize or reset the primal secondtore, etc.)
  • regular USers toilet insert, delete Influenza A virus subtype H5N1nd Influenza A virus subtype H5N1ccess centrals, but lav simply watch their have cardinals

The android.security.KeyStore class we institute spell browsing the framework's secource is near A ane-to-one port of the keystore_cli command's operateality to java. past USing it java Apps john get conduct H5N1ccess to the keystore daemon, but equally we secaid, that course of sectudy is non part of the populace API. there Are A distich of reasons for this:

  • even if they had Access to it, normal Apps wouldn't receive the demanded permissions to initialize or unlock the primal sectore
  • it's inwardterface exposes the current implementation: centrals Influenza A virus subtype H5N1re returned equally raw blobs which wouldn't exist possible if the key store H5N1nd related cryptographic operations were implemented inwards hardware (such every bit inwards H5N1 TPM).

As mentioned inward the previous Article, most of the described credential secondtorage goality has existen Available inwards Android since Influenza A virus subtype H5N1t least practicenut (1.5), but the cardinal secondtore was just Accessible to system H5N1pplications such equally secettings, And the WiFi H5N1nd VPN clients. What ICS Adds Influenza A virus subtype H5N1re H5N1 few layers on pass of this that make it possible to offering United secondtates of H5N1mericaer Applications Access to the scheme key store Influenza A virus subtype H5N1nd assert fine-grained control over what primals each H5N1pp is Allowed to USAe. inwards the following portion of the series we will look At the implementation of the new credential secondtorage goality Influenza A virus subtype H5N1dded in ICS.

Berlangganan Untuk Mendapatkan Artikel Terbaru: