This is an automated email from the ASF dual-hosted git repository.

mssun pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave.git


The following commit(s) were added to refs/heads/develop by this push:
     new bcf490f  [management] Implement register_input_file and 
register_output_file (#219)
bcf490f is described below

commit bcf490fe564e90cac8ee2d542ca1f54b2145e62f
Author: TX <[email protected]>
AuthorDate: Thu Feb 6 16:13:04 2020 -0800

    [management] Implement register_input_file and register_output_file (#219)
---
 cmake/scripts/test.sh                              |   5 +-
 config/runtime.config.toml                         |   4 +-
 services/management/enclave/Cargo.toml             |   2 +
 services/management/enclave/src/file.rs            | 108 +++++++++++++++++
 services/management/enclave/src/lib.rs             |  34 +++++-
 services/management/enclave/src/service.rs         | 133 ++++++++++++++++++++-
 tests/fixtures/runtime.config.toml                 |   4 +-
 tests/functional_tests/enclave/src/lib.rs          |   2 +
 .../enclave/src/teaclave_management_service.rs     |  77 ++++++++++++
 tests/unit_tests/enclave/Cargo.toml                |   3 +
 tests/unit_tests/enclave/src/lib.rs                |   2 +
 types/src/crypto.rs                                |   9 +-
 12 files changed, 364 insertions(+), 19 deletions(-)

diff --git a/cmake/scripts/test.sh b/cmake/scripts/test.sh
index b3fad6e..81b30ea 100755
--- a/cmake/scripts/test.sh
+++ b/cmake/scripts/test.sh
@@ -37,12 +37,13 @@ cargo test --manifest-path 
${MESATEE_PROJECT_ROOT}/common/protected_fs_rs/Cargo.
 echo_title "functional tests"
 trap 'kill $(jobs -p)' EXIT
 pushd ${MESATEE_SERVICE_INSTALL_DIR}
-./teaclave_access_control_service &
 ./teaclave_authentication_service &
-sleep 3    # wait for authentication service
 ./teaclave_storage_service &
+sleep 3    # wait for authentication and storage service
+./teaclave_access_control_service &
 ./teaclave_execution_service &
 ./teaclave_frontend_service &
+./teaclave_management_service &
 popd
 sleep 3    # wait for other services
 ./teaclave_functional_tests
diff --git a/config/runtime.config.toml b/config/runtime.config.toml
index b34cce5..1f3a9f5 100644
--- a/config/runtime.config.toml
+++ b/config/runtime.config.toml
@@ -12,8 +12,8 @@ frontend = { listen_address = "0.0.0.0:7777" }
 access_control = { listen_address = "0.0.0.0:7779", advertised_address = 
"localhost:7779" }
 authentication = { listen_address = "0.0.0.0:17776", advertised_address = 
"localhost:17776", inbound_services = ["frontend"] }
 management = { listen_address = "0.0.0.0:17777", advertised_address = 
"localhost:17777" }
-storage = { listen_address = "0.0.0.0:7778", advertised_address = 
"127.0.0.1:7778", inbound_services = ["frontend"] }
-execution = { listen_address = "0.0.0.0:7989", advertised_address = 
"127.0.0.1:7989" }
+storage = { listen_address = "0.0.0.0:7778", advertised_address = 
"localhost:7778", inbound_services = ["frontend", "management"] }
+execution = { listen_address = "0.0.0.0:7989", advertised_address = 
"localhost:7989" }
 
 [audit]
 enclave_info = { path = "enclave_info.toml" }
diff --git a/services/management/enclave/Cargo.toml 
b/services/management/enclave/Cargo.toml
index 5767172..7c361af 100644
--- a/services/management/enclave/Cargo.toml
+++ b/services/management/enclave/Cargo.toml
@@ -34,6 +34,8 @@ serde_json = { version = "1.0.39" }
 thiserror = { version = "1.0.9" }
 ring      = { version = "0.16.5" }
 rand      = { version = "0.7.0" }
+uuid      = { version = "0.7.4", features = ["v4"] }
+url       = { version = "2.1.1", features = ["serde"]}
 
 teaclave_attestation           = { path = "../../../attestation" }
 teaclave_config                = { path = "../../../config" }
diff --git a/services/management/enclave/src/file.rs 
b/services/management/enclave/src/file.rs
new file mode 100644
index 0000000..90de8fa
--- /dev/null
+++ b/services/management/enclave/src/file.rs
@@ -0,0 +1,108 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+use anyhow::{anyhow, Result};
+use serde::{Deserialize, Serialize};
+use serde_json;
+use std::prelude::v1::*;
+use teaclave_types::TeaclaveFileCryptoInfo;
+use url::Url;
+use uuid::Uuid;
+
+#[derive(Debug, Deserialize, Serialize)]
+pub(crate) struct InputFile {
+    pub(crate) url: Url,
+    pub(crate) hash: String,
+    pub(crate) crypto_info: TeaclaveFileCryptoInfo,
+    pub(crate) owner: String,
+    pub(crate) data_id: String,
+}
+
+impl InputFile {
+    pub(crate) fn new(
+        url: Url,
+        hash: String,
+        crypto_info: TeaclaveFileCryptoInfo,
+        owner: String,
+    ) -> InputFile {
+        InputFile {
+            url,
+            hash,
+            crypto_info,
+            owner,
+            data_id: Uuid::new_v4().to_string(),
+        }
+    }
+
+    #[cfg(feature = "enclave_unit_test")]
+    pub(crate) fn from_slice(bytes: &[u8]) -> Result<Self> {
+        let ret: InputFile =
+            serde_json::from_slice(&bytes).map_err(|_| anyhow!("failed to 
Deserialize"))?;
+        Ok(ret)
+    }
+
+    pub(crate) fn to_vec(&self) -> Result<Vec<u8>> {
+        serde_json::to_vec(&self).map_err(|_| anyhow!("failed to Serialize"))
+    }
+
+    pub(crate) fn get_key_vec_from_id(id: &str) -> Vec<u8> {
+        let mut key = b"input-file-".to_vec();
+        key.extend_from_slice(id.as_bytes());
+        key
+    }
+    pub(crate) fn get_key_vec(&self) -> Vec<u8> {
+        InputFile::get_key_vec_from_id(&self.data_id)
+    }
+}
+
+#[derive(Debug, Deserialize, Serialize)]
+pub(crate) struct OutputFile {
+    pub(crate) url: Url,
+    pub(crate) hash: Option<String>,
+    pub(crate) crypto_info: TeaclaveFileCryptoInfo,
+    pub(crate) owner: String,
+    pub(crate) data_id: String,
+}
+
+impl OutputFile {
+    pub(crate) fn new(url: Url, crypto_info: TeaclaveFileCryptoInfo, owner: 
String) -> OutputFile {
+        OutputFile {
+            url,
+            hash: None,
+            crypto_info,
+            owner,
+            data_id: Uuid::new_v4().to_string(),
+        }
+    }
+
+    #[cfg(feature = "enclave_unit_test")]
+    pub(crate) fn from_slice(bytes: &[u8]) -> Result<Self> {
+        serde_json::from_slice(&bytes).map_err(|_| anyhow!("failed to 
Deserialize"))
+    }
+
+    pub(crate) fn to_vec(&self) -> Result<Vec<u8>> {
+        serde_json::to_vec(&self).map_err(|_| anyhow!("failed to Serialize"))
+    }
+
+    pub(crate) fn get_key_vec_from_id(id: &str) -> Vec<u8> {
+        let mut key = b"output-file-".to_vec();
+        key.extend_from_slice(id.as_bytes());
+        key
+    }
+    pub(crate) fn get_key_vec(&self) -> Vec<u8> {
+        OutputFile::get_key_vec_from_id(&self.data_id)
+    }
+}
diff --git a/services/management/enclave/src/lib.rs 
b/services/management/enclave/src/lib.rs
index d0fe71b..6c1320f 100644
--- a/services/management/enclave/src/lib.rs
+++ b/services/management/enclave/src/lib.rs
@@ -24,20 +24,24 @@ extern crate sgx_tstd as std;
 extern crate log;
 
 use std::prelude::v1::*;
+use teaclave_attestation::verifier;
 use teaclave_attestation::{AttestationConfig, RemoteAttestation};
 use teaclave_binder::proto::{
     ECallCommand, FinalizeEnclaveInput, FinalizeEnclaveOutput, 
InitEnclaveInput, InitEnclaveOutput,
     StartServiceInput, StartServiceOutput,
 };
 use teaclave_binder::{handle_ecall, register_ecall_handler};
+use teaclave_config::BUILD_CONFIG;
 use teaclave_proto::teaclave_management_service::{
     TeaclaveManagementRequest, TeaclaveManagementResponse,
 };
+use teaclave_rpc::config::SgxTrustedTlsClientConfig;
 use teaclave_rpc::config::SgxTrustedTlsServerConfig;
+use teaclave_rpc::endpoint::Endpoint;
 use teaclave_rpc::server::SgxTrustedTlsServer;
 use teaclave_service_enclave_utils::ServiceEnclave;
 use teaclave_types::{TeeServiceError, TeeServiceResult};
-
+mod file;
 mod service;
 
 fn start_service(args: &StartServiceInput) -> anyhow::Result<()> {
@@ -59,7 +63,25 @@ fn start_service(args: &StartServiceInput) -> 
anyhow::Result<()> {
             listen_address,
             &config,
         );
-    let service = service::TeaclaveManagementService;
+
+    let enclave_info = teaclave_types::EnclaveInfo::from_bytes(
+        &args.config.audit.enclave_info_bytes.as_ref().unwrap(),
+    );
+    let enclave_attr = enclave_info
+        .get_enclave_attr("teaclave_storage_service")
+        .expect("storage");
+    let config = SgxTrustedTlsClientConfig::new()
+        .client_cert(&attestation.cert, &attestation.private_key)
+        .attestation_report_verifier(
+            vec![enclave_attr],
+            BUILD_CONFIG.ias_root_ca_cert,
+            verifier::universal_quote_verifier,
+        );
+    let storage_service_address = 
&args.config.internal_endpoints.storage.advertised_address;
+
+    let storage_service_endpoint = 
Endpoint::new(storage_service_address).config(config);
+
+    let service = 
service::TeaclaveManagementService::new(storage_service_endpoint)?;
     match server.start(service) {
         Ok(_) => (),
         Err(e) => {
@@ -99,6 +121,12 @@ register_ecall_handler!(
 #[cfg(feature = "enclave_unit_test")]
 pub mod tests {
     use super::*;
+    use teaclave_test_utils::*;
 
-    pub fn run_tests() -> bool {}
+    pub fn run_tests() -> bool {
+        run_tests!(
+            service::tests::handle_input_file,
+            service::tests::handle_output_file,
+        )
+    }
 }
diff --git a/services/management/enclave/src/service.rs 
b/services/management/enclave/src/service.rs
index bc41bd9..30ada1f 100644
--- a/services/management/enclave/src/service.rs
+++ b/services/management/enclave/src/service.rs
@@ -1,12 +1,34 @@
+use crate::file::{InputFile, OutputFile};
+use anyhow::{anyhow, Result};
 use std::prelude::v1::*;
+use std::sync::{Arc, SgxMutex as Mutex};
 use teaclave_proto::teaclave_frontend_service::{
     RegisterInputFileRequest, RegisterInputFileResponse, 
RegisterOutputFileRequest,
     RegisterOutputFileResponse,
 };
 use teaclave_proto::teaclave_management_service::TeaclaveManagement;
+use teaclave_proto::teaclave_storage_service::{PutRequest, 
TeaclaveStorageClient};
+use teaclave_rpc::endpoint::Endpoint;
 use teaclave_rpc::Request;
 use teaclave_service_enclave_utils::teaclave_service;
-use teaclave_types::TeaclaveServiceResponseResult;
+use teaclave_types::{TeaclaveServiceResponseError, 
TeaclaveServiceResponseResult};
+use thiserror::Error;
+
+#[derive(Error, Debug)]
+enum TeaclaveManagementError {
+    #[error("invalid request")]
+    InvalidRequest,
+    #[error("data error")]
+    DataError,
+    #[error("storage error")]
+    StorageError,
+}
+
+impl From<TeaclaveManagementError> for TeaclaveServiceResponseError {
+    fn from(error: TeaclaveManagementError) -> Self {
+        TeaclaveServiceResponseError::RequestError(error.to_string())
+    }
+}
 
 #[teaclave_service(
     teaclave_management_service,
@@ -14,20 +36,119 @@ use teaclave_types::TeaclaveServiceResponseResult;
     TeaclaveManagementError
 )]
 #[derive(Clone)]
-pub(crate) struct TeaclaveManagementService;
+pub(crate) struct TeaclaveManagementService {
+    storage_client: Arc<Mutex<TeaclaveStorageClient>>,
+}
 
 impl TeaclaveManagement for TeaclaveManagementService {
     fn register_input_file(
         &self,
-        _request: Request<RegisterInputFileRequest>,
+        request: Request<RegisterInputFileRequest>,
     ) -> TeaclaveServiceResponseResult<RegisterInputFileResponse> {
-        unimplemented!()
+        let user_id = request
+            .metadata
+            .get("id")
+            .ok_or_else(|| TeaclaveManagementError::InvalidRequest)?
+            .to_string();
+
+        let request = request.message;
+        let input_file = InputFile::new(request.url, request.hash, 
request.crypto_info, user_id);
+        let key = input_file.get_key_vec();
+        let value = input_file
+            .to_vec()
+            .map_err(|_| TeaclaveManagementError::DataError)?;
+
+        self.write_to_storage(&key, &value)
+            .map_err(|_| TeaclaveManagementError::StorageError)?;
+        let response = RegisterInputFileResponse {
+            data_id: input_file.data_id,
+        };
+        Ok(response)
     }
 
     fn register_output_file(
         &self,
-        _request: Request<RegisterOutputFileRequest>,
+        request: Request<RegisterOutputFileRequest>,
     ) -> TeaclaveServiceResponseResult<RegisterOutputFileResponse> {
-        unimplemented!()
+        let user_id = request
+            .metadata
+            .get("id")
+            .ok_or_else(|| TeaclaveManagementError::InvalidRequest)?
+            .to_string();
+
+        let request = request.message;
+        let output_file = OutputFile::new(request.url, request.crypto_info, 
user_id);
+        let key = output_file.get_key_vec();
+        let value = output_file
+            .to_vec()
+            .map_err(|_| TeaclaveManagementError::DataError)?;
+
+        self.write_to_storage(&key, &value)
+            .map_err(|_| TeaclaveManagementError::StorageError)?;
+        let response = RegisterOutputFileResponse {
+            data_id: output_file.data_id,
+        };
+        Ok(response)
+    }
+}
+
+impl TeaclaveManagementService {
+    pub(crate) fn new(storage_service_endpoint: Endpoint) -> Result<Self> {
+        let channel = storage_service_endpoint.connect()?;
+        let client = TeaclaveStorageClient::new(channel)?;
+        Ok(Self {
+            storage_client: Arc::new(Mutex::new(client)),
+        })
+    }
+
+    fn write_to_storage(&self, key: &[u8], value: &[u8]) -> Result<()> {
+        let put_request = PutRequest::new(key, value);
+        let _put_response = self
+            .storage_client
+            .clone()
+            .lock()
+            .map_err(|_| anyhow!("Cannot lock storage client"))?
+            .put(put_request)?;
+        Ok(())
+    }
+}
+
+#[cfg(feature = "enclave_unit_test")]
+pub mod tests {
+    use super::*;
+    use teaclave_types::{TeaclaveFileCryptoInfo, TeaclaveFileRootKey128};
+    use url::Url;
+
+    pub fn handle_input_file() {
+        let url = Url::parse("s3://bucket_id/path?token=mock_token").unwrap();
+        let hash = 
"a6d604b5987b693a19d94704532b5d928c2729f24dfd40745f8d03ac9ac75a8b".to_string();
+        let user_id = "mock_user".to_string();
+        let crypto_info = TeaclaveFileCryptoInfo::TeaclaveFileRootKey128(
+            TeaclaveFileRootKey128::new(&[0; 16]).unwrap(),
+        );
+        let input_file = InputFile::new(url, hash, crypto_info, user_id);
+        let key = input_file.get_key_vec();
+        let key_str = std::str::from_utf8(&key).unwrap();
+        info!("key: {}", key_str);
+        assert!(key_str.starts_with("input-file"));
+        let value = input_file.to_vec().unwrap();
+        let deserialized_file = InputFile::from_slice(&value).unwrap();
+        info!("file: {:?}", deserialized_file);
+    }
+
+    pub fn handle_output_file() {
+        let url = Url::parse("s3://bucket_id/path?token=mock_token").unwrap();
+        let user_id = "mock_user".to_string();
+        let crypto_info = TeaclaveFileCryptoInfo::TeaclaveFileRootKey128(
+            TeaclaveFileRootKey128::new(&[0; 16]).unwrap(),
+        );
+        let output_file = OutputFile::new(url, crypto_info, user_id);
+        let key = output_file.get_key_vec();
+        let key_str = std::str::from_utf8(&key).unwrap();
+        info!("key: {}", key_str);
+        assert!(key_str.starts_with("output-file"));
+        let value = output_file.to_vec().unwrap();
+        let deserialized_file = OutputFile::from_slice(&value).unwrap();
+        info!("file: {:?}", deserialized_file);
     }
 }
diff --git a/tests/fixtures/runtime.config.toml 
b/tests/fixtures/runtime.config.toml
index 716b478..6eefb30 100644
--- a/tests/fixtures/runtime.config.toml
+++ b/tests/fixtures/runtime.config.toml
@@ -6,8 +6,8 @@ frontend = { listen_address = "0.0.0.0:7777" }
 access_control = { listen_address = "0.0.0.0:7779", advertised_address = 
"localhost:7779" }
 authentication = { listen_address = "0.0.0.0:17776", advertised_address = 
"localhost:17776" }
 management = { listen_address = "0.0.0.0:17777", advertised_address = 
"localhost:17777" }
-storage = { listen_address = "0.0.0.0:7778", advertised_address = 
"127.0.0.1:7778", inbound_services = ["frontend"] }
-execution = { listen_address = "0.0.0.0:7989", advertised_address = 
"127.0.0.1:7989" }
+storage = { listen_address = "0.0.0.0:7778", advertised_address = 
"localhost:7778", inbound_services = ["frontend", "management"] }
+execution = { listen_address = "0.0.0.0:7989", advertised_address = 
"localhost:7989" }
 
 [audit]
 enclave_info = { path = "fixtures/enclave_info.toml" }
diff --git a/tests/functional_tests/enclave/src/lib.rs 
b/tests/functional_tests/enclave/src/lib.rs
index 8cb07f6..8702b16 100644
--- a/tests/functional_tests/enclave/src/lib.rs
+++ b/tests/functional_tests/enclave/src/lib.rs
@@ -40,6 +40,7 @@ mod teaclave_access_control_service;
 mod teaclave_authentication_service;
 mod teaclave_execution_service;
 mod teaclave_frontend_service;
+mod teaclave_management_service;
 mod teaclave_storage_service;
 
 #[handle_ecall]
@@ -50,6 +51,7 @@ fn handle_run_test(_args: &RunTestInput) -> 
TeeServiceResult<RunTestOutput> {
         teaclave_storage_service::run_tests(),
         teaclave_execution_service::run_tests(),
         teaclave_frontend_service::run_tests(),
+        teaclave_management_service::run_tests(),
     );
 
     assert_eq!(ret, true);
diff --git a/tests/functional_tests/enclave/src/teaclave_management_service.rs 
b/tests/functional_tests/enclave/src/teaclave_management_service.rs
new file mode 100644
index 0000000..2b33c4f
--- /dev/null
+++ b/tests/functional_tests/enclave/src/teaclave_management_service.rs
@@ -0,0 +1,77 @@
+use std::collections::HashMap;
+use std::prelude::v1::*;
+use teaclave_attestation::verifier;
+use teaclave_config::RuntimeConfig;
+use teaclave_config::BUILD_CONFIG;
+use teaclave_proto::teaclave_frontend_service::*;
+use teaclave_proto::teaclave_management_service::*;
+use teaclave_rpc::config::SgxTrustedTlsClientConfig;
+use teaclave_rpc::endpoint::Endpoint;
+use teaclave_types::*;
+use url::Url;
+
+pub fn run_tests() -> bool {
+    use teaclave_test_utils::*;
+
+    run_tests!(test_register_input_file, test_register_output_file)
+}
+
+fn get_client() -> TeaclaveManagementClient {
+    let runtime_config = 
RuntimeConfig::from_toml("runtime.config.toml").expect("runtime");
+    let enclave_info =
+        
EnclaveInfo::from_bytes(&runtime_config.audit.enclave_info_bytes.as_ref().unwrap());
+    let enclave_attr = enclave_info
+        .get_enclave_attr("teaclave_management_service")
+        .expect("management");
+    let config = SgxTrustedTlsClientConfig::new().attestation_report_verifier(
+        vec![enclave_attr],
+        BUILD_CONFIG.ias_root_ca_cert,
+        verifier::universal_quote_verifier,
+    );
+
+    let channel = Endpoint::new(
+        &runtime_config
+            .internal_endpoints
+            .management
+            .advertised_address,
+    )
+    .config(config)
+    .connect()
+    .unwrap();
+
+    let mut metadata = HashMap::new();
+    metadata.insert("id".to_string(), "mock_user".to_string());
+    metadata.insert("token".to_string(), "".to_string());
+
+    TeaclaveManagementClient::new_with_metadata(channel, metadata).unwrap()
+}
+fn test_register_input_file() {
+    let request = RegisterInputFileRequest {
+        url: 
Url::parse("s3://s3.us-west-2.amazonaws.com/mybucket/puppy.jpg.enc?key-id=deadbeefdeadbeef&key=deadbeefdeadbeef").unwrap(),
+        hash: "deadbeefdeadbeef".to_string(),
+        crypto_info: TeaclaveFileCryptoInfo::AesGcm128(AesGcm128CryptoInfo {
+            key: [0x90u8; 16],
+            iv: [0x89u8; 12],
+        }),
+    };
+
+    let mut client = get_client();
+    let response = client.register_input_file(request);
+
+    assert!(response.is_ok());
+}
+
+fn test_register_output_file() {
+    let request = RegisterOutputFileRequest {
+        url: 
Url::parse("s3://s3.us-west-2.amazonaws.com/mybucket/puppy.jpg.enc?key-id=deadbeefdeadbeef&key=deadbeefdeadbeef").unwrap(),
+        crypto_info: TeaclaveFileCryptoInfo::AesGcm128(AesGcm128CryptoInfo {
+            key: [0x90u8; 16],
+            iv: [0x89u8; 12],
+        }),
+    };
+
+    let mut client = get_client();
+    let response = client.register_output_file(request);
+
+    assert!(response.is_ok());
+}
diff --git a/tests/unit_tests/enclave/Cargo.toml 
b/tests/unit_tests/enclave/Cargo.toml
index d8c9888..66548f0 100644
--- a/tests/unit_tests/enclave/Cargo.toml
+++ b/tests/unit_tests/enclave/Cargo.toml
@@ -25,6 +25,8 @@ mesalock_sgx = [
   "teaclave_access_control_service_enclave/enclave_unit_test",
   "teaclave_authentication_service_enclave/mesalock_sgx",
   "teaclave_authentication_service_enclave/enclave_unit_test",
+  "teaclave_management_service_enclave/mesalock_sgx",
+  "teaclave_management_service_enclave/enclave_unit_test",
   "teaclave_storage_service_enclave/mesalock_sgx",
   "teaclave_storage_service_enclave/enclave_unit_test",
   "teaclave_execution_service_enclave/mesalock_sgx",
@@ -44,6 +46,7 @@ teaclave_access_control_service_enclave = { path = 
"../../../services/access_con
 teaclave_authentication_service_enclave = { path = 
"../../../services/authentication/enclave" }
 teaclave_storage_service_enclave = { path = 
"../../../services/storage/enclave" }
 teaclave_execution_service_enclave = { path = 
"../../../services/execution/enclave" }
+teaclave_management_service_enclave = { path = 
"../../../services/management/enclave" }
 teaclave_worker                 = { path = "../../../worker" }
 
 teaclave_test_utils            = { path = "../../test_utils" }
diff --git a/tests/unit_tests/enclave/src/lib.rs 
b/tests/unit_tests/enclave/src/lib.rs
index 25718e7..e8328e8 100644
--- a/tests/unit_tests/enclave/src/lib.rs
+++ b/tests/unit_tests/enclave/src/lib.rs
@@ -37,12 +37,14 @@ use teaclave_service_enclave_utils::ServiceEnclave;
 use teaclave_access_control_service_enclave;
 use teaclave_authentication_service_enclave;
 use teaclave_execution_service_enclave;
+use teaclave_management_service_enclave;
 use teaclave_test_utils::check_all_passed;
 use teaclave_worker;
 
 #[handle_ecall]
 fn handle_run_test(_args: &RunTestInput) -> TeeServiceResult<RunTestOutput> {
     let ret = check_all_passed!(
+        teaclave_management_service_enclave::tests::run_tests(),
         teaclave_storage_service_enclave::tests::run_tests(),
         teaclave_access_control_service_enclave::tests::run_tests(),
         teaclave_execution_service_enclave::tests::run_tests(),
diff --git a/types/src/crypto.rs b/types/src/crypto.rs
index 134163e..04c7b84 100644
--- a/types/src/crypto.rs
+++ b/types/src/crypto.rs
@@ -4,12 +4,13 @@ use std::prelude::v1::*;
 use anyhow;
 use rand::prelude::RngCore;
 use ring;
+use serde::{Deserialize, Serialize};
 use std::format;
 
 const AES_GCM_256_KEY_LENGTH: usize = 32;
 const AES_GCM_256_IV_LENGTH: usize = 12;
 
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, Serialize, Deserialize)]
 pub struct AesGcm256CryptoInfo {
     pub key: [u8; AES_GCM_256_KEY_LENGTH],
     pub iv: [u8; AES_GCM_256_IV_LENGTH],
@@ -60,7 +61,7 @@ impl Default for AesGcm256CryptoInfo {
 const AES_GCM_128_KEY_LENGTH: usize = 16;
 const AES_GCM_128_IV_LENGTH: usize = 12;
 
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, Serialize, Deserialize)]
 pub struct AesGcm128CryptoInfo {
     pub key: [u8; AES_GCM_128_KEY_LENGTH],
     pub iv: [u8; AES_GCM_128_IV_LENGTH],
@@ -112,7 +113,7 @@ impl Default for AesGcm128CryptoInfo {
 
 const TEACLAVE_FILE_ROOT_KEY_128_LENGTH: usize = 16;
 
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, Serialize, Deserialize)]
 pub struct TeaclaveFileRootKey128 {
     pub key: [u8; TEACLAVE_FILE_ROOT_KEY_128_LENGTH],
 }
@@ -139,7 +140,7 @@ impl Default for TeaclaveFileRootKey128 {
     }
 }
 
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, Serialize, Deserialize)]
 pub enum TeaclaveFileCryptoInfo {
     AesGcm128(AesGcm128CryptoInfo),
     AesGcm256(AesGcm256CryptoInfo),


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to