| // 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.. |
| |
| #![crate_name = "enclave1"] |
| #![crate_type = "staticlib"] |
| |
| #![cfg_attr(not(target_env = "sgx"), no_std)] |
| #![cfg_attr(target_env = "sgx", feature(rustc_private))] |
| |
| extern crate sgx_types; |
| use sgx_types::*; |
| |
| extern crate attestation; |
| use attestation::types::*; |
| use attestation::err::*; |
| use attestation::func::*; |
| |
| fn verify_peer_enclave_trust(peer_enclave_identity: &sgx_dh_session_enclave_identity_t )-> u32 { |
| |
| if peer_enclave_identity.isv_prod_id != 0 || peer_enclave_identity.attributes.flags & SGX_FLAGS_INITTED == 0 { |
| // || peer_enclave_identity->attributes.xfrm !=3)// || peer_enclave_identity->mr_signer != xx //TODO: To be hardcoded with values to check |
| ATTESTATION_STATUS::ENCLAVE_TRUST_ERROR as u32 |
| } else { |
| ATTESTATION_STATUS::SUCCESS as u32 |
| } |
| } |
| |
| #[no_mangle] |
| pub extern "C" fn test_enclave_init() { |
| let cb = Callback{ |
| verify: verify_peer_enclave_trust, |
| }; |
| init(cb); |
| } |
| |
| #[no_mangle] |
| pub extern "C" fn test_create_session(src_enclave_id: sgx_enclave_id_t, dest_enclave_id: sgx_enclave_id_t) -> u32 { |
| create_session(src_enclave_id, dest_enclave_id) as u32 |
| } |
| |
| #[no_mangle] |
| #[allow(unused_variables)] |
| pub extern "C" fn test_close_session(src_enclave_id: sgx_enclave_id_t, dest_enclave_id: sgx_enclave_id_t) -> u32 { |
| close_session(src_enclave_id, dest_enclave_id) as u32 |
| } |