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

Key gen #188

Open
wants to merge 126 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
7bba131
add example json files
chester-leung Sep 12, 2018
9ef3d1a
change json
chester-leung Sep 13, 2018
c6d1447
increase size of dataset
chester-leung Sep 13, 2018
db35a36
new json files
chester-leung Sep 14, 2018
4e62823
test which op
chester-leung Sep 14, 2018
eebda35
oblivioius union exec
chester-leung Sep 14, 2018
2b91940
d
chester-leung Sep 14, 2018
d20bc21
add script
chester-leung Sep 14, 2018
dfd4fcc
try
chester-leung Sep 14, 2018
147e39e
main
chester-leung Sep 14, 2018
9ba0e93
try
chester-leung Sep 14, 2018
b9484c6
script like
chester-leung Sep 14, 2018
98f038b
ugh
chester-leung Sep 14, 2018
3241617
hmm
chester-leung Sep 14, 2018
5d76a82
good to go now
chester-leung Sep 14, 2018
4df358c
rename
chester-leung Sep 14, 2018
ccb0590
repartition in obliviousUnionExec if Rdds are different
chester-leung Sep 15, 2018
323a0b1
rm enc_join.scala to prevent compile errors
chester-leung Sep 15, 2018
eba9d26
try again
chester-leung Sep 15, 2018
342b566
repartition both to 1 if different sizes
chester-leung Sep 15, 2018
1306c06
h
chester-leung Sep 15, 2018
e4ba8be
try coalesce
chester-leung Sep 15, 2018
71bc6e4
copy ankur fix
chester-leung Sep 18, 2018
0a470af
repartition to coalesce
chester-leung Sep 18, 2018
1f8dd72
rm redundant code
chester-leung Sep 18, 2018
e8599fa
syntax error
chester-leung Sep 18, 2018
07151d9
fix merge conflict
chester-leung Sep 18, 2018
e97caf7
revert master
chester-leung Sep 18, 2018
824a33a
merge conflict
chester-leung Sep 23, 2018
a3f2b70
Merge remote-tracking branch 'upstream/master'
chester-leung Oct 14, 2018
3c503ed
Merge remote-tracking branch 'upstream/master'
chester-leung Oct 19, 2018
2a5da1b
Merge remote-tracking branch 'upstream/master'
chester-leung Oct 30, 2018
efac04f
Merge remote-tracking branch 'upstream/master'
chester-leung Nov 8, 2018
973d5ea
merge upstream changes
chester-leung Nov 8, 2018
2903cdf
rm unnecessary files
chester-leung Nov 9, 2018
6202ac7
Merge remote-tracking branch 'upstream/master'
chester-leung Nov 15, 2018
c7f1bbc
Merge branch 'master' of https://github.com/chester-leung/opaque
chester-leung Nov 15, 2018
12f98a8
Merge remote-tracking branch 'upstream/master'
chester-leung Nov 28, 2018
1d229be
Merge remote-tracking branch 'upstream/master'
chester-leung Jan 30, 2019
8785652
Merge remote-tracking branch 'upstream/master'
chester-leung Apr 19, 2019
e6555d4
Update master
chester-leung Apr 19, 2019
74e4f7c
disable attestation and hardcode shared key
Oct 24, 2019
3824a8d
hardcoded shared key working. Using SGXEnclave.RemoteAttestation3 to …
vtikoo Oct 29, 2019
2127b87
remove code for unused attestation steps
vtikoo Oct 29, 2019
b6df907
remove sgx calls
vtikoo Nov 11, 2019
b99e5e9
remove version script related linker options
vtikoo Nov 13, 2019
f5d6181
replace sgx_read_rand with mbedtls ctr drbg based impl
vtikoo Nov 23, 2019
197e4d9
replace malloc impl with oe_host_malloc
vtikoo Nov 27, 2019
c3fcc0d
OE report and RSA encryption
yentsanglee Dec 27, 2019
a02813f
mCrypto
yentsanglee Dec 27, 2019
c6499ef
uncomment strftime usages
vtikoo Dec 30, 2019
ae690ce
new oe_remote_verify_report api
yentsanglee Dec 30, 2019
2d470f3
Merge branch 'yenlee_no_sgx' of github.com:vtikoo/opaque into yenlee_…
yentsanglee Dec 30, 2019
187c467
Porting OpenEnclave
wzheng Jun 12, 2020
af932a2
Added mrsigner verification
wzheng Jun 13, 2020
eb487fd
Updated gitignore
wzheng Jun 14, 2020
66bca5a
Merge branch 'openenclave' of github.com:wzheng/opaque into openenclave
wzheng Jun 14, 2020
fe7b66e
Added the other verification steps for remote attestaion
wzheng Jun 14, 2020
397efba
Shared key for each client wip
chester-leung Jun 18, 2020
ed8e750
shared key xor
chester-leung Jun 22, 2020
8c79576
Everything builds but runtime failure
chester-leung Jun 25, 2020
9523b6d
initRA finishes but tests fail
chester-leung Jun 25, 2020
ea356a6
Add +5 to user cert len
chester-leung Jun 25, 2020
e69c69a
Filter works
chester-leung Jun 26, 2020
24cadcd
Adding username to retrieve proper client key
chester-leung Jul 1, 2020
f6f6ee8
Add utils function to set client key
chester-leung Jul 1, 2020
f8c39f7
Decryption with different keys
chester-leung Jul 1, 2020
7a9204e
Loading from files encrypted with differnt keys works, this checkpoin…
chester-leung Jul 2, 2020
e02308c
Added fixmes to remove testing code
chester-leung Jul 2, 2020
ba76eb9
Code cleanup
chester-leung Jul 2, 2020
0fecefd
Add test scripts and sample serialized dataframes
chester-leung Jul 6, 2020
a520713
Merge branch 'master' of https://github.com/mc2-project/opaque
chester-leung Sep 16, 2020
732a8a9
Removed all mention of test key
chester-leung Oct 8, 2020
3a38ce8
comment out print statements
chester-leung Oct 8, 2020
f0525e5
Merge branch 'master' of https://github.com/mc2-project/opaque
chester-leung Oct 8, 2020
7161e5a
Merge master
chester-leung Oct 8, 2020
3c20d70
Set environment variables to point to key paths
chester-leung Oct 8, 2020
6641f6a
create sbt task to encrypt wip
chester-leung Oct 14, 2020
a622119
Merge branch 'master' of https://github.com/mc2-project/opaque
chester-leung Oct 14, 2020
4553ee4
Remove extra files
chester-leung Oct 15, 2020
813c833
Opaqueenv
chester-leung Nov 2, 2020
7986f32
Merge branch 'master' of https://github.com/mc2-project/opaque
chester-leung Nov 2, 2020
d220d1f
Clean up
chester-leung Nov 2, 2020
3710716
Merge master
chester-leung Nov 2, 2020
9c87e8e
Clean up
chester-leung Nov 2, 2020
8cfa2a1
Merge master into multiparty (#134)
eric-feng-2011 Jan 22, 2021
a2b7f3a
merge request
eric-feng-2011 Feb 17, 2021
b008c07
merge conflict
eric-feng-2011 Feb 17, 2021
bb85a74
merge conflict resolution
eric-feng-2011 Feb 17, 2021
c032e88
Prelim key gen skeleton
eric-feng-2011 Feb 17, 2021
5bba78e
Add enclave shared key gen
eric-feng-2011 Feb 18, 2021
29c2cae
Update opaqueenv and finish shared key generation
eric-feng-2011 Feb 18, 2021
01a12db
Merge remote-tracking branch 'upstream/master' into key-gen
Feb 22, 2021
117c2a1
LA initial compile success
Feb 22, 2021
633be46
Modify RA
eric-feng-2011 Feb 22, 2021
9fc8205
Compile pass 2. Still wrong key
eric-feng-2011 Feb 23, 2021
f507115
second step sk_list compile
eric-feng-2011 Feb 23, 2021
48a0d9a
Shared key gen, public key verification in progress
eric-feng-2011 Feb 25, 2021
55a0d30
oe evidence pk verify
eric-feng-2011 Mar 9, 2021
0205361
enclave verification
eric-feng-2011 Mar 10, 2021
87f665a
Trying to inject public key through cmake
eric-feng-2011 Mar 12, 2021
7d1ddd7
Finish attestation with oe verification
eric-feng-2011 Mar 18, 2021
0687cdb
Merge conflict 1
eric-feng-2011 Mar 23, 2021
013c1da
merge conflict attempt 2
eric-feng-2011 Mar 23, 2021
b38cbe7
Merge conflict 3 - compile and run pass
eric-feng-2011 Mar 23, 2021
b39a7fb
Merge attempt 3
eric-feng-2011 Mar 23, 2021
96de8ce
merge 5
eric-feng-2011 Mar 23, 2021
77601b8
need to change branches
eric-feng-2011 Mar 23, 2021
62177c3
remove driver and sp keys
eric-feng-2011 Mar 24, 2021
1534f5f
Update LA syntax and LA enclave check
eric-feng-2011 Mar 24, 2021
8fbf4bf
Merge remote-tracking branch 'upstream/master' into key-gen
eric-feng-2011 Mar 24, 2021
7504ac1
Delete client_key.txt
eric-feng-2011 Mar 24, 2021
d495f37
Delete Enclave_private.pem
eric-feng-2011 Mar 24, 2021
9a3409a
Delete user1.crt
eric-feng-2011 Mar 24, 2021
d025c0c
clean code 1
eric-feng-2011 Mar 24, 2021
abc6b5a
Merge branch 'key-gen' of https://github.com/eric-feng-2011/opaque in…
eric-feng-2011 Mar 24, 2021
1c2f4af
clean serviceprovider (keeping some key stuff for future)
eric-feng-2011 Mar 24, 2021
7a60a0e
sanity test 0 key debugging
eric-feng-2011 Mar 25, 2021
de05e17
build/sbt test
eric-feng-2011 Mar 27, 2021
55a2614
remove RA print statements
eric-feng-2011 Mar 27, 2021
cfd2bb1
Remove initEnclave and port to Utils for LA calls
eric-feng-2011 Mar 30, 2021
98c4dd3
Resolve issue of Utils shared key size in in case of simulation mode
eric-feng-2011 Mar 30, 2021
b7b87f5
Resolve single partition test memory
eric-feng-2011 Mar 30, 2021
9f0ebcf
Resolve simulation flag issue
eric-feng-2011 Mar 30, 2021
3cdf7f4
Merge branch 'master' into key-gen
eric-feng-2011 Apr 15, 2021
884a051
resolve key issue
eric-feng-2011 Apr 15, 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
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ enclaveBuildTask := {
).!
if (cmakeResult != 0) sys.error("C++ build failed.")
val nproc = java.lang.Runtime.getRuntime.availableProcessors
val mode = sys.env.get("MODE").get
val buildResult = Process(Seq("make", "-j" + nproc), enclaveBuildDir).!
if (buildResult != 0) sys.error("C++ build failed.")
val installResult = Process(Seq("make", "install"), enclaveBuildDir).!
Expand Down
27 changes: 27 additions & 0 deletions gen_pubkey_header.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

# Copyright (c) Open Enclave SDK contributors.
# Licensed under the MIT License.

destfile="$1"
pubkey_file="$2"

cat > "$destfile" << EOF
// Copyright (c) Open Enclave SDK contributors.
// Licensed under the MIT License.

EOF

printf 'static const char OTHER_ENCLAVE_PUBLIC_KEY[] =' >> "$destfile"
while IFS="" read -r p || [ -n "$p" ]
do
# Sometimes openssl can insert carriage returns into the PEM files. Let's remove those!
CR=$(printf "\r")
p=$(echo "$p" | tr -d "$CR")
printf '\n \"%s\\n\"' "$p" >> "$destfile"
done < "$pubkey_file"
printf ';\n' >> "$destfile"

cat >> "$destfile" << EOF

EOF
Binary file added keys/key_share.txt
Binary file not shown.
115 changes: 115 additions & 0 deletions src/enclave/App/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,88 @@ JNIEXPORT void JNICALL Java_edu_berkeley_cs_rise_opaque_execution_SGXEnclave_Fin
env->ReleaseByteArrayElements(shared_key_msg_input, shared_key_msg_bytes, 0);
}

/////////////////////////////// Shared Key Gen Begin ////////////////////////////////

JNIEXPORT jbyteArray JNICALL Java_edu_berkeley_cs_rise_opaque_execution_SGXEnclave_GetPublicKey(
JNIEnv *env, jobject obj, jlong eid) {
(void)obj;
(void)eid;

uint8_t* report_msg = NULL;
size_t report_msg_size = 0;

oe_check_and_time("Get enclave public key",
ecall_get_public_key((oe_enclave_t*)eid,
&report_msg,
&report_msg_size));

// Allocate memory
jbyteArray report_msg_bytes = env->NewByteArray(report_msg_size);
env->SetByteArrayRegion(report_msg_bytes, 0, report_msg_size, reinterpret_cast<jbyte *>(report_msg));

return report_msg_bytes;
}

JNIEXPORT jbyteArray JNICALL Java_edu_berkeley_cs_rise_opaque_execution_SGXEnclave_GetListEncrypted(
JNIEnv *env, jobject obj, jlong eid, jbyteArray shared_key_msg_input) {
(void)obj;

jboolean if_copy = false;
jbyte *shared_key_msg_bytes = env->GetByteArrayElements(shared_key_msg_input, &if_copy);
uint32_t shared_key_msg_size = static_cast<uint32_t>(env->GetArrayLength(shared_key_msg_input));

size_t report_msg_size = OE_SHARED_KEY_CIPHERTEXT_SIZE * (shared_key_msg_size / OE_PUBLIC_KEY_SIZE);
uint8_t* report_msg = new uint8_t[report_msg_size];

oe_check_and_time("Get List Encrypted",
ecall_get_list_encrypted((oe_enclave_t*)eid,
reinterpret_cast<uint8_t *>(shared_key_msg_bytes),
shared_key_msg_size,
report_msg,
report_msg_size));

// Allocate memory
jbyteArray report_msg_bytes = env->NewByteArray(report_msg_size);
env->SetByteArrayRegion(report_msg_bytes, 0, report_msg_size, reinterpret_cast<jbyte *>(report_msg));

env->ReleaseByteArrayElements(shared_key_msg_input, (jbyte *) shared_key_msg_bytes, 0);

delete[] report_msg;

return report_msg_bytes;
}

JNIEXPORT jbyteArray JNICALL Java_edu_berkeley_cs_rise_opaque_execution_SGXEnclave_FinishSharedKey(
JNIEnv *env, jobject obj, jlong eid, jbyteArray shared_key_msg_input) {
(void)obj;

jboolean if_copy = false;

jbyte *shared_key_msg_bytes = env->GetByteArrayElements(shared_key_msg_input, &if_copy);
uint32_t shared_key_msg_size = static_cast<uint32_t>(env->GetArrayLength(shared_key_msg_input));

size_t report_msg_size = SGX_AESGCM_KEY_SIZE;
uint8_t* report_msg = new uint8_t[report_msg_size];

oe_check_and_time("Finish attestation",
ecall_finish_shared_key((oe_enclave_t*)eid,
reinterpret_cast<uint8_t *>(shared_key_msg_bytes),
shared_key_msg_size,
report_msg,
report_msg_size));

// Allocate memory
jbyteArray report_msg_bytes = env->NewByteArray(report_msg_size);
env->SetByteArrayRegion(report_msg_bytes, 0, report_msg_size, reinterpret_cast<jbyte *>(report_msg));

env->ReleaseByteArrayElements(shared_key_msg_input, shared_key_msg_bytes, 0);
delete[] report_msg;

return report_msg_bytes;
}

/////////////////////////////// Shared Key Gen End ////////////////////////////////

JNIEXPORT void JNICALL Java_edu_berkeley_cs_rise_opaque_execution_SGXEnclave_StopEnclave(
JNIEnv *env, jobject obj, jlong eid) {
(void)env;
Expand Down Expand Up @@ -345,6 +427,39 @@ JNIEXPORT jbyteArray JNICALL Java_edu_berkeley_cs_rise_opaque_execution_SGXEncla
return ciphertext;
}

// Added Decryption function
JNIEXPORT jbyteArray JNICALL Java_edu_berkeley_cs_rise_opaque_execution_SGXEnclave_Decrypt(
JNIEnv *env, jobject obj, jlong eid, jbyteArray ciphertext) {
(void)obj;

uint32_t clength = (uint32_t)env->GetArrayLength(ciphertext);
jboolean if_copy = false;
uint8_t *ciphertext_ptr = (uint8_t *)env->GetByteArrayElements(ciphertext, &if_copy);

uint8_t *plaintext_copy = nullptr;
jsize plength = 0;

if (ciphertext_ptr == nullptr) {
ocall_throw("Encrypt: JNI failed to get input byte array.");
} else {
plength = clength - SGX_AESGCM_IV_SIZE - SGX_AESGCM_MAC_SIZE;
plaintext_copy = new uint8_t[clength];

oe_check("Decrypt", ecall_decrypt((oe_enclave_t *)eid, ciphertext_ptr, clength,
plaintext_copy, (uint32_t)plength));
}

jbyteArray plaintext = env->NewByteArray(plength);
env->SetByteArrayRegion(plaintext, 0, plength, (jbyte *)plaintext_copy);

env->ReleaseByteArrayElements(ciphertext, (jbyte *)ciphertext_ptr, 0);

delete[] plaintext_copy;

return plaintext;
}


JNIEXPORT jbyteArray JNICALL Java_edu_berkeley_cs_rise_opaque_execution_SGXEnclave_Sample(
JNIEnv *env, jobject obj, jlong eid, jbyteArray input_rows) {
(void)obj;
Expand Down
9 changes: 9 additions & 0 deletions src/enclave/App/SGXEnclave.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ Java_edu_berkeley_cs_rise_opaque_execution_SGXEnclave_GenerateReport(JNIEnv *, j
JNIEXPORT void JNICALL Java_edu_berkeley_cs_rise_opaque_execution_SGXEnclave_FinishAttestation(
JNIEnv *, jobject, jlong, jbyteArray);

JNIEXPORT jbyteArray JNICALL Java_edu_berkeley_cs_rise_opaque_execution_SGXEnclave_GetPublicKey(
JNIEnv *, jobject, jlong);

JNIEXPORT jbyteArray JNICALL Java_edu_berkeley_cs_rise_opaque_execution_SGXEnclave_GetListEncrypted(
JNIEnv *, jobject, jlong, jbyteArray);

JNIEXPORT jbyteArray JNICALL Java_edu_berkeley_cs_rise_opaque_execution_SGXEnclave_FinishSharedKey(
JNIEnv *, jobject, jlong, jbyteArray);

#ifdef __cplusplus
}
#endif
Expand Down
Loading