Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uuid fixes #71

Merged
merged 2 commits into from
Dec 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion libteec/src/tee_client_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,19 @@ static TEEC_Result ioctl_errno_to_res(int err)
}
}

static void uuid_to_octets(uint8_t d[TEE_IOCTL_UUID_LEN], const TEEC_UUID *s)
{
d[0] = s->timeLow >> 24;
d[1] = s->timeLow >> 16;
d[2] = s->timeLow >> 8;
d[3] = s->timeLow;
d[4] = s->timeMid >> 8;
d[5] = s->timeMid;
d[6] = s->timeHiAndVersion >> 8;
d[7] = s->timeHiAndVersion;
memcpy(d + 8, s->clockSeqAndNode, sizeof(s->clockSeqAndNode));
}

TEEC_Result TEEC_OpenSession(TEEC_Context *ctx, TEEC_Session *session,
const TEEC_UUID *destination,
uint32_t connection_method, const void *connection_data,
Expand Down Expand Up @@ -475,7 +488,7 @@ TEEC_Result TEEC_OpenSession(TEEC_Context *ctx, TEEC_Session *session,
arg->num_params = TEEC_CONFIG_PAYLOAD_REF_COUNT;
params = (struct tee_ioctl_param *)(arg + 1);

memcpy(arg->uuid, destination, sizeof(TEEC_UUID));
uuid_to_octets(arg->uuid, destination);
arg->clnt_login = connection_method;

res = teec_pre_process_operation(ctx, operation, params, shm);
Expand Down
10 changes: 9 additions & 1 deletion tee-supplicant/src/tee_supplicant.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ static void process_sql_fs(union tee_rpc_invoke *request)
request->send.ret = sql_fs_process(&request->recv);
}

static void uuid_from_octets(TEEC_UUID *d, const uint8_t s[TEE_IOCTL_UUID_LEN])
{
d->timeLow = (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3];
d->timeMid = (s[4] << 8) | s[5];
d->timeHiAndVersion = (s[6] << 8) | s[7];
memcpy(d->clockSeqAndNode, s + 8, sizeof(d->clockSeqAndNode));
}

static void load_ta(union tee_rpc_invoke *request)
{
int ta_found = 0;
Expand All @@ -194,7 +202,7 @@ static void load_ta(union tee_rpc_invoke *request)
request->send.ret = TEEC_ERROR_BAD_PARAMETERS;
return;
}
memcpy(&uuid, val_cmd, sizeof(uuid));
uuid_from_octets(&uuid, (void *)val_cmd);

size = shm_ta.size;
ta_found = TEECI_LoadSecureModule(ta_dir, &uuid, shm_ta.buffer, &size);
Expand Down
2 changes: 1 addition & 1 deletion tee-supplicant/src/teec_ta_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static int try_load_secure_module(const char* prefix,
}

n = snprintf(fname, PATH_MAX,
"%s/%s/%08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x.ta",
"%s/%s/%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x.ta",
prefix, dev_path,
destination->timeLow,
destination->timeMid,
Expand Down