trusty: keymaster: Implement configure
This patch also forces the underlying structure of enum keymaster_command to be uint32_t. Test: builds Change-Id: Ie8969beb9d6a15313456fbe54ef3806f6778ade2
This commit is contained in:
parent
e194e272f3
commit
dccc76cd0b
4 changed files with 27 additions and 4 deletions
|
|
@ -32,7 +32,7 @@ include $(CLEAR_VARS)
|
|||
LOCAL_MODULE := trusty_keymaster_tipc
|
||||
LOCAL_SRC_FILES := \
|
||||
trusty_keymaster_device.cpp \
|
||||
trusty_keymaster_ipc.c \
|
||||
trusty_keymaster_ipc.cpp \
|
||||
trusty_keymaster_main.cpp
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libcrypto \
|
||||
|
|
@ -53,7 +53,7 @@ include $(CLEAR_VARS)
|
|||
LOCAL_MODULE := keystore.trusty
|
||||
LOCAL_MODULE_RELATIVE_PATH := hw
|
||||
LOCAL_SRC_FILES := module.cpp \
|
||||
trusty_keymaster_ipc.c \
|
||||
trusty_keymaster_ipc.cpp \
|
||||
trusty_keymaster_device.cpp
|
||||
LOCAL_CLFAGS = -fvisibility=hidden -Wall -Werror
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#define KEYMASTER_MAX_BUFFER_LENGTH 4096
|
||||
|
||||
// Commands
|
||||
enum keymaster_command {
|
||||
enum keymaster_command : uint32_t {
|
||||
KEYMASTER_RESP_BIT = 1,
|
||||
KEYMASTER_REQ_SHIFT = 1,
|
||||
|
||||
|
|
@ -42,6 +42,7 @@ enum keymaster_command {
|
|||
KM_GET_SUPPORTED_IMPORT_FORMATS = (13 << KEYMASTER_REQ_SHIFT),
|
||||
KM_GET_SUPPORTED_EXPORT_FORMATS = (14 << KEYMASTER_REQ_SHIFT),
|
||||
KM_GET_KEY_CHARACTERISTICS = (15 << KEYMASTER_REQ_SHIFT),
|
||||
KM_CONFIGURE = (18 << KEYMASTER_REQ_SHIFT),
|
||||
};
|
||||
|
||||
#ifdef __ANDROID__
|
||||
|
|
|
|||
|
|
@ -138,6 +138,28 @@ TrustyKeymasterDevice::~TrustyKeymasterDevice() {
|
|||
|
||||
keymaster_error_t TrustyKeymasterDevice::configure(const keymaster_key_param_set_t* params) {
|
||||
ALOGD("Device received configure\n");
|
||||
|
||||
if (error_ != KM_ERROR_OK) {
|
||||
return error_;
|
||||
}
|
||||
if (!params) {
|
||||
return KM_ERROR_UNEXPECTED_NULL_POINTER;
|
||||
}
|
||||
|
||||
AuthorizationSet params_copy(*params);
|
||||
ConfigureRequest request;
|
||||
if (!params_copy.GetTagValue(TAG_OS_VERSION, &request.os_version) ||
|
||||
!params_copy.GetTagValue(TAG_OS_PATCHLEVEL, &request.os_patchlevel)) {
|
||||
ALOGD("Configuration parameters must contain OS version and patch level");
|
||||
return KM_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
ConfigureResponse response;
|
||||
keymaster_error_t err = Send(KM_CONFIGURE, request, &response);
|
||||
if (err != KM_ERROR_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
return KM_ERROR_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ int trusty_keymaster_call(uint32_t cmd, void* in, uint32_t in_size, uint8_t* out
|
|||
}
|
||||
|
||||
size_t msg_size = in_size + sizeof(struct keymaster_message);
|
||||
struct keymaster_message* msg = malloc(msg_size);
|
||||
struct keymaster_message* msg = reinterpret_cast<struct keymaster_message*>(malloc(msg_size));
|
||||
msg->cmd = cmd;
|
||||
memcpy(msg->payload, in, in_size);
|
||||
|
||||
Loading…
Add table
Reference in a new issue