Skip to content

Commit

Permalink
changed up a lot of import resolutions to make everything work, inclu…
Browse files Browse the repository at this point in the history
…ding in IDEs

also ran cargo fmt on a few files
  • Loading branch information
reuvenpo committed May 26, 2020
1 parent 129037b commit 124a396
Show file tree
Hide file tree
Showing 10 changed files with 547 additions and 439 deletions.
648 changes: 365 additions & 283 deletions cosmwasm/lib/wasmi-runtime/Cargo.lock

Large diffs are not rendered by default.

40 changes: 11 additions & 29 deletions cosmwasm/lib/wasmi-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,18 @@ SGX_MODE_HW = []
production = []
test = []

# This annotation is here to trick the IDE into showing us type information about this crate.
# we alwats compile to the "sgx" target, so this will always be false.
# when compiling to the "sgx" target, we pull this from the target root with an "extern crate" directive
[target.'cfg(not(target_env = "sgx"))'.dependencies]
sgx_types = { rev = "v1.1.2", git = "https://github.com/apache/teaclave-sgx-sdk.git" }

[dependencies]
sgx_tse = { rev = "v1.1.2", git = "https://github.com/apache/teaclave-sgx-sdk.git" }
sgx_rand = { rev = "v1.1.2", git = "https://github.com/apache/teaclave-sgx-sdk.git" }
sgx_trts = { rev = "v1.1.2", git = "https://github.com/apache/teaclave-sgx-sdk.git" }
sgx_tseal = { rev = "v1.1.2", git = "https://github.com/apache/teaclave-sgx-sdk.git" }
sgx_tcrypto = { rev = "v1.1.2", git = "https://github.com/apache/teaclave-sgx-sdk.git" }
enclave-ffi-types = { path = "../enclave-ffi-types" }
pwasm-utils = { version = "0.12.0", default-features = false }
parity-wasm = { version = "0.41.0", default-features = false }
Expand Down Expand Up @@ -68,32 +79,3 @@ features = ["dangerous_configuration", "mesalock_sgx"]

[dev-dependencies]
sgx_edl = { rev = "v1.1.2", git = "https://github.com/apache/teaclave-sgx-sdk.git" }
# Comment out these following lines to use rust-sgx-sdk from git
# [patch.'https://github.com/apache/teaclave-sgx-sdk.git']
# sgx_alloc = { path = "../incubator-teaclave-sgx-sdk/sgx_alloc" }
# sgx_backtrace = { path = "../incubator-teaclave-sgx-sdk/sgx_backtrace" }
# sgx_backtrace_sys = { path = "../incubator-teaclave-sgx-sdk/sgx_backtrace_sys" }
# sgx_build_helper = { path = "../incubator-teaclave-sgx-sdk/sgx_build_helper" }
# sgx_cov = { path = "../incubator-teaclave-sgx-sdk/sgx_cov" }
# sgx_crypto_helper = { path = "../incubator-teaclave-sgx-sdk/sgx_crypto_helper" }
# sgx_demangle = { path = "../incubator-teaclave-sgx-sdk/sgx_demangle" }
# sgx_libc = { path = "../incubator-teaclave-sgx-sdk/sgx_libc" }
# sgx_rand = { path = "../incubator-teaclave-sgx-sdk/sgx_rand" }
# sgx_rand_derive = { path = "../incubator-teaclave-sgx-sdk/sgx_rand_derive" }
# sgx_serialize = { path = "../incubator-teaclave-sgx-sdk/sgx_serialize" }
# sgx_serialize_derive = { path = "../incubator-teaclave-sgx-sdk/sgx_serialize_derive" }
# sgx_serialize_derive_internals = { path = "../incubator-teaclave-sgx-sdk/sgx_serialize_derive_internals" }
# sgx_tcrypto = { path = "../incubator-teaclave-sgx-sdk/sgx_tcrypto" }
# sgx_tcrypto_helper = { path = "../incubator-teaclave-sgx-sdk/sgx_tcrypto_helper" }
# sgx_tdh = { path = "../incubator-teaclave-sgx-sdk/sgx_tdh" }
# sgx_tkey_exchange = { path = "../incubator-teaclave-sgx-sdk/sgx_tkey_exchange" }
# sgx_tprotected_fs = { path = "../incubator-teaclave-sgx-sdk/sgx_tprotected_fs" }
# sgx_trts = { path = "../incubator-teaclave-sgx-sdk/sgx_trts" }
# sgx_tse = { path = "../incubator-teaclave-sgx-sdk/sgx_tse" }
# sgx_tseal = { path = "../incubator-teaclave-sgx-sdk/sgx_tseal" }
# sgx_tstd = { path = "../incubator-teaclave-sgx-sdk/sgx_tstd" }
# sgx_tunittest = { path = "../incubator-teaclave-sgx-sdk/sgx_tunittest" }
# sgx_types = { path = "../incubator-teaclave-sgx-sdk/sgx_types" }
# sgx_ucrypto = { path = "../incubator-teaclave-sgx-sdk/sgx_ucrypto" }
# sgx_unwind = { path = "../incubator-teaclave-sgx-sdk/sgx_unwind" }
# sgx_urts = { path = "../incubator-teaclave-sgx-sdk/sgx_urts" }
10 changes: 4 additions & 6 deletions cosmwasm/lib/wasmi-runtime/src/attestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use sgx_tse::*;
use sgx_types::*;
use std::io::{Read, Write};
use std::net::TcpStream;
use std::prelude::v1::*;

use std::ptr;
use std::str;
Expand All @@ -17,8 +16,8 @@ use std::sync::Arc;
use std::untrusted::fs;
use std::vec::Vec;

use crate::crypto::KeyPair;
use crate::consts::{API_KEY_FILE, SPID_FILE};
use crate::crypto::KeyPair;
use crate::hex;
use crate::imports::*;

Expand Down Expand Up @@ -117,7 +116,6 @@ pub fn create_attestation_certificate(
kp: &KeyPair,
sign_type: sgx_quote_sign_type_t,
) -> Result<(Vec<u8>, Vec<u8>), sgx_status_t> {

// extract private key from KeyPair
let mut priv_key_buf: [u8; 32] = [0u8; 32];
priv_key_buf.copy_from_slice(kp.get_privkey());
Expand All @@ -132,7 +130,7 @@ pub fn create_attestation_certificate(

// convert keypair private to sgx ecc private
let prv_k = sgx_ec256_private_t {
r: priv_key_buf.clone()
r: priv_key_buf.clone(),
};
// generate the P256 public (will be different from KeyPair's public key)
let pub_k = rsgx_ecc256_pub_from_priv(&prv_k).unwrap();
Expand Down Expand Up @@ -227,8 +225,8 @@ pub fn create_attestation_report(
report_data.d[..64].copy_from_slice(pub_k);

/* This is used to match the encoding of the public key here with the ecc key, but honestly
the certificate uses curve P256, so that will cause issues anyway -- I'm leaving the code here
as a reference in case we want to take another look at this at some point */
the certificate uses curve P256, so that will cause issues anyway -- I'm leaving the code here
as a reference in case we want to take another look at this at some point */

// let mut pub_k_gx = pub_k.gx.clone();
// pub_k_gx.reverse();
Expand Down
Loading

0 comments on commit 124a396

Please sign in to comment.