fix compiler error on sealing and examples (#3)
Reviewed-on: SGX/detee-sgx#3 Reviewed-by: Valentyn Faychuk <valy@detee.ltd> Co-authored-by: Noor <noormohammedb@protonmail.com> Co-committed-by: Noor <noormohammedb@protonmail.com>
This commit is contained in:
parent
e782423ffd
commit
a47753a8e0
@ -2,10 +2,10 @@ pub mod pb {
|
|||||||
tonic::include_proto!("/grpc.examples.unaryecho");
|
tonic::include_proto!("/grpc.examples.unaryecho");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use detee_sgx::prelude::*;
|
||||||
|
use detee_sgx::RaTlsConfigBuilder;
|
||||||
use hyper::Uri;
|
use hyper::Uri;
|
||||||
use hyper_util::{client::legacy::connect::HttpConnector, rt::TokioExecutor};
|
use hyper_util::{client::legacy::connect::HttpConnector, rt::TokioExecutor};
|
||||||
use occlum_ratls::prelude::*;
|
|
||||||
use occlum_ratls::RaTlsConfigBuilder;
|
|
||||||
use pb::{echo_client::EchoClient, EchoRequest};
|
use pb::{echo_client::EchoClient, EchoRequest};
|
||||||
use tokio_rustls::rustls::ClientConfig;
|
use tokio_rustls::rustls::ClientConfig;
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@ pub mod pb {
|
|||||||
tonic::include_proto!("/grpc.examples.unaryecho");
|
tonic::include_proto!("/grpc.examples.unaryecho");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use detee_sgx::prelude::*;
|
||||||
|
use detee_sgx::RaTlsConfigBuilder;
|
||||||
use hyper::server::conn::http2::Builder;
|
use hyper::server::conn::http2::Builder;
|
||||||
use hyper_util::{
|
use hyper_util::{
|
||||||
rt::{TokioExecutor, TokioIo},
|
rt::{TokioExecutor, TokioIo},
|
||||||
@ -19,9 +21,6 @@ use tonic::{body::boxed, service::Routes, Request, Response, Status};
|
|||||||
use tower::ServiceBuilder;
|
use tower::ServiceBuilder;
|
||||||
use tower::ServiceExt;
|
use tower::ServiceExt;
|
||||||
|
|
||||||
use occlum_ratls::prelude::*;
|
|
||||||
use occlum_ratls::RaTlsConfigBuilder;
|
|
||||||
|
|
||||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
static COUNTER: AtomicUsize = AtomicUsize::new(0);
|
static COUNTER: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use occlum_ratls::prelude::*;
|
use detee_sgx::prelude::*;
|
||||||
use reqwest::ClientBuilder;
|
use reqwest::ClientBuilder;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use actix_web::{get, App, HttpServer};
|
use actix_web::{get, App, HttpServer};
|
||||||
use occlum_ratls::prelude::*;
|
use detee_sgx::prelude::*;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use occlum_ratls::prelude::*;
|
use detee_sgx::prelude::*;
|
||||||
use std::{
|
use std::{
|
||||||
fs,
|
fs,
|
||||||
path::Path,
|
path::Path,
|
||||||
@ -9,7 +9,7 @@ const DATA_PATH: &str = "/host/sealed_data";
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Example of sealing");
|
println!("Example of sealing");
|
||||||
let sgx_sealing = SgxSealing::new().unwrap();
|
let sgx_sealing = SealingConfig::new().unwrap();
|
||||||
println!("sealing : {:?}", sgx_sealing);
|
println!("sealing : {:?}", sgx_sealing);
|
||||||
|
|
||||||
let timestamp = SystemTime::now()
|
let timestamp = SystemTime::now()
|
||||||
@ -35,13 +35,13 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn seal_and_write_data(sgx_sealing: SgxSealing, payload: Vec<u8>) {
|
fn seal_and_write_data(sgx_sealing: SealingConfig, payload: Vec<u8>) {
|
||||||
let sealed_data = sgx_sealing.seal_data(payload).unwrap();
|
let sealed_data = sgx_sealing.seal_data(payload).unwrap();
|
||||||
println!("sealed_data: {:?}", &sealed_data);
|
println!("sealed_data: {:?}", &sealed_data);
|
||||||
fs::write(DATA_PATH, &sealed_data).expect("Failed to write file {DATA_PATH}");
|
fs::write(DATA_PATH, &sealed_data).expect("Failed to write file {DATA_PATH}");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unseal_data(sgx_sealing: SgxSealing, sealed_data: Vec<u8>) {
|
fn unseal_data(sgx_sealing: SealingConfig, sealed_data: Vec<u8>) {
|
||||||
println!("sealed_data: {:?}", &sealed_data);
|
println!("sealed_data: {:?}", &sealed_data);
|
||||||
let unsealed_data = sgx_sealing.un_seal_data(sealed_data).unwrap();
|
let unsealed_data = sgx_sealing.un_seal_data(sealed_data).unwrap();
|
||||||
println!("unsealed_data: {:?}", &unsealed_data);
|
println!("unsealed_data: {:?}", &unsealed_data);
|
||||||
|
@ -25,7 +25,7 @@ mod sealing;
|
|||||||
|
|
||||||
pub use crate::config::RaTlsConfig;
|
pub use crate::config::RaTlsConfig;
|
||||||
#[cfg(feature = "sealing")]
|
#[cfg(feature = "sealing")]
|
||||||
pub use crate::sealing::SgxSealing;
|
pub use crate::sealing::SealingConfig;
|
||||||
|
|
||||||
#[cfg(feature = "occlum")]
|
#[cfg(feature = "occlum")]
|
||||||
pub use crate::config::InstanceMeasurement;
|
pub use crate::config::InstanceMeasurement;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
pub use crate::RaTlsConfig;
|
pub use crate::RaTlsConfig;
|
||||||
#[cfg(feature = "sealing")]
|
#[cfg(feature = "sealing")]
|
||||||
pub use crate::SgxSealing;
|
pub use crate::SealingConfig;
|
||||||
|
|
||||||
#[cfg(feature = "occlum")]
|
#[cfg(feature = "occlum")]
|
||||||
pub use crate::config::InstanceMeasurement;
|
pub use crate::config::InstanceMeasurement;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use aes_gcm::{aead::Aead, Aes256Gcm, Key, KeyInit, Nonce};
|
use aes_gcm::{aead::Aead, Aes256Gcm, Key, KeyInit, Nonce};
|
||||||
|
|
||||||
use super::SgxSealing;
|
use crate::SealingConfig;
|
||||||
use crate::SgxError;
|
use crate::SgxError;
|
||||||
|
|
||||||
impl SgxSealing {
|
impl SealingConfig {
|
||||||
pub fn un_seal_data(self, payload_encrypted_packet: Vec<u8>) -> Result<Vec<u8>, SgxError> {
|
pub fn un_seal_data(self, payload_encrypted_packet: Vec<u8>) -> Result<Vec<u8>, SgxError> {
|
||||||
let sealing_key = self.get_aes256_sealing_key()?;
|
let sealing_key = self.get_aes256_sealing_key()?;
|
||||||
|
|
||||||
|
@ -3,10 +3,10 @@ use aes_gcm::{
|
|||||||
Aes256Gcm, Key, KeyInit,
|
Aes256Gcm, Key, KeyInit,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::SgxSealing;
|
use crate::SealingConfig;
|
||||||
use crate::SgxError;
|
use crate::SgxError;
|
||||||
|
|
||||||
impl SgxSealing {
|
impl SealingConfig {
|
||||||
pub fn seal_data(self, payload_plain_text: Vec<u8>) -> Result<Vec<u8>, SgxError> {
|
pub fn seal_data(self, payload_plain_text: Vec<u8>) -> Result<Vec<u8>, SgxError> {
|
||||||
let sealing_key = self.get_aes256_sealing_key()?;
|
let sealing_key = self.get_aes256_sealing_key()?;
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
use pbkdf2::pbkdf2_hmac_array;
|
use pbkdf2::pbkdf2_hmac_array;
|
||||||
use sha2::Sha256;
|
use sha2::Sha256;
|
||||||
|
|
||||||
use super::SgxSealing;
|
use crate::SealingConfig;
|
||||||
use crate::SgxError;
|
use crate::SgxError;
|
||||||
|
|
||||||
pub type SealingKey256BitDerived = [u8; 32];
|
pub type SealingKey256BitDerived = [u8; 32];
|
||||||
|
|
||||||
impl SgxSealing {
|
impl SealingConfig {
|
||||||
pub fn get_aes256_sealing_key(self) -> Result<SealingKey256BitDerived, SgxError> {
|
pub fn get_aes256_sealing_key(self) -> Result<SealingKey256BitDerived, SgxError> {
|
||||||
let mrsigner_for_salt = Self::get_current_sgx_quote()?.mrsigner().m;
|
let mrsigner_for_salt = Self::get_current_sgx_quote()?.mrsigner().m;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ mod decrypt;
|
|||||||
mod encrypt;
|
mod encrypt;
|
||||||
pub mod key_derivation;
|
pub mod key_derivation;
|
||||||
pub mod sealing_config;
|
pub mod sealing_config;
|
||||||
pub mod sealing_error;
|
// pub mod sealing_error;
|
||||||
|
|
||||||
pub use sealing_config::SealingConfig;
|
pub use sealing_config::SealingConfig;
|
||||||
pub use sealing_error::SealingError;
|
// pub use sealing_error::SealingError;
|
||||||
|
@ -18,12 +18,12 @@ pub enum SealingKeyPolicy {
|
|||||||
pub type Sgx128BitKey = sgx_key_128bit_t;
|
pub type Sgx128BitKey = sgx_key_128bit_t;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct SgxSealing {
|
pub struct SealingConfig {
|
||||||
#[cfg(feature = "occlum")]
|
#[cfg(feature = "occlum")]
|
||||||
pub sealing_key: Sgx128BitKey,
|
pub sealing_key: Sgx128BitKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SgxSealing {
|
impl SealingConfig {
|
||||||
#[cfg(feature = "occlum")]
|
#[cfg(feature = "occlum")]
|
||||||
pub(crate) fn get_current_sgx_quote() -> Result<&'static Quote, SgxError> {
|
pub(crate) fn get_current_sgx_quote() -> Result<&'static Quote, SgxError> {
|
||||||
Ok(STATIC_QUOTE.as_ref().map_err(|e| e.clone())?)
|
Ok(STATIC_QUOTE.as_ref().map_err(|e| e.clone())?)
|
Loading…
Reference in New Issue
Block a user