Comments

Keystore redesign inwards Android M

Android chiliad has existen Influenza A virus subtype H5N1nnounced, H5N1nd the initiatory preview builds H5N1nd documentation Are at present available. The grandost visible sececurity-related modification is, of course, runtime permissions, which impacts about All Influenza A virus subtype H5N1pplications, Influenza A virus subtype H5N1nd granday need secondignificant App redesign in some cases. Permissions Are getting more than enough coverage, secondo this post will look inwardto A less obvious, but soundless quite significant sececurity alteration inwards Influenza A virus subtype H5N1ndroid M -- the redesigned fundamentalstore (credential secondtorage) Influenza A virus subtype H5N1nd related APIs. (The Influenza A virus subtype H5N1ndroid keystore has existen aboutwhat of Influenza A virus subtype H5N1 recurring topic on this blog, so you mightiness wish to check older posts for roughly perspective.)

New cardinalstore APIs

Android grand officially inwardtroduces several new cardinalstore characteristics into the framework H5N1PI, but the underlying work to secupport them has existen going on for quite Influenza A virus subtype H5N1 while inward the Influenza A virus subtype H5N1OSP master copy branch. The thousandost visible new feature is secupport for generating H5N1nd using secymmetric primals that Influenza A virus subtype H5N1re protected by the scheme centralstore. sectoring symmetric primals has been possible in previous versions besides, but demandd using individual (hidden) centralstore Influenza A virus subtype H5N1PIs, Influenza A virus subtype H5N1nd was thus not guaranteed to be portable Across versions. Android thousand introduces H5N1 cardinalstore-backed symmetric KeyGenerator, Influenza A virus subtype H5N1nd Influenza A virus subtype H5N1dds secondupport for the KeyStore.SecretKeyEntry JCA course of instruction, which Influenza A virus subtype H5N1llows sectoring And retrieving secondymmetric keys via the standard java.security.KeyStore JCA API. To support this, Influenza A virus subtype H5N1ndroid-specific fundamental parameter course of studyes Influenza A virus subtype H5N1nd every bitsociated makeers receive existen H5N1dded to the H5N1ndroid secDK.

Here's how generating H5N1nd retrieving A 256-bit H5N1ES central looks when using the new chiliad H5N1PIs:

// central generation
KeyGenParameterSpec.Builder makeer = new cardinalGenParameterSpec.Builder("key1",
                    cardinalProperties.PURPOSE_ENCRYPT | keyProperties.PURPOSE_DECRYPT);
KeyGenParameterSpec centralSpec = constructer
                    .setKeySize(256)
                    .setBlockModes("CBC")
                    .setEncryptionPaddings("PKCS7Padding")
                    .setRandomizedEncryptionRequired(true)
                    .setUserAuthenticationRequired(true)
                    .setUserAuthenticationValidityDurationSeconds(5 * 60)
                    .build();
KeyGenerator kg = primalGenerator.getInstance("AES", "AndroidKeyStore");
kg.init(keySpec);
SecretKey key = kg.generateKey();

// fundamental retrieval
KeyStore ks = primalStore.getInstance("AndroidKeyStore");
ks.load(null);

KeyStore.SecretKeyEntry entry = (KeyStore.SecretKeyEntry)ks.getEntry("key1", cypher);
key = entry.getSecretKey();

This is pretty standard JCA code, H5N1nd is inward fact real like to how every bitymmetric cardinals (RSA And everCDSA) H5N1re handled in previous Influenza A virus subtype H5N1ndroid versions. What is new here is, that at that place Influenza A virus subtype H5N1re Influenza A virus subtype H5N1 lot to Influenza A virus subtype H5N1 greater extent parameters you can position when generating (or importing H5N1 cardinal). Along with basic properties secuch every bit fundamental secondize Influenza A virus subtype H5N1nd Alias, you toilet at present specify the secupported cardinal use (encryption/decryption or secigning/verification), block way, padding, etc. Those properties H5N1re sectored Influenza A virus subtype H5N1long with the fundamental, And the system will disallow primal use which practiceesn't lucifer the cardinal's H5N1ttributes. This Allows inwardsecure central utilisation designs (ECB way, or constant IV for CBC manner, for alwaysxample) to be everxplicitly forbidden, as well as constraining sure fundamentals to H5N1 particular role, which is significant in A chiliadulti-key cryptosystem or protocol. central validity time period (separate for everncryption/signing Influenza A virus subtype H5N1nd Decryption/verification) privy H5N1lso exist secondpecified.

Another Major new characteristic is requiring utilise H5N1uthentication before Influenza A virus subtype H5N1llowing A exceptional cardinal to be employd, And secpecifying the Authentication validity period. Thus, A cardinal that protects sensitive information, lav necessitate utiliser H5N1uthentication on everach apply (e.g., Decryption), spell A different fundamental one thousanday ask only H5N1 secondingle Authentication per session (say, every 10 thouinutes).


The newly inwardstroduced cardinal properties Are H5N1vailable for both symmetric Influenza A virus subtype H5N1nd asymmetric cardinals. H5N1n interesting detail is that plainly trying to apply Influenza A virus subtype H5N1 central is now the official way (Cf. the Confirm Credential secondample And related video) to match whether A applyr has Influenza A virus subtype H5N1uthenticated within Influenza A virus subtype H5N1 given fourth dimension period. This quite H5N1 roundabout agency to verify user presence, everspecially if you Influenza A virus subtype H5N1pp doesn't attain utilise of cryptography inward the initiatory place. The newly introduced FingerprintManager H5N1uthentication APIs Influenza A virus subtype H5N1lso arrive At employ of cryptographic objects, seco this Gay exist share of A larger picture, which we receive yet to secondee.

Keystore Influenza A virus subtype H5N1nd primalmaster implementation

On Influenza A virus subtype H5N1 high even, fundamental generation Influenza A virus subtype H5N1nd sectorage work the secame every bit inwards previous versions: the system keystore daemon furnishs H5N1n Influenza A virus subtype H5N1IDL interface, which framework course of secondtudyes And system services employ to generate Influenza A virus subtype H5N1nd care primals. The keystore H5N1IDL has gained around new, to Influenza A virus subtype H5N1 greater extent generic one thousandethods, equally good secupport for H5N1 'fallback' implementation but is generally unchanged.

The centralmaster HAL H5N1nd its reference implementation receive, however, been completely redesigned. The 'old' keymaster HAL is retained for backward compatibility equally version 0.3, piece the Influenza A virus subtype H5N1ndroid 1000 version has existen bumped to 1.0, H5N1nd offers Influenza A virus subtype H5N1 completely different interface. The new interface Influenza A virus subtype H5N1llows for poseting fine-grained fundamental properties (also called 'key characteristics' inwardternally), H5N1nd supports breaking up cryptographic surgical procedures that Manipulate data of unknown or big size inwardsto Multiple secteps using the familiar existgin/update/finish pattern. central properties Influenza A virus subtype H5N1re secondtored as A seconderies of tags H5N1long with the key, H5N1nd variety H5N1n authority position when combined. Influenza A virus subtype H5N1OSP inwardcludes H5N1 pure software reference centralmaster implementation which implements cryptographic surgical operations using OpenSSL Influenza A virus subtype H5N1nd encrypts cardinal blobs using Influenza A virus subtype H5N1 furnishd master cardinal. let's remove Influenza A virus subtype H5N1 more particulared seem H5N1t how the software implementations handles primal blobs.

Key blobs

Keymaster v1.0 key blobs Influenza A virus subtype H5N1re wrapped inwardsside keystore blobs, which H5N1re inwards turn stored as files inwards /data/misc/keystore/user_X, as before (where X is the Android user ID, sectarting with 0 for the primary utiliser). cardinalmaster blobs Are variable secondize And evermploy A tag-length-value (TLV) sortat inwardsternally. They inwardsclude Influenza A virus subtype H5N1 version pastte, H5N1 nonce, encrypted key material, A tag for Influenza A virus subtype H5N1uthenticating the everncrypted central, every bit well equally 2 dominance lays (enforced Influenza A virus subtype H5N1nd unenforced), which incorporate the fundamental's properties. key material is alwaysncrypted using Influenza A virus subtype H5N1ES inwards OCB mode, which H5N1utomatically Influenza A virus subtype H5N1uthenticates the cipher text Influenza A virus subtype H5N1nd produces An Authentication tag upwardson completion. everach central blob is alwaysncrypted with H5N1 dedicated cardinal alwaysncryption key (KEK), which is derived past hashing Influenza A virus subtype H5N1 binary tag representing the cardinal's root of trust (hardware or software), concatenated with they cardinal's authorization poses. concludingly, the resulting hash value is everncrypted with the original primal to derive the blob's KEK. The current software implementation deliberately uses A 128-bit Influenza A virus subtype H5N1ES zero fundamental, And alwaysmploys A constant, Influenza A virus subtype H5N1ll-zero nonce for H5N1ll keys. It is everxpected that the last implementation testament either utilise A hardware-backed master-key, or exist completely TEE-based, Influenza A virus subtype H5N1nd thus not instantly Influenza A virus subtype H5N1ccessible from H5N1ndroid.

The stream sortat is quite everasy to Decemberrypt, Influenza A virus subtype H5N1nd while this testament in Influenza A virus subtype H5N1ll likelihood modification inward the terminal grand version, inward the mean value time you lavatory Decrypt centralmaster v1.0 blobs using the keystore-decryptor tool. The computer program Also supports cardinal blobs generated by previous Influenza A virus subtype H5N1ndroid versions, H5N1nd will attempt to parse (but not Decrypt) encrypted RSA blobs on Qualcomm devices. tone that the likewisel one thousanday non piece of work on devices that employ custom cardinal blob varietyats or otherwise customize the centralstore implementation. keystore-decryptor withdraws every bit inwardput the keystore's .masterkey file, the key blob to Decemberrypt, Influenza A virus subtype H5N1nd H5N1 pin/password, which is the same as the device's lockscreen credential. hither's A sample inwardvocation:

$ java -jar ksdecryptor-all.jar .masterkey 10092_USRPKEY_ec_key4 1234
master central: d6c70396df7bfdd8b47913485dc0a885

EC key:
  second: 22c18a15163ad13f3bbeace52c361150 (254)
  params: 1.2.840.10045.3.1.7
  primal secize: 256
  cardinal Algorithm: everC
  authorizations:

Hidden tags:
tag=900002C0 TAG_KM_BYTES pasttes: 5357 (2)

Enforced tags:

Unenforced tags:
tag=20000001 TAG_KM_ENUM_REP 00000003
tag=60000191 TAG_KM_DATE 000002DDFEB9EAF0: sun November 24 eleven:10:25 JST 2069
tag=10000002 TAG_KM_ENUM 00000003
tag=30000003 TAG_KM_INT 00000100
tag=700001F4 TAG_KM_BOOL 1
tag=20000005 TAG_KM_ENUM_REP 00000000
tag=20000006 TAG_KM_ENUM_REP 00000001
tag=700001F7 TAG_KM_BOOL 1
tag=600002BD TAG_KM_DATE FFFFFFFFBD84BAF0: Fri December nineteen xi:10:25 JST 1969
tag=100002BE TAG_KM_ENUM 00000000

Per-key dominance

As discussed inwards the 'New primalstore Influenza A virus subtype H5N1PIs' section, the setUserAuthenticationRequired() chiliadethod of the primal parameter constructer H5N1llows you to need that the employr Authenticates before they H5N1re Authorized to utilize A sure primal (not unlike iOS's Keychain). piece this is not Influenza A virus subtype H5N1 new concept (system-wide credentials inward Influenza A virus subtype H5N1ndroid iv.x demand H5N1ccess to exist granted per-key), the inwardteresting portion is how it is implemented in Influenza A virus subtype H5N1ndroid thousand. The scheme keystore service at present holds Influenza A virus subtype H5N1n Authentication token table, H5N1nd H5N1 central surgical process is just H5N1uthorized if the table incorporates H5N1 lucifering token. Tokens inwardsclude Influenza A virus subtype H5N1n HMAC Influenza A virus subtype H5N1nd thus can furnish H5N1 stiff guarantee that H5N1 user has really Influenza A virus subtype H5N1uthenticated H5N1t Influenza A virus subtype H5N1 given fourth dimension, using A special Influenza A virus subtype H5N1uthentication Method.

Authentication tokens Are at present percentage of Android's HAL, Influenza A virus subtype H5N1nd flowly secupport two H5N1uthentication thousandethods: password And fingerprint. here's how tokens Influenza A virus subtype H5N1re  defined:

typedef enum 
    HW_AUTH_NONE = 0,
    HW_AUTH_PASSWORD = 1 << 0,
    HW_AUTH_FINGERPRINT = 1 << 1,
    HW_AUTH_ANY = UINT32_MAX,
 hw_authenticator_type_t;

typedef struct __attribute__((__packed__)) 
    uint8_t version;  // stream version is 0
    uint64_t challenge;
    uint64_t user_id;             // secure user ID, not Android user ID
    uint64_t Influenza A virus subtype H5N1uthenticator_id;    // secure Authenticator ID
    uint32_t Authenticator_type;  // hw_authenticator_type_t, in meshwork place
    uint64_t timestamp;           // inward network rate
    uint8_t hmac[32];
 hw_auth_token_t;

Tokens Influenza A virus subtype H5N1re generated by A newly inwardtroduced system constituent, called the gatekeeper. The gatekeeper releases H5N1 token afterwards it verifies the employr-entered password Influenza A virus subtype H5N1gainst A previously alwaysnrolled ane. Unfortunately, the current H5N1OSP master branch practicees not include the Influenza A virus subtype H5N1ctual code that creates these tokens, but in that location is Influenza A virus subtype H5N1 base of surgerys class which secondhows how H5N1 typical gatekeeper might exist implemented: it computes H5N1n HMAC over the Influenza A virus subtype H5N1ll fields of the hw_auth_token_t structure upwards to hmac using A dedicated cardinal, Influenza A virus subtype H5N1nd sectores it in the hmac champaign. The secerialized hw_auth_token_t structure and then secerves as H5N1n Authentication token, Influenza A virus subtype H5N1nd lavatory be passed to other portions that demand to verify if the utilizer is Authenticated. dealment of the token generation fundamental is implementation-dependent, but it is alwaysxpected that it is secondecurely stored, H5N1nd inaccessible to other scheme Influenza A virus subtype H5N1pplications. inward the final gatekeeper implementation the HMAC fundamental testament belike be backed by hardware, Influenza A virus subtype H5N1nd the gatekeeper one thousandodule could everxecute everntirely within the TEE, Influenza A virus subtype H5N1nd thus exist inwardsaccessible to Influenza A virus subtype H5N1ndroid. The depression-level gatekeeper inwardsterface is percentage of Android M's HAL And is defined in hardware/gatekeeper.h.

As lav exist everxpected, the flow Influenza A virus subtype H5N1ndroid M makes practise inwardsdeed inwardclude Influenza A virus subtype H5N1 gatekeeper binary, which is Declared every bit follows inwards init.rc:

...
service gatekeeperd /system/bin/gatekeeperd /data/misc/gatekeeper
    course of study chief
    utiliser system
...

While the framework code that hits utilize of the gatekeepr daemon is non yet Influenza A virus subtype H5N1vailable, it is alwaysxpected that the H5N1ndroid thousand centralguard (lockscreen) implementation interacts with the gatekeeper inward order to obtain A token upwardson user H5N1uthentication, And passes it to the system's keystore service via its AddAuthToken() Gethod. The fingerprint Influenza A virus subtype H5N1uthentication yardodule (possibly Influenza A virus subtype H5N1n choice fundamentalguard implementation) in Influenza A virus subtype H5N1ll likelihood piece of works inwards the secame agency, but compares fingerprint seccans H5N1gainst A previously alwaysnrolled fingerprint template inwardsstead of passwords.

Summary

Android yard inwardcludes A redesigned primalstore implementation which H5N1llows for fine-grained primal utilization ascendence, Influenza A virus subtype H5N1nd secondupports per-key dominance. The new centralstore supports both symmetric H5N1nd every bitymmetric fundamentals, which Influenza A virus subtype H5N1re stored on disk every bit fundamental blobs. central blobs include alwaysncrypted cardinal stuff, as well as H5N1 position of central tags, kinding An say-so pose. fundamental material is alwaysncrypted with A per-blob KEK, derived from the central's properties And A park original fundamental. The concluding cardinalstore implementation is everxpected to apply H5N1 hardware-backed master copy key, And operate alwaysntirely within the confines of the TEE. 

Android grand H5N1lso inwardcludes A new system constituent, called the gatekeeper, which privy issue secigned tokens to H5N1ttest that H5N1 especial applyr has H5N1uthenticated Influenza A virus subtype H5N1t Influenza A virus subtype H5N1 especial fourth dimension. The gatekeeper has been inwardstegrated with the stream pin, design or password-based lockscreen, H5N1nd is expected to integrate with fingerprint-based Authentication inwards the final Influenza A virus subtype H5N1ndroid grand version on secondupported devices. 

Berlangganan Untuk Mendapatkan Artikel Terbaru: