From f7b4769c479a8a52b5b143cf8035140c2d7bf4a6 Mon Sep 17 00:00:00 2001 From: Pi Delport Date: Tue, 1 Jun 2021 14:25:52 +0200 Subject: [PATCH 1/4] deps(rtc_types): add rkyv --- Cargo.lock | 52 +++++++++++++++++++++++++++++++++++++ rtc_auth_enclave/Cargo.lock | 52 +++++++++++++++++++++++++++++++++++++ rtc_data_enclave/Cargo.lock | 52 +++++++++++++++++++++++++++++++++++++ rtc_exec_enclave/Cargo.lock | 52 +++++++++++++++++++++++++++++++++++++ rtc_tenclave/Cargo.lock | 52 +++++++++++++++++++++++++++++++++++++ rtc_types/Cargo.toml | 3 +++ 6 files changed, 263 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 98413e7d..660099cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1095,6 +1095,15 @@ version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" +[[package]] +name = "memoffset" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83fb6581e8ed1f85fd45c116db8405483899489e38406156c25eb743554361d" +dependencies = [ + "autocfg 1.0.1", +] + [[package]] name = "mime" version = "0.3.16" @@ -1457,6 +1466,26 @@ dependencies = [ "tempfile", ] +[[package]] +name = "ptr_meta" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7424255320182a46c403331afed6f95e0259a7c578f9da54a27e262ef3b60118" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53005b9863728f508d3f23ae37e03d60986a01b65f7ae8397dcebaa1d5e54e10" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "quick-error" version = "1.2.3" @@ -1618,6 +1647,28 @@ dependencies = [ "winapi", ] +[[package]] +name = "rkyv" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f10244dc3cf3eddbf33245a69d154620746c60f629bec071e236d135b654556d" +dependencies = [ + "memoffset", + "ptr_meta", + "rkyv_derive", +] + +[[package]] +name = "rkyv_derive" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e3fccbf52ee0b76a29417794226e225798dd6bd32e40debd9e284cecc20dd76" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "rsa" version = "0.3.0" @@ -1686,6 +1737,7 @@ dependencies = [ name = "rtc_types" version = "0.1.0" dependencies = [ + "rkyv", "sgx_tstd", "sgx_types", "thiserror 1.0.24", diff --git a/rtc_auth_enclave/Cargo.lock b/rtc_auth_enclave/Cargo.lock index 25ed8007..9657d3e1 100644 --- a/rtc_auth_enclave/Cargo.lock +++ b/rtc_auth_enclave/Cargo.lock @@ -209,6 +209,15 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "memoffset" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +dependencies = [ + "autocfg", +] + [[package]] name = "once_cell" version = "1.4.0" @@ -243,6 +252,26 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "ptr_meta" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7424255320182a46c403331afed6f95e0259a7c578f9da54a27e262ef3b60118" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53005b9863728f508d3f23ae37e03d60986a01b65f7ae8397dcebaa1d5e54e10" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "quote" version = "1.0.9" @@ -355,6 +384,28 @@ dependencies = [ "winapi", ] +[[package]] +name = "rkyv" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f10244dc3cf3eddbf33245a69d154620746c60f629bec071e236d135b654556d" +dependencies = [ + "memoffset", + "ptr_meta", + "rkyv_derive", +] + +[[package]] +name = "rkyv_derive" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e3fccbf52ee0b76a29417794226e225798dd6bd32e40debd9e284cecc20dd76" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "rtc_auth_enclave" version = "0.1.0" @@ -394,6 +445,7 @@ dependencies = [ name = "rtc_types" version = "0.1.0" dependencies = [ + "rkyv", "sgx_tstd", "sgx_types", "thiserror 1.0.24", diff --git a/rtc_data_enclave/Cargo.lock b/rtc_data_enclave/Cargo.lock index 5fe94351..d9b8446f 100644 --- a/rtc_data_enclave/Cargo.lock +++ b/rtc_data_enclave/Cargo.lock @@ -258,6 +258,15 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "memoffset" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +dependencies = [ + "autocfg 1.0.1", +] + [[package]] name = "num-bigint" version = "0.2.5" @@ -322,6 +331,26 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "ptr_meta" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7424255320182a46c403331afed6f95e0259a7c578f9da54a27e262ef3b60118" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53005b9863728f508d3f23ae37e03d60986a01b65f7ae8397dcebaa1d5e54e10" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "quote" version = "1.0.9" @@ -434,6 +463,28 @@ dependencies = [ "winapi", ] +[[package]] +name = "rkyv" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f10244dc3cf3eddbf33245a69d154620746c60f629bec071e236d135b654556d" +dependencies = [ + "memoffset", + "ptr_meta", + "rkyv_derive", +] + +[[package]] +name = "rkyv_derive" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e3fccbf52ee0b76a29417794226e225798dd6bd32e40debd9e284cecc20dd76" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "rtc_data_enclave" version = "0.0.1" @@ -491,6 +542,7 @@ dependencies = [ name = "rtc_types" version = "0.1.0" dependencies = [ + "rkyv", "sgx_tstd", "sgx_types", "thiserror 1.0.24", diff --git a/rtc_exec_enclave/Cargo.lock b/rtc_exec_enclave/Cargo.lock index dfea55dc..e757b8d5 100644 --- a/rtc_exec_enclave/Cargo.lock +++ b/rtc_exec_enclave/Cargo.lock @@ -209,6 +209,15 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "memoffset" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +dependencies = [ + "autocfg", +] + [[package]] name = "once_cell" version = "1.4.0" @@ -243,6 +252,26 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "ptr_meta" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7424255320182a46c403331afed6f95e0259a7c578f9da54a27e262ef3b60118" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53005b9863728f508d3f23ae37e03d60986a01b65f7ae8397dcebaa1d5e54e10" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "quote" version = "1.0.9" @@ -355,6 +384,28 @@ dependencies = [ "winapi", ] +[[package]] +name = "rkyv" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f10244dc3cf3eddbf33245a69d154620746c60f629bec071e236d135b654556d" +dependencies = [ + "memoffset", + "ptr_meta", + "rkyv_derive", +] + +[[package]] +name = "rkyv_derive" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e3fccbf52ee0b76a29417794226e225798dd6bd32e40debd9e284cecc20dd76" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "rtc_exec_enclave" version = "0.1.0" @@ -394,6 +445,7 @@ dependencies = [ name = "rtc_types" version = "0.1.0" dependencies = [ + "rkyv", "sgx_tstd", "sgx_types", "thiserror 1.0.24", diff --git a/rtc_tenclave/Cargo.lock b/rtc_tenclave/Cargo.lock index d0b9fd95..298da866 100644 --- a/rtc_tenclave/Cargo.lock +++ b/rtc_tenclave/Cargo.lock @@ -201,6 +201,15 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" +[[package]] +name = "memoffset" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +dependencies = [ + "autocfg", +] + [[package]] name = "mockall" version = "0.9.1" @@ -326,6 +335,26 @@ dependencies = [ "tempfile", ] +[[package]] +name = "ptr_meta" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7424255320182a46c403331afed6f95e0259a7c578f9da54a27e262ef3b60118" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53005b9863728f508d3f23ae37e03d60986a01b65f7ae8397dcebaa1d5e54e10" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "quick-error" version = "1.2.3" @@ -541,6 +570,28 @@ dependencies = [ "winapi", ] +[[package]] +name = "rkyv" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f10244dc3cf3eddbf33245a69d154620746c60f629bec071e236d135b654556d" +dependencies = [ + "memoffset", + "ptr_meta", + "rkyv_derive", +] + +[[package]] +name = "rkyv_derive" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e3fccbf52ee0b76a29417794226e225798dd6bd32e40debd9e284cecc20dd76" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "rtc_tenclave" version = "0.1.0" @@ -577,6 +628,7 @@ dependencies = [ name = "rtc_types" version = "0.1.0" dependencies = [ + "rkyv", "sgx_tstd", "sgx_types", "thiserror 1.0.24", diff --git a/rtc_types/Cargo.toml b/rtc_types/Cargo.toml index b1e56636..b50ac1b2 100644 --- a/rtc_types/Cargo.toml +++ b/rtc_types/Cargo.toml @@ -17,6 +17,9 @@ teaclave_sgx = ["thiserror_sgx", "sgx_tstd"] [dependencies] sgx_types = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk.git", rev = "b9d1bda", features = ["extra_traits"] } +# no_std libraries +rkyv = { version = "0.6.6", default_features = false, features = ["const_generics", "strict"] } + # default thiserror = { version = "1.0.24", optional = true} From cc2dc35417f08119ce8aafa5be622ba9b95234cc Mon Sep 17 00:00:00 2001 From: Pi Delport Date: Wed, 9 Jun 2021 16:30:06 +0200 Subject: [PATCH 2/4] deps(rtc_types): add (dev) proptest + proptest-derive --- Cargo.lock | 178 +++++++++++++++++++++++++++---------------- rtc_types/Cargo.toml | 4 + 2 files changed, 117 insertions(+), 65 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 660099cb..030bb771 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -106,8 +106,8 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbcb2b608f0accc2f5bcf3dd872194ce13d94ee45b571487035864cf966b04ef" dependencies = [ - "quote", - "syn", + "quote 1.0.9", + "syn 1.0.71", ] [[package]] @@ -237,9 +237,9 @@ version = "0.5.0-beta.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f138ac357a674c3b480ddb7bbd894b13c1b6e8927d728bc9ea5e17eee2f8fc9" dependencies = [ - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.26", + "quote 1.0.9", + "syn 1.0.71", ] [[package]] @@ -248,9 +248,9 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d44b8fee1ced9671ba043476deddef739dd0959bf77030b26b738cc591737a7" dependencies = [ - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.26", + "quote 1.0.9", + "syn 1.0.71", ] [[package]] @@ -373,8 +373,8 @@ dependencies = [ "lazycell", "log", "peeking_take_while", - "proc-macro2", - "quote", + "proc-macro2 1.0.26", + "quote 1.0.9", "regex", "rustc-hash", "shlex", @@ -642,9 +642,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f82b1b72f1263f214c0f823371768776c4f5841b942c9883aa8e5ec584fd0ba6" dependencies = [ "convert_case", - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.26", + "quote 1.0.9", + "syn 1.0.71", ] [[package]] @@ -1164,9 +1164,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dd4234635bca06fc96c7368d038061e0aae1b00a764dc817e900dc974e3deea" dependencies = [ "cfg-if", - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.26", + "quote 1.0.9", + "syn 1.0.71", ] [[package]] @@ -1176,9 +1176,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e25b78d34b2b713b1d000d629079755cfc166e6a65f9f4c1c012a94305467c5" dependencies = [ "cfg-if", - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.26", + "quote 1.0.9", + "syn 1.0.71", ] [[package]] @@ -1379,9 +1379,9 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48c950132583b500556b1efd71d45b319029f2b71518d979fcc208e16b42426f" dependencies = [ - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.26", + "quote 1.0.9", + "syn 1.0.71", ] [[package]] @@ -1437,13 +1437,22 @@ version = "0.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid 0.1.0", +] + [[package]] name = "proc-macro2" version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" dependencies = [ - "unicode-xid", + "unicode-xid 0.2.1", ] [[package]] @@ -1466,6 +1475,17 @@ dependencies = [ "tempfile", ] +[[package]] +name = "proptest-derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90b46295382dc76166cb7cf2bb4a97952464e4b7ed5a43e6cd34e1fec3349ddc" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "syn 0.15.44", +] + [[package]] name = "ptr_meta" version = "0.1.3" @@ -1481,9 +1501,9 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53005b9863728f508d3f23ae37e03d60986a01b65f7ae8397dcebaa1d5e54e10" dependencies = [ - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.26", + "quote 1.0.9", + "syn 1.0.71", ] [[package]] @@ -1498,13 +1518,22 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ac73b1112776fc109b2e61909bc46c7e1bf0d7f690ffb1676553acce16d5cda" +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2 0.4.30", +] + [[package]] name = "quote" version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.26", ] [[package]] @@ -1664,9 +1693,9 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e3fccbf52ee0b76a29417794226e225798dd6bd32e40debd9e284cecc20dd76" dependencies = [ - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.26", + "quote 1.0.9", + "syn 1.0.71", ] [[package]] @@ -1737,6 +1766,8 @@ dependencies = [ name = "rtc_types" version = "0.1.0" dependencies = [ + "proptest", + "proptest-derive", "rkyv", "sgx_tstd", "sgx_types", @@ -1906,9 +1937,9 @@ version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" dependencies = [ - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.26", + "quote 1.0.9", + "syn 1.0.71", ] [[package]] @@ -2183,11 +2214,11 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.26", + "quote 1.0.9", "serde 1.0.125", "serde_derive", - "syn", + "syn 1.0.71", ] [[package]] @@ -2197,13 +2228,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" dependencies = [ "base-x", - "proc-macro2", - "quote", + "proc-macro2 1.0.26", + "quote 1.0.9", "serde 1.0.125", "serde_derive", "serde_json", "sha1", - "syn", + "syn 1.0.71", ] [[package]] @@ -2224,15 +2255,26 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "unicode-xid 0.1.0", +] + [[package]] name = "syn" version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad184cc9470f9117b2ac6817bfe297307418819ba40552f9b3846f05c33d5373" dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", + "proc-macro2 1.0.26", + "quote 1.0.9", + "unicode-xid 0.2.1", ] [[package]] @@ -2241,10 +2283,10 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" dependencies = [ - "proc-macro2", - "quote", - "syn", - "unicode-xid", + "proc-macro2 1.0.26", + "quote 1.0.9", + "syn 1.0.71", + "unicode-xid 0.2.1", ] [[package]] @@ -2312,9 +2354,9 @@ name = "thiserror-impl" version = "1.0.9" source = "git+https://github.com/mesalock-linux/thiserror-sgx.git#c2f806b88616e06aab0af770366a76885d974fdc" dependencies = [ - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.26", + "quote 1.0.9", + "syn 1.0.71", ] [[package]] @@ -2323,9 +2365,9 @@ version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0" dependencies = [ - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.26", + "quote 1.0.9", + "syn 1.0.71", ] [[package]] @@ -2370,10 +2412,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5c3be1edfad6027c69f5491cf4cb310d1a71ecd6af742788c6ff8bced86b8fa" dependencies = [ "proc-macro-hack", - "proc-macro2", - "quote", + "proc-macro2 1.0.26", + "quote 1.0.9", "standback", - "syn", + "syn 1.0.71", ] [[package]] @@ -2499,6 +2541,12 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + [[package]] name = "unicode-xid" version = "0.2.1" @@ -2599,9 +2647,9 @@ dependencies = [ "bumpalo", "lazy_static", "log", - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.26", + "quote 1.0.9", + "syn 1.0.71", "wasm-bindgen-shared", ] @@ -2611,7 +2659,7 @@ version = "0.2.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e734d91443f177bfdb41969de821e15c516931c3c3db3d318fa1b68975d0f6f" dependencies = [ - "quote", + "quote 1.0.9", "wasm-bindgen-macro-support", ] @@ -2621,9 +2669,9 @@ version = "0.2.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d53739ff08c8a68b0fdbcd54c372b8ab800b1449ab3c9d706503bc7dd1621b2c" dependencies = [ - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.26", + "quote 1.0.9", + "syn 1.0.71", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2727,8 +2775,8 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2c1e130bebaeab2f23886bf9acbaca14b092408c452543c857f66399cd6dab1" dependencies = [ - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.26", + "quote 1.0.9", + "syn 1.0.71", "synstructure", ] diff --git a/rtc_types/Cargo.toml b/rtc_types/Cargo.toml index b50ac1b2..36502013 100644 --- a/rtc_types/Cargo.toml +++ b/rtc_types/Cargo.toml @@ -26,3 +26,7 @@ thiserror = { version = "1.0.24", optional = true} # teaclave_sgx thiserror_sgx = { git = "https://github.com/mesalock-linux/thiserror-sgx.git", package = "thiserror", optional = true } sgx_tstd = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk.git", rev = "b9d1bda", features = ["backtrace"], optional = true } + +[dev-dependencies] +proptest = "1.0.0" +proptest-derive = "0.3.0" From 4b90c6f937072aae5946b7a0bbe7c315fe90819c Mon Sep 17 00:00:00 2001 From: Pi Delport Date: Mon, 7 Jun 2021 13:48:39 +0200 Subject: [PATCH 3/4] feat(rtc_types): add mod byte_formats --- rtc_types/src/byte_formats/mod.rs | 20 ++++++++++++++++++++ rtc_types/src/lib.rs | 2 ++ 2 files changed, 22 insertions(+) create mode 100644 rtc_types/src/byte_formats/mod.rs diff --git a/rtc_types/src/byte_formats/mod.rs b/rtc_types/src/byte_formats/mod.rs new file mode 100644 index 00000000..101b2048 --- /dev/null +++ b/rtc_types/src/byte_formats/mod.rs @@ -0,0 +1,20 @@ +//! Helpers for serializing the types in this library to various byte formats. +//! +//! # Naming convention +//! +//! Sub-modules should be named `{name}_format`, for each binary format implemented. +//! +//! Functions in each module use the following naming convention: +//! +//! > `(write|read|view)_(array|slice)` +//! +//! 1. Operation: +//! +//! - `write` to serialize a structure to bytes +//! - `read` to deserialize bytes to a new Rust structure (copying data) +//! - `view` to deserialize bytes to a structured view (sharing data) +//! +//! 2. Type suffix, for the byte representation: +//! +//! - `array` for working with constant-sized arrays (`[u8; ?]`) +//! - `slice` for working with variable-sized slices (`[u8]`) diff --git a/rtc_types/src/lib.rs b/rtc_types/src/lib.rs index 7a5f7892..a36646ab 100644 --- a/rtc_types/src/lib.rs +++ b/rtc_types/src/lib.rs @@ -25,6 +25,8 @@ pub use exec_token::*; mod ecall_result; pub use ecall_result::*; +pub mod byte_formats; + #[repr(C)] #[derive(Clone, Debug)] pub struct EncryptedMessage { From c7ea48272d34afde6b63f61d65eb7fe475e11a2c Mon Sep 17 00:00:00 2001 From: Pi Delport Date: Thu, 10 Jun 2021 11:48:28 +0200 Subject: [PATCH 4/4] feat(rtc_types,byte_formats): add mod rkyv_format --- rtc_types/src/byte_formats/mod.rs | 2 + rtc_types/src/byte_formats/rkyv_format.rs | 105 ++++++++++++++++++++++ rtc_types/src/lib.rs | 4 + 3 files changed, 111 insertions(+) create mode 100644 rtc_types/src/byte_formats/rkyv_format.rs diff --git a/rtc_types/src/byte_formats/mod.rs b/rtc_types/src/byte_formats/mod.rs index 101b2048..ec9344f8 100644 --- a/rtc_types/src/byte_formats/mod.rs +++ b/rtc_types/src/byte_formats/mod.rs @@ -18,3 +18,5 @@ //! //! - `array` for working with constant-sized arrays (`[u8; ?]`) //! - `slice` for working with variable-sized slices (`[u8]`) + +pub mod rkyv_format; diff --git a/rtc_types/src/byte_formats/rkyv_format.rs b/rtc_types/src/byte_formats/rkyv_format.rs new file mode 100644 index 00000000..6eba3d9b --- /dev/null +++ b/rtc_types/src/byte_formats/rkyv_format.rs @@ -0,0 +1,105 @@ +//! [`rkyv`] byte format helpers. + +use core::mem::size_of; + +use rkyv::{ + archived_root, + ser::{ + serializers::{BufferSerializer, BufferSerializerError}, + Serializer, + }, + Aligned, Archive, Deserialize, Infallible, Serialize, Unreachable, +}; + +pub fn write_array(value: &T) -> Result<[u8; size_of::()], BufferSerializerError> +where + T: Serialize()]>>>, +{ + let mut serializer = BufferSerializer::new(Aligned([0u8; size_of::()])); + serializer.serialize_value(value)?; + let Aligned(buf) = serializer.into_inner(); + Ok(buf) +} + +/// # Safety +/// +/// This does not perform input validation, and may have undefined behaviour for untrusted input. +/// +/// See safety of [`archived_root`]: +/// +/// > The caller must guarantee that the byte slice represents an archived object and that the root +/// > object is stored at the end of the byte slice. +/// +/// TODO: Use `check_archived_root` once it's stable without `std` (rkyv 0.7.0?). +/// See issue: [no_std validation #107](https://github.com/djkoloski/rkyv/issues/107) +pub unsafe fn view_array(bytes: &[u8; size_of::()]) -> &T::Archived +where + T: Archive, +{ + archived_root::(bytes) +} + +/// # Safety +/// +/// See safety of [`view_array`]. +pub unsafe fn read_array(bytes: &[u8; size_of::()]) -> T +where + T: Archive, + T::Archived: Deserialize, +{ + let archived = view_array::(bytes); + let result: Result = archived.deserialize(&mut Infallible); + // Safety: this should not allocate, so it should not fail. + result.expect("read_array: unexpected deserialize failure!") +} + +#[cfg(test)] +mod tests { + use core::mem::{size_of, size_of_val}; + + use rkyv::{Archive, Deserialize, Serialize}; + + use super::*; + + use proptest::prelude::*; + use proptest_derive::Arbitrary; + + /// Arbitrary structure to test with. + #[derive( + Debug, + PartialEq, + // rkyv: + Archive, + Deserialize, + Serialize, + // proptest: + Arbitrary, + )] + struct Foo { + byte: u8, + int: u32, + opt: Option, + ary: [u8; 16], + } + + const ARCHIVED_FOO_SIZE: usize = size_of::(); + + /// [`write_array`] roundtrips with [`view_array`] and [`read_array`]. + #[test] + fn prop_rkyv_array_roundtrip() { + let test = |value: &Foo| { + let bytes = &write_array(value).unwrap(); + assert_eq!(size_of_val(bytes), ARCHIVED_FOO_SIZE); + + let view = unsafe { view_array::(bytes) }; + assert_eq!(value.byte, view.byte); + assert_eq!(value.int, view.int); + assert_eq!(value.opt, view.opt); + assert_eq!(value.ary, view.ary); + + let read = &unsafe { read_array(bytes) }; + assert_eq!(value, read); + }; + proptest!(|(value: Foo)| test(&value)); + } +} diff --git a/rtc_types/src/lib.rs b/rtc_types/src/lib.rs index a36646ab..9cad1da6 100644 --- a/rtc_types/src/lib.rs +++ b/rtc_types/src/lib.rs @@ -1,3 +1,7 @@ +// Used by rtc_types::byte_formats::rkyv_format +#![allow(incomplete_features)] +#![feature(const_generics)] +#![feature(const_evaluatable_checked)] // TODO: Document #![cfg_attr(feature = "teaclave_sgx", no_std)] #[cfg(feature = "teaclave_sgx")]