|
1 | 1 | use crate::networking::messages::*; |
2 | | -use sgx_types::sgx_enclave_id_t; |
| 2 | +use sgx_types::{sgx_enclave_id_t, sgx_status_t}; |
3 | 3 | use futures::{Future, Stream}; |
4 | 4 | use std::sync::Arc; |
5 | 5 | use tokio_zmq::prelude::*; |
6 | 6 | use tokio_zmq::{Error, Multipart, Rep}; |
7 | 7 |
|
| 8 | + |
8 | 9 | pub struct IpcListener { |
9 | 10 | _context: Arc<zmq::Context>, |
10 | 11 | rep_future: Box<dyn Future<Item = Rep, Error = Error>>, |
@@ -49,13 +50,17 @@ pub(self) mod handling { |
49 | 50 | use crate::networking::messages::*; |
50 | 51 | use crate::keys_u; |
51 | 52 | use failure::Error; |
52 | | - use sgx_types::sgx_enclave_id_t; |
| 53 | + use sgx_types::{sgx_enclave_id_t, sgx_status_t}; |
53 | 54 | use hex::{FromHex, ToHex}; |
54 | 55 | use std::str; |
55 | 56 | use rmp_serde::Deserializer; |
56 | 57 | use serde::Deserialize; |
57 | 58 | use serde_json::Value; |
58 | 59 |
|
| 60 | + extern { |
| 61 | + fn ecall_add_personal_data(eid: sgx_enclave_id_t, ret: *mut sgx_status_t, |
| 62 | + some_string: *const u8, len: usize) -> sgx_status_t; |
| 63 | + } |
59 | 64 |
|
60 | 65 | type ResponseResult = Result<IpcResponse, Error>; |
61 | 66 |
|
@@ -86,6 +91,11 @@ pub(self) mod handling { |
86 | 91 | //#[logfn(DEBUG)] |
87 | 92 | // pub fn compute_task(db: &mut DB, input: IpcTask, eid: sgx_enclave_id_t) -> ResponseResult { |
88 | 93 | pub fn add_personal_data( input: IpcInput, eid: sgx_enclave_id_t) -> ResponseResult { |
| 94 | + let mut ret = sgx_status_t::SGX_SUCCESS; |
| 95 | + let data = serde_json::to_string(&input).unwrap(); |
| 96 | + |
| 97 | + unsafe { ecall_add_personal_data(eid, &mut ret as *mut sgx_status_t, data.as_ptr() as * const u8, data.len()) }; |
| 98 | + |
89 | 99 | let result = IpcResults::AddPersonalData { status: Status::Passed }; |
90 | 100 | Ok(IpcResponse::AddPersonalData { result }) |
91 | 101 | } |
|
0 commit comments