diff options
author | Tri Vo <trong@google.com> | 2022-10-11 17:16:04 -0700 |
---|---|---|
committer | Tri Vo <trong@google.com> | 2022-10-12 10:46:27 -0700 |
commit | 4ae0b0c8e4da5bfdf5bfd66ed0270da6d2c1d0ae (patch) | |
tree | bafc0b5366cec0cf93c7950fee4813ca18e2fd32 /include | |
parent | 2ba49e7a087d684d067e8b13ebefc02fe56d501d (diff) | |
download | keymaster-4ae0b0c8e4da5bfdf5bfd66ed0270da6d2c1d0ae.tar.gz |
Push getHardwareInfo() implementation from HAL to TA
This way HAL code doesn't need to be aware of device-specific details
and only needs to marshal messages to the TA backend.
Bug: 253109915
Test: keymaster_tests
Test: VtsHalRemotelyProvisionedComponentTargetTest
Change-Id: Ia59b0277499a2c46ced9115b3286278aa4f65f92
Diffstat (limited to 'include')
4 files changed, 35 insertions, 0 deletions
diff --git a/include/keymaster/android_keymaster.h b/include/keymaster/android_keymaster.h index 6c3acc5..3b6f445 100644 --- a/include/keymaster/android_keymaster.h +++ b/include/keymaster/android_keymaster.h @@ -100,6 +100,7 @@ class AndroidKeymaster { ConfigureVerifiedBootInfoResponse ConfigureVerifiedBootInfo(const ConfigureVerifiedBootInfoRequest& request); GetRootOfTrustResponse GetRootOfTrust(const GetRootOfTrustRequest& request); + GetHwInfoResponse GetHwInfo(); bool has_operation(keymaster_operation_handle_t op_handle) const; diff --git a/include/keymaster/android_keymaster_messages.h b/include/keymaster/android_keymaster_messages.h index 528eb78..08dd84b 100644 --- a/include/keymaster/android_keymaster_messages.h +++ b/include/keymaster/android_keymaster_messages.h @@ -70,6 +70,7 @@ enum AndroidKeymasterCommand : uint32_t { CONFIGURE_BOOT_PATCHLEVEL = 33, CONFIGURE_VERIFIED_BOOT_INFO = 34, GET_ROOT_OF_TRUST = 35, + GET_HW_INFO = 36, }; /** @@ -1250,4 +1251,34 @@ struct GetRootOfTrustResponse : public KeymasterResponse { std::vector<uint8_t> rootOfTrust; }; +struct GetHwInfoRequest : public EmptyKeymasterRequest { + explicit GetHwInfoRequest(int32_t ver) : EmptyKeymasterRequest(ver) {} +}; + +struct GetHwInfoResponse : public KeymasterResponse { + explicit GetHwInfoResponse(int32_t ver) : KeymasterResponse(ver) {} + + size_t NonErrorSerializedSize() const override { + return sizeof(version) + sizeof(uint32_t) + rpcAuthorName.size() + + sizeof(supportedEekCurve) + sizeof(uint32_t) + uniqueId.size(); + } + uint8_t* NonErrorSerialize(uint8_t* buf, const uint8_t* end) const override { + buf = append_uint32_to_buf(buf, end, version); + buf = append_collection_to_buf(buf, end, rpcAuthorName); + buf = append_uint32_to_buf(buf, end, supportedEekCurve); + return append_collection_to_buf(buf, end, uniqueId); + } + bool NonErrorDeserialize(const uint8_t** buf_ptr, const uint8_t* end) override { + return copy_uint32_from_buf(buf_ptr, end, &version) && + copy_collection_from_buf(buf_ptr, end, &rpcAuthorName) && + copy_uint32_from_buf(buf_ptr, end, &supportedEekCurve) && + copy_collection_from_buf(buf_ptr, end, &uniqueId); + } + + uint32_t version; + std::string rpcAuthorName; + uint32_t supportedEekCurve; + std::string uniqueId; +}; + } // namespace keymaster diff --git a/include/keymaster/contexts/pure_soft_remote_provisioning_context.h b/include/keymaster/contexts/pure_soft_remote_provisioning_context.h index 90cd79f..06cd6d9 100644 --- a/include/keymaster/contexts/pure_soft_remote_provisioning_context.h +++ b/include/keymaster/contexts/pure_soft_remote_provisioning_context.h @@ -45,6 +45,7 @@ class PureSoftRemoteProvisioningContext : public RemoteProvisioningContext { const std::vector<uint8_t>& aad) const override; std::optional<cppcose::HmacSha256> GenerateHmacSha256(const cppcose::bytevec& input) const override; + void GetHwInfo(GetHwInfoResponse* hwInfo) const override; void SetSystemVersion(uint32_t os_version, uint32_t os_patchlevel); void SetVendorPatchlevel(uint32_t vendor_patchlevel); diff --git a/include/keymaster/remote_provisioning_context.h b/include/keymaster/remote_provisioning_context.h index fee1d44..ed40c55 100644 --- a/include/keymaster/remote_provisioning_context.h +++ b/include/keymaster/remote_provisioning_context.h @@ -23,6 +23,7 @@ #include <vector> #include <cppbor.h> +#include <keymaster/android_keymaster_messages.h> #include <keymaster/cppcose/cppcose.h> namespace keymaster { @@ -42,6 +43,7 @@ class RemoteProvisioningContext { // input hasn't changed across multiple calls to the remote provisioning HAL. virtual std::optional<cppcose::HmacSha256> GenerateHmacSha256(const cppcose::bytevec& input) const = 0; + virtual void GetHwInfo(GetHwInfoResponse* hwInfo) const = 0; private: // Uncopyable. |