Skip to content

Patch jve #210

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

Open
wants to merge 89 commits into
base: comp-integrity
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
f17d8a8
Support for multiple branched CaseWhen
Oct 2, 2020
366e92c
Interval (#116)
eric-feng-2011 Nov 22, 2020
c7fcd98
Remove partition ID argument from enclaves
chester-leung Nov 23, 2020
93dbf5e
Fix comments
chester-leung Nov 24, 2020
f357ab2
updates
chester-leung Nov 24, 2020
bb4018a
Merge serialization of ecall string as int
chester-leung Nov 30, 2020
56ace17
Modifications to integrate crumb, log-mac, and all-outputs_mac, wip
chester-leung Dec 2, 2020
21bbbfb
Store log mac after each output buffer, add all-outputs-mac to each e…
chester-leung Dec 4, 2020
549566f
Add all_outputs_mac to all EncryptedBlocks once all log_macs have bee…
chester-leung Dec 7, 2020
55ee664
Almost builds
chester-leung Dec 9, 2020
057caec
cpp builds
chester-leung Dec 10, 2020
db54c44
Use ubyte for all_outputs_mac
chester-leung Dec 10, 2020
e77f1eb
use Mac for all_outputs_mac
chester-leung Dec 10, 2020
736b8f6
Hopefully this works for flatbuffers all_outputs_mac mutation, cpp bu…
chester-leung Dec 10, 2020
cbb2373
merge
Dec 10, 2020
0351b5d
Merge branch 'comp-integrity' of https://github.com/mc2-project/opaqu…
Dec 10, 2020
3002bd3
Scala builds now too, running into error with union
chester-leung Dec 11, 2020
dc54741
Stuff builds, error with all outputs mac serialization. this commit u…
chester-leung Dec 11, 2020
5be9b7c
Fixed bug, basic encryption / show works
chester-leung Dec 12, 2020
86fab02
All single partition tests pass, multiple partiton passes until tpch-9
chester-leung Dec 12, 2020
8b1a1d1
All tests pass except tpch-9 and skew join
chester-leung Dec 12, 2020
18f45d6
comment tpch back in
chester-leung Dec 12, 2020
123fa1f
Merge branch 'crumb-path' of http://github.com/chester-leung/opaque i…
Dec 13, 2020
bfc06ba
Check same number of ecalls per partition - exception for scanCollect…
Dec 14, 2020
c818a41
First attempt at constructing executed DAG
Dec 14, 2020
39a4945
Fix typos
Dec 14, 2020
c970965
Rework graph
Dec 14, 2020
43ccd2e
Add log macs to graph nodes
Dec 15, 2020
69fc49e
Construct expected DAG and refactor JobNode.
Dec 16, 2020
35691ff
Implement 'paths to sink' for a DAG
Dec 17, 2020
98d5fc4
add crumb for last ecall
Dec 18, 2020
29e3312
Fix NULL handling for aggregation (#130)
wzheng Dec 18, 2020
51b621b
Changing operator matching from logical to physical (#129)
wzheng Dec 21, 2020
e9fe7bb
Aggregation rewrite (#132)
wzheng Jan 21, 2021
1ee8d5b
Merge new aggregate
Jan 25, 2021
4a97c66
updated build/sbt file (#135)
octaviansima Jan 26, 2021
2400a94
Travis update (#137)
wzheng Jan 29, 2021
6031a4a
update breeze (#138)
octaviansima Jan 29, 2021
0a20d71
TPC-H test suite added (#136)
octaviansima Jan 29, 2021
2fec4ad
Separate IN PR (#124)
Chenyu-Shi Jan 30, 2021
7cb2f9a
Merge new aggregate
Feb 1, 2021
c3b3f33
Uncomment log_mac_lst clear
Feb 1, 2021
f41ba90
Clean up comments
Feb 2, 2021
b78b4a4
Separate Concat PR (#125)
Chenyu-Shi Feb 2, 2021
2bb2e8d
Clean up comments in other files
Feb 4, 2021
2685530
Update pathsEqual to be less conservative
Feb 4, 2021
7efb677
Remove print statements from unit tests
Feb 4, 2021
0519def
Removed calls to toSet in TPC-H tests (#140)
octaviansima Feb 5, 2021
0d69b7b
Documentation update (#148)
wzheng Feb 5, 2021
0f877d4
Cluster Remote Attestation Fix (#146)
octaviansima Feb 8, 2021
c215a99
upgrade to 3.0.1 (#144)
octaviansima Feb 8, 2021
8bd1e09
Update two TPC-H queries (#149)
wzheng Feb 8, 2021
823d95d
TPC-H 20 Fix (#142)
octaviansima Feb 8, 2021
fbe324c
Add expected operator DAG generation from executedPlan string
Feb 8, 2021
f822784
Rebase
Feb 8, 2021
40e8e13
Merge comp-integrity
Feb 9, 2021
6e60c7c
Merge master
Feb 9, 2021
1321eaa
Merge branch 'expected-dag' of https://github.com/andrewlawhh/opaque …
Feb 9, 2021
b4ba2db
Join update (#145)
wzheng Feb 9, 2021
375de7f
Merge join update
Feb 9, 2021
8682f22
Integrate new join
Feb 9, 2021
c21cb7b
Add expected operator for sortexec
Feb 10, 2021
c1adf85
Merge comp-integrity with join update
Feb 10, 2021
9391435
Merge comp-integrity with join update
Feb 10, 2021
2b37dab
Merge join integration with expected dag update
Feb 10, 2021
8a93c6c
Remove some print statements
Feb 10, 2021
c190aae
Migrate from Travis CI to Github Actions (#156)
octaviansima Feb 10, 2021
41ea7b9
Upgrade to OE 0.12 (#153)
wzheng Feb 12, 2021
29da474
Update README.md
wzheng Feb 13, 2021
4d89ecb
Support for scalar subquery (#157)
wzheng Feb 18, 2021
96e6285
Add TPC-H Benchmarks (#139)
octaviansima Feb 19, 2021
b350992
Construct expected DAG from dataframe physical plan
Feb 23, 2021
20f4749
Refactor collect and add integrity checking helper function to Opaque…
Feb 23, 2021
3c28b5f
Float expressions (#160)
wzheng Feb 23, 2021
a4a6ff9
Broadcast Nested Loop Join - Left Anti and Left Semi (#159)
octaviansima Feb 24, 2021
a96abc5
Move join condition handling for equi-joins into enclave code (#164)
wzheng Feb 26, 2021
a5278a4
Distinct aggregation support (#163)
octaviansima Mar 1, 2021
e9b075b
Remove addExpectedOperator from JobVerificationEngine, add comments
Mar 4, 2021
dabc178
Implement expected DAG construction by doing graph manipulation on da…
Mar 4, 2021
38c9da5
Merge
Mar 15, 2021
98bcfdb
Fix merge errors in the test cases
Mar 15, 2021
592ec17
Fix merge errors
Mar 15, 2021
e3e140d
Merge BNLJ into integrity branch
Apr 2, 2021
67fd713
Merge join logic migration into integrity branch
Apr 2, 2021
29db9e6
Merge join logic migration into integrity branch
Apr 2, 2021
886eda8
Merge distinct aggregation support into integrity branch
Apr 2, 2021
1fb4a5a
Fix merge errors
Apr 2, 2021
8ba5f75
fix treeToList to skip visited vertices and operatorDAGFromPlan to pr…
Apr 10, 2021
898a1b4
Add descriptive comments to each function and class
Apr 11, 2021
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
Prev Previous commit
Next Next commit
Almost builds
  • Loading branch information
chester-leung committed Dec 9, 2020
commit 55ee6648161bfa9a40f89006a2082aa40e6d52f7
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ buildFlatbuffersTask := {
if (gen.isEmpty || fbsLastMod > gen.map(_.lastModified).max) {
for (fbs <- flatbuffers) {
streams.value.log.info(s"Generating flatbuffers for ${fbs}")
if (Seq(flatc.getPath, "--cpp", "-o", flatbuffersGenCppDir.value.getPath, fbs.getPath).! != 0
if (Seq(flatc.getPath, "--cpp", "--gen-mutable", "-o", flatbuffersGenCppDir.value.getPath, fbs.getPath).! != 0
|| Seq(flatc.getPath, "--java", "-o", javaOutDir.getPath, fbs.getPath).! != 0) {
sys.error("Flatbuffers build failed.")
}
Expand Down
17 changes: 10 additions & 7 deletions src/enclave/Enclave/Enclave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <mbedtls/pk.h>
#include <mbedtls/rsa.h>
#include <mbedtls/sha256.h>
#include "EnclaveContext.h"
// #include "EnclaveContext.h"
#include "IntegrityUtils.h"

// This file contains definitions of the ecalls declared in Enclave.edl. Errors originating within
Expand Down Expand Up @@ -152,7 +152,7 @@ void ecall_partition_for_sort(uint8_t *sort_order, size_t sort_order_length,
output_partitions, output_partition_lengths);
// Assert that there are num_partitions log_macs in EnclaveContext
// TODO: Iterate over &output_partitions[i] for i in num_partitions
for (int i = 0; i < num_partitions; i++) {
for (uint32_t i = 0; i < num_partitions; i++) {
complete_encrypted_blocks(output_partitions[i]);
}
EnclaveContext::getInstance().finish_ecall();
Expand Down Expand Up @@ -325,13 +325,15 @@ void ecall_compute_num_rows_per_partition(uint32_t limit,
}
}

void ecall_local_limit(uint8_t *input_rows, size_t input_rows_length,
void ecall_local_limit(uint32_t limit,
uint8_t *input_rows, size_t input_rows_length,
uint8_t **output_rows, size_t *output_rows_length) {
assert(oe_is_outside_enclave(input_rows, input_rows_length) == 1);
__builtin_ia32_lfence();

try {
limit_return_rows(input_rows, input_rows_length,
limit_return_rows(limit,
input_rows, input_rows_length,
output_rows, output_rows_length);
complete_encrypted_blocks(*output_rows);
EnclaveContext::getInstance().finish_ecall();
Expand All @@ -341,15 +343,17 @@ void ecall_local_limit(uint8_t *input_rows, size_t input_rows_length,
}
}

void ecall_limit_return_rows(uint8_t *limits, size_t limits_length,
void ecall_limit_return_rows(uint64_t partition_id,
uint8_t *limits, size_t limits_length,
uint8_t *input_rows, size_t input_rows_length,
uint8_t **output_rows, size_t *output_rows_length) {
assert(oe_is_outside_enclave(limits, limits_length) == 1);
assert(oe_is_outside_enclave(input_rows, input_rows_length) == 1);
__builtin_ia32_lfence();

try {
limit_return_rows(limits, limits_length,
limit_return_rows(partition_id,
limits, limits_length,
input_rows, input_rows_length,
output_rows, output_rows_length);
complete_encrypted_blocks(*output_rows);
Expand All @@ -375,7 +379,6 @@ void ecall_finish_attestation(uint8_t *shared_key_msg_input,
}

set_shared_key(shared_key_plaintext, shared_key_plaintext_size);
EnclaveContext::getInstance().reset_pid_jobid_map();
} catch (const std::runtime_error &e) {
ocall_throw(e.what());
}
Expand Down
21 changes: 12 additions & 9 deletions src/enclave/Enclave/EnclaveContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ struct Crumb {
int ecall; // ecall executed
uint8_t log_mac[OE_HMAC_SIZE]; // LogEntryChain MAC for this output
uint8_t all_outputs_mac[OE_HMAC_SIZE];
// FIXME: change this to num_input_log_macs
int num_input_macs; // Num MACS in the below vector
std::vector<uint8_t> input_log_macs;

Expand All @@ -22,8 +23,6 @@ struct Crumb {
if (this->ecall != c.ecall) {
return false;
}
bool log_macs_match = true;
bool all_outputs_mac_match = true;

// Check whether the log_mac and the all_outputs_mac are the same
for (int i = 0; i < OE_HMAC_SIZE; i++) {
Expand All @@ -41,7 +40,7 @@ struct Crumb {
}

// Check whether the input_log_macs themselves are the same
for (int i = 0; i < this->input_log_macs.size(); i++) {
for (uint32_t i = 0; i < this->input_log_macs.size(); i++) {
if (this->input_log_macs[i] != c.input_log_macs[i]) {
return false;
}
Expand All @@ -55,7 +54,7 @@ class CrumbHashFunction {
// Example taken from https://www.geeksforgeeks.org/how-to-create-an-unordered_set-of-user-defined-class-or-struct-in-c/
size_t operator()(const Crumb& c) const
{
return (std::hash<int>()(c.ecall)) ^ (std::hash<uint8_t*>()(c.log_mac)) ^ (std::hash<uint8_t*>()(c.all_outputs_mac)) ^ (std::hash<int>()(c.num_input_macs)) ^ (std::hash<uint8_t*>()(c.input_log_macs.data()));
return (std::hash<int>()(c.ecall)) ^ (std::hash<uint8_t*>()((uint8_t*) c.log_mac)) ^ (std::hash<uint8_t*>()((uint8_t*) c.all_outputs_mac)) ^ (std::hash<int>()(c.num_input_macs)) ^ (std::hash<uint8_t*>()((uint8_t*) c.input_log_macs.data()));
}
};

Expand All @@ -64,7 +63,7 @@ static Crypto mcrypto;
class EnclaveContext {
private:
std::unordered_set<Crumb, CrumbHashFunction> crumbs;
std::vector<std::vector<uint8_t>> input_macs;
std::vector<uint8_t> input_macs;
int num_input_macs;

// Contiguous array of log_macs: log_mac_1 || log_mac_2 || ...
Expand Down Expand Up @@ -138,16 +137,20 @@ class EnclaveContext {
return append_mac;
}

void append_crumb(int ecall, uint8_t log_mac[OE_HMAC_SIZE], uint8_t all_outputs_mac[OE_HMAC_SIZE], int num_input_macs, std::vector<uint8_t> input_log_macs) {
// FIXME: make the arrays here const?
void append_crumb(int ecall, const uint8_t log_mac[OE_HMAC_SIZE], const uint8_t all_outputs_mac[OE_HMAC_SIZE], int num_input_macs, std::vector<uint8_t> input_log_macs) {
// FIXME: for some reason, compiler thinks the following two arguments are unused
(void) log_mac;
(void) all_outputs_mac;
Crumb new_crumb;

new_crumb.ecall = ecall;
memcpy(new_crumb.log_mac, (const uint8_t*) log_mac, OE_HMAC_SIZE);
memcpy(new_crumb.all_outputs_mac, (const uint8_t* all_outputs_mac), OE_HMAC_SIZE);
memcpy(new_crumb.all_outputs_mac, (const uint8_t*) all_outputs_mac, OE_HMAC_SIZE);
new_crumb.num_input_macs = num_input_macs;

// Copy over input_log_macs
for (int i = 0; i < input_log_macs.size(); i++) {
for (uint32_t i = 0; i < input_log_macs.size(); i++) {
new_crumb.input_log_macs.push_back(input_log_macs[i]);
}
crumbs.insert(new_crumb);
Expand All @@ -159,7 +162,7 @@ class EnclaveContext {
}

void append_input_mac(std::vector<uint8_t> input_mac) {
for (int i = 0; i < input_mac.size(); i++) {
for (uint32_t i = 0; i < input_mac.size(); i++) {
input_macs.push_back(input_mac[i]);
}
num_input_macs++;
Expand Down
23 changes: 10 additions & 13 deletions src/enclave/Enclave/FlatbuffersWriters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ flatbuffers::Offset<tuix::EncryptedBlocks> RowWriter::finish_blocks(std::string
curr_ecall_id,
num_macs,
enc_block_builder.CreateVector(mac_lst_ptr.get(), num_macs * SGX_AESGCM_MAC_SIZE),
enc_block_builder.CreateVector(mac_lst_mac_ptr.get(), OE_HMAC_SIZE)
enc_block_builder.CreateVector(mac_lst_mac_ptr.get(), OE_HMAC_SIZE),
enc_block_builder.CreateVector(input_macs_ptr.get(), num_input_macs * OE_HMAC_SIZE),
num_input_macs);

Expand All @@ -188,9 +188,9 @@ flatbuffers::Offset<tuix::EncryptedBlocks> RowWriter::finish_blocks(std::string
int crumb_ecall = crumb.ecall;

// FIXME: do these need to be memcpy'ed
std::vector<uint8_t> crumb_input_macs = crumb.input_macs;
std::vector<uint8_t> crumb_input_macs = crumb.input_log_macs;
uint8_t* crumb_all_outputs_mac = crumb.all_outputs_mac;
uint8_t* crumb_log_mac = crumb.log_mac
uint8_t* crumb_log_mac = crumb.log_mac;

// Copy crumb input macs to untrusted memory
uint8_t* untrusted_crumb_input_macs = nullptr;
Expand All @@ -213,7 +213,7 @@ flatbuffers::Offset<tuix::EncryptedBlocks> RowWriter::finish_blocks(std::string
&ocall_free);
memcpy(crumb_log_mac_ptr.get(), crumb_log_mac, OE_HMAC_SIZE);

auto serialized_crumb = tuix::CreateLogEntry(enc_block_builder,
auto serialized_crumb = tuix::CreateCrumb(enc_block_builder,
enc_block_builder.CreateVector(crumb_input_macs_ptr.get(), crumb_num_input_macs * OE_HMAC_SIZE),
num_input_macs,
enc_block_builder.CreateVector(crumb_all_outputs_mac_ptr.get(), OE_HMAC_SIZE),
Expand All @@ -239,18 +239,19 @@ flatbuffers::Offset<tuix::EncryptedBlocks> RowWriter::finish_blocks(std::string
int log_entry_num_bytes_to_mac = 3 * sizeof(int) + OE_HMAC_SIZE + num_input_macs * OE_HMAC_SIZE;

int num_bytes_in_crumbs_list = 0;
for (int k = 0; k < crumbs.size(); k++) {
for (uint32_t k = 0; k < crumbs.size(); k++) {
int num_bytes_in_crumb = 2 * sizeof(int) + 2 * OE_HMAC_SIZE + OE_HMAC_SIZE * crumbs[k].num_input_macs;
num_bytes_in_crumbs_list += num_byte_in_crumb;
num_bytes_in_crumbs_list += num_bytes_in_crumb;
}

// Below, we add sizeof(int) to include the num_past_entries entry that is part of LogEntryChain
int num_bytes_to_mac = log_entry_num_byte_to_mac + num_bytes_in_crumbs_list + sizeof(int);
int num_bytes_to_mac = log_entry_num_bytes_to_mac + num_bytes_in_crumbs_list + sizeof(int);
// FIXME: VLA
uint8_t to_mac[num_bytes_to_mac];

uint8_t log_mac[OE_HMAC_SIZE];
mac_log_entry_chain(num_bytes_to_mac, to_mac, mac_lst_mac, curr_ecall_id, num_macs, num_input_macs,
mac_lst_mac, input_macs, num_past_entries, crumbs, 0, num_past_entries, log_mac);
mac_log_entry_chain(num_bytes_to_mac, to_mac, curr_ecall_id, num_macs, num_input_macs,
mac_lst_mac, input_macs, num_crumbs, crumbs, 0, num_crumbs, log_mac);

// Copy the log_mac to untrusted memory
uint8_t* untrusted_log_mac = nullptr;
Expand All @@ -261,12 +262,8 @@ flatbuffers::Offset<tuix::EncryptedBlocks> RowWriter::finish_blocks(std::string
enc_block_builder.CreateVector(log_mac_ptr.get(), OE_HMAC_SIZE));
log_mac_vector.push_back(log_mac_offset);

// TODO: store the log mac in Enclave so that we can later compute all_outputs_mac over it
EnclaveContext::getInstance().append_log_mac(log_mac);

// Temporarily store 32 0's as the all_outputs_mac
uint8_t tmp_all_outputs_mac[OE_HMAC_SIZE] = {0};

// Clear log entry state
EnclaveContext::getInstance().reset_log_entry();
}
Expand Down
30 changes: 16 additions & 14 deletions src/enclave/Enclave/IntegrityUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ void init_log(const tuix::EncryptedBlocks *encrypted_blocks) {
EnclaveContext::getInstance().append_crumb(crumb_ecall, crumb_log_mac, crumb_all_outputs_mac, crumb_num_input_macs, crumb_vector_input_macs);

// Initialize crumb for LogEntryChain MAC verification
Crumb crumb;
crumb.ecall = crumb_ecall;
crumb.log_mac = crumb_log_mac;
crumb.all_outputs_mac = crumb_all_outputs_mac;
crumb.num_input_macs = crumb_num_input_macs;
crumb.input_log_macs = crumb_vector_input_macs;
crumbs.push_back(crumb);
Crumb new_crumb;
new_crumb.ecall = crumb_ecall;
memcpy(new_crumb.log_mac, crumb_log_mac, OE_HMAC_SIZE);
memcpy(new_crumb.all_outputs_mac, crumb_all_outputs_mac, OE_HMAC_SIZE);
new_crumb.num_input_macs = crumb_num_input_macs;
new_crumb.input_log_macs = crumb_vector_input_macs;
crumbs.push_back(new_crumb);
}

if (curr_entries_vec->size() > 0) {
Expand Down Expand Up @@ -75,9 +75,9 @@ void init_log(const tuix::EncryptedBlocks *encrypted_blocks) {
std::vector<uint8_t> vector_prev_input_macs(prev_input_macs, prev_input_macs + num_prev_input_macs * OE_HMAC_SIZE);

// Create new crumb given recently received EncryptedBlocks
uint8_t* mac_input = encrypted_blocks->all_outputs_mac()->Get(i)->mac()->data();
const uint8_t* mac_input = encrypted_blocks->all_outputs_mac()->Get(i)->mac()->data();
EnclaveContext::getInstance().append_crumb(
ecall, encrypted_blocks->log_mac()->Get(i)->mac()->data(),
logged_ecall, encrypted_blocks->log_mac()->Get(i)->mac()->data(),
mac_input, num_prev_input_macs, vector_prev_input_macs);

std::vector<uint8_t> mac_input_vector(mac_input, mac_input + OE_HMAC_SIZE);
Expand Down Expand Up @@ -160,7 +160,7 @@ void verify_log(const tuix::EncryptedBlocks *encrypted_blocks,
// MAC the data
uint8_t actual_mac[OE_HMAC_SIZE];
mac_log_entry_chain(total_bytes_to_mac, to_mac, curr_ecall, num_macs, num_input_macs,
curr_log_entry->mac_lst_mac()->data(), curr_log_entry->input_macs()->data(),
(uint8_t*) curr_log_entry->mac_lst_mac()->data(), (uint8_t*) curr_log_entry->input_macs()->data(),
num_past_entries, crumbs, past_entries_seen,
past_entries_seen + num_past_entries, actual_mac);

Expand Down Expand Up @@ -198,13 +198,13 @@ void mac_log_entry_chain(int num_bytes_to_mac, uint8_t* to_mac, int curr_ecall,
auto crumb = crumbs[i];
int past_ecall = crumb.ecall;
int num_input_macs = crumb.num_input_macs;
std::vector<uint8_t> input_macs = crumb.input_macs;
std::vector<uint8_t> input_log_macs = crumb.input_log_macs;
uint8_t* all_outputs_mac = crumb.all_outputs_mac;
uint8_t* log_mac = crumb.log_mac;

memcpy(tmp_ptr, &past_ecall, sizeof(int));
memcpy(tmp_ptr + sizeof(int), &num_input_macs, sizeof(int));
memcpy(tmp_ptr + 2 * sizeof(int), input_macs.data(), num_input_macs * OE_HMAC_SIZE);
memcpy(tmp_ptr + 2 * sizeof(int), input_log_macs.data(), num_input_macs * OE_HMAC_SIZE);
memcpy(tmp_ptr + 2 * sizeof(int) + num_input_macs * OE_HMAC_SIZE, all_outputs_mac, OE_HMAC_SIZE);
memcpy(tmp_ptr + 2 * sizeof(int) + (num_input_macs + 1) * OE_HMAC_SIZE, log_mac, OE_HMAC_SIZE);

Expand All @@ -216,18 +216,20 @@ void mac_log_entry_chain(int num_bytes_to_mac, uint8_t* to_mac, int curr_ecall,
}

// Replace dummy all_outputs_mac in output EncryptedBlocks with actual all_outputs_mac
void complete_encrypted_blocks(const tuix::EncryptedBlocks* encrypted_blocks) {
void complete_encrypted_blocks(uint8_t* encrypted_blocks) {
uint8_t all_outputs_mac[32];
generate_all_outputs_mac(all_outputs_mac);
// Perform in-place flatbuffers mutation to modify EncryptedBlocks with updated all_outputs_mac
auto blocks = tuix::GetMutableEncryptedBlocks(encrypted_blocks);
for (int i = 0; i < OE_HMAC_SIZE; i+) {
for (int i = 0; i < OE_HMAC_SIZE; i++) {
blocks->mutable_all_outputs_mac()->mutable_mac()->Mutate(i, all_outputs_mac[i]);
}
// TODO: check that buffer was indeed modified
}

void generate_all_outputs_mac(uint8_t all_outputs_mac[32]) {
// FIXME: for some reason compiler thinks the parameter is unused
(void) all_outputs_mac;
std::vector<uint8_t> log_macs_vector = EnclaveContext::getInstance().get_log_macs();
int num_log_macs = EnclaveContext::getInstance().get_num_log_macs();
uint8_t* log_macs = log_macs_vector.data();
Expand Down
4 changes: 2 additions & 2 deletions src/enclave/Enclave/IntegrityUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ void mac_log_entry_chain(int num_bytes_to_mac, uint8_t* to_mac, int curr_ecall,
int num_past_entries, std::vector<Crumb> crumbs, int first_crumb_index,
int last_crumb_index, uint8_t* ret_hmac);

void complete_encrypted_blocks(const tuix::EncryptedBlocks* encrypted_blocks);
void complete_encrypted_blocks(uint8_t* encrypted_blocks);

void generate_all_outputs_mac(uint8_t all_outputs_mac[32]) {
void generate_all_outputs_mac(uint8_t all_outputs_mac[32]);