Skip to content

Commit

Permalink
Add SGX
Browse files Browse the repository at this point in the history
  • Loading branch information
dingelish committed Sep 19, 2019
1 parent 3f73764 commit bdfc1ca
Show file tree
Hide file tree
Showing 16 changed files with 288 additions and 30 deletions.
101 changes: 101 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
kind: pipeline
name: rustcrypto-traits-sgx-xargo-1604-release

steps:
- name: release-compile
image: baiduxlab/sgx-rust:1604-1.0.9
commands:
- . /opt/sgxsdk/environment
- . /root/.cargo/env
- RUST_TARGET_PATH=`pwd` xargo build --target x86_64-unknown-linux-sgx --release

---

kind: pipeline
name: rustcrypto-traits-sgx-xargo-1604-debug

steps:
- name: debug-compile
image: baiduxlab/sgx-rust:1604-1.0.9
commands:
- . /opt/sgxsdk/environment
- . /root/.cargo/env
- RUST_TARGET_PATH=`pwd` xargo build --target x86_64-unknown-linux-sgx

---

kind: pipeline
name: rustcrypto-traits-sgx-xargo-1804-release

steps:
- name: release-compile
image: baiduxlab/sgx-rust:1804-1.0.9
commands:
- . /opt/sgxsdk/environment
- . /root/.cargo/env
- RUST_TARGET_PATH=`pwd` xargo build --target x86_64-unknown-linux-sgx --release

---

kind: pipeline
name: rustcrypto-traits-sgx-xargo-1804-debug

steps:
- name: debug-compile
image: baiduxlab/sgx-rust:1804-1.0.9
commands:
- . /opt/sgxsdk/environment
- . /root/.cargo/env
- RUST_TARGET_PATH=`pwd` xargo build --target x86_64-unknown-linux-sgx

---

kind: pipeline
name: rustcrypto-traits-sgx-1604-release

steps:
- name: release-compile
image: baiduxlab/sgx-rust:1604-1.0.9
commands:
- . /opt/sgxsdk/environment
- . /root/.cargo/env
- cargo build --release

---

kind: pipeline
name: rustcrypto-traits-sgx-1604-hw-debug

steps:
- name: debug-compile
image: baiduxlab/sgx-rust:1604-1.0.9
commands:
- . /opt/sgxsdk/environment
- . /root/.cargo/env
- cargo build

---

kind: pipeline
name: rustcrypto-traits-sgx-1804-release

steps:
- name: release-compile
image: baiduxlab/sgx-rust:1804-1.0.9
commands:
- . /opt/sgxsdk/environment
- . /root/.cargo/env
- cargo build --release

---

kind: pipeline
name: rustcrypto-traits-sgx-1804-debug

steps:
- name: debug-compile
image: baiduxlab/sgx-rust:1804-1.0.9
commands:
- . /opt/sgxsdk/environment
- . /root/.cargo/env
- cargo build
5 changes: 5 additions & 0 deletions .github/pull.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: "1"
rules:
- base: master
upstream: RustCrypto:master
mergeMethod: none
90 changes: 90 additions & 0 deletions Xargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
[dependencies]
alloc = {}

[dependencies.sgx_types]
git = "https://github.com/baidu/rust-sgx-sdk.git"
stage = 1

[dependencies.sgx_demangle]
git = "https://github.com/baidu/rust-sgx-sdk.git"
stage = 1

[dependencies.panic_abort]
git = "https://github.com/baidu/rust-sgx-sdk.git"
stage = 1

[dependencies.sgx_libc]
git = "https://github.com/baidu/rust-sgx-sdk.git"
stage = 2

[dependencies.sgx_tkey_exchange]
git = "https://github.com/baidu/rust-sgx-sdk.git"
stage = 2

[dependencies.sgx_tservice]
git = "https://github.com/baidu/rust-sgx-sdk.git"
stage = 2

[dependencies.sgx_tse]
git = "https://github.com/baidu/rust-sgx-sdk.git"
stage = 2

[dependencies.sgx_tcrypto]
git = "https://github.com/baidu/rust-sgx-sdk.git"
stage = 2

[dependencies.sgx_trts]
git = "https://github.com/baidu/rust-sgx-sdk.git"
stage = 3

[dependencies.sgx_backtrace_sys]
git = "https://github.com/baidu/rust-sgx-sdk.git"
stage = 3

[dependencies.sgx_unwind]
git = "https://github.com/baidu/rust-sgx-sdk.git"
stage = 4

[dependencies.sgx_tdh]
git = "https://github.com/baidu/rust-sgx-sdk.git"
stage = 4

[dependencies.sgx_tseal]
git = "https://github.com/baidu/rust-sgx-sdk.git"
stage = 4

[dependencies.sgx_tprotected_fs]
git = "https://github.com/baidu/rust-sgx-sdk.git"
stage = 4

[dependencies.sgx_alloc]
git = "https://github.com/baidu/rust-sgx-sdk.git"
stage = 4

[dependencies.panic_unwind]
git = "https://github.com/baidu/rust-sgx-sdk.git"
stage = 5

[dependencies.std]
git = "https://github.com/baidu/rust-sgx-sdk.git"
stage = 6

[dependencies.sgx_rand]
git = "https://github.com/baidu/rust-sgx-sdk.git"
stage = 7

[dependencies.sgx_serialize]
git = "https://github.com/baidu/rust-sgx-sdk.git"
stage = 7

[dependencies.sgx_tunittest]
git = "https://github.com/baidu/rust-sgx-sdk.git"
stage = 7

[dependencies.sgx_backtrace]
git = "https://github.com/baidu/rust-sgx-sdk.git"
stage = 8

[dependencies.sgx_cov]
git = "https://github.com/baidu/rust-sgx-sdk.git"
stage = 8
6 changes: 4 additions & 2 deletions block-cipher-trait/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ categories = ["cryptography", "no-std"]

[dependencies]
generic-array = "0.12"
blobby = { version = "0.1", optional = true }
blobby = { git = "https://github.com/mesalock-linux/rustcrypto-utils-sgx", optional = true }
sgx_tstd = { rev = "v1.0.9", git = "https://github.com/baidu/rust-sgx-sdk.git", optional = true }

[features]
std = []
std = ["mesalock_sgx"]
dev = ["blobby"]
mesalock_sgx = ["sgx_tstd"]

[badges]
travis-ci = { repository = "RustCrypto/traits" }
Expand Down
4 changes: 2 additions & 2 deletions block-cipher-trait/src/dev.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#[macro_export]
macro_rules! new_test {
($name:ident, $test_name:expr, $cipher:ty) => {
#[test]
fn $name() {
//#[test]
pub fn $name() {
use block_cipher_trait::blobby::Blob3Iterator;
use block_cipher_trait::generic_array::typenum::Unsigned;
use block_cipher_trait::generic_array::GenericArray;
Expand Down
9 changes: 7 additions & 2 deletions block-cipher-trait/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@
//! block ciphers.
#![no_std]
#![doc(html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo_small.png")]
#![cfg_attr(all(target_env = "sgx", target_vendor = "mesalock"), feature(rustc_private))]
#[cfg(feature = "dev")]
pub extern crate blobby;
pub extern crate generic_array;
#[cfg(feature = "std")]

#[cfg(all(feature = "std", feature = "mesalock_sgx", target_env = "sgx"))]
extern crate std;

#[cfg(all(feature = "std", feature = "mesalock_sgx", not(target_env = "sgx")))]
extern crate sgx_tstd as std;

use generic_array::{GenericArray, ArrayLength};
use generic_array::typenum::Unsigned;
use generic_array::{ArrayLength, GenericArray};

#[cfg(feature = "dev")]
pub mod dev;
Expand Down
6 changes: 4 additions & 2 deletions crypto-mac/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ categories = ["cryptography", "no-std"]
[dependencies]
generic-array = "0.12"
subtle = { version = "2", default-features = false }
blobby = { version = "0.1", optional = true }
blobby = { git = "https://github.com/mesalock-linux/rustcrypto-utils-sgx", optional = true }
sgx_tstd = { rev = "v1.0.9", git = "https://github.com/baidu/rust-sgx-sdk.git", optional = true }

[features]
dev = ["blobby"]
std = []
std = ["mesalock_sgx"]
mesalock_sgx = ["sgx_tstd"]

[badges]
travis-ci = { repository = "RustCrypto/traits" }
Expand Down
4 changes: 2 additions & 2 deletions crypto-mac/src/dev.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#[macro_export]
macro_rules! new_test {
($name:ident, $test_name:expr, $mac:ty) => {
#[test]
fn $name() {
//#[test]
pub fn $name() {
use crypto_mac::blobby::Blob3Iterator;
use crypto_mac::Mac;

Expand Down
11 changes: 11 additions & 0 deletions crypto-mac/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
//! This crate provides trait for Message Authentication Code (MAC) algorithms.
#![no_std]
#![doc(html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo_small.png")]
#![cfg_attr(all(target_env = "sgx", target_vendor = "mesalock"), feature(rustc_private))]
pub extern crate generic_array;
extern crate subtle;

#[cfg(all(feature = "std", feature = "mesalock_sgx", target_env = "sgx"))]
extern crate std;
#[cfg(all(feature = "std", feature = "mesalock_sgx", not(target_env = "sgx")))]
extern crate sgx_tstd as std;

#[cfg(feature = "dev")]
pub extern crate blobby;
#[cfg(feature = "std")]
Expand Down Expand Up @@ -92,6 +98,11 @@ where
pub fn code(self) -> GenericArray<u8, N> {
self.code
}

/// Added by @dingelish, to provide backward compatibility
pub fn code_ref(&self) -> &GenericArray<u8, N> {
&self.code
}
}

impl<N> ConstantTimeEq for MacResult<N>
Expand Down
8 changes: 5 additions & 3 deletions digest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ categories = ["cryptography", "no-std"]

[dependencies]
generic-array = "0.12"
blobby = { version = "0.1", optional = true }
blobby = { git = "https://github.com/mesalock-linux/rustcrypto-utils-sgx", optional = true }
sgx_tstd = { rev = "v1.0.9", git = "https://github.com/baidu/rust-sgx-sdk.git", optional = true }

[features]
std = []
std = ["mesalock_sgx"]
dev = ["blobby"]
mesalock_sgx = ["sgx_tstd"]

[badges]
travis-ci = { repository = "RustCrypto/traits" }

[package.metadata.docs.rs]
features = ["std"]
features = ["std"]
4 changes: 2 additions & 2 deletions digest/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use core::fmt::Debug;
#[macro_export]
macro_rules! new_test {
($name:ident, $test_name:expr, $hasher:ty, $test_func:ident) => {
#[test]
fn $name() {
//#[test]
pub fn $name() {
use digest::blobby::Blob2Iterator;
let data = include_bytes!(concat!("data/", $test_name, ".blb"));

Expand Down
8 changes: 5 additions & 3 deletions digest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
//! The `Digest` trait is the most commonly used trait.
#![no_std]
#![doc(html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo_small.png")]
#![cfg_attr(all(target_env = "sgx", target_vendor = "mesalock"), feature(rustc_private))]
pub extern crate generic_array;
#[cfg(feature = "std")]
#[macro_use]
extern crate std;
#[cfg(all(feature = "std", feature = "mesalock_sgx", target_env = "sgx"))]
#[macro_use] extern crate std;
#[cfg(all(feature = "std", feature = "mesalock_sgx", not(target_env = "sgx")))]
#[macro_use] extern crate sgx_tstd as std;
#[cfg(feature = "dev")]
pub extern crate blobby;
use generic_array::{ArrayLength, GenericArray};
Expand Down
6 changes: 4 additions & 2 deletions stream-cipher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ categories = ["cryptography", "no-std"]

[dependencies]
generic-array = "0.12"
blobby = { version = "0.1", optional = true }
blobby = { git = "https://github.com/mesalock-linux/rustcrypto-utils-sgx", optional = true }
sgx_tstd = { rev = "v1.0.9", git = "https://github.com/baidu/rust-sgx-sdk.git", optional = true }

[features]
std = []
std = ["mesalock_sgx"]
dev = ["blobby"]
mesalock_sgx = ["sgx_tstd"]

[badges]
travis-ci = { repository = "RustCrypto/traits" }
Expand Down
Loading

0 comments on commit bdfc1ca

Please sign in to comment.