From 7bc383ce3cbce9ac2ddfe3d077c098fb6a4788c0 Mon Sep 17 00:00:00 2001 From: Alain Brenzikofer Date: Wed, 13 Sep 2023 15:54:46 +0200 Subject: [PATCH] submitting TCB info works and is accepted by chain --- Cargo.lock | 73 +++++++++++-------- cli/Cargo.toml | 1 + cli/README.md | 4 + .../base_cli/commands/register_tcb_info.rs | 17 +++-- 4 files changed, 59 insertions(+), 36 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8068839eef..5ce15f6102 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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]] @@ -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]] @@ -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]] @@ -404,7 +404,7 @@ dependencies = [ "peeking_take_while", "proc-macro2", "quote", - "regex 1.8.4", + "regex 1.9.5", "rustc-hash", "shlex", ] @@ -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", ] @@ -1362,7 +1362,7 @@ dependencies = [ "atty", "humantime", "log 0.4.19", - "regex 1.8.4", + "regex 1.9.5", "termcolor", ] @@ -1375,7 +1375,7 @@ dependencies = [ "humantime", "is-terminal", "log 0.4.19", - "regex 1.8.4", + "regex 1.9.5", "termcolor", ] @@ -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", @@ -2256,7 +2256,7 @@ dependencies = [ "bstr", "fnv 1.0.7", "log 0.4.19", - "regex 1.8.4", + "regex 1.9.5", ] [[package]] @@ -2777,6 +2777,7 @@ dependencies = [ "primitive-types", "rand 0.8.5", "rayon", + "regex 1.9.5", "reqwest", "sc-keystore", "serde 1.0.164", @@ -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]] @@ -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" @@ -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", @@ -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", ] @@ -5235,7 +5236,7 @@ dependencies = [ "crc32fast", "hashbrown 0.12.3", "indexmap 1.9.3", - "memchr 2.5.0", + "memchr 2.6.3", ] [[package]] @@ -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]] @@ -5970,7 +5971,7 @@ checksum = "7037e5e93e0172a5a96874380bf73bc6ecef022e26fa25f2be26864d6b3ba95d" dependencies = [ "lazy_static", "num 0.2.1", - "regex 1.8.4", + "regex 1.9.5", ] [[package]] @@ -6120,7 +6121,7 @@ dependencies = [ "itertools", "normalize-line-endings", "predicates-core", - "regex 1.8.4", + "regex 1.9.5", ] [[package]] @@ -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", @@ -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]] @@ -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" @@ -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" @@ -7803,7 +7816,7 @@ dependencies = [ "paste", "primitive-types", "rand 0.8.5", - "regex 1.8.4", + "regex 1.9.5", "scale-info", "schnorrkel", "secp256k1", @@ -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]] @@ -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", @@ -9359,7 +9372,7 @@ dependencies = [ "cc", "cxx", "cxx-build", - "regex 1.8.4", + "regex 1.9.5", ] [[package]] @@ -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]] diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 3a15f45a4c..665b74c14d 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -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" } diff --git a/cli/README.md b/cli/README.md index 44e89c789e..e0e2cfd1fb 100644 --- a/cli/README.md +++ b/cli/README.md @@ -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 +``` diff --git a/cli/src/base_cli/commands/register_tcb_info.rs b/cli/src/base_cli/commands/register_tcb_info.rs index 8e40cdb333..12c6e081b1 100644 --- a/cli/src/base_cli/commands/register_tcb_info.rs +++ b/cli/src/base_cli/commands/register_tcb_info.rs @@ -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; @@ -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 ));