summaryrefslogtreecommitdiff
path: root/keystore/include
diff options
context:
space:
mode:
authorShawn Willden <swillden@google.com>2017-02-17 12:29:42 -0700
committerShawn Willden <swillden@google.com>2017-03-24 22:23:56 -0600
commit76f21b2676092911ab030c3dde1489902c00ab71 (patch)
treedb5af3493a7a611eaa0f86e03cf5e1f405b828a7 /keystore/include
parentb8550a0929286bd8b91135c2beea1f61c01a441f (diff)
downloadsecurity-76f21b2676092911ab030c3dde1489902c00ab71.tar.gz
Delegate auth token parsing to HAL.
Auth tokens have an unfortunate dual character. To most of the system they are opaque blobs that are intended only to be obtained from one HAL (e.g. gatekeeper or fingerprint) and passed to another HAL (keymaster), but keystore actually needs to extract some bits of information from them in order to determine which of the available blobs should be provided for a given keymaster key operation. This CL adds a method that resolves this dual nature by moving the responsibility of parsing blobs to the HAL so that no component of the framework has to make any assumptions about their content and all can treat them as fully opaque. This still means that the various HAL implementers have to agree on content, but they also have to agree on an HMAC key which much be securely distributed to all at every boot, so asking them to agree on an auth token format is perfectly acceptable. But now the Android system doesn't have to care about the format. Bug: 32962548 Test: CTS tests pass, plus manual testing. Change-Id: I2ab4b4fbea1425fc08aa754fc10f8e386899af25
Diffstat (limited to 'keystore/include')
-rw-r--r--keystore/include/keystore/keymaster_tags.h2
-rw-r--r--keystore/include/keystore/keystore_hidl_support.h24
2 files changed, 1 insertions, 25 deletions
diff --git a/keystore/include/keystore/keymaster_tags.h b/keystore/include/keystore/keymaster_tags.h
index 05a33cd9..a003c600 100644
--- a/keystore/include/keystore/keymaster_tags.h
+++ b/keystore/include/keystore/keymaster_tags.h
@@ -70,7 +70,7 @@ using ::android::hardware::keymaster::V3_0::BlockMode;
using ::android::hardware::keymaster::V3_0::Digest;
using ::android::hardware::keymaster::V3_0::EcCurve;
using ::android::hardware::keymaster::V3_0::ErrorCode;
-using ::android::hardware::keymaster::V3_0::HardwareAuthToken;
+using ::android::hardware::keymaster::V3_0::HardwareAuthTokenInfo;
using ::android::hardware::keymaster::V3_0::HardwareAuthenticatorType;
using ::android::hardware::keymaster::V3_0::IKeymasterDevice;
using ::android::hardware::keymaster::V3_0::KeyBlobUsageRequirements;
diff --git a/keystore/include/keystore/keystore_hidl_support.h b/keystore/include/keystore/keystore_hidl_support.h
index 3c64d2af..253e81a4 100644
--- a/keystore/include/keystore/keystore_hidl_support.h
+++ b/keystore/include/keystore/keystore_hidl_support.h
@@ -97,30 +97,6 @@ inline static OutIter copy_bytes_to_iterator(const T& value, OutIter dest) {
return std::copy(value_ptr, value_ptr + sizeof(value), dest);
}
-inline static hidl_vec<uint8_t> authToken2HidlVec(const HardwareAuthToken& token) {
- static_assert(
- std::is_same<decltype(token.hmac), ::android::hardware::hidl_array<uint8_t, 32>>::value,
- "This function assumes token HMAC is 32 bytes, but it might not be.");
- static_assert(1 /* version size */ + sizeof(token.challenge) + sizeof(token.userId) +
- sizeof(token.authenticatorId) + sizeof(token.authenticatorType) +
- sizeof(token.timestamp) + 32 /* HMAC size */
- == sizeof(hw_auth_token_t),
- "HardwareAuthToken content size does not match hw_auth_token_t size");
-
- hidl_vec<uint8_t> result;
- result.resize(sizeof(hw_auth_token_t));
- auto pos = result.begin();
- *pos++ = 0; // Version byte
- pos = copy_bytes_to_iterator(token.challenge, pos);
- pos = copy_bytes_to_iterator(token.userId, pos);
- pos = copy_bytes_to_iterator(token.authenticatorId, pos);
- pos = copy_bytes_to_iterator(token.authenticatorType, pos);
- pos = copy_bytes_to_iterator(token.timestamp, pos);
- pos = std::copy(token.hmac.data(), token.hmac.data() + token.hmac.size(), pos);
-
- return result;
-}
-
inline std::string hidlVec2String(const hidl_vec<uint8_t>& value) {
return std::string(reinterpret_cast<const std::string::value_type*>(&value[0]), value.size());
}