Skip to content

Commit

Permalink
submitting TCB info works and is accepted by chain
Browse files Browse the repository at this point in the history
  • Loading branch information
brenzi committed Sep 13, 2023
1 parent db821d2 commit 7bc383c
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 36 deletions.
73 changes: 43 additions & 30 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3"
dependencies = [
"lazy_static",
"regex 1.8.4",
"regex 1.9.5",
]

[[package]]
Expand Down Expand Up @@ -155,7 +155,7 @@ version = "0.7.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"
dependencies = [
"memchr 2.5.0",
"memchr 2.6.3",
]

[[package]]
Expand All @@ -164,7 +164,7 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41"
dependencies = [
"memchr 2.5.0",
"memchr 2.6.3",
]

[[package]]
Expand Down Expand Up @@ -404,7 +404,7 @@ dependencies = [
"peeking_take_while",
"proc-macro2",
"quote",
"regex 1.8.4",
"regex 1.9.5",
"rustc-hash",
"shlex",
]
Expand Down Expand Up @@ -536,7 +536,7 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a246e68bb43f6cd9db24bea052a53e40405417c5fb372e3d1a8a7f770a564ef5"
dependencies = [
"memchr 2.5.0",
"memchr 2.6.3",
"serde 1.0.164",
]

Expand Down Expand Up @@ -1362,7 +1362,7 @@ dependencies = [
"atty",
"humantime",
"log 0.4.19",
"regex 1.8.4",
"regex 1.9.5",
"termcolor",
]

Expand All @@ -1375,7 +1375,7 @@ dependencies = [
"humantime",
"is-terminal",
"log 0.4.19",
"regex 1.8.4",
"regex 1.9.5",
"termcolor",
]

Expand Down Expand Up @@ -2156,7 +2156,7 @@ dependencies = [
"futures-macro 0.3.28",
"futures-sink 0.3.28",
"futures-task 0.3.28",
"memchr 2.5.0",
"memchr 2.6.3",
"pin-project-lite",
"pin-utils",
"slab 0.4.8",
Expand Down Expand Up @@ -2256,7 +2256,7 @@ dependencies = [
"bstr",
"fnv 1.0.7",
"log 0.4.19",
"regex 1.8.4",
"regex 1.9.5",
]

[[package]]
Expand Down Expand Up @@ -2777,6 +2777,7 @@ dependencies = [
"primitive-types",
"rand 0.8.5",
"rayon",
"regex 1.9.5",
"reqwest",
"sc-keystore",
"serde 1.0.164",
Expand Down Expand Up @@ -4623,7 +4624,7 @@ version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1"
dependencies = [
"regex-automata",
"regex-automata 0.1.10",
]

[[package]]
Expand Down Expand Up @@ -4653,9 +4654,9 @@ dependencies = [

[[package]]
name = "memchr"
version = "2.5.0"
version = "2.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c"

[[package]]
name = "memfd"
Expand Down Expand Up @@ -4872,7 +4873,7 @@ dependencies = [
"http 0.2.9",
"httparse 1.8.0",
"log 0.4.19",
"memchr 2.5.0",
"memchr 2.6.3",
"mime",
"spin 0.9.8",
"version_check",
Expand Down Expand Up @@ -4987,7 +4988,7 @@ version = "7.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
dependencies = [
"memchr 2.5.0",
"memchr 2.6.3",
"minimal-lexical",
]

Expand Down Expand Up @@ -5235,7 +5236,7 @@ dependencies = [
"crc32fast",
"hashbrown 0.12.3",
"indexmap 1.9.3",
"memchr 2.5.0",
"memchr 2.6.3",
]

[[package]]
Expand All @@ -5244,7 +5245,7 @@ version = "0.30.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385"
dependencies = [
"memchr 2.5.0",
"memchr 2.6.3",
]

[[package]]
Expand Down Expand Up @@ -5970,7 +5971,7 @@ checksum = "7037e5e93e0172a5a96874380bf73bc6ecef022e26fa25f2be26864d6b3ba95d"
dependencies = [
"lazy_static",
"num 0.2.1",
"regex 1.8.4",
"regex 1.9.5",
]

[[package]]
Expand Down Expand Up @@ -6120,7 +6121,7 @@ dependencies = [
"itertools",
"normalize-line-endings",
"predicates-core",
"regex 1.8.4",
"regex 1.9.5",
]

[[package]]
Expand Down Expand Up @@ -6242,7 +6243,7 @@ dependencies = [
"fnv 1.0.7",
"lazy_static",
"libc",
"memchr 2.5.0",
"memchr 2.6.3",
"parking_lot 0.12.1",
"procfs",
"protobuf",
Expand Down Expand Up @@ -6528,13 +6529,14 @@ dependencies = [

[[package]]
name = "regex"
version = "1.8.4"
version = "1.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f"
checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47"
dependencies = [
"aho-corasick 1.0.2",
"memchr 2.5.0",
"regex-syntax 0.7.2",
"memchr 2.6.3",
"regex-automata 0.3.8",
"regex-syntax 0.7.5",
]

[[package]]
Expand All @@ -6546,6 +6548,17 @@ dependencies = [
"regex-syntax 0.6.29",
]

[[package]]
name = "regex-automata"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795"
dependencies = [
"aho-corasick 1.0.2",
"memchr 2.6.3",
"regex-syntax 0.7.5",
]

[[package]]
name = "regex-syntax"
version = "0.6.12"
Expand All @@ -6562,9 +6575,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"

[[package]]
name = "regex-syntax"
version = "0.7.2"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78"
checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"

[[package]]
name = "reqwest"
Expand Down Expand Up @@ -7803,7 +7816,7 @@ dependencies = [
"paste",
"primitive-types",
"rand 0.8.5",
"regex 1.8.4",
"regex 1.9.5",
"scale-info",
"schnorrkel",
"secp256k1",
Expand Down Expand Up @@ -8008,7 +8021,7 @@ source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.4
dependencies = [
"backtrace",
"lazy_static",
"regex 1.8.4",
"regex 1.9.5",
]

[[package]]
Expand Down Expand Up @@ -8856,7 +8869,7 @@ dependencies = [
"chrono 0.4.26",
"lazy_static",
"matchers",
"regex 1.8.4",
"regex 1.9.5",
"serde 1.0.164",
"serde_json 1.0.96",
"sharded-slab",
Expand Down Expand Up @@ -9359,7 +9372,7 @@ dependencies = [
"cc",
"cxx",
"cxx-build",
"regex 1.8.4",
"regex 1.9.5",
]

[[package]]
Expand Down Expand Up @@ -9858,7 +9871,7 @@ version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699"
dependencies = [
"memchr 2.5.0",
"memchr 2.6.3",
]

[[package]]
Expand Down
1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ sgx_crypto_helper = { branch = "master", git = "https://github.com/apache/teacla
thiserror = "1.0"
ws = { version = "0.9.1", features = ["ssl"] }
urlencoding = "2.1.3"
regex = "1.9.5"

# scs / integritee
my-node-runtime = { package = "integritee-node-runtime", git = "https://github.com/integritee-network/integritee-node.git", branch = "sdk-v0.12.0-polkadot-v0.9.42" }
Expand Down
4 changes: 4 additions & 0 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ Trusted call 0x69ddfd1698bd2d629180c2dca34ce7add087526c51f43cf68245241b3f13154e
## housekeeping tasks

populate all TCBinfo's Intel has published
```
../target/release/integritee-cli register-tcb-info //Alice --fmspc 00606a000000
../target/release/integritee-cli register-tcb-info //Alice --all
```
17 changes: 11 additions & 6 deletions cli/src/base_cli/commands/register_tcb_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use itp_node_api::api_client::{ParentchainExtrinsicSigner, TEEREX};
use itp_types::{parentchain::Hash, OpaqueCall};
use itp_utils::ToHexPrefixed;
use log::*;
use regex::Regex;
use serde::Deserialize;
use serde_json::Value;
use sp_core::sr25519 as sr25519_core;
Expand Down Expand Up @@ -103,18 +104,22 @@ impl RegisterTcbInfoCommand {
.to_string();
trace!("certificate chain: \n{}", certificate_chain);

let tcb_info: TcbInfo = response.json().expect("Error parsing JSON");
let body = response.text().unwrap();
trace!("raw json: \n{}", body);
let re = Regex::new(r#"tcbInfo\"\s?:(\{.*\}),\s?\"signature"#).unwrap();
let tcb_info = &re.captures(&body).unwrap()[1];
let re = Regex::new(r#"\"signature\"\s?:\s?\"(.*)\"\}"#).unwrap();
let intel_signature_hex = &re.captures(&body).unwrap()[1];
trace!("TCB info: {}", tcb_info);
trace!("signature: {}", body);

trace!("TCB info: {:?}", tcb_info.tcbInfo);
trace!("signature: {:?}", tcb_info.signature);

let intel_signature = hex::decode(tcb_info.signature).unwrap();
let intel_signature = hex::decode(intel_signature_hex).unwrap();

let call = OpaqueCall::from_tuple(&compose_call!(
chain_api.metadata(),
TEEREX,
"register_tcb_info",
tcb_info.tcbInfo.to_string(),
tcb_info,
intel_signature,
certificate_chain
));
Expand Down

0 comments on commit 7bc383c

Please sign in to comment.