diff --git a/vsock-proxy/Cargo.lock b/vsock-proxy/Cargo.lock index d63abba..2c088ac 100644 --- a/vsock-proxy/Cargo.lock +++ b/vsock-proxy/Cargo.lock @@ -185,12 +185,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "autocfg" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" - [[package]] name = "autocfg" version = "1.1.0" @@ -409,15 +403,6 @@ dependencies = [ "vec_map", ] -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - [[package]] name = "cmake" version = "0.1.46" @@ -509,7 +494,7 @@ version = "0.9.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" dependencies = [ - "autocfg 1.1.0", + "autocfg", "cfg-if 1.0.0", "crossbeam-utils", "memoffset 0.9.0", @@ -584,62 +569,34 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "em-app" version = "0.4.0" -source = "git+https://github.com/fortanix/rust-sgx.git?branch=ns/RTE-147#a8a42b160201cc3ea7d8bc293b2803db559adc67" +source = "git+https://github.com/fortanix/rust-sgx.git#9bcd71b7426ca0154a3445ea2165c0a6a23bc8af" dependencies = [ "aws-nitro-enclaves-nsm-api", "b64-ct", - "em-client 3.1.0", + "em-client", "em-node-agent-client", "hyper", - "mbedtls 0.12.1", + "mbedtls", "pkix", "rustc-serialize", - "sdkms 0.3.0", + "sdkms", "serde", "serde_bytes", "serde_derive", "serde_json 1.0.68", - "sgx-isa 0.4.1 (git+https://github.com/fortanix/rust-sgx.git?branch=ns/RTE-147)", - "sgx_pkix 0.2.2 (git+https://github.com/fortanix/rust-sgx.git?branch=ns/RTE-147)", + "sgx-isa", + "sgx_pkix", "url 1.7.2", "uuid 0.6.5", "uuid 0.8.2", - "vme-pkix 0.1.1", - "yasna 0.3.2", -] - -[[package]] -name = "em-app" -version = "0.4.0" -source = "git+https://github.com/fortanix/rust-sgx.git#c9028cffb8d80fe325f10eefb26f1f912c235c21" -dependencies = [ - "aws-nitro-enclaves-nsm-api", - "b64-ct", - "em-client 3.0.0", - "em-node-agent-client", - "hyper", - "mbedtls 0.9.3", - "pkix", - "rustc-serialize", - "sdkms 0.2.1", - "serde", - "serde_bytes", - "serde_derive", - "serde_json 1.0.68", - "sgx-isa 0.4.1 (git+https://github.com/fortanix/rust-sgx.git)", - "sgx_pkix 0.2.2 (git+https://github.com/fortanix/rust-sgx.git)", - "url 1.7.2", - "uuid 0.6.5", - "uuid 0.7.4", - "vme-pkix 0.1.0", + "vme-pkix", "yasna 0.3.2", ] [[package]] name = "em-client" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0bd923300728ad79f8c36f689f96d928d224524a2120a204fa2bb7801991e7c" +version = "4.0.0" +source = "git+https://github.com/fortanix/em-client-rust#60c5764e78a24caa80591d79a260fcd83359319b" dependencies = [ "base64 0.10.1", "bitflags", @@ -648,28 +605,7 @@ dependencies = [ "hyper", "lazy_static 1.4.0", "log 0.3.9", - "mime", - "serde", - "serde_derive", - "serde_ignored", - "serde_json 1.0.68", - "url 1.7.2", - "uuid 0.6.5", -] - -[[package]] -name = "em-client" -version = "3.1.0" -source = "git+https://github.com/fortanix/em-client-rust?branch=ns/RTE-147#f23e6a89474fd79d1334d6710405730b231c5a33" -dependencies = [ - "base64 0.10.1", - "bitflags", - "chrono", - "futures 0.1.31", - "hyper", - "lazy_static 1.4.0", - "log 0.3.9", - "mbedtls 0.9.3", + "mbedtls", "mime", "serde", "serde_derive", @@ -710,7 +646,7 @@ dependencies = [ "base64 0.13.0", "clap", "const_format", - "em-app 0.4.0 (git+https://github.com/fortanix/rust-sgx.git?branch=ns/RTE-147)", + "em-app", "env_logger 0.7.1", "futures 0.3.16", "hyper", @@ -718,13 +654,13 @@ dependencies = [ "ipnetwork", "lazy_static 1.4.0", "log 0.4.14", - "mbedtls 0.12.1", + "mbedtls", "nix 0.15.0", "parent_lib", "pkix", "rand 0.8.5", "rtnetlink", - "sdkms 0.3.0", + "sdkms", "serde", "serde_cbor", "serde_json 1.0.2", @@ -1272,24 +1208,6 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" -[[package]] -name = "mbedtls" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3a846b1d4b990bc3d900554a12528dfe4b3ab920eac016ee5b314aef4f8e4a9" -dependencies = [ - "bitflags", - "byteorder", - "cc", - "cfg-if 1.0.0", - "mbedtls-platform-support", - "mbedtls-sys-auto", - "rs-libc", - "serde", - "serde_derive", - "yasna 0.2.2", -] - [[package]] name = "mbedtls" version = "0.12.1" @@ -1348,7 +1266,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" dependencies = [ - "autocfg 1.1.0", + "autocfg", ] [[package]] @@ -1357,7 +1275,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" dependencies = [ - "autocfg 1.1.0", + "autocfg", ] [[package]] @@ -1366,7 +1284,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" dependencies = [ - "autocfg 1.1.0", + "autocfg", ] [[package]] @@ -1604,7 +1522,7 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" dependencies = [ - "autocfg 1.1.0", + "autocfg", "num-integer", "num-traits 0.2.14", ] @@ -1615,7 +1533,7 @@ version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" dependencies = [ - "autocfg 1.1.0", + "autocfg", "num-traits 0.2.14", ] @@ -1634,7 +1552,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" dependencies = [ - "autocfg 1.1.0", + "autocfg", ] [[package]] @@ -1691,7 +1609,7 @@ version = "0.9.80" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7" dependencies = [ - "autocfg 1.1.0", + "autocfg", "cc", "libc", "pkg-config", @@ -1705,7 +1623,7 @@ dependencies = [ "api-model", "async-process", "clap", - "em-app 0.4.0 (git+https://github.com/fortanix/rust-sgx.git)", + "em-app", "env_logger 0.7.1", "etherparse", "futures 0.3.16", @@ -1919,25 +1837,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg 0.1.7", - "libc", - "rand_chacha 0.1.1", - "rand_core 0.4.2", - "rand_hc", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg", - "rand_xorshift", - "winapi 0.3.9", -] - [[package]] name = "rand" version = "0.8.5" @@ -1945,20 +1844,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha 0.3.1", + "rand_chacha", "rand_core 0.6.4", ] -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.3.1", -] - [[package]] name = "rand_chacha" version = "0.3.1" @@ -1993,68 +1882,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi 0.3.9", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi 0.3.9", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.4.2", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "rayon" version = "1.7.0" @@ -2213,24 +2040,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" -[[package]] -name = "sdkms" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c843377a2ed87d63e487c7b41b1a82446ab7dc836addd66d63010ea05b14aaf7" -dependencies = [ - "bitflags", - "chrono", - "hyper", - "log 0.4.14", - "rustc-serialize", - "serde", - "serde_derive", - "serde_json 1.0.68", - "url 1.7.2", - "uuid 0.7.4", -] - [[package]] name = "sdkms" version = "0.3.0" @@ -2283,9 +2092,9 @@ dependencies = [ [[package]] name = "serde_bytes" -version = "0.11.5" +version = "0.11.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16ae07dd2f88a366f15bd0632ba725227018c69a1c8550a927324f8eb8368bb9" +checksum = "f3c5113243e4a3a1c96587342d067f3e6b0f50790b6cf40d2868eb647a3eef0e" dependencies = [ "serde", ] @@ -2346,15 +2155,7 @@ dependencies = [ [[package]] name = "sgx-isa" version = "0.4.1" -source = "git+https://github.com/fortanix/rust-sgx.git?branch=ns/RTE-147#a8a42b160201cc3ea7d8bc293b2803db559adc67" -dependencies = [ - "bitflags", -] - -[[package]] -name = "sgx-isa" -version = "0.4.1" -source = "git+https://github.com/fortanix/rust-sgx.git#c9028cffb8d80fe325f10eefb26f1f912c235c21" +source = "git+https://github.com/fortanix/rust-sgx.git#9bcd71b7426ca0154a3445ea2165c0a6a23bc8af" dependencies = [ "bitflags", ] @@ -2362,25 +2163,13 @@ dependencies = [ [[package]] name = "sgx_pkix" version = "0.2.2" -source = "git+https://github.com/fortanix/rust-sgx.git?branch=ns/RTE-147#a8a42b160201cc3ea7d8bc293b2803db559adc67" -dependencies = [ - "byteorder", - "lazy_static 1.4.0", - "pkix", - "quick-error", - "sgx-isa 0.4.1 (git+https://github.com/fortanix/rust-sgx.git?branch=ns/RTE-147)", -] - -[[package]] -name = "sgx_pkix" -version = "0.2.2" -source = "git+https://github.com/fortanix/rust-sgx.git#c9028cffb8d80fe325f10eefb26f1f912c235c21" +source = "git+https://github.com/fortanix/rust-sgx.git#9bcd71b7426ca0154a3445ea2165c0a6a23bc8af" dependencies = [ "byteorder", "lazy_static 1.4.0", "pkix", "quick-error", - "sgx-isa 0.4.1 (git+https://github.com/fortanix/rust-sgx.git)", + "sgx-isa", ] [[package]] @@ -2611,7 +2400,7 @@ version = "1.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0020c875007ad96677dcc890298f4b942882c5d4eb7cc8f439fc3bf813dc9c95" dependencies = [ - "autocfg 1.1.0", + "autocfg", "bytes 1.0.1", "libc", "memchr", @@ -2782,10 +2571,6 @@ name = "uuid" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" -dependencies = [ - "rand 0.6.5", - "serde", -] [[package]] name = "uuid" @@ -2821,19 +2606,10 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" -[[package]] -name = "vme-pkix" -version = "0.1.0" -source = "git+https://github.com/fortanix/rust-sgx.git#c9028cffb8d80fe325f10eefb26f1f912c235c21" -dependencies = [ - "lazy_static 1.4.0", - "pkix", -] - [[package]] name = "vme-pkix" version = "0.1.1" -source = "git+https://github.com/fortanix/rust-sgx.git?branch=ns/RTE-147#a8a42b160201cc3ea7d8bc293b2803db559adc67" +source = "git+https://github.com/fortanix/rust-sgx.git#9bcd71b7426ca0154a3445ea2165c0a6a23bc8af" dependencies = [ "lazy_static 1.4.0", "pkix", diff --git a/vsock-proxy/Cargo.toml b/vsock-proxy/Cargo.toml index 3b0191e..3fb3fa1 100644 --- a/vsock-proxy/Cargo.toml +++ b/vsock-proxy/Cargo.toml @@ -5,3 +5,11 @@ members = [ "parent", "enclave", ] + +[workspace.dependencies] +em-app = { version = "0.4.0" } +em-client = { version = "4.0.0" } + +[patch.crates-io] +em-app = { git = "https://github.com/fortanix/rust-sgx.git" } +em-client = { git = "https://github.com/fortanix/em-client-rust" } diff --git a/vsock-proxy/enclave/Cargo.toml b/vsock-proxy/enclave/Cargo.toml index 024d790..bb72204 100644 --- a/vsock-proxy/enclave/Cargo.toml +++ b/vsock-proxy/enclave/Cargo.toml @@ -15,7 +15,7 @@ async-trait = "0.1.51" base64 = "0.13.0" clap = "2.33" const_format = "0.2.32" -em-app = { git = "https://github.com/fortanix/rust-sgx.git", branch = "ns/RTE-147" } +em-app = { workspace = true } env_logger = "0.7" futures = "0.3" hyper = "0.10" diff --git a/vsock-proxy/enclave/src/app_configuration.rs b/vsock-proxy/enclave/src/app_configuration.rs index 7cc314c..bbab141 100644 --- a/vsock-proxy/enclave/src/app_configuration.rs +++ b/vsock-proxy/enclave/src/app_configuration.rs @@ -8,6 +8,7 @@ use std::collections::BTreeMap; use std::fs; use std::path::{Component, Path, PathBuf}; use std::sync::Arc; +use std::convert::TryFrom; use em_app::utils::models::{ ApplicationConfigContents, ApplicationConfigExtra, ApplicationConfigSdkmsCredentials, RuntimeAppConfig, @@ -17,7 +18,7 @@ use mbedtls::alloc::List as MbedtlsList; use mbedtls::pk::Pk; use mbedtls::x509::Certificate; use sdkms::api_model::Blob; -use shared::models::CCMBackendUrl; +use shared::models::{CCMBackendUrl}; use crate::certificate::CertificateResult; use crate::enclave::write_to_file; @@ -42,21 +43,25 @@ const CREDENTIALS_FILE: &str = "credentials.bin"; const LOCATION_FILE: &str = "location.txt"; +const APPLICATION_CONFIGURATION_ID_LENGTH: usize = 32; + pub(crate) fn setup_application_configuration( em_app_credentials: &EmAppCredentials, ccm_backend_url: &CCMBackendUrl, api: T, fs_root: &Path, - app_config_id: Blob + app_config_id: &str ) -> Result<(), String> where T: ApplicationConfiguration, { info!("Requesting application configuration."); + let app_config_id_raw = <[u8; APPLICATION_CONFIGURATION_ID_LENGTH]>::try_from(app_config_id.as_bytes()).map_err(|err| format!("Cannot convert application config id into an array. Error: {:?}. Perhaps your id isn't {} characters long?", err, APPLICATION_CONFIGURATION_ID_LENGTH))?; + let app_config = api .runtime_config_api() - .get_checked_runtime_configuration(&ccm_backend_url, em_app_credentials, app_config_id)?; + .get_checked_runtime_configuration(&ccm_backend_url, em_app_credentials, &app_config_id_raw)?; write_runtime_configuration_to_file(&app_config, fs_root)?; @@ -301,9 +306,9 @@ impl RuntimeConfiguration for EmAppRuntimeConfiguration { &self, ccm_backend_url: &CCMBackendUrl, credentials: &EmAppCredentials, - expected_hash: Blob + expected_hash: &[u8; APPLICATION_CONFIGURATION_ID_LENGTH] ) -> Result { - em_app::utils::get_checked_runtime_configuration( + em_app::utils::get_runtime_configuration( &ccm_backend_url.host, ccm_backend_url.port, credentials.certificate.clone(), @@ -320,7 +325,7 @@ pub(crate) trait RuntimeConfiguration { &self, ccm_backend_url: &CCMBackendUrl, credentials: &EmAppCredentials, - expected_hash: Blob + expected_hash: &[u8; APPLICATION_CONFIGURATION_ID_LENGTH] ) -> Result; } @@ -438,6 +443,7 @@ mod tests { use std::collections::BTreeMap; use std::fs; use std::path::Path; + use std::convert::TryFrom; use em_app::utils::models::{ ApplicationConfigConnection, ApplicationConfigConnectionApplication, ApplicationConfigConnectionDataset, @@ -446,7 +452,7 @@ mod tests { use sdkms::api_model::Blob; use shared::models::CCMBackendUrl; - use crate::app_configuration::{normalize_path_and_make_relative, setup_app_configs, setup_datasets, ApplicationFiles, DataSetFiles, EmAppCredentials, RuntimeConfiguration, SdkmsDataset, ApplicationConfiguration}; + use crate::app_configuration::{normalize_path_and_make_relative, setup_app_configs, setup_datasets, ApplicationFiles, DataSetFiles, EmAppCredentials, RuntimeConfiguration, SdkmsDataset, ApplicationConfiguration, APPLICATION_CONFIGURATION_ID_LENGTH}; const TEST_FOLDER: &'static str = "/tmp/salm-unit-test"; @@ -579,7 +585,7 @@ mod tests { struct MockDataSet { pub json_data: &'static str, - pub hash: Blob + pub hash: [u8; APPLICATION_CONFIGURATION_ID_LENGTH] } impl MockDataSet { @@ -616,9 +622,9 @@ mod tests { &self, _ccm_backend_url: &CCMBackendUrl, _credentials: &EmAppCredentials, - expected_hash: Blob + expected_hash: &[u8; APPLICATION_CONFIGURATION_ID_LENGTH] ) -> Result { - if self.hash != expected_hash { + if self.hash != *expected_hash { Err(format!("Expected hash: {:?} doesn't equal saved hash: {:?}", expected_hash, self.hash)) } else { Ok(serde_json::from_str(self.json_data).expect("Failed serializing test json")) @@ -665,9 +671,9 @@ mod tests { }; let credentials = EmAppCredentials::mock(); - let api: Box = Box::new(MockDataSet { json_data, hash: Blob::default() }); + let api: Box = Box::new(MockDataSet { json_data, hash: [0; APPLICATION_CONFIGURATION_ID_LENGTH] }); - let result = api.get_checked_runtime_configuration(&backend_url, &credentials, Blob::default()); + let result = api.get_checked_runtime_configuration(&backend_url, &credentials, &[0; APPLICATION_CONFIGURATION_ID_LENGTH]); assert!(result.is_ok(), "{:?}", result); result.unwrap() @@ -679,7 +685,7 @@ mod tests { let credentials = EmAppCredentials::mock(); let api = MockDataSet { json_data: VALID_APP_CONF, - hash: Blob::default() + hash: [0; APPLICATION_CONFIGURATION_ID_LENGTH] }; let result = setup_datasets(&config, &credentials, &api, Path::new("/")); @@ -696,12 +702,12 @@ mod tests { let credentials = EmAppCredentials::mock(); let api = MockDataSet { json_data: VALID_APP_CONF, - hash: Blob::default() + hash: [0; APPLICATION_CONFIGURATION_ID_LENGTH] }; let test_folder_path = Path::new(TEST_FOLDER).join("datasets"); let test_folder = TempDir(&test_folder_path); - let files = DataSetFiles::new("test_location", "test_port", test_folder.0.clone()); + let files = DataSetFiles::new("test_location", "test_port", test_folder.0); let _temp_dataset_dir = TempDir(&files.dataset_dir); let result = setup_datasets(&config, &credentials, &api, &test_folder.0); @@ -739,13 +745,13 @@ mod tests { let credentials = EmAppCredentials::mock(); let api = MockDataSet { json_data: VALID_APP_CONF, - hash: Blob::default() + hash: [0; APPLICATION_CONFIGURATION_ID_LENGTH] }; let test_folder_path = Path::new(TEST_FOLDER).join("appconfig-location"); let test_folder = TempDir(&test_folder_path); - let files = ApplicationFiles::new("test_location", "test_port", &test_folder.0.clone()); + let files = ApplicationFiles::new("test_location", "test_port", &test_folder.0); let _temp_dir = TempDir(&files.application_dir); let result = setup_datasets(&config, &credentials, &api, &test_folder.0); @@ -840,12 +846,13 @@ mod tests { #[test] fn check_application_config_id_correct_hash() { let credentials = EmAppCredentials::mock(); + let correct_hash = <[u8; APPLICATION_CONFIGURATION_ID_LENGTH]>::try_from("a1B2c3D4e5F6g7H8i9J0kLmNoPqRsTux".as_bytes()).unwrap(); let api = MockDataSet { json_data: VALID_APP_CONF, - hash: Blob::from("correct hash".as_bytes().to_vec()) + hash: correct_hash.clone() }; let backend_url = CCMBackendUrl::default(); - let runtime_config = api.runtime_config_api().get_checked_runtime_configuration(&backend_url, &credentials, Blob::from("correct hash".as_bytes().to_vec())); + let runtime_config = api.runtime_config_api().get_checked_runtime_configuration(&backend_url, &credentials, &correct_hash); assert!(runtime_config.is_ok()); } @@ -853,12 +860,14 @@ mod tests { #[test] fn check_application_config_id_incorrect_hash() { let credentials = EmAppCredentials::mock(); + let correct_hash = <[u8; APPLICATION_CONFIGURATION_ID_LENGTH]>::try_from("a1B2c3D4e5F6g7H8i9J0kLmNoPqRsTux".as_bytes()).unwrap(); + let incorrect_hash = <[u8; APPLICATION_CONFIGURATION_ID_LENGTH]>::try_from("Xy9Wq2rT6vZa8Lc1Pd0BmJk4Gh7UfVsN".as_bytes()).unwrap(); let api = MockDataSet { json_data: VALID_APP_CONF, - hash: Blob::from("correct hash".as_bytes().to_vec()) + hash: correct_hash }; let backend_url = CCMBackendUrl::default(); - let runtime_config = api.runtime_config_api().get_checked_runtime_configuration(&backend_url, &credentials, Blob::from("This_is_not_a_valid_hash".as_bytes().to_vec())); + let runtime_config = api.runtime_config_api().get_checked_runtime_configuration(&backend_url, &credentials, &incorrect_hash); assert!(runtime_config.is_err()); } diff --git a/vsock-proxy/enclave/src/enclave.rs b/vsock-proxy/enclave/src/enclave.rs index 8b5eeaf..070a96e 100644 --- a/vsock-proxy/enclave/src/enclave.rs +++ b/vsock-proxy/enclave/src/enclave.rs @@ -19,7 +19,6 @@ use futures::stream::FuturesUnordered; use futures::{AsyncBufReadExt, StreamExt}; use log::{debug, info, warn}; use nix::net::if_::if_nametoindex; -use sdkms::api_model::Blob; use shared::models::{ ApplicationConfiguration, NBDConfiguration, NetworkDeviceSettings, PrivateNetworkDeviceSettings, SetupMessages, UserProgramExitStatus, @@ -219,7 +218,7 @@ fn setup_app_configuration( &app_config.ccm_backend_url, api, Path::new(ENCLAVE_FS_OVERLAY_ROOT), - Blob::from(id.as_str()), + &id, ) } else { Ok(()) diff --git a/vsock-proxy/parent/Cargo.toml b/vsock-proxy/parent/Cargo.toml index 55025f0..d601ae3 100644 --- a/vsock-proxy/parent/Cargo.toml +++ b/vsock-proxy/parent/Cargo.toml @@ -12,7 +12,7 @@ repository = "https://github.com/fortanix/salmiac" api-model = { path = "../../api-model" } async-process = "1.2.0" clap = "2.33" -em-app = { git = "https://github.com/fortanix/rust-sgx.git" } +em-app = { workspace = true } env_logger = "0.7" etherparse = { git = "https://github.com/fortanix/etherparse.git", branch = "udp_checksum_from_slice" } futures = "0.3"