33ab0389e908b98702806c746e7babc0d46eb452 |
|
08-Jul-2015 |
Shawn Willden <swillden@google.com> |
Add support for KM_TAG_MIN_MAC_LENGTH. HMAC and AES-GCM keys must be bound to a mininum MAC/tag length at creation, and operations may not specify a length smaller than the minimum, or provide a length smaller than the minimum during verification. Bug: 22337277 Change-Id: Id5ae2f4259045ba1418c28e9de8f4a47e67fd433
/system/keymaster/symmetric_key.cpp
|
0f906ec40f6ade7955c6b967ea522aade54ea2e4 |
|
20-Jun-2015 |
Shawn Willden <swillden@google.com> |
Add buffer wrap checks and disable throwing of std::bad_alloc. Android is built with exceptions disabled, but "operator new" and "operator new[]" still throw std::bad_alloc on failure rather than returning new. In general this is a good thing, because it will cause an immediate crash of the process rather than assigning a null pointer which is probably not checked. But most memory allocations in Keymaster are checked, because it's written to run in an environment where new does *not* throw. This CL updates the code to explicitly use the non-throwing new. A handful of throwing news remain, but only in places where a crash on failure is appropriate. In addition, this CL also inserts buffer wrap checks in key locations and changes the development-machine Makefile to build in 32-bit mode, to make memory problems more apparent. Bug: 21888473 Change-Id: I8ebc5ec12053e4f5274f6f57ce312abc10611cef
/system/keymaster/symmetric_key.cpp
|
0629810b145187575bc26c910dded0d24c64569d |
|
26-May-2015 |
Shawn Willden <swillden@google.com> |
Another refactor, deleting AbstractFactoryRegistry. I should have known better than to make these singletons to begin with. Globals create problems. This undoes that mistake. Change-Id: Idf61d5f72e3c34b5c4ddb27cc94b05f506561743
/system/keymaster/symmetric_key.cpp
|
0cb6942d3efb6c056f96321c82a4b3d86af601d6 |
|
26-May-2015 |
Shawn Willden <swillden@google.com> |
Revert "Revert "Large refactor to move context out of AndroidKeymaster."" This reverts commit 13fbe3e93247943c26e7ca2ed27b6d650282b8bf. Bug: 20912868, 19799085 Change-Id: Iadd6ce5cbe94956c2a2fe277f1bf5b108e4bcf57
/system/keymaster/symmetric_key.cpp
|
13fbe3e93247943c26e7ca2ed27b6d650282b8bf |
|
23-May-2015 |
Shawn Willden <swillden@google.com> |
Revert "Large refactor to move context out of AndroidKeymaster." This reverts commit 8ba2a043f0d44ad3f58d4af518f9391c03eca9c3. I need to update the Volantis non-secure code in sync. Reverting while I get that done. Change-Id: I0fb9f928e7e624ad678050a04bb873b43b1c9a48
/system/keymaster/symmetric_key.cpp
|
8ba2a043f0d44ad3f58d4af518f9391c03eca9c3 |
|
18-May-2015 |
Shawn Willden <swillden@google.com> |
Large refactor to move context out of AndroidKeymaster. AndroidKeymaster made a number of assumptions about its context that are really only valid for TEE-based usage. In addition, KeyFactory made some similarly TEE-focused assumptions about key blob creation and parsing. Both concerns have been moved to a new KeymasterContext class, which is responsible for building and parsing key blobs in a manner appropriate for the context in which AndroidKeymaster is running, as well as providing other context-specific services, such as random number generation. In addition, the refactor reduces the need for the KeyBlob and UnencryptedKeyBlob classes, which encode too many assumptions about blob formatting and encryption, to the point that they can be removed and replaced by a handful of utility functions which are much cleaner and more flexible. How to review this CL: I looked hard at breaking this up into smaller CLs, but it's mostly not feasible. However, it's probably easier to approach it by starting with the fundamental changes, and then looking at the cascade effects. 1. Look at keymaster_context.h. The core of the change was pulling this set of features out of AndroidKeymaster. Note that the revised approach to key blob creation does not involve the KeyBlob and UnencryptedKeyBlob classes, but instead goes directly from raw key material plus ancillary data (e.g. auth sets) to a serialized buffer ready to return to keystore. The same is true in reverse direction for parsing key blobs. 2. Look at key.h. The revised KeyFactory GenerateKey, ImportKey and LoadKey methods are essential. GenerateKey and ImportKey no longer produce a Key object, because all that's needed is a returnable blob. LoadKey produces a Key object, but it starts with raw key material, rather than an UnencryptedKeyBlob. Also note the change to the Key class; because Key objects are only created by LoadKey, when there's a need to use a key, there's only one constructor. 3. Look at asymmetric_key.h, rsa_key.h and rsa_key.cpp. rsa_key.cpp provides a good example of how the new structure works. GenerateKey and ImportKey do all of the work necessary to produce an OpenSSL RSA key and extract the internal representation (using EvpToKeyMaterial; defined in asymmetric_key.h because it's the same for EC keys). Then, with the raw key data in hand, they call KeymasterContext::CreateKeyBlob to wrap the key data in a key blob that can be returned to the caller -- whatever that wrapping means in the current context. There's a subtlety not apparent here which is crucial to the rationale for the refactoring: RsaKeyFactory uses KeymasterContext::get_instance to retrieve the context, but key factories which depend on operating in a particular context can use a different way to get their context object, which may have a larger interface. RsaKeymaster0KeyFactory will do this. 4. Look at soft_keymaster_context. In particular, SoftKeymasterContext::CreateKeyBlob and ParseKeyBlob. CreateKeyBlob allocates authorization tags from key_description to hw_enforced and sw_enforced, then encrypts the key material and serializes it to a blob. This approach is compatible with the keys softkeymaster has been producing, but I'm going to change it (post M), because there's no reason to bother encrypting SW keys with a SW key. ParseKeyBlob reverses the process to recover the unencrypted key material and the auth lists. One debatable point was the decision to implement BuildHiddenAuthorizations and SetAuthorizations here, since all contexts will need something similar, and they really should all do it the same. I may refactor later to pull that functionality up to KeymasterContext; it will depend on what I learn implementing TrustyKeymasterContext and HybridKeymasterContext (used for the keymaster0 adapter). 5. Look at ocb_utils and auth_encrypted_key_blob. These contain the key encryption and key blob serialization code which was formerly split between AndroidKeymaster::SerializeKeyBlob, UnencryptedKeyBlob and KeyBlob, now divided into separate encryption and serialization utilities. Note the refactored key_blob_test.cpp, updated to use the new utilities rather than UnencryptedKeyBlob. 6. Look at soft_keymaster_device.cpp. Since KeyBlob no longer exists to provide a nice way to peer into a blob to extract the algorithm, for use in determining how to parse the keymaster0 signing key params (which come in as a void*, yuck), we now have to use get_key_characteristics to recover the params. This was the right way all along; the device layer should not depend on being able to parse key blobs. 7. The rest. Bug: 20912868, 19799085 Change-Id: Ieb74b8da39974f674eb8baa959bde75011fdd2e8
/system/keymaster/symmetric_key.cpp
|
125e4866f98eb1b5ad65a563afd34aca215d983d |
|
11-May-2015 |
Shawn Willden <swillden@google.com> |
Remove rescoping support. Change-Id: Ia8e36e41e04f15befccbb7b4138f599849facd28 (cherry picked from commit 0c14b2c5f42abdab58118106d5a7117a88d4a324)
/system/keymaster/symmetric_key.cpp
|
344549836442988693f27be8252c31bd2ebefdee |
|
30-Apr-2015 |
Shawn Willden <swillden@google.com> |
Modify RAND_bytes calls to handle -1 return code. Bug: 20554394 Change-Id: I54dce88f7bb90bd5660e9d3a7be9b9646bcc12bd (cherry picked from commit 9ee79fb55049c242b12e067df1a824f18622ccfd)
/system/keymaster/symmetric_key.cpp
|
f01329d8692edde9a9ffb88f29f5d684eab481e2 |
|
12-Mar-2015 |
Shawn Willden <swillden@google.com> |
Improve error reporting and logging. Bug: 19603049 Bug: 19509317 Change-Id: I041c973802e6c567adc5b1f280fc5bac27ba28d6
/system/keymaster/symmetric_key.cpp
|
5fad785a94716e4b71d51dcf2434ec09ff447b27 |
|
27-Jan-2015 |
Shawn Willden <swillden@google.com> |
Add initial support for rescoping. This code does not yet validate that rescoping is authorized. A future CL will integrate rescoping enforcement. Change-Id: Iff66860630eef717562bce7c534a09d80b85a7a3
/system/keymaster/symmetric_key.cpp
|
7dad93b6552a2253ad6e7a493ddf0c9113806712 |
|
05-Feb-2015 |
Shawn Willden <swillden@google.com> |
Implement symmetric key import. Change-Id: I902933c06c74c7b3b434873f53fb2c767d3b9721
/system/keymaster/symmetric_key.cpp
|
567a4a04f43d35b785d50508e6459b01f2ab4d14 |
|
31-Dec-2014 |
Shawn Willden <swillden@google.com> |
Switch to using global logger Change-Id: I7af02342320a9a431cd9845baaf5dbcf61d460c2
/system/keymaster/symmetric_key.cpp
|
a278f6156b9e57e1de8ca380b14fef113ad10be8 |
|
23-Dec-2014 |
Shawn Willden <swillden@google.com> |
Refactor key creation to use a registry of key factories. Change-Id: I6ebab7b44e4a5dbea282397ab8aca437e71bdca0
/system/keymaster/symmetric_key.cpp
|
0d560bfedd40389387f31f6696660fff6bc3a48a |
|
16-Dec-2014 |
Shawn Willden <swillden@google.com> |
Add HMAC-SHA256 support. Change-Id: I64c7bdf77388e3cb491b702c52c6746d32f317b0
/system/keymaster/symmetric_key.cpp
|
95e1382b75bab7d8b4cce3c1267fa23df2006957 |
|
16-Dec-2014 |
Shawn Willden <swillden@google.com> |
Refactor AesKey, extracting most functionality to SymmetricKey. Symmetric key material handling is the same for all symmetric keys (except, perhaps, DES if we want to handle parity bits correctly), so move it into a common base. Change-Id: I6ad5d35ce9020c1ae155bf0a8f2efe35674b1604
/system/keymaster/symmetric_key.cpp
|