From d8eba96a6d444b9a4beb982827b98e2873fac94a Mon Sep 17 00:00:00 2001 From: Pi Delport Date: Thu, 28 Apr 2022 11:36:31 +0200 Subject: [PATCH 01/22] feat: add Vault CLI & data package library (#1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(ntc-vault-cli): initial layout * style(ntc-vault-cli): add rustfmt.toml * feat(ntc-vault-cli): add clap-based CLI skeleton * feat(ntc-vault-cli): flesh out structure, implement identity subcommand * refactor(ntc-vault-cli): separate code into two crates: core, cli * refactor(ntc-vault-cli): move rand-using code from core to cli * test(ntc-vault-cli): generate_secure_seed smoke test * feat(ntc-vault-cli): data package and JSON Schema work-in-progress * refactor: move crates into rust-workspace * docs: add comment about using "cargo +nightly fmt" * docs: add ARCHITECTURE.md * refactor: rename package "ntc-vault-core" → "ntc-data-packages" * feat(ntc-data-packages): replace anyhow with thiserror * build(ntc-data-packages): drop jsonschema's default features We don't need jsonschema's CLI, or the file / HTTP resolving features. This greatly reduces our dependency tree. * build: declare rust-version * docs: add package descriptions * feat(ntc-data-packages): better validation error messages * ci(rust-workspace): add check and test workflows for GitHub Actions * docs: fix rustdoc link issues * build(rust-workspace): add rust-toolchain.toml, with channel = "stable" * docs(README): add link to ARCHITECTURE.md * deps(ntc-vault-cli): update confy revision for store_path fix Upstream PR: https://github.com/rust-cli/confy/pull/60 (fix: `store_path` should create missing directories, like `load_path`) * refactor(ntc-data-packages): move tests to API-based integration tests Motivation: https://matklad.github.io/2021/02/27/delete-cargo-integration-tests.html * refactor(ntc-vault-cli): move try_exists to compat module * refactor(ntc-vault-cli): VaultIdentityConfig: make pub * deps(ntc-vault-cli): add dev dependencies for CLI tests * test(ntc-vault-cli): add snapshot-based CLI tests * deps(ntc-data-packages): add serde * feat(ntc-data-packages): add Metadata::from_json_bytes * feat(ntc-vault-cli): add fs_io, with read_metadata * feat(ntc-vault-cli): implement more of the "data" subcommand * chore: add todos to keep track of changes that needs to be made to allign with design * chore(deps): update dependencies and bump jsonschema to 0.16 Co-authored-by: Herman --- .github/workflows/rust-workspace-check.yaml | 93 ++ .github/workflows/rust-workspace-test.yaml | 56 + ARCHITECTURE.md | 25 + README.md | 2 + rust-workspace/.gitignore | 1 + rust-workspace/Cargo.lock | 1184 +++++++++++++++++ rust-workspace/Cargo.toml | 2 + .../crates/ntc-data-packages/Cargo.toml | 20 + .../src/data_packages/common.rs | 49 + .../src/data_packages/json_schema.rs | 103 ++ .../src/data_packages/mod.rs | 5 + .../src/data_packages/sealing.rs | 34 + .../crates/ntc-data-packages/src/identity.rs | 17 + .../crates/ntc-data-packages/src/lib.rs | 4 + .../tests/data_packages/common.rs | 47 + .../tests/data_packages/json_schema.rs | 130 ++ .../tests/data_packages/main.rs | 4 + .../crates/ntc-vault-cli/Cargo.toml | 33 + .../crates/ntc-vault-cli/src/actions.rs | 64 + .../crates/ntc-vault-cli/src/bin/ntc-vault.rs | 5 + .../crates/ntc-vault-cli/src/commands.rs | 116 ++ .../crates/ntc-vault-cli/src/compat.rs | 17 + .../crates/ntc-vault-cli/src/crypto.rs | 22 + .../crates/ntc-vault-cli/src/fs_io.rs | 37 + .../ntc-vault-cli/src/identity_files.rs | 45 + .../crates/ntc-vault-cli/src/lib.rs | 8 + .../tests/subcommands/common/cli_fixture.rs | 207 +++ .../tests/subcommands/common/mod.rs | 3 + .../ntc-vault-cli/tests/subcommands/data.rs | 161 +++ .../tests/subcommands/identity.rs | 115 ++ .../ntc-vault-cli/tests/subcommands/main.rs | 6 + .../ntc-vault-cli/tests/subcommands/usage.rs | 57 + rust-workspace/rust-toolchain.toml | 4 + rust-workspace/rustfmt.toml | 6 + 34 files changed, 2682 insertions(+) create mode 100644 .github/workflows/rust-workspace-check.yaml create mode 100644 .github/workflows/rust-workspace-test.yaml create mode 100644 ARCHITECTURE.md create mode 100644 rust-workspace/.gitignore create mode 100644 rust-workspace/Cargo.lock create mode 100644 rust-workspace/Cargo.toml create mode 100644 rust-workspace/crates/ntc-data-packages/Cargo.toml create mode 100644 rust-workspace/crates/ntc-data-packages/src/data_packages/common.rs create mode 100644 rust-workspace/crates/ntc-data-packages/src/data_packages/json_schema.rs create mode 100644 rust-workspace/crates/ntc-data-packages/src/data_packages/mod.rs create mode 100644 rust-workspace/crates/ntc-data-packages/src/data_packages/sealing.rs create mode 100644 rust-workspace/crates/ntc-data-packages/src/identity.rs create mode 100644 rust-workspace/crates/ntc-data-packages/src/lib.rs create mode 100644 rust-workspace/crates/ntc-data-packages/tests/data_packages/common.rs create mode 100644 rust-workspace/crates/ntc-data-packages/tests/data_packages/json_schema.rs create mode 100644 rust-workspace/crates/ntc-data-packages/tests/data_packages/main.rs create mode 100644 rust-workspace/crates/ntc-vault-cli/Cargo.toml create mode 100644 rust-workspace/crates/ntc-vault-cli/src/actions.rs create mode 100644 rust-workspace/crates/ntc-vault-cli/src/bin/ntc-vault.rs create mode 100644 rust-workspace/crates/ntc-vault-cli/src/commands.rs create mode 100644 rust-workspace/crates/ntc-vault-cli/src/compat.rs create mode 100644 rust-workspace/crates/ntc-vault-cli/src/crypto.rs create mode 100644 rust-workspace/crates/ntc-vault-cli/src/fs_io.rs create mode 100644 rust-workspace/crates/ntc-vault-cli/src/identity_files.rs create mode 100644 rust-workspace/crates/ntc-vault-cli/src/lib.rs create mode 100644 rust-workspace/crates/ntc-vault-cli/tests/subcommands/common/cli_fixture.rs create mode 100644 rust-workspace/crates/ntc-vault-cli/tests/subcommands/common/mod.rs create mode 100644 rust-workspace/crates/ntc-vault-cli/tests/subcommands/data.rs create mode 100644 rust-workspace/crates/ntc-vault-cli/tests/subcommands/identity.rs create mode 100644 rust-workspace/crates/ntc-vault-cli/tests/subcommands/main.rs create mode 100644 rust-workspace/crates/ntc-vault-cli/tests/subcommands/usage.rs create mode 100644 rust-workspace/rust-toolchain.toml create mode 100644 rust-workspace/rustfmt.toml diff --git a/.github/workflows/rust-workspace-check.yaml b/.github/workflows/rust-workspace-check.yaml new file mode 100644 index 0000000..fafc38b --- /dev/null +++ b/.github/workflows/rust-workspace-check.yaml @@ -0,0 +1,93 @@ +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions + +name: rust-workspace (check) + +on: push + +# Action docs: +# https://github.com/actions/checkout#readme +# https://github.com/actions-rs/toolchain#readme +# https://github.com/Swatinem/rust-cache#readme +# https://github.com/actions-rs/cargo#readme + +# NOTE: This uses the fork to work around + +jobs: + + # "cargo fmt" produces no changes + rustfmt-check: + runs-on: ubuntu-latest + steps: + - + uses: actions/checkout@v3 + - + uses: actions-rs/toolchain@v1 + with: + # Use nightly toolchain, for unstable features in rustfmt.toml + toolchain: nightly + profile: minimal + components: rustfmt + default: true + - + name: cargo fmt + uses: MarcoPolo/cargo@a527bf4d534717ff4424a84446c5d710f8833139 + with: + working-directory: rust-workspace + command: fmt + args: -- --check + + # "cargo clippy" produces no errors or warnings (for all targets) + clippy: + runs-on: ubuntu-latest + steps: + - + uses: actions/checkout@v3 + - + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + components: clippy + default: true + - + uses: Swatinem/rust-cache@v1 + with: + working-directory: rust-workspace + sharedKey: clippy + key: ${{ github.ref }} + - + name: cargo clippy + uses: MarcoPolo/cargo@a527bf4d534717ff4424a84446c5d710f8833139 + with: + working-directory: rust-workspace + command: clippy + args: --all-targets -- --deny warnings + + # "cargo doc" builds cleanly (including private items) + doc-check: + runs-on: ubuntu-latest + steps: + - + uses: actions/checkout@v3 + - + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + components: rust-docs + default: true + - + uses: Swatinem/rust-cache@v1 + with: + working-directory: rust-workspace + sharedKey: doc-check + key: ${{ github.ref }} + - + name: cargo doc + uses: MarcoPolo/cargo@a527bf4d534717ff4424a84446c5d710f8833139 + with: + working-directory: rust-workspace + command: doc + args: --no-deps --document-private-items + env: + RUSTDOCFLAGS: --deny warnings diff --git a/.github/workflows/rust-workspace-test.yaml b/.github/workflows/rust-workspace-test.yaml new file mode 100644 index 0000000..f645dff --- /dev/null +++ b/.github/workflows/rust-workspace-test.yaml @@ -0,0 +1,56 @@ +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions + +name: rust-workspace (test) + +on: push + +# Action docs: +# https://github.com/actions/checkout#readme +# https://github.com/actions-rs/toolchain#readme +# https://github.com/Swatinem/rust-cache#readme +# https://github.com/actions-rs/cargo#readme + +# NOTE: This uses the fork to work around + +jobs: + + # "cargo build" and "cargo test" pass on all supported Rust toolchain channels. + test: + runs-on: ubuntu-latest + strategy: + # No fail-fast: We want to see test results for all toolchain channels, even if one fails. + fail-fast: false + matrix: + rust: + - '1.57' # MSRV + - stable + - nightly + steps: + - + uses: actions/checkout@v3 + - + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + profile: minimal + default: true + - + uses: Swatinem/rust-cache@v1 + with: + working-directory: rust-workspace + sharedKey: test + key: ${{ github.ref }} + - + name: cargo build + uses: MarcoPolo/cargo@a527bf4d534717ff4424a84446c5d710f8833139 + with: + working-directory: rust-workspace + command: build + args: ${{ matrix.cargo-flags }} --all-targets + - + name: cargo test + uses: MarcoPolo/cargo@a527bf4d534717ff4424a84446c5d710f8833139 + with: + working-directory: rust-workspace + command: test + args: ${{ matrix.cargo-flags }} diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md new file mode 100644 index 0000000..83a2333 --- /dev/null +++ b/ARCHITECTURE.md @@ -0,0 +1,25 @@ +# Nautilus Trusted Compute Architecture + +This document describes the high-level architecture of Nautilus Trusted Compute. + +(Inspired by Aleksey Klado's [ARCHITECTURE.md]) + +[ARCHITECTURE.md]: https://matklad.github.io/2021/02/06/ARCHITECTURE.md.html + +## Cargo workspaces + +The repository is organised into Cargo workspaces, each containing a flat layout of crates under `crates/*`, as described in "[Large Rust Workspaces]". + +[Large Rust Workspaces]: https://matklad.github.io/2021/08/22/large-rust-workspaces.html + +### `rust-workspace/crates/*` + +This workspace contains all crates that compile with the Rust's `stable` toolchain. + +### `rust-sgx-workspace/crates/*` + +This workspace contains all "SGX-flavoured" crates: that is, all crates that depend on [incubator-teaclave-sgx-sdk] and a supported Rust `nightly` toolchain to compile. + +[incubator-teaclave-sgx-sdk]: https://github.com/apache/incubator-teaclave-sgx-sdk + +**Architecture Invariant:** `rust-sgx-workspace` crates may depend on `rust-workspace` crates, but not the other way around. diff --git a/README.md b/README.md index e241cc0..99e9399 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ # Nautilus Trusted Compute + +See [ARCHITECTURE.md](ARCHITECTURE.md) for an overview of the repository layout. diff --git a/rust-workspace/.gitignore b/rust-workspace/.gitignore new file mode 100644 index 0000000..2f7896d --- /dev/null +++ b/rust-workspace/.gitignore @@ -0,0 +1 @@ +target/ diff --git a/rust-workspace/Cargo.lock b/rust-workspace/Cargo.lock new file mode 100644 index 0000000..31bd13e --- /dev/null +++ b/rust-workspace/Cargo.lock @@ -0,0 +1,1184 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom", + "once_cell", + "serde", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +dependencies = [ + "memchr", +] + +[[package]] +name = "anyhow" +version = "1.0.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc" + +[[package]] +name = "assert_cmd" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93ae1ddd39efd67689deb1979d80bad3bf7f2b09c6e6117c8d1f2443b5e2f83e" +dependencies = [ + "bstr", + "doc-comment", + "predicates", + "predicates-core", + "predicates-tree", + "wait-timeout", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base64" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" + +[[package]] +name = "bit-set" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e11e16035ea35e4e5997b393eacbf6f63983188f7a2ad25bfb13465f5ad59de" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bstr" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" +dependencies = [ + "lazy_static", + "memchr", + "regex-automata", +] + +[[package]] +name = "bytecount" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72feb31ffc86498dacdbd0fcebb56138e7177a8cc5cea4516031d15ae85a742e" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clap" +version = "3.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c167e37342afc5f33fd87bbc870cedd020d2a6dffa05d45ccd9241fbdd146db" +dependencies = [ + "atty", + "bitflags", + "clap_derive", + "clap_lex", + "indexmap", + "lazy_static", + "strsim", + "termcolor", + "textwrap", +] + +[[package]] +name = "clap_derive" +version = "3.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3aab4734e083b809aaf5794e14e756d1c798d2c69c7f7de7a09a2f5214993c1" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "189ddd3b5d32a70b35e7686054371742a937b0d99128e76dde6340210e966669" +dependencies = [ + "os_str_bytes", +] + +[[package]] +name = "colored" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4ffc801dacf156c5854b9df4f425a626539c3a6ef7893cc0c5084a23f0b6c59" +dependencies = [ + "atty", + "lazy_static", + "winapi", +] + +[[package]] +name = "confy" +version = "0.4.0" +source = "git+https://github.com/rust-cli/confy?branch=master#642822413139ce38a96b916190e8c7fd5b88e814" +dependencies = [ + "directories-next", + "serde", + "thiserror", + "toml", +] + +[[package]] +name = "darling" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "diff" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499" + +[[package]] +name = "difflib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + +[[package]] +name = "directories-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "339ee130d97a610ea5a5872d2bbb130fdf68884ff09d3028b81bec8a1ac23bbc" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "fancy-regex" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d95b4efe5be9104a4a18a9916e86654319895138be727b229820c39257c30dda" +dependencies = [ + "bit-set", + "regex", +] + +[[package]] +name = "fastrand" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" +dependencies = [ + "instant", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +dependencies = [ + "matches", + "percent-encoding", +] + +[[package]] +name = "fraction" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bb65943183b6b3cbf00f64c181e8178217e30194381b150e4f87ec59864c803" +dependencies = [ + "lazy_static", + "num", +] + +[[package]] +name = "getrandom" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" + +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "index-fixed" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161ceaf2f41b6cd3f6502f5da085d4ad4393a51e0c70ed2fce1d5698d798fae" + +[[package]] +name = "indexmap" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f647032dfaa1f8b6dc29bd3edb7bbef4861b8b8007ebb118d6db284fd59f6ee" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "iso8601" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a59a3f2be6271b2a844cd0dd13bf8ccc88a9540482d872c7ce58ab1c4db9fab" +dependencies = [ + "nom", +] + +[[package]] +name = "itertools" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" + +[[package]] +name = "jsonschema" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebd40599e7f1230ce296f73b88c022b98ed66689f97eaa54bbeadc337a2ffa6" +dependencies = [ + "ahash", + "anyhow", + "base64", + "bytecount", + "fancy-regex", + "fraction", + "iso8601", + "itoa", + "lazy_static", + "memchr", + "num-cmp", + "parking_lot", + "percent-encoding", + "regex", + "serde", + "serde_json", + "time", + "url", + "uuid", +] + +[[package]] +name = "k9" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "611dc69892d72bfa0848a2e6bf55ef2e3fdc7283381c97713a75043326decc5d" +dependencies = [ + "anyhow", + "colored", + "diff", + "lazy_static", + "libc", + "proc-macro2", + "regex", + "syn", + "term_size", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.124" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21a41fed9d98f27ab1c6d161da622a4fa35e8a54a8adc24bbf3ddd0ef70b0e50" + +[[package]] +name = "lock_api" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "matches" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" + +[[package]] +name = "memchr" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "nom" +version = "7.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "ntc-data-packages" +version = "0.1.0" +dependencies = [ + "anyhow", + "jsonschema", + "k9", + "rusty-sodalite", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "ntc-vault-cli" +version = "0.1.0" +dependencies = [ + "anyhow", + "assert_cmd", + "base64", + "clap", + "confy", + "k9", + "ntc-data-packages", + "rand", + "rusty-sodalite", + "serde", + "serde_with", + "tempfile", + "walkdir", +] + +[[package]] +name = "num" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8536030f9fea7127f841b45bb6243b27255787fb4eb83958aa1ef9d2fdc0c36" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + +[[package]] +name = "num-bigint" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-cmp" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63335b2e2c34fae2fb0aa2cecfd9f0832a1e24b3b32ecec612c3426d46dc8aaa" + +[[package]] +name = "num-complex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" +dependencies = [ + "autocfg", + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_threads" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aba1801fb138d8e85e11d0fc70baf4fe1cdfffda7c6cd34a854905df588e5ed0" +dependencies = [ + "libc", +] + +[[package]] +name = "once_cell" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" + +[[package]] +name = "os_str_bytes" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" + +[[package]] +name = "parking_lot" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "995f667a6c822200b0433ac218e05582f0e2efa1b922a3fd2fbaadc5f87bab37" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys", +] + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "ppv-lite86" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" + +[[package]] +name = "predicates" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5aab5be6e4732b473071984b3164dbbfb7a3674d30ea5ff44410b6bcd960c3c" +dependencies = [ + "difflib", + "itertools", + "predicates-core", +] + +[[package]] +name = "predicates-core" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da1c2388b1513e1b605fcec39a95e0a9e8ef088f71443ef37099fa9ae6673fcb" + +[[package]] +name = "predicates-tree" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d86de6de25020a36c6d3643a86d9a6a9f552107c0559c60ea03551b5e16c032" +dependencies = [ + "predicates-core", + "termtree", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom", + "redox_syscall", + "thiserror", +] + +[[package]] +name = "regex" +version = "1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" + +[[package]] +name = "regex-syntax" +version = "0.6.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "rustversion" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" + +[[package]] +name = "rusty-sodalite" +version = "0.1.0" +source = "git+https://github.com/PiDelport/rusty-sodalite?branch=initial-version#42480a9a1698e6e8604075ad7f063117fcc14524" +dependencies = [ + "sodalite", +] + +[[package]] +name = "ryu" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "serde" +version = "1.0.136" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.136" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_with" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b827f2113224f3f19a665136f006709194bdfdcb1fdc1e4b2b5cbac8e0cced54" +dependencies = [ + "base64", + "rustversion", + "serde", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e182d6ec6f05393cc0e5ed1bf81ad6db3a8feedf8ee515ecdd369809bcce8082" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "smallvec" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" + +[[package]] +name = "sodalite" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41784a359d15c58bba298cccb7f30a847a1a42d0620c9bdaa0aa42fdb3c280e0" +dependencies = [ + "index-fixed", +] + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "syn" +version = "1.0.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b683b2b825c8eef438b77c36a06dc262294da3d5a5813fac20da149241dcd44d" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "tempfile" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +dependencies = [ + "cfg-if", + "fastrand", + "libc", + "redox_syscall", + "remove_dir_all", + "winapi", +] + +[[package]] +name = "term_size" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e4129646ca0ed8f45d09b929036bafad5377103edd06e50bf574b353d2b08d9" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "termtree" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "507e9898683b6c43a9aa55b64259b721b52ba226e0f3779137e50ad114a4c90b" + +[[package]] +name = "textwrap" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" + +[[package]] +name = "thiserror" +version = "1.0.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "time" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2702e08a7a860f005826c6815dcac101b19b5eb330c27fe4a5928fec1d20ddd" +dependencies = [ + "libc", + "num_threads", + "time-macros", +] + +[[package]] +name = "time-macros" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792" + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "toml" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +dependencies = [ + "serde", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" + +[[package]] +name = "unicode-normalization" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "url" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" +dependencies = [ + "form_urlencoded", + "idna", + "matches", + "percent-encoding", +] + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wait-timeout" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +dependencies = [ + "libc", +] + +[[package]] +name = "walkdir" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +dependencies = [ + "same-file", + "winapi", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5acdd78cb4ba54c0045ac14f62d8f94a03d10047904ae2a40afa1e99d8f70825" +dependencies = [ + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_msvc" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17cffbe740121affb56fad0fc0e421804adf0ae00891205213b5cecd30db881d" + +[[package]] +name = "windows_i686_gnu" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2564fde759adb79129d9b4f54be42b32c89970c18ebf93124ca8870a498688ed" + +[[package]] +name = "windows_i686_msvc" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cd9d32ba70453522332c14d38814bceeb747d80b3958676007acadd7e166956" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfce6deae227ee8d356d19effc141a509cc503dfd1f850622ec4b0f84428e1f4" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d19538ccc21819d01deaf88d6a17eae6596a12e9aafdbb97916fb49896d89de9" diff --git a/rust-workspace/Cargo.toml b/rust-workspace/Cargo.toml new file mode 100644 index 0000000..4216c62 --- /dev/null +++ b/rust-workspace/Cargo.toml @@ -0,0 +1,2 @@ +[workspace] +members = ['crates/*'] diff --git a/rust-workspace/crates/ntc-data-packages/Cargo.toml b/rust-workspace/crates/ntc-data-packages/Cargo.toml new file mode 100644 index 0000000..219b922 --- /dev/null +++ b/rust-workspace/crates/ntc-data-packages/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "ntc-data-packages" +version = "0.1.0" +edition = "2021" +rust-version = "1.56" +description = "Support for working with Nautilus Trusted Compute data packages" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +jsonschema = { version = "0.16", default-features = false } +serde = "1.0" +serde_json = "1.0" +thiserror = "1.0" + +rusty-sodalite = { git = "https://github.com/PiDelport/rusty-sodalite", branch = "initial-version" } + +[dev-dependencies] +anyhow = "1.0" +k9 = "0.11" diff --git a/rust-workspace/crates/ntc-data-packages/src/data_packages/common.rs b/rust-workspace/crates/ntc-data-packages/src/data_packages/common.rs new file mode 100644 index 0000000..ef39554 --- /dev/null +++ b/rust-workspace/crates/ntc-data-packages/src/data_packages/common.rs @@ -0,0 +1,49 @@ +//! The common, serialised representation of data packages. + +use serde::{Deserialize, Serialize}; + +/// A data package associates a [`Dataset`] with some descriptive [`Metadata`]. +pub struct DataPackage { + pub metadata: Metadata, + pub dataset: Dataset, +} + +/// Metadata that describes some [`Dataset`]. +#[derive(Debug)] // core +#[derive(Serialize, Deserialize)] // serde +pub struct Metadata { + pub name: String, + pub version: String, + pub creator: String, + pub timestamp: String, + pub description: String, + // TODO: Add oracle node URIs and public keys +} + +impl Metadata { + pub fn from_json_bytes(value: &[u8]) -> Result { + serde_json::from_slice(value) + } +} + +/// A serialised dataset contains some serialised data, and some serialised schema describing it. +#[derive(Debug)] +pub struct Dataset { + pub schema_type: SchemaType, + pub schema: Box<[u8]>, + + pub data_type: DataType, + pub data: Box<[u8]>, +} + +#[derive(Copy, Clone, Debug)] +#[non_exhaustive] +pub enum SchemaType { + JsonSchema, +} + +#[derive(Copy, Clone, Debug)] +#[non_exhaustive] +pub enum DataType { + Json, +} diff --git a/rust-workspace/crates/ntc-data-packages/src/data_packages/json_schema.rs b/rust-workspace/crates/ntc-data-packages/src/data_packages/json_schema.rs new file mode 100644 index 0000000..99f852a --- /dev/null +++ b/rust-workspace/crates/ntc-data-packages/src/data_packages/json_schema.rs @@ -0,0 +1,103 @@ +//! Support for JSON + JSON Schema datasets. +//! +//! # Choice of JSON Schema implementation +//! +//! (As of 2022, by Pi Delport) +//! +//! 1. : Well-maintained, fast, comprehensive. +//! 2. : Inactive (~1 year), less comprehensive. +//! 3. : Inactive (~2 years), less comprehensive. + +use jsonschema::JSONSchema; +use thiserror::Error; + +use crate::data_packages::common::{DataType, Dataset, SchemaType}; + +#[derive(Debug)] +pub struct JsonDataset { + pub schema: serde_json::Value, + pub data: serde_json::Value, +} + +impl TryFrom for JsonDataset { + type Error = JsonDatasetParseError; + + fn try_from( + Dataset { + schema_type, + schema, + data_type, + data, + }: Dataset, + ) -> Result { + match (schema_type, data_type) { + (SchemaType::JsonSchema, DataType::Json) => { + let schema = serde_json::from_slice(&schema) + .map_err(JsonDatasetParseError::ParseSchemaFailed)?; + let data = serde_json::from_slice(&data) + .map_err(JsonDatasetParseError::ParseDataFailed)?; + Ok(Self { schema, data }) + } + } + } +} + +impl JsonDataset { + pub fn validate(&self) -> Result<(), JsonDatasetValidationError> { + let compiled = JSONSchema::compile(&self.schema) + .map_err(|err| JsonDatasetValidationError::CompileSchemaFailed(err.into()))?; + compiled + .validate(&self.data) + .map_err(|errs| JsonDatasetValidationError::InvalidData(errs.into())) + } +} + +#[derive(Debug, Error)] +pub enum JsonDatasetParseError { + #[error("failed to parse schema as JSON")] + ParseSchemaFailed(#[source] serde_json::Error), + + #[error("failed to parse data as JSON")] + ParseDataFailed(#[source] serde_json::Error), +} + +#[derive(Debug, Error)] +pub enum JsonDatasetValidationError { + #[error("failed to compile JSON Schema")] + CompileSchemaFailed(#[source] ValidationErrorMessage), + + #[error("data validation failed")] + InvalidData(#[source] ValidationErrorMessages), +} + +/// This contains the message from [`jsonschema::ValidationError`] as a string, +/// to avoid propagating the error's lifetime. +#[derive(Debug, Error)] +#[error("validation error: {0}")] +pub struct ValidationErrorMessage(String); + +impl From> for ValidationErrorMessage { + fn from(err: jsonschema::ValidationError) -> Self { + Self(validation_error_message(err)) + } +} + +/// This contains messages from [`jsonschema::ErrorIterator`] as strings, +/// to avoid propagating the iterator's lifetime. +#[derive(Debug, Error)] +#[error("validation errors: {}", .0.join(", "))] +pub struct ValidationErrorMessages(Box<[String]>); + +impl From> for ValidationErrorMessages { + fn from(errs: jsonschema::ErrorIterator) -> Self { + Self(errs.map(validation_error_message).collect()) + } +} + +/// Internal helper: Format a validation error as a stand-alone error message. +fn validation_error_message(err: jsonschema::ValidationError) -> String { + format!( + "{} (path={} schema={})", + err, err.instance_path, err.schema_path + ) +} diff --git a/rust-workspace/crates/ntc-data-packages/src/data_packages/mod.rs b/rust-workspace/crates/ntc-data-packages/src/data_packages/mod.rs new file mode 100644 index 0000000..4877cf3 --- /dev/null +++ b/rust-workspace/crates/ntc-data-packages/src/data_packages/mod.rs @@ -0,0 +1,5 @@ +//! Data package support. + +pub mod common; +pub mod json_schema; +pub mod sealing; diff --git a/rust-workspace/crates/ntc-data-packages/src/data_packages/sealing.rs b/rust-workspace/crates/ntc-data-packages/src/data_packages/sealing.rs new file mode 100644 index 0000000..81c8c86 --- /dev/null +++ b/rust-workspace/crates/ntc-data-packages/src/data_packages/sealing.rs @@ -0,0 +1,34 @@ +//! Data package sealing. + +use std::fs::Metadata; + +use crate::data_packages::common::{DataType, SchemaType}; + +// TODO(Herman): Update doc or types here to be consistent. +// Data packages is currently assumed to be sealed in the doc. +// TODO: Wrap unsealed representation of datasets with zeroize? + +/// Information about how a data package was sealed. +pub struct Seal { + // TODO +} + +/// A [`DataPackage`] with a sealed dataset. +/// +/// [`DataPackage`]: crate::data_packages::common::DataPackage +pub struct SealedDataPackage { + pub seal: Seal, + pub metadata: Metadata, + pub sealed_dataset: SealedDataset, +} + +/// A [`Dataset`] with sealed data. +/// +/// [`Dataset`]: crate::data_packages::common::Dataset +pub struct SealedDataset { + pub schema_type: SchemaType, + pub schema: Box<[u8]>, + + pub data_type: DataType, + pub sealed_data: Box<[u8]>, +} diff --git a/rust-workspace/crates/ntc-data-packages/src/identity.rs b/rust-workspace/crates/ntc-data-packages/src/identity.rs new file mode 100644 index 0000000..811f060 --- /dev/null +++ b/rust-workspace/crates/ntc-data-packages/src/identity.rs @@ -0,0 +1,17 @@ +//! Identity and key management. + +use rusty_sodalite::safe_sign::{safe_sign_keypair_seed, SafeSignPublicKey}; +use rusty_sodalite::types::SafeSecureSeed; + +pub struct VaultIdentity { + pub name: String, + + pub seed: SafeSecureSeed, +} + +impl VaultIdentity { + pub fn get_sign_public_key(&self) -> SafeSignPublicKey { + let (pk, _sk) = safe_sign_keypair_seed(&self.seed); + pk + } +} diff --git a/rust-workspace/crates/ntc-data-packages/src/lib.rs b/rust-workspace/crates/ntc-data-packages/src/lib.rs new file mode 100644 index 0000000..b94a04c --- /dev/null +++ b/rust-workspace/crates/ntc-data-packages/src/lib.rs @@ -0,0 +1,4 @@ +//! Support for working with Nautilus Trusted Compute data packages. + +pub mod data_packages; +pub mod identity; diff --git a/rust-workspace/crates/ntc-data-packages/tests/data_packages/common.rs b/rust-workspace/crates/ntc-data-packages/tests/data_packages/common.rs new file mode 100644 index 0000000..4b9fe5b --- /dev/null +++ b/rust-workspace/crates/ntc-data-packages/tests/data_packages/common.rs @@ -0,0 +1,47 @@ +//! Tests for [`ntc_data_packages::data_packages::common`]. + +/// Tests for [`Metadata`]. +mod metadata { + use ntc_data_packages::data_packages::common::Metadata; + use serde_json::json; + + #[test] + fn from_json_bytes_empty() { + let err = Metadata::from_json_bytes(b"").unwrap_err(); + k9::snapshot!( + err, + r#"Error("EOF while parsing a value", line: 1, column: 0)"# + ); + } + + #[test] + fn from_json_bytes_invalid() { + let err = Metadata::from_json_bytes(b"{}").unwrap_err(); + k9::snapshot!(err, r#"Error("missing field `name`", line: 1, column: 2)"#); + } + + #[test] + fn from_json_bytes_valid() { + let value = serde_json::to_vec(&json!({ + "name": "Test Data", + "version": "0.1", + "creator": "Test Creator", + "timestamp": "2022-01-01", + "description": "A test data package", + })) + .unwrap(); + let metadata = Metadata::from_json_bytes(&value).unwrap(); + k9::snapshot!( + metadata, + r#" +Metadata { + name: "Test Data", + version: "0.1", + creator: "Test Creator", + timestamp: "2022-01-01", + description: "A test data package", +} +"# + ); + } +} diff --git a/rust-workspace/crates/ntc-data-packages/tests/data_packages/json_schema.rs b/rust-workspace/crates/ntc-data-packages/tests/data_packages/json_schema.rs new file mode 100644 index 0000000..1535525 --- /dev/null +++ b/rust-workspace/crates/ntc-data-packages/tests/data_packages/json_schema.rs @@ -0,0 +1,130 @@ +//! Tests for [`ntc_data_packages::data_packages::json_schema`]. + +use ntc_data_packages::data_packages::common::{DataType, Dataset, SchemaType}; +use ntc_data_packages::data_packages::json_schema::JsonDataset; +use serde_json::{json, Value}; + +#[test] +fn json_try_from_no_data() { + let dataset = Dataset { + schema_type: SchemaType::JsonSchema, + schema: "".as_bytes().into(), + data_type: DataType::Json, + data: "".as_bytes().into(), + }; + let err = JsonDataset::try_from(dataset).unwrap_err(); + k9::snapshot!( + format_err(err), + " +failed to parse schema as JSON + +Caused by: + EOF while parsing a value at line 1 column 0 +" + ); +} + +#[test] +fn json_try_from_empty_object() { + let dataset = Dataset { + schema_type: SchemaType::JsonSchema, + schema: "{}".as_bytes().into(), + data_type: DataType::Json, + data: "{}".as_bytes().into(), + }; + let json_dataset = JsonDataset::try_from(dataset).unwrap(); + assert_eq!(json_dataset.schema, json!({})); + assert_eq!(json_dataset.data, json!({})); +} + +#[test] +fn validate_empty() { + let json_dataset = JsonDataset { + schema: json!({}), + data: json!({}), + }; + json_dataset.validate().unwrap(); +} + +#[test] +fn validate_false_schema() { + let json_dataset = JsonDataset { + schema: json!(false), + data: json!({}), + }; + let err = json_dataset.validate().unwrap_err(); + k9::snapshot!( + format_err(err), + " +data validation failed + +Caused by: + validation errors: False schema does not allow {} (path= schema=) +" + ); +} + +#[test] +fn validate_example_person_schema() { + let json_dataset = JsonDataset { + schema: example_person_schema(), + data: json!({ + "firstName": "John", + "lastName": "Doe", + "age": 21 + }), + }; + json_dataset.validate().expect("validate should succeed"); +} + +#[test] +fn validate_example_person_schema_invalid() { + let json_dataset = JsonDataset { + schema: example_person_schema(), + data: json!({ + "firstName": false, + "lastName": null, + "age": -1, + }), + }; + let err = json_dataset.validate().unwrap_err(); + k9::snapshot!( + format_err(err), + r#" +data validation failed + +Caused by: + validation errors: -1 is less than the minimum of 0 (path=/age schema=/properties/age/minimum), false is not of type "string" (path=/firstName schema=/properties/firstName/type), null is not of type "string" (path=/lastName schema=/properties/lastName/type) +"# + ); +} + +/// The `person.schema.json` example schema from . +fn example_person_schema() -> Value { + json!({ + "$id": "https://example.com/person.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "Person", + "type": "object", + "properties": { + "firstName": { + "type": "string", + "description": "The person's first name." + }, + "lastName": { + "type": "string", + "description": "The person's last name." + }, + "age": { + "description": "Age in years which must be equal to or greater than zero.", + "type": "integer", + "minimum": 0 + } + } + }) +} + +/// Helper: Format an error chain as a readable string. +fn format_err(err: impl Into) -> String { + format!("{:?}", err.into()) +} diff --git a/rust-workspace/crates/ntc-data-packages/tests/data_packages/main.rs b/rust-workspace/crates/ntc-data-packages/tests/data_packages/main.rs new file mode 100644 index 0000000..eca7961 --- /dev/null +++ b/rust-workspace/crates/ntc-data-packages/tests/data_packages/main.rs @@ -0,0 +1,4 @@ +//! Tests for the [`ntc_data_packages::data_packages`] API. + +mod common; +mod json_schema; diff --git a/rust-workspace/crates/ntc-vault-cli/Cargo.toml b/rust-workspace/crates/ntc-vault-cli/Cargo.toml new file mode 100644 index 0000000..a70dce0 --- /dev/null +++ b/rust-workspace/crates/ntc-vault-cli/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "ntc-vault-cli" +version = "0.1.0" +edition = "2021" +rust-version = "1.57" +description = "Nautilus Trusted Compute Vault CLI" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +anyhow = "1.0" +base64 = "0.13" +clap = { version = "3.1", features = ["derive"] } +serde = { version = "1.0", features = ["derive"] } +serde_with = { version = "1.12", features = ["base64"] } + +# XXX: Waiting for release 0.5.0: +# (Please release more often #41) +# (fix: store_path should create missing directories, like load_path #60) +confy = { git = "https://github.com/rust-cli/confy", branch = "master" } + +# Crypto libraries +rand = "0.8" +rusty-sodalite = { git = "https://github.com/PiDelport/rusty-sodalite", branch = "initial-version" } + +# Local libraries +ntc-data-packages = { path = "../ntc-data-packages" } + +[dev-dependencies] +assert_cmd = "2" +k9 = "0.11" +tempfile = "3" +walkdir = "2" diff --git a/rust-workspace/crates/ntc-vault-cli/src/actions.rs b/rust-workspace/crates/ntc-vault-cli/src/actions.rs new file mode 100644 index 0000000..b576d7a --- /dev/null +++ b/rust-workspace/crates/ntc-vault-cli/src/actions.rs @@ -0,0 +1,64 @@ +//! CLI action implementations. +//! +//! These provide the functionality invoked by [`crate::commands`]. + +use std::fs; +use std::path::Path; + +use anyhow::{anyhow, Context}; +use ntc_data_packages::identity::VaultIdentity; + +use crate::crypto::generate_secure_seed; +use crate::identity_files::VaultIdentityConfig; +use crate::{compat, fs_io}; + +pub fn identity_create(name: String) -> anyhow::Result<()> { + let path = &VaultIdentityConfig::get_default_path()?; + if compat::try_exists(path)? { + Err(anyhow!("File exists: {}", path.to_string_lossy()) + .context("Identity already configured")) + } else { + let seed = generate_secure_seed()?; + let config = VaultIdentityConfig { name, seed }; + config.store(path)?; + println!("Identity created at {}", path.to_string_lossy()); + Ok(()) + } +} + +pub fn identity_show() -> anyhow::Result<()> { + let path = &VaultIdentityConfig::get_default_path()?; + if compat::try_exists(path)? { + let config = VaultIdentityConfig::load(path)?; + let identity: VaultIdentity = config.into(); + let pk = identity.get_sign_public_key(); + let pk_base64 = base64::encode(*pk.as_ref()); + println!("Path: {}", path.to_string_lossy()); + println!("Name: {}", identity.name); + println!("Public key: {}", pk_base64); + Ok(()) + } else { + Err(anyhow!("File not found: {}", path.to_string_lossy()) + .context("Identity not configured")) + } +} + +pub(crate) fn data_create( + metadata: &Path, + schema: &Path, + data: &Path, + output: &Path, +) -> anyhow::Result<()> { + fs_io::read_metadata(metadata).context(anyhow!("failed to read metadata from {metadata:?}"))?; + fs::read(schema)?; + fs::read(data)?; + fs::write(output, "")?; + todo!(); + // Ok(()) +} + +pub fn data_inspect(path: &Path) -> anyhow::Result<()> { + fs::read(path) + .with_context(|| format!("failed to inspect file: {}", path.to_string_lossy()))?; + Ok(()) +} diff --git a/rust-workspace/crates/ntc-vault-cli/src/bin/ntc-vault.rs b/rust-workspace/crates/ntc-vault-cli/src/bin/ntc-vault.rs new file mode 100644 index 0000000..ab141ae --- /dev/null +++ b/rust-workspace/crates/ntc-vault-cli/src/bin/ntc-vault.rs @@ -0,0 +1,5 @@ +//! `ntc-vault` binary entrypoint. + +fn main() -> anyhow::Result<()> { + ntc_vault_cli::commands::main() +} diff --git a/rust-workspace/crates/ntc-vault-cli/src/commands.rs b/rust-workspace/crates/ntc-vault-cli/src/commands.rs new file mode 100644 index 0000000..e822146 --- /dev/null +++ b/rust-workspace/crates/ntc-vault-cli/src/commands.rs @@ -0,0 +1,116 @@ +//! [`clap`] command and argument definitions. +//! +//! See [`crate::actions`] for the implementations of these commands. +//! +//! Quick reference: +//! +//! * +//! * + +use std::path::PathBuf; + +use clap::{Parser, Subcommand}; + +use crate::actions; + +/// Top-level entrypoint. +pub fn main() -> anyhow::Result<()> { + VaultInvocation::parse().invoke() +} + +/// Nautilus Trusted Compute Vault +#[derive(Debug, Parser)] +#[clap(version, about)] +#[clap(disable_help_subcommand = true)] +#[clap(infer_subcommands = true)] +struct VaultInvocation { + // TODO: Allow overriding identity file with global arg or env var. + #[clap(subcommand)] + command: VaultCommand, +} + +impl VaultInvocation { + pub fn invoke(self) -> anyhow::Result<()> { + self.command.invoke() + } +} + +#[derive(Debug, Subcommand)] +enum VaultCommand { + #[clap(subcommand)] + Identity(IdentityCommand), + + #[clap(subcommand)] + Data(DataCommand), +} + +impl VaultCommand { + fn invoke(self) -> anyhow::Result<()> { + match self { + VaultCommand::Identity(command) => command.invoke(), + VaultCommand::Data(command) => command.invoke(), + } + } +} + +/// Manage identities +#[derive(Debug, Subcommand)] +enum IdentityCommand { + /// Create a new identity + Create { + /// Public name to attach to this identity. + #[clap(long, short)] + name: String, + }, + + /// Show the current identity + Show, +} + +impl IdentityCommand { + fn invoke(self) -> anyhow::Result<()> { + match self { + IdentityCommand::Create { name } => actions::identity_create(name), + IdentityCommand::Show => actions::identity_show(), + } + } +} + +/// Manage data packages +#[derive(Debug, Subcommand)] +enum DataCommand { + /// Create a new data package + Create { + #[clap(long, short)] + metadata: PathBuf, + + #[clap(long, short)] + schema: PathBuf, + + #[clap(long, short)] + data: PathBuf, + + #[clap(long, short)] + output: PathBuf, + }, + + /// Inspect a data package + Inspect { + #[clap(long, short)] + file: PathBuf, + }, +} + +impl DataCommand { + fn invoke(&self) -> anyhow::Result<()> { + match self { + DataCommand::Create { + metadata, + schema, + data, + output, + } => actions::data_create(metadata, schema, data, output), + DataCommand::Inspect { file } => actions::data_inspect(file), + } + } +} diff --git a/rust-workspace/crates/ntc-vault-cli/src/compat.rs b/rust-workspace/crates/ntc-vault-cli/src/compat.rs new file mode 100644 index 0000000..3b1038a --- /dev/null +++ b/rust-workspace/crates/ntc-vault-cli/src/compat.rs @@ -0,0 +1,17 @@ +//! Compatibility code. + +use std::io; +use std::path::Path; + +/// See: [`Path::try_exists`] +/// +/// TODO: Drop this once `path_try_exists` is stable. +/// +/// Tracking Issue: +pub fn try_exists(path: &Path) -> io::Result { + match path.metadata() { + Ok(_) => Ok(true), + Err(error) if error.kind() == io::ErrorKind::NotFound => Ok(false), + Err(error) => Err(error), + } +} diff --git a/rust-workspace/crates/ntc-vault-cli/src/crypto.rs b/rust-workspace/crates/ntc-vault-cli/src/crypto.rs new file mode 100644 index 0000000..3968365 --- /dev/null +++ b/rust-workspace/crates/ntc-vault-cli/src/crypto.rs @@ -0,0 +1,22 @@ +//! Cryptographic helper code. + +use rand::{thread_rng, RngCore}; +use rusty_sodalite::types::SecureSeed; + +/// Generate a new secure seed using [`thread_rng`]. +pub(crate) fn generate_secure_seed() -> Result { + let mut seed = SecureSeed::default(); + thread_rng().try_fill_bytes(&mut seed)?; + Ok(seed) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn generate_secure_seed_works() { + let seed = generate_secure_seed().unwrap(); + assert_ne!(seed, SecureSeed::default()); + } +} diff --git a/rust-workspace/crates/ntc-vault-cli/src/fs_io.rs b/rust-workspace/crates/ntc-vault-cli/src/fs_io.rs new file mode 100644 index 0000000..b6f80de --- /dev/null +++ b/rust-workspace/crates/ntc-vault-cli/src/fs_io.rs @@ -0,0 +1,37 @@ +//! File I/O support. + +use std::fs; +use std::path::Path; + +use anyhow::anyhow; +use ntc_data_packages::data_packages::common::Metadata; + +enum FileType { + Json, +} + +impl FileType { + fn for_extension(path: &Path) -> anyhow::Result { + let extension = path + .extension() + .ok_or_else(|| anyhow!("file has no extension: {}", path.to_string_lossy()))?; + if extension.eq_ignore_ascii_case("json") { + Ok(Self::Json) + } else { + Err(anyhow!( + "unsupported file extension {extension:?} ({})", + path.to_string_lossy() + )) + } + } +} + +/// Read [`Metadata`] from the given file. +pub fn read_metadata(path: &Path) -> anyhow::Result { + let file_type = FileType::for_extension(path)?; + let bytes = fs::read(path)?; + let metadata = match file_type { + FileType::Json => Metadata::from_json_bytes(&bytes)?, + }; + Ok(metadata) +} diff --git a/rust-workspace/crates/ntc-vault-cli/src/identity_files.rs b/rust-workspace/crates/ntc-vault-cli/src/identity_files.rs new file mode 100644 index 0000000..a1023c4 --- /dev/null +++ b/rust-workspace/crates/ntc-vault-cli/src/identity_files.rs @@ -0,0 +1,45 @@ +//! Support for working with identity files. + +use std::path::{Path, PathBuf}; + +use anyhow::Context; +use confy::ConfyError; +use ntc_data_packages::identity::VaultIdentity; +use rusty_sodalite::types::SecureSeed; +use serde::{Deserialize, Serialize}; +use serde_with::base64::Base64; +use serde_with::serde_as; + +#[derive(Default, Debug)] // core +#[serde_as] +#[derive(Serialize, Deserialize)] // serde +pub struct VaultIdentityConfig { + pub(crate) name: String, + + #[serde_as(as = "Base64")] + pub(crate) seed: SecureSeed, +} + +impl VaultIdentityConfig { + pub fn load(path: impl AsRef) -> anyhow::Result { + let path = path.as_ref(); + confy::load_path(path).with_context(|| format!("Failed to load {}", path.to_string_lossy())) + } + + pub(crate) fn store(&self, path: impl AsRef) -> anyhow::Result<()> { + let path = path.as_ref(); + confy::store_path(path, self) + .with_context(|| format!("Failed to store {}", path.to_string_lossy())) + } + + pub(crate) fn get_default_path() -> Result { + confy::get_configuration_file_path("ntc-vault", "identity") + } +} + +impl From for VaultIdentity { + fn from(VaultIdentityConfig { name, seed }: VaultIdentityConfig) -> Self { + let seed = seed.into(); + VaultIdentity { name, seed } + } +} diff --git a/rust-workspace/crates/ntc-vault-cli/src/lib.rs b/rust-workspace/crates/ntc-vault-cli/src/lib.rs new file mode 100644 index 0000000..78ac370 --- /dev/null +++ b/rust-workspace/crates/ntc-vault-cli/src/lib.rs @@ -0,0 +1,8 @@ +//! Nautilus Trusted Compute Vault CLI. + +pub mod actions; +pub mod commands; +mod compat; +mod crypto; +mod fs_io; +pub mod identity_files; diff --git a/rust-workspace/crates/ntc-vault-cli/tests/subcommands/common/cli_fixture.rs b/rust-workspace/crates/ntc-vault-cli/tests/subcommands/common/cli_fixture.rs new file mode 100644 index 0000000..fa9d3f1 --- /dev/null +++ b/rust-workspace/crates/ntc-vault-cli/tests/subcommands/common/cli_fixture.rs @@ -0,0 +1,207 @@ +//! Fixture-based CLI tests. + +use std::ffi::OsStr; +use std::path::{Path, PathBuf}; +use std::process::Output; +use std::{fs, io}; + +use anyhow::{anyhow, Context}; +use assert_cmd::Command; +use ntc_data_packages::identity::VaultIdentity; +use ntc_vault_cli::identity_files::VaultIdentityConfig; +use tempfile::TempDir; +use walkdir::{DirEntry, WalkDir}; + +/// CLI executable name. +const CLI_NAME: &str = "ntc-vault"; + +/// Config file path, relative to the home directory. +const CONFIG_REL_PATH: &str = ".config/ntc-vault/identity.toml"; + +/// A fixture for invoking CLI commands in. +#[derive(Debug)] +pub struct CliFixture { + base_dir: TempDir, +} + +impl CliFixture { + pub fn with(f: fn(&Self) -> R) -> R { + let fixture = Self::new().unwrap(); + let result = f(&fixture); + fixture.close().unwrap(); + result + } + + pub fn new() -> anyhow::Result { + let base = TempDir::new()?; + let fixture = Self { base_dir: base }; + fs::create_dir(fixture.home_dir())?; + fs::create_dir(fixture.current_dir())?; + Ok(fixture) + } + + fn home_dir(&self) -> PathBuf { + self.base_dir.path().join("home") + } + + fn current_dir(&self) -> PathBuf { + self.base_dir.path().join("cwd") + } + + pub fn command(&self) -> anyhow::Result { + FixtureCommand::new(self) + } + + pub fn invoke_without_args(&self) -> anyhow::Result { + let mut command = self.command()?; + let result: InvocationResult = command.invoke()?; + Ok(result) + } + + pub fn invoke( + &self, + args: impl IntoIterator>, + ) -> anyhow::Result { + self.command()?.args(args).invoke() + } + + pub fn list_files(&self) -> anyhow::Result> { + list_files(self.base_dir.path()) + } + + pub fn close(self) -> io::Result<()> { + self.base_dir.close() + } +} + +fn list_files(base: &Path) -> anyhow::Result> { + WalkDir::new(base) + .sort_by_file_name() + .into_iter() + .filter_map(|entry| match entry { + Ok(entry) if entry.file_type().is_dir() => None, // Skip directories + Ok(entry) => Some(rel_path(base, entry)), // List files + Err(err) => Some(Err(err.into())), // Propagate errors + }) + .collect() +} + +fn rel_path(base: &Path, entry: DirEntry) -> anyhow::Result { + let rel_path = entry.path().strip_prefix(base)?; + Ok(rel_path.to_path_buf()) +} + +/// A [`Command`] in the context of a [`CliFixture`]. +pub struct FixtureCommand<'a> { + fixture: &'a CliFixture, + command: Command, +} + +impl<'a> FixtureCommand<'a> { + fn new(fixture: &'a CliFixture) -> anyhow::Result { + let mut command = Command::cargo_bin(CLI_NAME)?; + command.env_clear(); + command.env("HOME", fixture.home_dir()); + command.current_dir(&fixture.current_dir()); + Ok(Self { fixture, command }) + } + pub fn args(mut self, args: impl IntoIterator>) -> Self { + self.command.args(args); + self + } + + pub fn invoke(&mut self) -> anyhow::Result> { + let output = self.command.output()?; + let mut result = InvocationResult::from_output(self.fixture, output)?; + result.redact_defaults()?; + Ok(result) + } +} + +/// The result of invoking a [`FixtureCommand`]. +#[derive(Debug)] +pub struct InvocationResult<'a> { + fixture: &'a CliFixture, + + /// Like [`Output`], but assume a non-signal exit code. + pub status: i32, + + /// Like [`Output`], but assume a UTF-8 string result. + pub stdout: String, + + /// Like [`Output`], but assume a UTF-8 string result. + pub stderr: String, +} + +impl<'a> InvocationResult<'a> { + /// Convert an [`Output`] to an [`InvocationResult`]. + /// + /// Fail if the CLI binary was terminated by a signal, or if `stdout` and `stderr` are not valid UTF-8. + pub fn from_output(fixture: &'a CliFixture, output: Output) -> anyhow::Result { + Ok(Self { + fixture, + status: output.status.code().ok_or_else(|| { + anyhow!("expected non-signal exit status, got {:?}", output.status) + })?, + stdout: String::from_utf8(output.stdout).context("expected UTF-8 stdout")?, + stderr: String::from_utf8(output.stderr).context("expected UTF-8 stderr")?, + }) + } + + /// Redact a string from `stdout` and `stderr`. + fn redact(&mut self, from: &str, to: &str) { + for s in [&mut self.stdout, &mut self.stderr] { + *s = s.replace(from, to); + } + } + + /// Redact the home directory prefix. + fn redact_home_dir(&mut self, to: &str) { + let home_dir = self.fixture.home_dir(); + let home_dir_str = home_dir.to_str().unwrap(); + self.redact(home_dir_str, to) + } + + /// Redact the configured public key, if any + fn redact_public_key(&mut self, to: &str) -> anyhow::Result<()> { + let config_path = self.fixture.home_dir().join(CONFIG_REL_PATH); + if config_path.exists() { + let config = VaultIdentityConfig::load(&config_path)?; + let identity: VaultIdentity = config.into(); + let pk = identity.get_sign_public_key(); + let pk_base64 = base64::encode(pk.as_ref()); + self.redact(&pk_base64, to); + } + Ok(()) + } + + /// Redact a default set of values. + fn redact_defaults(&mut self) -> anyhow::Result<()> { + self.redact_home_dir("${HOME}"); + self.redact_public_key("<>")?; + Ok(()) + } + + pub fn expect_success(&self) -> anyhow::Result<&str> { + if self.status == 0 && self.stderr.is_empty() { + Ok(&self.stdout) + } else { + Err(anyhow!("{self:?}")) + } + } + + pub fn expect_error_code(&self, code: i32) -> anyhow::Result<&str> { + if self.status == code && self.stdout.is_empty() { + Ok(&self.stderr) + } else { + Err(anyhow!("{self:?}")) + } + } + + pub fn expect_app_error(&self) -> anyhow::Result<&str> { + self.expect_error_code(1) + } + pub fn expect_usage_error(&self) -> anyhow::Result<&str> { + self.expect_error_code(2) + } +} diff --git a/rust-workspace/crates/ntc-vault-cli/tests/subcommands/common/mod.rs b/rust-workspace/crates/ntc-vault-cli/tests/subcommands/common/mod.rs new file mode 100644 index 0000000..d67dd08 --- /dev/null +++ b/rust-workspace/crates/ntc-vault-cli/tests/subcommands/common/mod.rs @@ -0,0 +1,3 @@ +//! Common test helpers. + +pub mod cli_fixture; diff --git a/rust-workspace/crates/ntc-vault-cli/tests/subcommands/data.rs b/rust-workspace/crates/ntc-vault-cli/tests/subcommands/data.rs new file mode 100644 index 0000000..bf3e37c --- /dev/null +++ b/rust-workspace/crates/ntc-vault-cli/tests/subcommands/data.rs @@ -0,0 +1,161 @@ +//! Test the `data` subcommand + +use crate::common::cli_fixture::CliFixture; + +#[test] +fn usage() { + CliFixture::with(|fixture| { + let result = fixture.invoke(["data"]).unwrap(); + let stderr = result.expect_usage_error().unwrap(); + k9::snapshot!( + stderr, + " +ntc-vault-data +Manage data packages + +USAGE: + ntc-vault data + +OPTIONS: + -h, --help Print help information + +SUBCOMMANDS: + create Create a new data package + inspect Inspect a data package + +" + ); + }); +} + +#[test] +fn create_usage() { + CliFixture::with(|fixture| { + let result = fixture.invoke(["data", "create"]).unwrap(); + let stderr = result.expect_usage_error().unwrap(); + k9::snapshot!( + stderr, + " +error: The following required arguments were not provided: + --metadata + --schema + --data + --output + +USAGE: + ntc-vault data create --metadata --schema --data --output + +For more information try --help + +" + ); + }); +} + +#[test] +fn create_no_extension() { + CliFixture::with(|fixture| { + let result = fixture + .invoke([ + "data", "create", "-m", "spam", "-s", "spam", "-d", "spam", "-o", "out", + ]) + .unwrap(); + let stderr = result.expect_app_error().unwrap(); + k9::snapshot!( + stderr, + r#" +Error: failed to read metadata from "spam" + +Caused by: + file has no extension: spam + +"# + ); + }); +} + +#[test] +fn create_bad_extension() { + CliFixture::with(|fixture| { + let result = fixture + .invoke([ + "data", "create", "-m", "ham.spam", "-s", "ham.spam", "-d", "ham.spam", "-o", "out", + ]) + .unwrap(); + let stderr = result.expect_app_error().unwrap(); + k9::snapshot!( + stderr, + r#" +Error: failed to read metadata from "ham.spam" + +Caused by: + unsupported file extension "spam" (ham.spam) + +"# + ); + }); +} + +#[test] +fn inspect_usage() { + CliFixture::with(|fixture| { + let result = fixture.invoke(["data", "inspect"]).unwrap(); + let stderr = result.expect_usage_error().unwrap(); + k9::snapshot!( + stderr, + " +error: The following required arguments were not provided: + --file + +USAGE: + ntc-vault data inspect --file + +For more information try --help + +" + ); + }); +} + +#[test] +fn inspect_help() { + CliFixture::with(|fixture| { + let result = fixture.invoke(["data", "inspect", "-h"]).unwrap(); + let stderr = result.expect_success().unwrap(); + k9::snapshot!( + stderr, + " +ntc-vault-data-inspect +Inspect a data package + +USAGE: + ntc-vault data inspect --file + +OPTIONS: + -f, --file + -h, --help Print help information + +" + ); + }); +} + +#[test] +fn inspect_nonexistent() { + CliFixture::with(|fixture| { + let result = fixture + .invoke(["data", "inspect", "-f", "nonexistent"]) + .unwrap(); + let stderr = result.expect_app_error().unwrap(); + k9::snapshot!( + stderr, + " +Error: failed to inspect file: nonexistent + +Caused by: + No such file or directory (os error 2) + +" + ); + }); +} diff --git a/rust-workspace/crates/ntc-vault-cli/tests/subcommands/identity.rs b/rust-workspace/crates/ntc-vault-cli/tests/subcommands/identity.rs new file mode 100644 index 0000000..ce1ea30 --- /dev/null +++ b/rust-workspace/crates/ntc-vault-cli/tests/subcommands/identity.rs @@ -0,0 +1,115 @@ +//! Test the `identity` subcommand. + +use crate::common::cli_fixture::CliFixture; + +#[test] +fn usage() { + CliFixture::with(|fixture| { + let result = fixture.invoke(["identity"]).unwrap(); + let stderr = result.expect_usage_error().unwrap(); + k9::snapshot!( + stderr, + " +ntc-vault-identity +Manage identities + +USAGE: + ntc-vault identity + +OPTIONS: + -h, --help Print help information + +SUBCOMMANDS: + create Create a new identity + show Show the current identity + +" + ); + }); +} + +#[test] +fn create_no_args() { + CliFixture::with(|fixture| { + let result = fixture.invoke(["identity", "create"]).unwrap(); + let stderr = result.expect_usage_error().unwrap(); + k9::snapshot!( + stderr, + " +error: The following required arguments were not provided: + --name + +USAGE: + ntc-vault identity create --name + +For more information try --help + +" + ); + }); +} + +#[test] +fn create_with_name() { + CliFixture::with(|fixture| { + let result = fixture + .invoke(["identity", "create", "--name", "Test User"]) + .unwrap(); + let stdout = result.expect_success().unwrap(); + + k9::snapshot!( + stdout, + " +Identity created at ${HOME}/.config/ntc-vault/identity.toml + +" + ); + let files = fixture.list_files().unwrap(); + k9::snapshot!( + files, + r#" +[ + "home/.config/ntc-vault/identity.toml", +] +"# + ); + }); +} + +#[test] +fn show_not_configured() { + CliFixture::with(|fixture| { + let result = fixture.invoke(["identity", "show"]).unwrap(); + let stderr = result.expect_app_error().unwrap(); + k9::snapshot!( + stderr, + " +Error: Identity not configured + +Caused by: + File not found: ${HOME}/.config/ntc-vault/identity.toml + +" + ); + }); +} + +#[test] +fn create_show() { + CliFixture::with(|fixture| { + fixture + .invoke(["identity", "create", "--name", "Test User"]) + .unwrap(); + let result = fixture.invoke(["identity", "show"]).unwrap(); + let stdout = result.expect_success().unwrap(); + k9::snapshot!( + stdout, + " +Path: ${HOME}/.config/ntc-vault/identity.toml +Name: Test User +Public key: <> + +" + ); + }); +} diff --git a/rust-workspace/crates/ntc-vault-cli/tests/subcommands/main.rs b/rust-workspace/crates/ntc-vault-cli/tests/subcommands/main.rs new file mode 100644 index 0000000..9c8fa32 --- /dev/null +++ b/rust-workspace/crates/ntc-vault-cli/tests/subcommands/main.rs @@ -0,0 +1,6 @@ +//! Tests for the CLI subcommands. + +mod common; +mod data; +mod identity; +mod usage; diff --git a/rust-workspace/crates/ntc-vault-cli/tests/subcommands/usage.rs b/rust-workspace/crates/ntc-vault-cli/tests/subcommands/usage.rs new file mode 100644 index 0000000..41ba32b --- /dev/null +++ b/rust-workspace/crates/ntc-vault-cli/tests/subcommands/usage.rs @@ -0,0 +1,57 @@ +//! Test the top-level CLI usage. + +use crate::common::cli_fixture::CliFixture; + +#[test] +fn usage_no_args() { + CliFixture::with(|fixture| { + let result = fixture.invoke_without_args().unwrap(); + let stderr = result.expect_usage_error().unwrap(); + k9::snapshot!( + stderr, + " +ntc-vault-cli 0.1.0 +Nautilus Trusted Compute Vault CLI + +USAGE: + ntc-vault + +OPTIONS: + -h, --help Print help information + -V, --version Print version information + +SUBCOMMANDS: + data Manage data packages + identity Manage identities + +" + ); + }); +} + +#[test] +fn help() { + CliFixture::with(|fixture| { + let result = fixture.invoke(["-h"]).unwrap(); + let stderr = result.expect_success().unwrap(); + k9::snapshot!( + stderr, + " +ntc-vault-cli 0.1.0 +Nautilus Trusted Compute Vault CLI + +USAGE: + ntc-vault + +OPTIONS: + -h, --help Print help information + -V, --version Print version information + +SUBCOMMANDS: + data Manage data packages + identity Manage identities + +" + ); + }); +} diff --git a/rust-workspace/rust-toolchain.toml b/rust-workspace/rust-toolchain.toml new file mode 100644 index 0000000..d39cd72 --- /dev/null +++ b/rust-workspace/rust-toolchain.toml @@ -0,0 +1,4 @@ +# Docs: https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file +[toolchain] +# This workspace should work with the latest stable Rust. +channel = "stable" diff --git a/rust-workspace/rustfmt.toml b/rust-workspace/rustfmt.toml new file mode 100644 index 0000000..437afce --- /dev/null +++ b/rust-workspace/rustfmt.toml @@ -0,0 +1,6 @@ +# https://rust-lang.github.io/rustfmt/ +# Use "cargo +nightly fmt" to take advantage of the group_imports feature. + +imports_layout = "HorizontalVertical" +imports_granularity = "Module" +group_imports = "StdExternalCrate" From a1a57f01599ac42130db0858a3cf66165cc1e3cd Mon Sep 17 00:00:00 2001 From: Pi Delport Date: Thu, 28 Apr 2022 13:13:29 +0200 Subject: [PATCH 02/22] feat: add initial TEE server (#3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * build(rust-sgx-workspace): add workspace for SGX code * build(ntc-tee-server): add SGX project for the TEE server * build(ntc-tee-server): bump Rust edition: "2018" → "2021" * build(ntc-tee-server): better error message for missing Enclave_u library * ci(rust-sgx-workspace): add check and test workflows for GitHub Actions * ci: use nested checkout for the multiple repositories to prevent _temp being deleted * style: fix clippy warnings * ci: remove --all-targets build arg to fix enclave builds and checks Co-authored-by: Herman --- .../workflows/rust-sgx-workspace-check.yaml | 162 + .../workflows/rust-sgx-workspace-test.yaml | 81 + rust-sgx-workspace/.gitignore | 1 + rust-sgx-workspace/Cargo.lock | 125 + rust-sgx-workspace/Cargo.toml | 8 + rust-sgx-workspace/README-SGX.md | 22 + .../projects/ntc-tee-server/.gitignore | 2 + .../projects/ntc-tee-server/Makefile | 46 + .../projects/ntc-tee-server/app/.gitignore | 1 + .../projects/ntc-tee-server/app/Cargo.toml | 10 + .../projects/ntc-tee-server/app/Makefile | 99 + .../projects/ntc-tee-server/app/build.rs | 47 + .../ntc-tee-server/app/codegen/Enclave_u.c | 964 ++++ .../ntc-tee-server/app/codegen/Enclave_u.h | 257 + .../ntc-tee-server/app/codegen/Enclave_u.rs | 12 + .../projects/ntc-tee-server/app/src/main.rs | 74 + .../projects/ntc-tee-server/buildenv.mk | 167 + .../projects/ntc-tee-server/buildenv_sgx.mk | 49 + .../ntc-tee-server/enclave/.gitignore | 1 + .../ntc-tee-server/enclave/Cargo.toml | 16 + .../ntc-tee-server/enclave/Enclave.config.xml | 12 + .../ntc-tee-server/enclave/Enclave.edl | 11 + .../ntc-tee-server/enclave/Enclave.lds | 9 + .../projects/ntc-tee-server/enclave/Makefile | 118 + .../enclave/codegen/Enclave_t.c | 4554 +++++++++++++++++ .../enclave/codegen/Enclave_t.h | 88 + .../ntc-tee-server/enclave/src/lib.rs | 25 + rust-sgx-workspace/rust-toolchain.toml | 4 + rust-sgx-workspace/rustfmt.toml | 6 + 29 files changed, 6971 insertions(+) create mode 100644 .github/workflows/rust-sgx-workspace-check.yaml create mode 100644 .github/workflows/rust-sgx-workspace-test.yaml create mode 100644 rust-sgx-workspace/.gitignore create mode 100644 rust-sgx-workspace/Cargo.lock create mode 100644 rust-sgx-workspace/Cargo.toml create mode 100644 rust-sgx-workspace/README-SGX.md create mode 100644 rust-sgx-workspace/projects/ntc-tee-server/.gitignore create mode 100644 rust-sgx-workspace/projects/ntc-tee-server/Makefile create mode 100644 rust-sgx-workspace/projects/ntc-tee-server/app/.gitignore create mode 100644 rust-sgx-workspace/projects/ntc-tee-server/app/Cargo.toml create mode 100644 rust-sgx-workspace/projects/ntc-tee-server/app/Makefile create mode 100644 rust-sgx-workspace/projects/ntc-tee-server/app/build.rs create mode 100644 rust-sgx-workspace/projects/ntc-tee-server/app/codegen/Enclave_u.c create mode 100644 rust-sgx-workspace/projects/ntc-tee-server/app/codegen/Enclave_u.h create mode 100644 rust-sgx-workspace/projects/ntc-tee-server/app/codegen/Enclave_u.rs create mode 100644 rust-sgx-workspace/projects/ntc-tee-server/app/src/main.rs create mode 100644 rust-sgx-workspace/projects/ntc-tee-server/buildenv.mk create mode 100644 rust-sgx-workspace/projects/ntc-tee-server/buildenv_sgx.mk create mode 100644 rust-sgx-workspace/projects/ntc-tee-server/enclave/.gitignore create mode 100644 rust-sgx-workspace/projects/ntc-tee-server/enclave/Cargo.toml create mode 100644 rust-sgx-workspace/projects/ntc-tee-server/enclave/Enclave.config.xml create mode 100644 rust-sgx-workspace/projects/ntc-tee-server/enclave/Enclave.edl create mode 100644 rust-sgx-workspace/projects/ntc-tee-server/enclave/Enclave.lds create mode 100644 rust-sgx-workspace/projects/ntc-tee-server/enclave/Makefile create mode 100644 rust-sgx-workspace/projects/ntc-tee-server/enclave/codegen/Enclave_t.c create mode 100644 rust-sgx-workspace/projects/ntc-tee-server/enclave/codegen/Enclave_t.h create mode 100644 rust-sgx-workspace/projects/ntc-tee-server/enclave/src/lib.rs create mode 100644 rust-sgx-workspace/rust-toolchain.toml create mode 100644 rust-sgx-workspace/rustfmt.toml diff --git a/.github/workflows/rust-sgx-workspace-check.yaml b/.github/workflows/rust-sgx-workspace-check.yaml new file mode 100644 index 0000000..4f9bcff --- /dev/null +++ b/.github/workflows/rust-sgx-workspace-check.yaml @@ -0,0 +1,162 @@ +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions + +name: rust-sgx-workspace (check) + +on: push + +# Action docs: +# https://github.com/actions/checkout#readme +# https://github.com/actions-rs/toolchain#readme +# https://github.com/Swatinem/rust-cache#readme +# https://github.com/actions-rs/cargo#readme + +# NOTE: This uses the fork to work around + +jobs: + + # "cargo fmt" produces no changes + rustfmt-check: + runs-on: ubuntu-latest + steps: + # Checkout the workspace first to prevent temp files from being deleted. + # See: https://github.com/actions/checkout#checkout-multiple-repos-nested + - + uses: actions/checkout@v3 + - + name: Checkout rust-sgx-sdk-dev-env + uses: actions/checkout@v3 + with: + repository: PiDelport/rust-sgx-sdk-dev-env + path: _temp/rust-sgx-sdk-dev-env + - + name: Prepare SGX environment + working-directory: _temp/rust-sgx-sdk-dev-env + run: | + ./prepare-1.1.4-intel-2.15.1.sh + . environment + # Persist environment to following steps. + echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >>$GITHUB_ENV + echo "SGX_SDK=$SGX_SDK" >>$GITHUB_ENV + echo "SGX_MODE=$SGX_MODE" >>$GITHUB_ENV + echo "CUSTOM_COMMON_PATH=$CUSTOM_COMMON_PATH" >>$GITHUB_ENV + echo "CUSTOM_EDL_PATH=$CUSTOM_EDL_PATH" >>$GITHUB_ENV + - + uses: actions-rs/toolchain@v1 + with: + # Use same toolchain as rust-sgx-workspace/rust-toolchain.toml + toolchain: nightly-2021-11-01 + profile: minimal + components: rustfmt + default: true + - + name: cargo fmt + uses: MarcoPolo/cargo@a527bf4d534717ff4424a84446c5d710f8833139 + with: + working-directory: rust-sgx-workspace + command: fmt + args: -- --check + + # "cargo clippy" produces no errors or warnings + clippy: + runs-on: ubuntu-latest + steps: + - + uses: actions/checkout@v3 + - + name: Checkout rust-sgx-sdk-dev-env + uses: actions/checkout@v3 + with: + repository: PiDelport/rust-sgx-sdk-dev-env + path: _temp/rust-sgx-sdk-dev-env + - + name: Prepare SGX environment + working-directory: _temp/rust-sgx-sdk-dev-env + run: | + ./prepare-1.1.4-intel-2.15.1.sh + . environment + # Persist environment to following steps. + echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >>$GITHUB_ENV + echo "SGX_SDK=$SGX_SDK" >>$GITHUB_ENV + echo "SGX_MODE=$SGX_MODE" >>$GITHUB_ENV + echo "CUSTOM_COMMON_PATH=$CUSTOM_COMMON_PATH" >>$GITHUB_ENV + echo "CUSTOM_EDL_PATH=$CUSTOM_EDL_PATH" >>$GITHUB_ENV + - + uses: actions-rs/toolchain@v1 + with: + # Use same toolchain as rust-sgx-workspace/rust-toolchain.toml + toolchain: nightly-2021-11-01 + profile: minimal + components: clippy + default: true + - + uses: Swatinem/rust-cache@v1 + with: + working-directory: rust-sgx-workspace + sharedKey: clippy + key: ${{ github.ref }} + - + name: Generate untrusted C EDL static library + working-directory: rust-sgx-workspace/projects/ntc-tee-server/app + run: | + make ../build/lib/libEnclave_u.a + - + name: cargo clippy + uses: MarcoPolo/cargo@a527bf4d534717ff4424a84446c5d710f8833139 + with: + working-directory: rust-sgx-workspace + command: clippy + # Do not use --all-targets to prevent enclave builds from failing + args: -- --deny warnings + + # "cargo doc" builds cleanly (including private items) + doc-check: + runs-on: ubuntu-latest + steps: + - + uses: actions/checkout@v3 + - + name: Checkout rust-sgx-sdk-dev-env + uses: actions/checkout@v3 + with: + repository: PiDelport/rust-sgx-sdk-dev-env + path: _temp/rust-sgx-sdk-dev-env + - + name: Prepare SGX environment + working-directory: _temp/rust-sgx-sdk-dev-env + run: | + ./prepare-1.1.4-intel-2.15.1.sh + . environment + # Persist environment to following steps. + echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >>$GITHUB_ENV + echo "SGX_SDK=$SGX_SDK" >>$GITHUB_ENV + echo "SGX_MODE=$SGX_MODE" >>$GITHUB_ENV + echo "CUSTOM_COMMON_PATH=$CUSTOM_COMMON_PATH" >>$GITHUB_ENV + echo "CUSTOM_EDL_PATH=$CUSTOM_EDL_PATH" >>$GITHUB_ENV + - + uses: actions-rs/toolchain@v1 + with: + # Use same toolchain as rust-sgx-workspace/rust-toolchain.toml + toolchain: nightly-2021-11-01 + profile: minimal + components: rust-docs + default: true + - + uses: Swatinem/rust-cache@v1 + with: + working-directory: rust-sgx-workspace + sharedKey: doc-check + key: ${{ github.ref }} + - + name: Generate untrusted C EDL static library + working-directory: rust-sgx-workspace/projects/ntc-tee-server/app + run: | + make ../build/lib/libEnclave_u.a + - + name: cargo doc + uses: MarcoPolo/cargo@a527bf4d534717ff4424a84446c5d710f8833139 + with: + working-directory: rust-sgx-workspace + command: doc + args: --no-deps --document-private-items + env: + RUSTDOCFLAGS: --deny warnings diff --git a/.github/workflows/rust-sgx-workspace-test.yaml b/.github/workflows/rust-sgx-workspace-test.yaml new file mode 100644 index 0000000..376811a --- /dev/null +++ b/.github/workflows/rust-sgx-workspace-test.yaml @@ -0,0 +1,81 @@ +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions + +name: rust-sgx-workspace (test) + +on: push + +# Action docs: +# https://github.com/actions/checkout#readme +# https://github.com/actions-rs/toolchain#readme +# https://github.com/Swatinem/rust-cache#readme +# https://github.com/actions-rs/cargo#readme + +# NOTE: This uses the fork to work around + +jobs: + + # "cargo build" and "cargo test" pass on all supported Rust toolchain channels. + test: + runs-on: ubuntu-latest + strategy: + # No fail-fast: We want to see test results for all toolchain channels, even if one fails. + fail-fast: false + matrix: + rust: + # Use same toolchain as rust-sgx-workspace/rust-toolchain.toml + - nightly-2021-11-01 + steps: + # Checkout the workspace first to prevent temp files from being deleted. + # See: https://github.com/actions/checkout#checkout-multiple-repos-nested + - + uses: actions/checkout@v3 + - + name: Checkout rust-sgx-sdk-dev-env + uses: actions/checkout@v3 + with: + repository: PiDelport/rust-sgx-sdk-dev-env + path: _temp/rust-sgx-sdk-dev-env + - + name: Prepare SGX environment + working-directory: _temp/rust-sgx-sdk-dev-env + run: | + ./prepare-1.1.4-intel-2.15.1.sh + . environment + # Persist environment to following steps. + echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >>$GITHUB_ENV + echo "SGX_SDK=$SGX_SDK" >>$GITHUB_ENV + echo "SGX_MODE=$SGX_MODE" >>$GITHUB_ENV + echo "CUSTOM_COMMON_PATH=$CUSTOM_COMMON_PATH" >>$GITHUB_ENV + echo "CUSTOM_EDL_PATH=$CUSTOM_EDL_PATH" >>$GITHUB_ENV + - + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + profile: minimal + default: true + - + uses: Swatinem/rust-cache@v1 + with: + working-directory: rust-sgx-workspace + sharedKey: test + key: ${{ github.ref }} + - + name: Generate untrusted C EDL static library + working-directory: rust-sgx-workspace/projects/ntc-tee-server/app + run: | + make ../build/lib/libEnclave_u.a + - + name: cargo build + uses: MarcoPolo/cargo@a527bf4d534717ff4424a84446c5d710f8833139 + with: + working-directory: rust-sgx-workspace + command: build + # Do not use --all-targets to prevent enclave builds from failing + args: ${{ matrix.cargo-flags }} + - + name: cargo test + uses: MarcoPolo/cargo@a527bf4d534717ff4424a84446c5d710f8833139 + with: + working-directory: rust-sgx-workspace + command: test + args: ${{ matrix.cargo-flags }} diff --git a/rust-sgx-workspace/.gitignore b/rust-sgx-workspace/.gitignore new file mode 100644 index 0000000..2f7896d --- /dev/null +++ b/rust-sgx-workspace/.gitignore @@ -0,0 +1 @@ +target/ diff --git a/rust-sgx-workspace/Cargo.lock b/rust-sgx-workspace/Cargo.lock new file mode 100644 index 0000000..e607395 --- /dev/null +++ b/rust-sgx-workspace/Cargo.lock @@ -0,0 +1,125 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" + +[[package]] +name = "hashbrown_tstd" +version = "0.11.2" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk#e8a9fc22939befa27ff67f5509b2c2dfe8499945" + +[[package]] +name = "libc" +version = "0.2.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4" + +[[package]] +name = "ntc-tee-server-app" +version = "0.1.0" +dependencies = [ + "sgx_types", + "sgx_urts", +] + +[[package]] +name = "ntc-tee-server-enclave" +version = "0.1.0" +dependencies = [ + "sgx_tstd", + "sgx_types", +] + +[[package]] +name = "sgx_alloc" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk#e8a9fc22939befa27ff67f5509b2c2dfe8499945" + +[[package]] +name = "sgx_backtrace_sys" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "cc", + "sgx_build_helper", + "sgx_libc", +] + +[[package]] +name = "sgx_build_helper" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk#e8a9fc22939befa27ff67f5509b2c2dfe8499945" + +[[package]] +name = "sgx_demangle" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk#e8a9fc22939befa27ff67f5509b2c2dfe8499945" + +[[package]] +name = "sgx_libc" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "sgx_types", +] + +[[package]] +name = "sgx_tprotected_fs" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "sgx_trts", + "sgx_types", +] + +[[package]] +name = "sgx_trts" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "sgx_libc", + "sgx_types", +] + +[[package]] +name = "sgx_tstd" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "hashbrown_tstd", + "sgx_alloc", + "sgx_backtrace_sys", + "sgx_demangle", + "sgx_libc", + "sgx_tprotected_fs", + "sgx_trts", + "sgx_types", + "sgx_unwind", +] + +[[package]] +name = "sgx_types" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk#e8a9fc22939befa27ff67f5509b2c2dfe8499945" + +[[package]] +name = "sgx_unwind" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "sgx_build_helper", +] + +[[package]] +name = "sgx_urts" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "libc", + "sgx_types", +] diff --git a/rust-sgx-workspace/Cargo.toml b/rust-sgx-workspace/Cargo.toml new file mode 100644 index 0000000..c55b651 --- /dev/null +++ b/rust-sgx-workspace/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = [ +# 'crates/*', + 'projects/*/app', + 'projects/*/enclave', +] + +[patch.'https://github.com/apache/teaclave-sgx-sdk.git'] diff --git a/rust-sgx-workspace/README-SGX.md b/rust-sgx-workspace/README-SGX.md new file mode 100644 index 0000000..282269f --- /dev/null +++ b/rust-sgx-workspace/README-SGX.md @@ -0,0 +1,22 @@ +# Rust SGX workspace + +This workspace requires mutually-compatible versions of the following tools, +listed here with their current versions: + +1. **Rust SGX SDK:** 1.1.4 + updates (revision [e8a9fc22939befa27ff67f5509b2c2dfe8499945]) +2. **Rust toolchain:** `nightly-2021-11-01` +3. **Intel SGX SDK:** [2.15.1] + +[e8a9fc22939befa27ff67f5509b2c2dfe8499945]: https://github.com/apache/incubator-teaclave-sgx-sdk/commit/e8a9fc22939befa27ff67f5509b2c2dfe8499945 + +[2.15.1]: https://01.org/intel-softwareguard-extensions/downloads/intel-sgx-linux-2.15.1-release + +To install and switch between versions of the SDK packages, you can use the [rust-sgx-sdk-dev-env] helper scripts. + +[rust-sgx-sdk-dev-env]: https://github.com/PiDelport/rust-sgx-sdk-dev-env + +## Notes + +* The Rust SGX SDK Git revision should be pinned and patched for all crates and all SGX dependencies in this project, to avoid Cargo dependency resolution and compilation issues. + +* When adding or upgrading SGX dependencies, monitor `Cargo.lock` to check that the change does not introduce multiple revisions of the same underlying SGX SDK crates: these should be patched to refer to the pinned revision above. diff --git a/rust-sgx-workspace/projects/ntc-tee-server/.gitignore b/rust-sgx-workspace/projects/ntc-tee-server/.gitignore new file mode 100644 index 0000000..438fbf5 --- /dev/null +++ b/rust-sgx-workspace/projects/ntc-tee-server/.gitignore @@ -0,0 +1,2 @@ +/build +/keys diff --git a/rust-sgx-workspace/projects/ntc-tee-server/Makefile b/rust-sgx-workspace/projects/ntc-tee-server/Makefile new file mode 100644 index 0000000..1955bdd --- /dev/null +++ b/rust-sgx-workspace/projects/ntc-tee-server/Makefile @@ -0,0 +1,46 @@ +# Dummy makefile, will call the host and enclave makefile when requested. + +SRC_U = app/ +SRC_T = enclave/ + +# Compilation process, will call the appropriate makefiles. + +all: host enclave + +host: + @echo "\033[32mRequest to compile the host part...\033[0m" + @make -C $(SRC_U) + +enclave: + @echo "\033[32mRequest to compile the enclave part...\033[0m" + @make -C $(SRC_T) + +clean: + @make -C $(SRC_U) clean + @make -C $(SRC_T) clean + +fclean: + @make -C $(SRC_U) fclean + @make -C $(SRC_T) fclean + +clean_host: + @make -C $(SRC_U) clean + +clean_enclave: + @make -C $(SRC_T) clean + +fclean_host: + @make -C $(SRC_U) fclean + +fclean_enclave: + @make -C $(SRC_T) fclean + +re_host: fclean_host host + +re_enclave: fclean_enclave enclave + +re: fclean all + +# Dummy rules to let make know that those rules are not files. + +.PHONY: host enclave clean clean_host clean_enclave fclean_host fclean_enclave fclean re re_host re_enclave \ No newline at end of file diff --git a/rust-sgx-workspace/projects/ntc-tee-server/app/.gitignore b/rust-sgx-workspace/projects/ntc-tee-server/app/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/rust-sgx-workspace/projects/ntc-tee-server/app/.gitignore @@ -0,0 +1 @@ +/target diff --git a/rust-sgx-workspace/projects/ntc-tee-server/app/Cargo.toml b/rust-sgx-workspace/projects/ntc-tee-server/app/Cargo.toml new file mode 100644 index 0000000..7dfbe89 --- /dev/null +++ b/rust-sgx-workspace/projects/ntc-tee-server/app/Cargo.toml @@ -0,0 +1,10 @@ +[package] +# name matches APP_U in Makefile +name = "ntc-tee-server-app" +version = "0.1.0" +edition = "2021" +build = "build.rs" + +[dependencies] +sgx_types = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk" } +sgx_urts = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk" } diff --git a/rust-sgx-workspace/projects/ntc-tee-server/app/Makefile b/rust-sgx-workspace/projects/ntc-tee-server/app/Makefile new file mode 100644 index 0000000..39763ec --- /dev/null +++ b/rust-sgx-workspace/projects/ntc-tee-server/app/Makefile @@ -0,0 +1,99 @@ +# Makefile settings - Host part + +LIB = ../build/lib/ +BIN = ../build/bin/ +# APP_U matches name in Cargo.toml +APP_U = ntc-tee-server-app +APP_T = enclave.so +NAME_U = libEnclave_u.a +SRC_U = ./ +CODEGEN_U = $(SRC_U)/codegen/ +SRC_T = ../enclave/ +OBJ_U = ../build/obj/ +FLAGS = -Wall -Wextra +GCC_STEP1_U = -I $(CODEGEN_U) -I./include -I$(SGX_SDK)/include -I$(CUSTOM_EDL_PATH) -fPIC -Wno-attributes $(SGX_COMMON_CFLAGS) +FILES_U = Enclave_u.c +FILES_U_H = Enclave_u.h +SGX_ARCH = x64 +TRTS_LIB = sgx_trts +SERVICE_LIB = sgx_tservice +# Addprefix dependant variables, no need to change those +OUTPUT_U = $(FILES_U:.c=.o) +BIN_U = $(addprefix $(BIN), $(APP_U)) +NAME_U_D = $(addprefix $(LIB), $(NAME_U)) +FILES_U_F=$(addprefix $(CODEGEN_U), $(FILES_U)) +FILES_U_H_F=$(addprefix $(CODEGEN_U), $(FILES_U_H)) +OUTPUT_W_FU=$(addprefix $(OBJ_U), $(OUTPUT_U)) + +# All Rust and other source files that the Cargo build depends on. +FILES_RUST_F = Cargo.toml ../../../Cargo.lock build.rs $(shell find src -name '*.rs') $(CODEGEN_U)Enclave_u.rs + +# Contains compilation rules for the enclave part + +include ../buildenv.mk +include ../buildenv_sgx.mk + +# Custom libraries, EDL paths. Needs to be specified with make (CUSTOM_EDL_PATH) (CUSTOM_COMMON_PATH) + +# Compilation process, we set up all the dependencies needed to have the correct order of build, and avoid relink + +all: $(BIN_U) + +$(FILES_U_F): $(SGX_EDGER8R) $(SRC_T)/Enclave.edl + @echo "\033[32mGenerating untrusted SGX C edl files...\033[0m" + @$(SGX_EDGER8R) --untrusted $(SRC_T)/Enclave.edl --search-path $(SGX_SDK)/include --search-path $(CUSTOM_EDL_PATH) --untrusted-dir $(CODEGEN_U) + +$(NAME_U_D): $(FILES_U_F) $(OUTPUT_W_FU) + @echo "\033[32mBuilding untrusted C edl static library...\033[0m" + @mkdir -p $(LIB) + @$(AR) rcsD $@ $(OUTPUT_W_FU) + +$(OBJ_U)%.o:$(CODEGEN_U)%.c + @mkdir -p $(OBJ_U) + @echo "\033[32m$?: Build in progress...\033[0m" + @$(CC) $(FLAGS) $(GCC_STEP1_U) -o $@ -c $? + +# We print the compilation mode we're in (hardware/software mode), just as a reminder. + +$(BIN_U): $(NAME_U_D) $(FILES_RUST_F) $(FILES_U_H_F) +ifeq ($(SGX_MODE), SW) + @echo "\033[32mSoftware / Simulation mode\033[0m" +else + @echo "\033[32mHardware mode\033[0m" +endif + @echo "\033[32mStarting cargo to build the host...\033[0m" + @cd $(SRC_U) && SGX_SDK=$(SGX_SDK) cargo build --release + @echo "\033[32mCopying the host to the correct location... ($(BIN_U))\033[0m" + @mkdir -p $(BIN) + @cp ../../../target/release/$(APP_U) $(BIN) + +$(CODEGEN_U)Enclave_u.rs: $(CODEGEN_U)Enclave_u.h + @echo "\033[32mGenerating Rust bindings: $@\033[0m" + @bindgen \ + --no-recursive-allowlist \ + --raw-line 'use sgx_types::*;' \ + --allowlist-function ecall_test \ + --output $@ \ + $? \ + -- -I$(SGX_SDK)/include -I$(CUSTOM_EDL_PATH) + +clean: c_clean + @rm -rf $(OBJ_U) + @echo "\033[32mObject files deleted\033[0m" + +fclean: clean fclean_host + +fclean_host: + @echo "\033[32mBinary file $(BIN_U) deleted\033[0m" + @rm -f $(BIN_U) + @rm -f $(NAME_U_D) + @cargo clean + +c_clean: + @echo "\033[32mC edl generated files deleted\033[0m" + @rm -rf $(FILES_U_F) + @rm -rf $(FILES_U_H_F) + +re: fclean all + +.PHONY: all clean c_clean fclean re fclean_host diff --git a/rust-sgx-workspace/projects/ntc-tee-server/app/build.rs b/rust-sgx-workspace/projects/ntc-tee-server/app/build.rs new file mode 100644 index 0000000..215eb30 --- /dev/null +++ b/rust-sgx-workspace/projects/ntc-tee-server/app/build.rs @@ -0,0 +1,47 @@ +use std::env; +use std::path::PathBuf; + +fn main() { + println!("cargo:rerun-if-env-changed=SGX_SDK"); + println!("cargo:rerun-if-env-changed=SGX_MODE"); + + let sdk_dir = env::var("SGX_SDK").unwrap_or_else(|_| "/opt/sgxsdk".to_string()); + let is_sim = env::var("SGX_MODE").unwrap_or_else(|_| "HW".to_string()); + + link_enclave_u(); + + println!("cargo:rustc-link-search=native={}/lib64", sdk_dir); + match is_sim.as_ref() { + "SW" => println!("cargo:rustc-link-lib=dylib=sgx_urts_sim"), + "HW" => println!("cargo:rustc-link-lib=dylib=sgx_urts"), + _ => println!("cargo:rustc-link-lib=dylib=sgx_urts"), // Treat undefined as HW + } +} + +/// Link the untrusted C EDL static library. +/// Fail with a helpful message if it does not exist. +fn link_enclave_u() { + // Match LIB and NAME_U_D in the Makefile. + const LIB: &str = "../build/lib"; + const NAME_U_D: &str = "libEnclave_u.a"; + + // Resolve paths relative to the local Cargo.toml + let cargo_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); + let lib_dir = PathBuf::from(cargo_dir).join(LIB); + + assert!( + lib_dir.join(NAME_U_D).exists(), + r#" + Could not find the untrusted C EDL static library. + Run "make {}/{}" or "make" to generate it. +"#, + LIB, + NAME_U_D, + ); + + std::println!( + "cargo:rustc-link-search=native={}", + lib_dir.to_str().unwrap() + ); + println!("cargo:rustc-link-lib=static=Enclave_u"); +} diff --git a/rust-sgx-workspace/projects/ntc-tee-server/app/codegen/Enclave_u.c b/rust-sgx-workspace/projects/ntc-tee-server/app/codegen/Enclave_u.c new file mode 100644 index 0000000..c4b408c --- /dev/null +++ b/rust-sgx-workspace/projects/ntc-tee-server/app/codegen/Enclave_u.c @@ -0,0 +1,964 @@ +#include "Enclave_u.h" +#include + +typedef struct ms_ecall_test_t { + sgx_status_t ms_retval; + const uint8_t* ms_some_string; + size_t ms_len; +} ms_ecall_test_t; + +typedef struct ms_t_global_init_ecall_t { + uint64_t ms_id; + const uint8_t* ms_path; + size_t ms_len; +} ms_t_global_init_ecall_t; + +typedef struct ms_u_thread_set_event_ocall_t { + int ms_retval; + int* ms_error; + const void* ms_tcs; +} ms_u_thread_set_event_ocall_t; + +typedef struct ms_u_thread_wait_event_ocall_t { + int ms_retval; + int* ms_error; + const void* ms_tcs; + const struct timespec* ms_timeout; +} ms_u_thread_wait_event_ocall_t; + +typedef struct ms_u_thread_set_multiple_events_ocall_t { + int ms_retval; + int* ms_error; + const void** ms_tcss; + int ms_total; +} ms_u_thread_set_multiple_events_ocall_t; + +typedef struct ms_u_thread_setwait_events_ocall_t { + int ms_retval; + int* ms_error; + const void* ms_waiter_tcs; + const void* ms_self_tcs; + const struct timespec* ms_timeout; +} ms_u_thread_setwait_events_ocall_t; + +typedef struct ms_u_clock_gettime_ocall_t { + int ms_retval; + int* ms_error; + int ms_clk_id; + struct timespec* ms_tp; +} ms_u_clock_gettime_ocall_t; + +typedef struct ms_u_read_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + void* ms_buf; + size_t ms_count; +} ms_u_read_ocall_t; + +typedef struct ms_u_pread64_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + void* ms_buf; + size_t ms_count; + int64_t ms_offset; +} ms_u_pread64_ocall_t; + +typedef struct ms_u_readv_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const struct iovec* ms_iov; + int ms_iovcnt; +} ms_u_readv_ocall_t; + +typedef struct ms_u_preadv64_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const struct iovec* ms_iov; + int ms_iovcnt; + int64_t ms_offset; +} ms_u_preadv64_ocall_t; + +typedef struct ms_u_write_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const void* ms_buf; + size_t ms_count; +} ms_u_write_ocall_t; + +typedef struct ms_u_pwrite64_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const void* ms_buf; + size_t ms_count; + int64_t ms_offset; +} ms_u_pwrite64_ocall_t; + +typedef struct ms_u_writev_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const struct iovec* ms_iov; + int ms_iovcnt; +} ms_u_writev_ocall_t; + +typedef struct ms_u_pwritev64_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const struct iovec* ms_iov; + int ms_iovcnt; + int64_t ms_offset; +} ms_u_pwritev64_ocall_t; + +typedef struct ms_u_fcntl_arg0_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int ms_cmd; +} ms_u_fcntl_arg0_ocall_t; + +typedef struct ms_u_fcntl_arg1_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int ms_cmd; + int ms_arg; +} ms_u_fcntl_arg1_ocall_t; + +typedef struct ms_u_ioctl_arg0_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int ms_request; +} ms_u_ioctl_arg0_ocall_t; + +typedef struct ms_u_ioctl_arg1_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int ms_request; + int* ms_arg; +} ms_u_ioctl_arg1_ocall_t; + +typedef struct ms_u_close_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; +} ms_u_close_ocall_t; + +typedef struct ms_u_malloc_ocall_t { + void* ms_retval; + int* ms_error; + size_t ms_size; +} ms_u_malloc_ocall_t; + +typedef struct ms_u_free_ocall_t { + void* ms_p; +} ms_u_free_ocall_t; + +typedef struct ms_u_mmap_ocall_t { + void* ms_retval; + int* ms_error; + void* ms_start; + size_t ms_length; + int ms_prot; + int ms_flags; + int ms_fd; + int64_t ms_offset; +} ms_u_mmap_ocall_t; + +typedef struct ms_u_munmap_ocall_t { + int ms_retval; + int* ms_error; + void* ms_start; + size_t ms_length; +} ms_u_munmap_ocall_t; + +typedef struct ms_u_msync_ocall_t { + int ms_retval; + int* ms_error; + void* ms_addr; + size_t ms_length; + int ms_flags; +} ms_u_msync_ocall_t; + +typedef struct ms_u_mprotect_ocall_t { + int ms_retval; + int* ms_error; + void* ms_addr; + size_t ms_length; + int ms_prot; +} ms_u_mprotect_ocall_t; + +typedef struct ms_u_open_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_pathname; + int ms_flags; +} ms_u_open_ocall_t; + +typedef struct ms_u_open64_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + int ms_oflag; + int ms_mode; +} ms_u_open64_ocall_t; + +typedef struct ms_u_fstat_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + struct stat_t* ms_buf; +} ms_u_fstat_ocall_t; + +typedef struct ms_u_fstat64_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + struct stat64_t* ms_buf; +} ms_u_fstat64_ocall_t; + +typedef struct ms_u_stat_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + struct stat_t* ms_buf; +} ms_u_stat_ocall_t; + +typedef struct ms_u_stat64_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + struct stat64_t* ms_buf; +} ms_u_stat64_ocall_t; + +typedef struct ms_u_lstat_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + struct stat_t* ms_buf; +} ms_u_lstat_ocall_t; + +typedef struct ms_u_lstat64_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + struct stat64_t* ms_buf; +} ms_u_lstat64_ocall_t; + +typedef struct ms_u_lseek_ocall_t { + uint64_t ms_retval; + int* ms_error; + int ms_fd; + int64_t ms_offset; + int ms_whence; +} ms_u_lseek_ocall_t; + +typedef struct ms_u_lseek64_ocall_t { + int64_t ms_retval; + int* ms_error; + int ms_fd; + int64_t ms_offset; + int ms_whence; +} ms_u_lseek64_ocall_t; + +typedef struct ms_u_ftruncate_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int64_t ms_length; +} ms_u_ftruncate_ocall_t; + +typedef struct ms_u_ftruncate64_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int64_t ms_length; +} ms_u_ftruncate64_ocall_t; + +typedef struct ms_u_truncate_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + int64_t ms_length; +} ms_u_truncate_ocall_t; + +typedef struct ms_u_truncate64_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + int64_t ms_length; +} ms_u_truncate64_ocall_t; + +typedef struct ms_u_fsync_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; +} ms_u_fsync_ocall_t; + +typedef struct ms_u_fdatasync_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; +} ms_u_fdatasync_ocall_t; + +typedef struct ms_u_fchmod_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + uint32_t ms_mode; +} ms_u_fchmod_ocall_t; + +typedef struct ms_u_unlink_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_pathname; +} ms_u_unlink_ocall_t; + +typedef struct ms_u_link_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_oldpath; + const char* ms_newpath; +} ms_u_link_ocall_t; + +typedef struct ms_u_linkat_ocall_t { + int ms_retval; + int* ms_error; + int ms_olddirfd; + const char* ms_oldpath; + int ms_newdirfd; + const char* ms_newpath; + int ms_flags; +} ms_u_linkat_ocall_t; + +typedef struct ms_u_rename_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_oldpath; + const char* ms_newpath; +} ms_u_rename_ocall_t; + +typedef struct ms_u_chmod_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + uint32_t ms_mode; +} ms_u_chmod_ocall_t; + +typedef struct ms_u_readlink_ocall_t { + size_t ms_retval; + int* ms_error; + const char* ms_path; + char* ms_buf; + size_t ms_bufsz; +} ms_u_readlink_ocall_t; + +typedef struct ms_u_symlink_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path1; + const char* ms_path2; +} ms_u_symlink_ocall_t; + +typedef struct ms_u_realpath_ocall_t { + char* ms_retval; + int* ms_error; + const char* ms_pathname; +} ms_u_realpath_ocall_t; + +typedef struct ms_u_mkdir_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_pathname; + uint32_t ms_mode; +} ms_u_mkdir_ocall_t; + +typedef struct ms_u_rmdir_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_pathname; +} ms_u_rmdir_ocall_t; + +typedef struct ms_u_opendir_ocall_t { + void* ms_retval; + int* ms_error; + const char* ms_pathname; +} ms_u_opendir_ocall_t; + +typedef struct ms_u_readdir64_r_ocall_t { + int ms_retval; + void* ms_dirp; + struct dirent64_t* ms_entry; + struct dirent64_t** ms_result; +} ms_u_readdir64_r_ocall_t; + +typedef struct ms_u_closedir_ocall_t { + int ms_retval; + int* ms_error; + void* ms_dirp; +} ms_u_closedir_ocall_t; + +typedef struct ms_u_dirfd_ocall_t { + int ms_retval; + int* ms_error; + void* ms_dirp; +} ms_u_dirfd_ocall_t; + +typedef struct ms_u_fstatat64_ocall_t { + int ms_retval; + int* ms_error; + int ms_dirfd; + const char* ms_pathname; + struct stat64_t* ms_buf; + int ms_flags; +} ms_u_fstatat64_ocall_t; + +static sgx_status_t SGX_CDECL Enclave_u_thread_set_event_ocall(void* pms) +{ + ms_u_thread_set_event_ocall_t* ms = SGX_CAST(ms_u_thread_set_event_ocall_t*, pms); + ms->ms_retval = u_thread_set_event_ocall(ms->ms_error, ms->ms_tcs); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_thread_wait_event_ocall(void* pms) +{ + ms_u_thread_wait_event_ocall_t* ms = SGX_CAST(ms_u_thread_wait_event_ocall_t*, pms); + ms->ms_retval = u_thread_wait_event_ocall(ms->ms_error, ms->ms_tcs, ms->ms_timeout); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_thread_set_multiple_events_ocall(void* pms) +{ + ms_u_thread_set_multiple_events_ocall_t* ms = SGX_CAST(ms_u_thread_set_multiple_events_ocall_t*, pms); + ms->ms_retval = u_thread_set_multiple_events_ocall(ms->ms_error, ms->ms_tcss, ms->ms_total); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_thread_setwait_events_ocall(void* pms) +{ + ms_u_thread_setwait_events_ocall_t* ms = SGX_CAST(ms_u_thread_setwait_events_ocall_t*, pms); + ms->ms_retval = u_thread_setwait_events_ocall(ms->ms_error, ms->ms_waiter_tcs, ms->ms_self_tcs, ms->ms_timeout); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_clock_gettime_ocall(void* pms) +{ + ms_u_clock_gettime_ocall_t* ms = SGX_CAST(ms_u_clock_gettime_ocall_t*, pms); + ms->ms_retval = u_clock_gettime_ocall(ms->ms_error, ms->ms_clk_id, ms->ms_tp); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_read_ocall(void* pms) +{ + ms_u_read_ocall_t* ms = SGX_CAST(ms_u_read_ocall_t*, pms); + ms->ms_retval = u_read_ocall(ms->ms_error, ms->ms_fd, ms->ms_buf, ms->ms_count); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_pread64_ocall(void* pms) +{ + ms_u_pread64_ocall_t* ms = SGX_CAST(ms_u_pread64_ocall_t*, pms); + ms->ms_retval = u_pread64_ocall(ms->ms_error, ms->ms_fd, ms->ms_buf, ms->ms_count, ms->ms_offset); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_readv_ocall(void* pms) +{ + ms_u_readv_ocall_t* ms = SGX_CAST(ms_u_readv_ocall_t*, pms); + ms->ms_retval = u_readv_ocall(ms->ms_error, ms->ms_fd, ms->ms_iov, ms->ms_iovcnt); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_preadv64_ocall(void* pms) +{ + ms_u_preadv64_ocall_t* ms = SGX_CAST(ms_u_preadv64_ocall_t*, pms); + ms->ms_retval = u_preadv64_ocall(ms->ms_error, ms->ms_fd, ms->ms_iov, ms->ms_iovcnt, ms->ms_offset); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_write_ocall(void* pms) +{ + ms_u_write_ocall_t* ms = SGX_CAST(ms_u_write_ocall_t*, pms); + ms->ms_retval = u_write_ocall(ms->ms_error, ms->ms_fd, ms->ms_buf, ms->ms_count); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_pwrite64_ocall(void* pms) +{ + ms_u_pwrite64_ocall_t* ms = SGX_CAST(ms_u_pwrite64_ocall_t*, pms); + ms->ms_retval = u_pwrite64_ocall(ms->ms_error, ms->ms_fd, ms->ms_buf, ms->ms_count, ms->ms_offset); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_writev_ocall(void* pms) +{ + ms_u_writev_ocall_t* ms = SGX_CAST(ms_u_writev_ocall_t*, pms); + ms->ms_retval = u_writev_ocall(ms->ms_error, ms->ms_fd, ms->ms_iov, ms->ms_iovcnt); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_pwritev64_ocall(void* pms) +{ + ms_u_pwritev64_ocall_t* ms = SGX_CAST(ms_u_pwritev64_ocall_t*, pms); + ms->ms_retval = u_pwritev64_ocall(ms->ms_error, ms->ms_fd, ms->ms_iov, ms->ms_iovcnt, ms->ms_offset); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_fcntl_arg0_ocall(void* pms) +{ + ms_u_fcntl_arg0_ocall_t* ms = SGX_CAST(ms_u_fcntl_arg0_ocall_t*, pms); + ms->ms_retval = u_fcntl_arg0_ocall(ms->ms_error, ms->ms_fd, ms->ms_cmd); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_fcntl_arg1_ocall(void* pms) +{ + ms_u_fcntl_arg1_ocall_t* ms = SGX_CAST(ms_u_fcntl_arg1_ocall_t*, pms); + ms->ms_retval = u_fcntl_arg1_ocall(ms->ms_error, ms->ms_fd, ms->ms_cmd, ms->ms_arg); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_ioctl_arg0_ocall(void* pms) +{ + ms_u_ioctl_arg0_ocall_t* ms = SGX_CAST(ms_u_ioctl_arg0_ocall_t*, pms); + ms->ms_retval = u_ioctl_arg0_ocall(ms->ms_error, ms->ms_fd, ms->ms_request); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_ioctl_arg1_ocall(void* pms) +{ + ms_u_ioctl_arg1_ocall_t* ms = SGX_CAST(ms_u_ioctl_arg1_ocall_t*, pms); + ms->ms_retval = u_ioctl_arg1_ocall(ms->ms_error, ms->ms_fd, ms->ms_request, ms->ms_arg); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_close_ocall(void* pms) +{ + ms_u_close_ocall_t* ms = SGX_CAST(ms_u_close_ocall_t*, pms); + ms->ms_retval = u_close_ocall(ms->ms_error, ms->ms_fd); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_malloc_ocall(void* pms) +{ + ms_u_malloc_ocall_t* ms = SGX_CAST(ms_u_malloc_ocall_t*, pms); + ms->ms_retval = u_malloc_ocall(ms->ms_error, ms->ms_size); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_free_ocall(void* pms) +{ + ms_u_free_ocall_t* ms = SGX_CAST(ms_u_free_ocall_t*, pms); + u_free_ocall(ms->ms_p); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_mmap_ocall(void* pms) +{ + ms_u_mmap_ocall_t* ms = SGX_CAST(ms_u_mmap_ocall_t*, pms); + ms->ms_retval = u_mmap_ocall(ms->ms_error, ms->ms_start, ms->ms_length, ms->ms_prot, ms->ms_flags, ms->ms_fd, ms->ms_offset); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_munmap_ocall(void* pms) +{ + ms_u_munmap_ocall_t* ms = SGX_CAST(ms_u_munmap_ocall_t*, pms); + ms->ms_retval = u_munmap_ocall(ms->ms_error, ms->ms_start, ms->ms_length); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_msync_ocall(void* pms) +{ + ms_u_msync_ocall_t* ms = SGX_CAST(ms_u_msync_ocall_t*, pms); + ms->ms_retval = u_msync_ocall(ms->ms_error, ms->ms_addr, ms->ms_length, ms->ms_flags); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_mprotect_ocall(void* pms) +{ + ms_u_mprotect_ocall_t* ms = SGX_CAST(ms_u_mprotect_ocall_t*, pms); + ms->ms_retval = u_mprotect_ocall(ms->ms_error, ms->ms_addr, ms->ms_length, ms->ms_prot); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_open_ocall(void* pms) +{ + ms_u_open_ocall_t* ms = SGX_CAST(ms_u_open_ocall_t*, pms); + ms->ms_retval = u_open_ocall(ms->ms_error, ms->ms_pathname, ms->ms_flags); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_open64_ocall(void* pms) +{ + ms_u_open64_ocall_t* ms = SGX_CAST(ms_u_open64_ocall_t*, pms); + ms->ms_retval = u_open64_ocall(ms->ms_error, ms->ms_path, ms->ms_oflag, ms->ms_mode); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_fstat_ocall(void* pms) +{ + ms_u_fstat_ocall_t* ms = SGX_CAST(ms_u_fstat_ocall_t*, pms); + ms->ms_retval = u_fstat_ocall(ms->ms_error, ms->ms_fd, ms->ms_buf); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_fstat64_ocall(void* pms) +{ + ms_u_fstat64_ocall_t* ms = SGX_CAST(ms_u_fstat64_ocall_t*, pms); + ms->ms_retval = u_fstat64_ocall(ms->ms_error, ms->ms_fd, ms->ms_buf); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_stat_ocall(void* pms) +{ + ms_u_stat_ocall_t* ms = SGX_CAST(ms_u_stat_ocall_t*, pms); + ms->ms_retval = u_stat_ocall(ms->ms_error, ms->ms_path, ms->ms_buf); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_stat64_ocall(void* pms) +{ + ms_u_stat64_ocall_t* ms = SGX_CAST(ms_u_stat64_ocall_t*, pms); + ms->ms_retval = u_stat64_ocall(ms->ms_error, ms->ms_path, ms->ms_buf); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_lstat_ocall(void* pms) +{ + ms_u_lstat_ocall_t* ms = SGX_CAST(ms_u_lstat_ocall_t*, pms); + ms->ms_retval = u_lstat_ocall(ms->ms_error, ms->ms_path, ms->ms_buf); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_lstat64_ocall(void* pms) +{ + ms_u_lstat64_ocall_t* ms = SGX_CAST(ms_u_lstat64_ocall_t*, pms); + ms->ms_retval = u_lstat64_ocall(ms->ms_error, ms->ms_path, ms->ms_buf); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_lseek_ocall(void* pms) +{ + ms_u_lseek_ocall_t* ms = SGX_CAST(ms_u_lseek_ocall_t*, pms); + ms->ms_retval = u_lseek_ocall(ms->ms_error, ms->ms_fd, ms->ms_offset, ms->ms_whence); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_lseek64_ocall(void* pms) +{ + ms_u_lseek64_ocall_t* ms = SGX_CAST(ms_u_lseek64_ocall_t*, pms); + ms->ms_retval = u_lseek64_ocall(ms->ms_error, ms->ms_fd, ms->ms_offset, ms->ms_whence); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_ftruncate_ocall(void* pms) +{ + ms_u_ftruncate_ocall_t* ms = SGX_CAST(ms_u_ftruncate_ocall_t*, pms); + ms->ms_retval = u_ftruncate_ocall(ms->ms_error, ms->ms_fd, ms->ms_length); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_ftruncate64_ocall(void* pms) +{ + ms_u_ftruncate64_ocall_t* ms = SGX_CAST(ms_u_ftruncate64_ocall_t*, pms); + ms->ms_retval = u_ftruncate64_ocall(ms->ms_error, ms->ms_fd, ms->ms_length); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_truncate_ocall(void* pms) +{ + ms_u_truncate_ocall_t* ms = SGX_CAST(ms_u_truncate_ocall_t*, pms); + ms->ms_retval = u_truncate_ocall(ms->ms_error, ms->ms_path, ms->ms_length); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_truncate64_ocall(void* pms) +{ + ms_u_truncate64_ocall_t* ms = SGX_CAST(ms_u_truncate64_ocall_t*, pms); + ms->ms_retval = u_truncate64_ocall(ms->ms_error, ms->ms_path, ms->ms_length); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_fsync_ocall(void* pms) +{ + ms_u_fsync_ocall_t* ms = SGX_CAST(ms_u_fsync_ocall_t*, pms); + ms->ms_retval = u_fsync_ocall(ms->ms_error, ms->ms_fd); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_fdatasync_ocall(void* pms) +{ + ms_u_fdatasync_ocall_t* ms = SGX_CAST(ms_u_fdatasync_ocall_t*, pms); + ms->ms_retval = u_fdatasync_ocall(ms->ms_error, ms->ms_fd); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_fchmod_ocall(void* pms) +{ + ms_u_fchmod_ocall_t* ms = SGX_CAST(ms_u_fchmod_ocall_t*, pms); + ms->ms_retval = u_fchmod_ocall(ms->ms_error, ms->ms_fd, ms->ms_mode); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_unlink_ocall(void* pms) +{ + ms_u_unlink_ocall_t* ms = SGX_CAST(ms_u_unlink_ocall_t*, pms); + ms->ms_retval = u_unlink_ocall(ms->ms_error, ms->ms_pathname); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_link_ocall(void* pms) +{ + ms_u_link_ocall_t* ms = SGX_CAST(ms_u_link_ocall_t*, pms); + ms->ms_retval = u_link_ocall(ms->ms_error, ms->ms_oldpath, ms->ms_newpath); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_linkat_ocall(void* pms) +{ + ms_u_linkat_ocall_t* ms = SGX_CAST(ms_u_linkat_ocall_t*, pms); + ms->ms_retval = u_linkat_ocall(ms->ms_error, ms->ms_olddirfd, ms->ms_oldpath, ms->ms_newdirfd, ms->ms_newpath, ms->ms_flags); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_rename_ocall(void* pms) +{ + ms_u_rename_ocall_t* ms = SGX_CAST(ms_u_rename_ocall_t*, pms); + ms->ms_retval = u_rename_ocall(ms->ms_error, ms->ms_oldpath, ms->ms_newpath); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_chmod_ocall(void* pms) +{ + ms_u_chmod_ocall_t* ms = SGX_CAST(ms_u_chmod_ocall_t*, pms); + ms->ms_retval = u_chmod_ocall(ms->ms_error, ms->ms_path, ms->ms_mode); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_readlink_ocall(void* pms) +{ + ms_u_readlink_ocall_t* ms = SGX_CAST(ms_u_readlink_ocall_t*, pms); + ms->ms_retval = u_readlink_ocall(ms->ms_error, ms->ms_path, ms->ms_buf, ms->ms_bufsz); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_symlink_ocall(void* pms) +{ + ms_u_symlink_ocall_t* ms = SGX_CAST(ms_u_symlink_ocall_t*, pms); + ms->ms_retval = u_symlink_ocall(ms->ms_error, ms->ms_path1, ms->ms_path2); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_realpath_ocall(void* pms) +{ + ms_u_realpath_ocall_t* ms = SGX_CAST(ms_u_realpath_ocall_t*, pms); + ms->ms_retval = u_realpath_ocall(ms->ms_error, ms->ms_pathname); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_mkdir_ocall(void* pms) +{ + ms_u_mkdir_ocall_t* ms = SGX_CAST(ms_u_mkdir_ocall_t*, pms); + ms->ms_retval = u_mkdir_ocall(ms->ms_error, ms->ms_pathname, ms->ms_mode); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_rmdir_ocall(void* pms) +{ + ms_u_rmdir_ocall_t* ms = SGX_CAST(ms_u_rmdir_ocall_t*, pms); + ms->ms_retval = u_rmdir_ocall(ms->ms_error, ms->ms_pathname); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_opendir_ocall(void* pms) +{ + ms_u_opendir_ocall_t* ms = SGX_CAST(ms_u_opendir_ocall_t*, pms); + ms->ms_retval = u_opendir_ocall(ms->ms_error, ms->ms_pathname); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_readdir64_r_ocall(void* pms) +{ + ms_u_readdir64_r_ocall_t* ms = SGX_CAST(ms_u_readdir64_r_ocall_t*, pms); + ms->ms_retval = u_readdir64_r_ocall(ms->ms_dirp, ms->ms_entry, ms->ms_result); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_closedir_ocall(void* pms) +{ + ms_u_closedir_ocall_t* ms = SGX_CAST(ms_u_closedir_ocall_t*, pms); + ms->ms_retval = u_closedir_ocall(ms->ms_error, ms->ms_dirp); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_dirfd_ocall(void* pms) +{ + ms_u_dirfd_ocall_t* ms = SGX_CAST(ms_u_dirfd_ocall_t*, pms); + ms->ms_retval = u_dirfd_ocall(ms->ms_error, ms->ms_dirp); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_fstatat64_ocall(void* pms) +{ + ms_u_fstatat64_ocall_t* ms = SGX_CAST(ms_u_fstatat64_ocall_t*, pms); + ms->ms_retval = u_fstatat64_ocall(ms->ms_error, ms->ms_dirfd, ms->ms_pathname, ms->ms_buf, ms->ms_flags); + + return SGX_SUCCESS; +} + +static const struct { + size_t nr_ocall; + void * table[56]; +} ocall_table_Enclave = { + 56, + { + (void*)Enclave_u_thread_set_event_ocall, + (void*)Enclave_u_thread_wait_event_ocall, + (void*)Enclave_u_thread_set_multiple_events_ocall, + (void*)Enclave_u_thread_setwait_events_ocall, + (void*)Enclave_u_clock_gettime_ocall, + (void*)Enclave_u_read_ocall, + (void*)Enclave_u_pread64_ocall, + (void*)Enclave_u_readv_ocall, + (void*)Enclave_u_preadv64_ocall, + (void*)Enclave_u_write_ocall, + (void*)Enclave_u_pwrite64_ocall, + (void*)Enclave_u_writev_ocall, + (void*)Enclave_u_pwritev64_ocall, + (void*)Enclave_u_fcntl_arg0_ocall, + (void*)Enclave_u_fcntl_arg1_ocall, + (void*)Enclave_u_ioctl_arg0_ocall, + (void*)Enclave_u_ioctl_arg1_ocall, + (void*)Enclave_u_close_ocall, + (void*)Enclave_u_malloc_ocall, + (void*)Enclave_u_free_ocall, + (void*)Enclave_u_mmap_ocall, + (void*)Enclave_u_munmap_ocall, + (void*)Enclave_u_msync_ocall, + (void*)Enclave_u_mprotect_ocall, + (void*)Enclave_u_open_ocall, + (void*)Enclave_u_open64_ocall, + (void*)Enclave_u_fstat_ocall, + (void*)Enclave_u_fstat64_ocall, + (void*)Enclave_u_stat_ocall, + (void*)Enclave_u_stat64_ocall, + (void*)Enclave_u_lstat_ocall, + (void*)Enclave_u_lstat64_ocall, + (void*)Enclave_u_lseek_ocall, + (void*)Enclave_u_lseek64_ocall, + (void*)Enclave_u_ftruncate_ocall, + (void*)Enclave_u_ftruncate64_ocall, + (void*)Enclave_u_truncate_ocall, + (void*)Enclave_u_truncate64_ocall, + (void*)Enclave_u_fsync_ocall, + (void*)Enclave_u_fdatasync_ocall, + (void*)Enclave_u_fchmod_ocall, + (void*)Enclave_u_unlink_ocall, + (void*)Enclave_u_link_ocall, + (void*)Enclave_u_linkat_ocall, + (void*)Enclave_u_rename_ocall, + (void*)Enclave_u_chmod_ocall, + (void*)Enclave_u_readlink_ocall, + (void*)Enclave_u_symlink_ocall, + (void*)Enclave_u_realpath_ocall, + (void*)Enclave_u_mkdir_ocall, + (void*)Enclave_u_rmdir_ocall, + (void*)Enclave_u_opendir_ocall, + (void*)Enclave_u_readdir64_r_ocall, + (void*)Enclave_u_closedir_ocall, + (void*)Enclave_u_dirfd_ocall, + (void*)Enclave_u_fstatat64_ocall, + } +}; +sgx_status_t ecall_test(sgx_enclave_id_t eid, sgx_status_t* retval, const uint8_t* some_string, size_t len) +{ + sgx_status_t status; + ms_ecall_test_t ms; + ms.ms_some_string = some_string; + ms.ms_len = len; + status = sgx_ecall(eid, 0, &ocall_table_Enclave, &ms); + if (status == SGX_SUCCESS && retval) *retval = ms.ms_retval; + return status; +} + +sgx_status_t t_global_init_ecall(sgx_enclave_id_t eid, uint64_t id, const uint8_t* path, size_t len) +{ + sgx_status_t status; + ms_t_global_init_ecall_t ms; + ms.ms_id = id; + ms.ms_path = path; + ms.ms_len = len; + status = sgx_ecall(eid, 1, &ocall_table_Enclave, &ms); + return status; +} + +sgx_status_t t_global_exit_ecall(sgx_enclave_id_t eid) +{ + sgx_status_t status; + status = sgx_ecall(eid, 2, &ocall_table_Enclave, NULL); + return status; +} + diff --git a/rust-sgx-workspace/projects/ntc-tee-server/app/codegen/Enclave_u.h b/rust-sgx-workspace/projects/ntc-tee-server/app/codegen/Enclave_u.h new file mode 100644 index 0000000..701aeb0 --- /dev/null +++ b/rust-sgx-workspace/projects/ntc-tee-server/app/codegen/Enclave_u.h @@ -0,0 +1,257 @@ +#ifndef ENCLAVE_U_H__ +#define ENCLAVE_U_H__ + +#include +#include +#include +#include +#include "sgx_edger8r.h" /* for sgx_status_t etc. */ + +#include "time.h" +#include "inc/stat.h" +#include "sys/uio.h" +#include "inc/stat.h" +#include "inc/dirent.h" + +#include /* for size_t */ + +#define SGX_CAST(type, item) ((type)(item)) + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef U_THREAD_SET_EVENT_OCALL_DEFINED__ +#define U_THREAD_SET_EVENT_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_thread_set_event_ocall, (int* error, const void* tcs)); +#endif +#ifndef U_THREAD_WAIT_EVENT_OCALL_DEFINED__ +#define U_THREAD_WAIT_EVENT_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_thread_wait_event_ocall, (int* error, const void* tcs, const struct timespec* timeout)); +#endif +#ifndef U_THREAD_SET_MULTIPLE_EVENTS_OCALL_DEFINED__ +#define U_THREAD_SET_MULTIPLE_EVENTS_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_thread_set_multiple_events_ocall, (int* error, const void** tcss, int total)); +#endif +#ifndef U_THREAD_SETWAIT_EVENTS_OCALL_DEFINED__ +#define U_THREAD_SETWAIT_EVENTS_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_thread_setwait_events_ocall, (int* error, const void* waiter_tcs, const void* self_tcs, const struct timespec* timeout)); +#endif +#ifndef U_CLOCK_GETTIME_OCALL_DEFINED__ +#define U_CLOCK_GETTIME_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_clock_gettime_ocall, (int* error, int clk_id, struct timespec* tp)); +#endif +#ifndef U_READ_OCALL_DEFINED__ +#define U_READ_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_read_ocall, (int* error, int fd, void* buf, size_t count)); +#endif +#ifndef U_PREAD64_OCALL_DEFINED__ +#define U_PREAD64_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_pread64_ocall, (int* error, int fd, void* buf, size_t count, int64_t offset)); +#endif +#ifndef U_READV_OCALL_DEFINED__ +#define U_READV_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_readv_ocall, (int* error, int fd, const struct iovec* iov, int iovcnt)); +#endif +#ifndef U_PREADV64_OCALL_DEFINED__ +#define U_PREADV64_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_preadv64_ocall, (int* error, int fd, const struct iovec* iov, int iovcnt, int64_t offset)); +#endif +#ifndef U_WRITE_OCALL_DEFINED__ +#define U_WRITE_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_write_ocall, (int* error, int fd, const void* buf, size_t count)); +#endif +#ifndef U_PWRITE64_OCALL_DEFINED__ +#define U_PWRITE64_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_pwrite64_ocall, (int* error, int fd, const void* buf, size_t count, int64_t offset)); +#endif +#ifndef U_WRITEV_OCALL_DEFINED__ +#define U_WRITEV_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_writev_ocall, (int* error, int fd, const struct iovec* iov, int iovcnt)); +#endif +#ifndef U_PWRITEV64_OCALL_DEFINED__ +#define U_PWRITEV64_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_pwritev64_ocall, (int* error, int fd, const struct iovec* iov, int iovcnt, int64_t offset)); +#endif +#ifndef U_FCNTL_ARG0_OCALL_DEFINED__ +#define U_FCNTL_ARG0_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_fcntl_arg0_ocall, (int* error, int fd, int cmd)); +#endif +#ifndef U_FCNTL_ARG1_OCALL_DEFINED__ +#define U_FCNTL_ARG1_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_fcntl_arg1_ocall, (int* error, int fd, int cmd, int arg)); +#endif +#ifndef U_IOCTL_ARG0_OCALL_DEFINED__ +#define U_IOCTL_ARG0_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_ioctl_arg0_ocall, (int* error, int fd, int request)); +#endif +#ifndef U_IOCTL_ARG1_OCALL_DEFINED__ +#define U_IOCTL_ARG1_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_ioctl_arg1_ocall, (int* error, int fd, int request, int* arg)); +#endif +#ifndef U_CLOSE_OCALL_DEFINED__ +#define U_CLOSE_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_close_ocall, (int* error, int fd)); +#endif +#ifndef U_MALLOC_OCALL_DEFINED__ +#define U_MALLOC_OCALL_DEFINED__ +void* SGX_UBRIDGE(SGX_NOCONVENTION, u_malloc_ocall, (int* error, size_t size)); +#endif +#ifndef U_FREE_OCALL_DEFINED__ +#define U_FREE_OCALL_DEFINED__ +void SGX_UBRIDGE(SGX_NOCONVENTION, u_free_ocall, (void* p)); +#endif +#ifndef U_MMAP_OCALL_DEFINED__ +#define U_MMAP_OCALL_DEFINED__ +void* SGX_UBRIDGE(SGX_NOCONVENTION, u_mmap_ocall, (int* error, void* start, size_t length, int prot, int flags, int fd, int64_t offset)); +#endif +#ifndef U_MUNMAP_OCALL_DEFINED__ +#define U_MUNMAP_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_munmap_ocall, (int* error, void* start, size_t length)); +#endif +#ifndef U_MSYNC_OCALL_DEFINED__ +#define U_MSYNC_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_msync_ocall, (int* error, void* addr, size_t length, int flags)); +#endif +#ifndef U_MPROTECT_OCALL_DEFINED__ +#define U_MPROTECT_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_mprotect_ocall, (int* error, void* addr, size_t length, int prot)); +#endif +#ifndef U_OPEN_OCALL_DEFINED__ +#define U_OPEN_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_open_ocall, (int* error, const char* pathname, int flags)); +#endif +#ifndef U_OPEN64_OCALL_DEFINED__ +#define U_OPEN64_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_open64_ocall, (int* error, const char* path, int oflag, int mode)); +#endif +#ifndef U_FSTAT_OCALL_DEFINED__ +#define U_FSTAT_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_fstat_ocall, (int* error, int fd, struct stat_t* buf)); +#endif +#ifndef U_FSTAT64_OCALL_DEFINED__ +#define U_FSTAT64_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_fstat64_ocall, (int* error, int fd, struct stat64_t* buf)); +#endif +#ifndef U_STAT_OCALL_DEFINED__ +#define U_STAT_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_stat_ocall, (int* error, const char* path, struct stat_t* buf)); +#endif +#ifndef U_STAT64_OCALL_DEFINED__ +#define U_STAT64_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_stat64_ocall, (int* error, const char* path, struct stat64_t* buf)); +#endif +#ifndef U_LSTAT_OCALL_DEFINED__ +#define U_LSTAT_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_lstat_ocall, (int* error, const char* path, struct stat_t* buf)); +#endif +#ifndef U_LSTAT64_OCALL_DEFINED__ +#define U_LSTAT64_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_lstat64_ocall, (int* error, const char* path, struct stat64_t* buf)); +#endif +#ifndef U_LSEEK_OCALL_DEFINED__ +#define U_LSEEK_OCALL_DEFINED__ +uint64_t SGX_UBRIDGE(SGX_NOCONVENTION, u_lseek_ocall, (int* error, int fd, int64_t offset, int whence)); +#endif +#ifndef U_LSEEK64_OCALL_DEFINED__ +#define U_LSEEK64_OCALL_DEFINED__ +int64_t SGX_UBRIDGE(SGX_NOCONVENTION, u_lseek64_ocall, (int* error, int fd, int64_t offset, int whence)); +#endif +#ifndef U_FTRUNCATE_OCALL_DEFINED__ +#define U_FTRUNCATE_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_ftruncate_ocall, (int* error, int fd, int64_t length)); +#endif +#ifndef U_FTRUNCATE64_OCALL_DEFINED__ +#define U_FTRUNCATE64_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_ftruncate64_ocall, (int* error, int fd, int64_t length)); +#endif +#ifndef U_TRUNCATE_OCALL_DEFINED__ +#define U_TRUNCATE_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_truncate_ocall, (int* error, const char* path, int64_t length)); +#endif +#ifndef U_TRUNCATE64_OCALL_DEFINED__ +#define U_TRUNCATE64_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_truncate64_ocall, (int* error, const char* path, int64_t length)); +#endif +#ifndef U_FSYNC_OCALL_DEFINED__ +#define U_FSYNC_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_fsync_ocall, (int* error, int fd)); +#endif +#ifndef U_FDATASYNC_OCALL_DEFINED__ +#define U_FDATASYNC_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_fdatasync_ocall, (int* error, int fd)); +#endif +#ifndef U_FCHMOD_OCALL_DEFINED__ +#define U_FCHMOD_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_fchmod_ocall, (int* error, int fd, uint32_t mode)); +#endif +#ifndef U_UNLINK_OCALL_DEFINED__ +#define U_UNLINK_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_unlink_ocall, (int* error, const char* pathname)); +#endif +#ifndef U_LINK_OCALL_DEFINED__ +#define U_LINK_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_link_ocall, (int* error, const char* oldpath, const char* newpath)); +#endif +#ifndef U_LINKAT_OCALL_DEFINED__ +#define U_LINKAT_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_linkat_ocall, (int* error, int olddirfd, const char* oldpath, int newdirfd, const char* newpath, int flags)); +#endif +#ifndef U_RENAME_OCALL_DEFINED__ +#define U_RENAME_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_rename_ocall, (int* error, const char* oldpath, const char* newpath)); +#endif +#ifndef U_CHMOD_OCALL_DEFINED__ +#define U_CHMOD_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_chmod_ocall, (int* error, const char* path, uint32_t mode)); +#endif +#ifndef U_READLINK_OCALL_DEFINED__ +#define U_READLINK_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_readlink_ocall, (int* error, const char* path, char* buf, size_t bufsz)); +#endif +#ifndef U_SYMLINK_OCALL_DEFINED__ +#define U_SYMLINK_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_symlink_ocall, (int* error, const char* path1, const char* path2)); +#endif +#ifndef U_REALPATH_OCALL_DEFINED__ +#define U_REALPATH_OCALL_DEFINED__ +char* SGX_UBRIDGE(SGX_NOCONVENTION, u_realpath_ocall, (int* error, const char* pathname)); +#endif +#ifndef U_MKDIR_OCALL_DEFINED__ +#define U_MKDIR_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_mkdir_ocall, (int* error, const char* pathname, uint32_t mode)); +#endif +#ifndef U_RMDIR_OCALL_DEFINED__ +#define U_RMDIR_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_rmdir_ocall, (int* error, const char* pathname)); +#endif +#ifndef U_OPENDIR_OCALL_DEFINED__ +#define U_OPENDIR_OCALL_DEFINED__ +void* SGX_UBRIDGE(SGX_NOCONVENTION, u_opendir_ocall, (int* error, const char* pathname)); +#endif +#ifndef U_READDIR64_R_OCALL_DEFINED__ +#define U_READDIR64_R_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_readdir64_r_ocall, (void* dirp, struct dirent64_t* entry, struct dirent64_t** result)); +#endif +#ifndef U_CLOSEDIR_OCALL_DEFINED__ +#define U_CLOSEDIR_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_closedir_ocall, (int* error, void* dirp)); +#endif +#ifndef U_DIRFD_OCALL_DEFINED__ +#define U_DIRFD_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_dirfd_ocall, (int* error, void* dirp)); +#endif +#ifndef U_FSTATAT64_OCALL_DEFINED__ +#define U_FSTATAT64_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_fstatat64_ocall, (int* error, int dirfd, const char* pathname, struct stat64_t* buf, int flags)); +#endif + +sgx_status_t ecall_test(sgx_enclave_id_t eid, sgx_status_t* retval, const uint8_t* some_string, size_t len); +sgx_status_t t_global_init_ecall(sgx_enclave_id_t eid, uint64_t id, const uint8_t* path, size_t len); +sgx_status_t t_global_exit_ecall(sgx_enclave_id_t eid); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/rust-sgx-workspace/projects/ntc-tee-server/app/codegen/Enclave_u.rs b/rust-sgx-workspace/projects/ntc-tee-server/app/codegen/Enclave_u.rs new file mode 100644 index 0000000..06883f4 --- /dev/null +++ b/rust-sgx-workspace/projects/ntc-tee-server/app/codegen/Enclave_u.rs @@ -0,0 +1,12 @@ +/* automatically generated by rust-bindgen 0.59.1 */ + +use sgx_types::*; + +extern "C" { + pub fn ecall_test( + eid: sgx_enclave_id_t, + retval: *mut sgx_status_t, + some_string: *const u8, + len: size_t, + ) -> sgx_status_t; +} diff --git a/rust-sgx-workspace/projects/ntc-tee-server/app/src/main.rs b/rust-sgx-workspace/projects/ntc-tee-server/app/src/main.rs new file mode 100644 index 0000000..1b3d152 --- /dev/null +++ b/rust-sgx-workspace/projects/ntc-tee-server/app/src/main.rs @@ -0,0 +1,74 @@ +extern crate sgx_types; +extern crate sgx_urts; + +#[path = "../codegen/Enclave_u.rs"] +mod enclave_u; + +use enclave_u::ecall_test; +use sgx_types::{ + sgx_attributes_t, + sgx_launch_token_t, + sgx_misc_attribute_t, + sgx_status_t, + SgxResult, +}; +use sgx_urts::SgxEnclave; + +static ENCLAVE_FILE: &str = "enclave.signed.so"; + +fn init_enclave() -> SgxResult { + let mut launch_token: sgx_launch_token_t = [0; 1024]; + let mut launch_token_updated: i32 = 0; + // call sgx_create_enclave to initialize an enclave instance + // Debug Support: set 2nd parameter to 1 + let debug = 1; + let mut misc_attr = sgx_misc_attribute_t { + secs_attr: sgx_attributes_t { flags: 0, xfrm: 0 }, + misc_select: 0, + }; + SgxEnclave::create( + ENCLAVE_FILE, + debug, + &mut launch_token, + &mut launch_token_updated, + &mut misc_attr, + ) +} + +fn main() { + let enclave = match init_enclave() { + Ok(r) => { + println!("[+] Init Enclave Successful {}!", r.geteid()); + r + } + Err(x) => { + println!("[-] Init Enclave Failed {}!", x.as_str()); + return; + } + }; + + let input_string = String::from("Sending this string to the enclave then printing it\n"); + + let mut retval = sgx_status_t::SGX_SUCCESS; + + let result = unsafe { + ecall_test( + enclave.geteid(), + &mut retval, + input_string.as_ptr() as *const u8, + input_string.len(), + ) + }; + + match result { + sgx_status_t::SGX_SUCCESS => {} + _ => { + println!("[-] ECALL Enclave Failed {}!", result.as_str()); + return; + } + } + + println!("[+] ecall_test success..."); + + enclave.destroy(); +} diff --git a/rust-sgx-workspace/projects/ntc-tee-server/buildenv.mk b/rust-sgx-workspace/projects/ntc-tee-server/buildenv.mk new file mode 100644 index 0000000..a86675e --- /dev/null +++ b/rust-sgx-workspace/projects/ntc-tee-server/buildenv.mk @@ -0,0 +1,167 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License.. +# +# + +CP := /bin/cp -f +MKDIR := mkdir -p +STRIP := strip +OBJCOPY := objcopy + +# clean the content of 'INCLUDE' - this variable will be set by vcvars32.bat +# thus it will cause build error when this variable is used by our Makefile, +# when compiling the code under Cygwin tainted by MSVC environment settings. +INCLUDE := + +# turn on stack protector for SDK +COMMON_FLAGS += -fstack-protector + +ifdef DEBUG + COMMON_FLAGS += -O0 -g -DDEBUG -UNDEBUG +else + COMMON_FLAGS += -O2 -D_FORTIFY_SOURCE=2 -UDEBUG -DNDEBUG +endif + +# turn on compiler warnings as much as possible +COMMON_FLAGS += -Wall -Wextra -Winit-self -Wpointer-arith -Wreturn-type \ + -Waddress -Wsequence-point -Wformat-security \ + -Wmissing-include-dirs -Wfloat-equal -Wundef -Wshadow \ + -Wcast-align -Wconversion -Wredundant-decls + +# additional warnings flags for C +CFLAGS += -Wjump-misses-init -Wstrict-prototypes -Wunsuffixed-float-constants + +# additional warnings flags for C++ +CXXFLAGS += -Wnon-virtual-dtor + +# for static_assert() +CXXFLAGS += -std=c++0x + +.DEFAULT_GOAL := all +# this turns off the RCS / SCCS implicit rules of GNU Make +% : RCS/%,v +% : RCS/% +% : %,v +% : s.% +% : SCCS/s.% + +# If a rule fails, delete $@. +.DELETE_ON_ERROR: + +HOST_FILE_PROGRAM := file + +UNAME := $(shell uname -m) +ifneq (,$(findstring 86,$(UNAME))) + HOST_ARCH := x86 + ifneq (,$(shell $(HOST_FILE_PROGRAM) -L $(SHELL) | grep 'x86[_-]64')) + HOST_ARCH := x86_64 + endif +else + $(info Unknown host CPU arhitecture $(UNAME)) + $(error Aborting) +endif + + +ifeq "$(findstring __INTEL_COMPILER, $(shell $(CC) -E -dM -xc /dev/null))" "__INTEL_COMPILER" + ifeq ($(shell test -f /usr/bin/dpkg; echo $$?), 0) + ADDED_INC := -I /usr/include/$(shell dpkg-architecture -qDEB_BUILD_MULTIARCH) + endif +endif + +ARCH := $(HOST_ARCH) +ifeq "$(findstring -m32, $(CXXFLAGS))" "-m32" + ARCH := x86 +endif + +ifeq ($(ARCH), x86) +COMMON_FLAGS += -DITT_ARCH_IA32 +else +COMMON_FLAGS += -DITT_ARCH_IA64 +endif + +CFLAGS += $(COMMON_FLAGS) +CXXFLAGS += $(COMMON_FLAGS) + +# Enable the security flags +COMMON_LDFLAGS := -Wl,-z,relro,-z,now,-z,noexecstack + +# mitigation options +MITIGATION_INDIRECT ?= 0 +MITIGATION_RET ?= 0 +MITIGATION_C ?= 0 +MITIGATION_ASM ?= 0 +MITIGATION_AFTERLOAD ?= 0 +MITIGATION_LIB_PATH := + +ifeq ($(MITIGATION-CVE-2020-0551), LOAD) + MITIGATION_C := 1 + MITIGATION_ASM := 1 + MITIGATION_INDIRECT := 1 + MITIGATION_RET := 1 + MITIGATION_AFTERLOAD := 1 + MITIGATION_LIB_PATH := cve_2020_0551_load +else ifeq ($(MITIGATION-CVE-2020-0551), CF) + MITIGATION_C := 1 + MITIGATION_ASM := 1 + MITIGATION_INDIRECT := 1 + MITIGATION_RET := 1 + MITIGATION_AFTERLOAD := 0 + MITIGATION_LIB_PATH := cve_2020_0551_cf +endif + +MITIGATION_CFLAGS := +MITIGATION_ASFLAGS := +ifeq ($(MITIGATION_C), 1) +ifeq ($(MITIGATION_INDIRECT), 1) + MITIGATION_CFLAGS += -mindirect-branch-register +endif +ifeq ($(MITIGATION_RET), 1) + MITIGATION_CFLAGS += -mfunction-return=thunk-extern +endif +endif + +ifeq ($(MITIGATION_ASM), 1) + MITIGATION_ASFLAGS += -fno-plt +ifeq ($(MITIGATION_AFTERLOAD), 1) + MITIGATION_ASFLAGS += -Wa,-mlfence-after-load=yes +else + MITIGATION_ASFLAGS += -Wa,-mlfence-before-indirect-branch=register +endif +ifeq ($(MITIGATION_RET), 1) + MITIGATION_ASFLAGS += -Wa,-mlfence-before-ret=not +endif +endif + +MITIGATION_CFLAGS += $(MITIGATION_ASFLAGS) + +# Compiler and linker options for an Enclave +# +# We are using '--export-dynamic' so that `g_global_data_sim' etc. +# will be exported to dynamic symbol table. +# +# When `pie' is enabled, the linker (both BFD and Gold) under Ubuntu 14.04 +# will hide all symbols from dynamic symbol table even if they are marked +# as `global' in the LD version script. +ENCLAVE_CFLAGS = -ffreestanding -nostdinc -fvisibility=hidden -fpie -fno-strict-overflow -fno-delete-null-pointer-checks +ENCLAVE_CXXFLAGS = $(ENCLAVE_CFLAGS) -nostdinc++ +ENCLAVE_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined \ + -Wl,-pie,-eenclave_entry -Wl,--export-dynamic \ + -Wl,--gc-sections \ + -Wl,--defsym,__ImageBase=0 + +ENCLAVE_CFLAGS += $(MITIGATION_CFLAGS) +ENCLAVE_ASFLAGS = $(MITIGATION_ASFLAGS) \ No newline at end of file diff --git a/rust-sgx-workspace/projects/ntc-tee-server/buildenv_sgx.mk b/rust-sgx-workspace/projects/ntc-tee-server/buildenv_sgx.mk new file mode 100644 index 0000000..4ec0119 --- /dev/null +++ b/rust-sgx-workspace/projects/ntc-tee-server/buildenv_sgx.mk @@ -0,0 +1,49 @@ +SGX_SDK ?= /opt/sgxsdk + +# Directly imported from the original Intel SGX samples, helpful to detect the system architecture + +ifeq ($(shell getconf LONG_BIT), 32) + SGX_ARCH := x86 +else ifeq ($(findstring -m32, $(CXXFLAGS)), -m32) + SGX_ARCH := x86 +endif + +ifeq ($(SGX_ARCH), x86) + SGX_COMMON_CFLAGS := -m32 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x86/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x86/sgx_edger8r +else + SGX_COMMON_CFLAGS := -m64 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib64 + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x64/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x64/sgx_edger8r +endif + +# If specified, software / simulation mode. Otherwise, hardware mode no matter what. + +ifeq ($(SGX_MODE), SW) + TRTS_LIB := sgx_trts_sim + SERVICE_LIB := sgx_tservice_sim +endif + +# If debug mode, we can set up extra options such as the debug flags + +ifeq ($(SGX_DEBUG), 1) + SGX_COMMON_CFLAGS += -O0 -g +else + SGX_COMMON_CFLAGS += -O2 +endif + +# Show helpful error messages if main environment variables are not set. + +$(SGX_EDGER8R): + $(error "$@" does not exist. (Is SGX_SDK set correctly?)) + +ifndef CUSTOM_EDL_PATH +$(error CUSTOM_EDL_PATH not set) +endif + +ifndef CUSTOM_COMMON_PATH +$(error CUSTOM_COMMON_PATH not set) +endif diff --git a/rust-sgx-workspace/projects/ntc-tee-server/enclave/.gitignore b/rust-sgx-workspace/projects/ntc-tee-server/enclave/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/rust-sgx-workspace/projects/ntc-tee-server/enclave/.gitignore @@ -0,0 +1 @@ +/target diff --git a/rust-sgx-workspace/projects/ntc-tee-server/enclave/Cargo.toml b/rust-sgx-workspace/projects/ntc-tee-server/enclave/Cargo.toml new file mode 100644 index 0000000..70772aa --- /dev/null +++ b/rust-sgx-workspace/projects/ntc-tee-server/enclave/Cargo.toml @@ -0,0 +1,16 @@ +[package] +# name matches ENCLAVE_CARGO_LIB in Makefile +name = "ntc-tee-server-enclave" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["staticlib"] +test = false + +[features] +default = [] + +[dependencies] +sgx_types = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk" } +sgx_tstd = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", features = ["backtrace"] } diff --git a/rust-sgx-workspace/projects/ntc-tee-server/enclave/Enclave.config.xml b/rust-sgx-workspace/projects/ntc-tee-server/enclave/Enclave.config.xml new file mode 100644 index 0000000..ee4c3f7 --- /dev/null +++ b/rust-sgx-workspace/projects/ntc-tee-server/enclave/Enclave.config.xml @@ -0,0 +1,12 @@ + + + 0 + 0 + 0x40000 + 0x100000 + 1 + 1 + 0 + 0 + 0xFFFFFFFF + diff --git a/rust-sgx-workspace/projects/ntc-tee-server/enclave/Enclave.edl b/rust-sgx-workspace/projects/ntc-tee-server/enclave/Enclave.edl new file mode 100644 index 0000000..740d877 --- /dev/null +++ b/rust-sgx-workspace/projects/ntc-tee-server/enclave/Enclave.edl @@ -0,0 +1,11 @@ +enclave { + from "sgx_tstd.edl" import *; + from "sgx_backtrace.edl" import *; + trusted + { + public sgx_status_t ecall_test([in, size=len] const uint8_t* some_string, size_t len); + }; + untrusted + { + }; +}; diff --git a/rust-sgx-workspace/projects/ntc-tee-server/enclave/Enclave.lds b/rust-sgx-workspace/projects/ntc-tee-server/enclave/Enclave.lds new file mode 100644 index 0000000..e3d9d0e --- /dev/null +++ b/rust-sgx-workspace/projects/ntc-tee-server/enclave/Enclave.lds @@ -0,0 +1,9 @@ +enclave.so +{ + global: + g_global_data_sim; + g_global_data; + enclave_entry; + local: + *; +}; diff --git a/rust-sgx-workspace/projects/ntc-tee-server/enclave/Makefile b/rust-sgx-workspace/projects/ntc-tee-server/enclave/Makefile new file mode 100644 index 0000000..439358a --- /dev/null +++ b/rust-sgx-workspace/projects/ntc-tee-server/enclave/Makefile @@ -0,0 +1,118 @@ +# Makefile settings + +APP_T_SIGNED = enclave.signed.so +KEYS = ../keys +LIB = ../build/lib/ +BIN = ../build/bin/ +APP_T = enclave.so +NAME_T = libenclave.a +SRC_U = ../app/ +SRC_T = ./ +CODEGEN_T = $(SRC_T)/codegen/ +OBJ_T = ../build/obj/ +FLAGS = -Wall -Wextra +GCC_STEP1_T = -fstack-protector -I$(CUSTOM_COMMON_PATH)/inc -I$(CUSTOM_EDL_PATH) -I$(SGX_SDK)/include \ + -I$(SGX_SDK)/include/tlibc -I$(SGX_SDK)/include/stlport -I$(SGX_SDK)/include/epid -I $(CODEGEN_T) \ + -L$(LIB) $(ENCLAVE_CFLAGS) $(SGX_COMMON_CFLAGS) +GCC_STEP2_T = -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L$(SGX_LIBRARY_PATH) \ + -Wl,--whole-archive -l$(TRTS_LIB) -Wl,--no-whole-archive \ + -Wl,--start-group -lsgx_tstdc -l$(SERVICE_LIB) -lsgx_tcrypto -L$(LIB) -lenclave -Wl,--end-group \ + -Wl,--version-script=$(SRC_T)Enclave.lds $(ENCLAVE_LDFLAGS) +FILES_T = Enclave_t.c +FILES_T_H = Enclave_t.h +EDL_FILE = Enclave.edl +ENCLAVE_CONFIG = Enclave.config.xml +SGX_ARCH = x64 +TRTS_LIB = sgx_trts +SERVICE_LIB = sgx_tservice +# ENCLAVE_CARGO_LIB matches name in Cargo.toml +ENCLAVE_CARGO_LIB=libntc_tee_server_enclave.a +# Addprefix dependant variables, no need to change those +OUTPUT_T = $(FILES_T:.c=.o) +NAME = $(addprefix $(BIN), $(APP_T_SIGNED)) +BIN_T = $(addprefix $(BIN), $(APP_T)) +NAME_T_D = $(addprefix $(LIB), $(NAME_T)) +OUTPUT_W_FU=$(addprefix $(OBJ_U), $(OUTPUT_U)) +FILES_T_F=$(addprefix $(CODEGEN_T), $(FILES_T)) +FILES_T_H_F=$(addprefix $(CODEGEN_T), $(FILES_T_H)) +FILES_T_F_RUST=$(addprefix $(SRC_T), $(FILES_T_RUST)) +OUTPUT_W_FT=$(addprefix $(OBJ_T), $(OUTPUT_T)) + +# All Rust and other source files that the Cargo build depends on. +FILES_RUST_F = Cargo.toml ../../../Cargo.lock $(shell find src -name '*.rs') + +# Contains compilation rules for the enclave part + +include ../buildenv.mk +include ../buildenv_sgx.mk + +# Custom header files and EDL paths needs to be specified with make (CUSTOM_EDL_PATH) (CUSTOM_COMMON_PATH) + +ifeq ($(MITIGATION-CVE-2020-0551), LOAD) +export MITIGATION_CVE_2020_0551=LOAD +else ifeq ($(MITIGATION-CVE-2020-0551), CF) +export MITIGATION_CVE_2020_0551=CF +endif + +# Compilation process, we set up all the dependencies needed to have the correct order of build, and avoid relink + +all: $(NAME) + +# We print the compilation mode we're in (hardware/software mode), just as a reminder. + +$(NAME): $(BIN_T) $(KEYS)/Enclave_private.pem +ifeq ($(SGX_MODE), SW) + @echo "\033[32mSoftware / Simulation mode\033[0m" +else + @echo "\033[32mHardware mode\033[0m" +endif + @echo "\033[32mSigning the enclave...\033[0m" + @mkdir -p $(BIN) + @$(SGX_ENCLAVE_SIGNER) sign -key $(KEYS)/Enclave_private.pem -enclave $(BIN_T) -out $@ -config $(SRC_T)Enclave.config.xml + +$(KEYS)/Enclave_private.pem $(KEYS)/Enclave_public.pem: + @echo "\033[32mGenerating keys...\033[0m" + @mkdir -p $(KEYS) + @openssl genrsa -out $(KEYS)/Enclave_private.pem -3 3072 + @openssl rsa -in $(KEYS)/Enclave_private.pem -pubout -out $(KEYS)/Enclave_public.pem + +$(BIN_T): $(NAME_T_D) + @echo "\033[32mBuilding the enclave...\033[0m" + @mkdir -p $(BIN) + @$(CXX) $(OUTPUT_W_FT) -o $@ $(GCC_STEP2_T) + +$(NAME_T_D): $(FILES_T_F) $(OUTPUT_W_FT) $(FILES_RUST_F) $(EDL_FILE) $(ENCLAVE_CONFIG) # We added as a reference the rust files, along with the EDL, the XML config file and the cargo.toml file, so Make can detect if any change was made + @echo "\033[32mBuilding enclave static library with Cargo...\033[0m" + @cargo build --release + @cp ../../../target/release/$(ENCLAVE_CARGO_LIB) $(LIB)libenclave.a + +$(FILES_T_F): $(SGX_EDGER8R) $(SRC_T)/Enclave.edl + @echo "\033[32mGenerating trusted SGX C edl files...\033[0m" + @$(SGX_EDGER8R) --trusted $(SRC_T)/Enclave.edl --search-path $(SGX_SDK)/include --search-path $(CUSTOM_EDL_PATH) --trusted-dir $(CODEGEN_T) + +$(OBJ_T)%.o:$(CODEGEN_T)%.c + @mkdir -p $(OBJ_T) + @echo "\033[32m$?: Build in progress...\033[0m" + @$(CC) $(FLAGS) $(GCC_STEP1_T) -o $@ -c $? + +clean: c_clean + @rm -rf $(OBJ_T) + @echo "\033[32mObject files deleted\033[0m" + +fclean: clean fclean_enclave + +fclean_enclave: + @echo "\033[32mBinary file $(NAME) deleted\033[0m" + @rm -f $(NAME) + @rm -f $(BIN_T) + @rm -f $(LIB)libenclave.a + @cargo clean + +c_clean: + @echo "\033[32mC edl generated files deleted\033[0m" + @rm -rf $(FILES_T_F) + @rm -f $(FILES_T_H_F) + +re: fclean all + +.PHONY: all clean c_clean fclean re fclean_enclave diff --git a/rust-sgx-workspace/projects/ntc-tee-server/enclave/codegen/Enclave_t.c b/rust-sgx-workspace/projects/ntc-tee-server/enclave/codegen/Enclave_t.c new file mode 100644 index 0000000..04ac8fb --- /dev/null +++ b/rust-sgx-workspace/projects/ntc-tee-server/enclave/codegen/Enclave_t.c @@ -0,0 +1,4554 @@ +#include "Enclave_t.h" + +#include "sgx_trts.h" /* for sgx_ocalloc, sgx_is_outside_enclave */ +#include "sgx_lfence.h" /* for sgx_lfence */ + +#include +#include /* for memcpy_s etc */ +#include /* for malloc/free etc */ + +#define CHECK_REF_POINTER(ptr, siz) do { \ + if (!(ptr) || ! sgx_is_outside_enclave((ptr), (siz))) \ + return SGX_ERROR_INVALID_PARAMETER;\ +} while (0) + +#define CHECK_UNIQUE_POINTER(ptr, siz) do { \ + if ((ptr) && ! sgx_is_outside_enclave((ptr), (siz))) \ + return SGX_ERROR_INVALID_PARAMETER;\ +} while (0) + +#define CHECK_ENCLAVE_POINTER(ptr, siz) do { \ + if ((ptr) && ! sgx_is_within_enclave((ptr), (siz))) \ + return SGX_ERROR_INVALID_PARAMETER;\ +} while (0) + +#define ADD_ASSIGN_OVERFLOW(a, b) ( \ + ((a) += (b)) < (b) \ +) + + +typedef struct ms_ecall_test_t { + sgx_status_t ms_retval; + const uint8_t* ms_some_string; + size_t ms_len; +} ms_ecall_test_t; + +typedef struct ms_t_global_init_ecall_t { + uint64_t ms_id; + const uint8_t* ms_path; + size_t ms_len; +} ms_t_global_init_ecall_t; + +typedef struct ms_u_thread_set_event_ocall_t { + int ms_retval; + int* ms_error; + const void* ms_tcs; +} ms_u_thread_set_event_ocall_t; + +typedef struct ms_u_thread_wait_event_ocall_t { + int ms_retval; + int* ms_error; + const void* ms_tcs; + const struct timespec* ms_timeout; +} ms_u_thread_wait_event_ocall_t; + +typedef struct ms_u_thread_set_multiple_events_ocall_t { + int ms_retval; + int* ms_error; + const void** ms_tcss; + int ms_total; +} ms_u_thread_set_multiple_events_ocall_t; + +typedef struct ms_u_thread_setwait_events_ocall_t { + int ms_retval; + int* ms_error; + const void* ms_waiter_tcs; + const void* ms_self_tcs; + const struct timespec* ms_timeout; +} ms_u_thread_setwait_events_ocall_t; + +typedef struct ms_u_clock_gettime_ocall_t { + int ms_retval; + int* ms_error; + int ms_clk_id; + struct timespec* ms_tp; +} ms_u_clock_gettime_ocall_t; + +typedef struct ms_u_read_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + void* ms_buf; + size_t ms_count; +} ms_u_read_ocall_t; + +typedef struct ms_u_pread64_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + void* ms_buf; + size_t ms_count; + int64_t ms_offset; +} ms_u_pread64_ocall_t; + +typedef struct ms_u_readv_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const struct iovec* ms_iov; + int ms_iovcnt; +} ms_u_readv_ocall_t; + +typedef struct ms_u_preadv64_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const struct iovec* ms_iov; + int ms_iovcnt; + int64_t ms_offset; +} ms_u_preadv64_ocall_t; + +typedef struct ms_u_write_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const void* ms_buf; + size_t ms_count; +} ms_u_write_ocall_t; + +typedef struct ms_u_pwrite64_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const void* ms_buf; + size_t ms_count; + int64_t ms_offset; +} ms_u_pwrite64_ocall_t; + +typedef struct ms_u_writev_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const struct iovec* ms_iov; + int ms_iovcnt; +} ms_u_writev_ocall_t; + +typedef struct ms_u_pwritev64_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const struct iovec* ms_iov; + int ms_iovcnt; + int64_t ms_offset; +} ms_u_pwritev64_ocall_t; + +typedef struct ms_u_fcntl_arg0_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int ms_cmd; +} ms_u_fcntl_arg0_ocall_t; + +typedef struct ms_u_fcntl_arg1_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int ms_cmd; + int ms_arg; +} ms_u_fcntl_arg1_ocall_t; + +typedef struct ms_u_ioctl_arg0_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int ms_request; +} ms_u_ioctl_arg0_ocall_t; + +typedef struct ms_u_ioctl_arg1_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int ms_request; + int* ms_arg; +} ms_u_ioctl_arg1_ocall_t; + +typedef struct ms_u_close_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; +} ms_u_close_ocall_t; + +typedef struct ms_u_malloc_ocall_t { + void* ms_retval; + int* ms_error; + size_t ms_size; +} ms_u_malloc_ocall_t; + +typedef struct ms_u_free_ocall_t { + void* ms_p; +} ms_u_free_ocall_t; + +typedef struct ms_u_mmap_ocall_t { + void* ms_retval; + int* ms_error; + void* ms_start; + size_t ms_length; + int ms_prot; + int ms_flags; + int ms_fd; + int64_t ms_offset; +} ms_u_mmap_ocall_t; + +typedef struct ms_u_munmap_ocall_t { + int ms_retval; + int* ms_error; + void* ms_start; + size_t ms_length; +} ms_u_munmap_ocall_t; + +typedef struct ms_u_msync_ocall_t { + int ms_retval; + int* ms_error; + void* ms_addr; + size_t ms_length; + int ms_flags; +} ms_u_msync_ocall_t; + +typedef struct ms_u_mprotect_ocall_t { + int ms_retval; + int* ms_error; + void* ms_addr; + size_t ms_length; + int ms_prot; +} ms_u_mprotect_ocall_t; + +typedef struct ms_u_open_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_pathname; + int ms_flags; +} ms_u_open_ocall_t; + +typedef struct ms_u_open64_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + int ms_oflag; + int ms_mode; +} ms_u_open64_ocall_t; + +typedef struct ms_u_fstat_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + struct stat_t* ms_buf; +} ms_u_fstat_ocall_t; + +typedef struct ms_u_fstat64_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + struct stat64_t* ms_buf; +} ms_u_fstat64_ocall_t; + +typedef struct ms_u_stat_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + struct stat_t* ms_buf; +} ms_u_stat_ocall_t; + +typedef struct ms_u_stat64_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + struct stat64_t* ms_buf; +} ms_u_stat64_ocall_t; + +typedef struct ms_u_lstat_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + struct stat_t* ms_buf; +} ms_u_lstat_ocall_t; + +typedef struct ms_u_lstat64_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + struct stat64_t* ms_buf; +} ms_u_lstat64_ocall_t; + +typedef struct ms_u_lseek_ocall_t { + uint64_t ms_retval; + int* ms_error; + int ms_fd; + int64_t ms_offset; + int ms_whence; +} ms_u_lseek_ocall_t; + +typedef struct ms_u_lseek64_ocall_t { + int64_t ms_retval; + int* ms_error; + int ms_fd; + int64_t ms_offset; + int ms_whence; +} ms_u_lseek64_ocall_t; + +typedef struct ms_u_ftruncate_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int64_t ms_length; +} ms_u_ftruncate_ocall_t; + +typedef struct ms_u_ftruncate64_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int64_t ms_length; +} ms_u_ftruncate64_ocall_t; + +typedef struct ms_u_truncate_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + int64_t ms_length; +} ms_u_truncate_ocall_t; + +typedef struct ms_u_truncate64_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + int64_t ms_length; +} ms_u_truncate64_ocall_t; + +typedef struct ms_u_fsync_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; +} ms_u_fsync_ocall_t; + +typedef struct ms_u_fdatasync_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; +} ms_u_fdatasync_ocall_t; + +typedef struct ms_u_fchmod_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + uint32_t ms_mode; +} ms_u_fchmod_ocall_t; + +typedef struct ms_u_unlink_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_pathname; +} ms_u_unlink_ocall_t; + +typedef struct ms_u_link_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_oldpath; + const char* ms_newpath; +} ms_u_link_ocall_t; + +typedef struct ms_u_linkat_ocall_t { + int ms_retval; + int* ms_error; + int ms_olddirfd; + const char* ms_oldpath; + int ms_newdirfd; + const char* ms_newpath; + int ms_flags; +} ms_u_linkat_ocall_t; + +typedef struct ms_u_rename_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_oldpath; + const char* ms_newpath; +} ms_u_rename_ocall_t; + +typedef struct ms_u_chmod_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + uint32_t ms_mode; +} ms_u_chmod_ocall_t; + +typedef struct ms_u_readlink_ocall_t { + size_t ms_retval; + int* ms_error; + const char* ms_path; + char* ms_buf; + size_t ms_bufsz; +} ms_u_readlink_ocall_t; + +typedef struct ms_u_symlink_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path1; + const char* ms_path2; +} ms_u_symlink_ocall_t; + +typedef struct ms_u_realpath_ocall_t { + char* ms_retval; + int* ms_error; + const char* ms_pathname; +} ms_u_realpath_ocall_t; + +typedef struct ms_u_mkdir_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_pathname; + uint32_t ms_mode; +} ms_u_mkdir_ocall_t; + +typedef struct ms_u_rmdir_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_pathname; +} ms_u_rmdir_ocall_t; + +typedef struct ms_u_opendir_ocall_t { + void* ms_retval; + int* ms_error; + const char* ms_pathname; +} ms_u_opendir_ocall_t; + +typedef struct ms_u_readdir64_r_ocall_t { + int ms_retval; + void* ms_dirp; + struct dirent64_t* ms_entry; + struct dirent64_t** ms_result; +} ms_u_readdir64_r_ocall_t; + +typedef struct ms_u_closedir_ocall_t { + int ms_retval; + int* ms_error; + void* ms_dirp; +} ms_u_closedir_ocall_t; + +typedef struct ms_u_dirfd_ocall_t { + int ms_retval; + int* ms_error; + void* ms_dirp; +} ms_u_dirfd_ocall_t; + +typedef struct ms_u_fstatat64_ocall_t { + int ms_retval; + int* ms_error; + int ms_dirfd; + const char* ms_pathname; + struct stat64_t* ms_buf; + int ms_flags; +} ms_u_fstatat64_ocall_t; + +static sgx_status_t SGX_CDECL sgx_ecall_test(void* pms) +{ + CHECK_REF_POINTER(pms, sizeof(ms_ecall_test_t)); + // + // fence after pointer checks + // + sgx_lfence(); + ms_ecall_test_t* ms = SGX_CAST(ms_ecall_test_t*, pms); + sgx_status_t status = SGX_SUCCESS; + const uint8_t* _tmp_some_string = ms->ms_some_string; + size_t _tmp_len = ms->ms_len; + size_t _len_some_string = _tmp_len; + uint8_t* _in_some_string = NULL; + + CHECK_UNIQUE_POINTER(_tmp_some_string, _len_some_string); + + // + // fence after pointer checks + // + sgx_lfence(); + + if (_tmp_some_string != NULL && _len_some_string != 0) { + if ( _len_some_string % sizeof(*_tmp_some_string) != 0) + { + status = SGX_ERROR_INVALID_PARAMETER; + goto err; + } + _in_some_string = (uint8_t*)malloc(_len_some_string); + if (_in_some_string == NULL) { + status = SGX_ERROR_OUT_OF_MEMORY; + goto err; + } + + if (memcpy_s(_in_some_string, _len_some_string, _tmp_some_string, _len_some_string)) { + status = SGX_ERROR_UNEXPECTED; + goto err; + } + + } + + ms->ms_retval = ecall_test((const uint8_t*)_in_some_string, _tmp_len); + +err: + if (_in_some_string) free(_in_some_string); + return status; +} + +static sgx_status_t SGX_CDECL sgx_t_global_init_ecall(void* pms) +{ + CHECK_REF_POINTER(pms, sizeof(ms_t_global_init_ecall_t)); + // + // fence after pointer checks + // + sgx_lfence(); + ms_t_global_init_ecall_t* ms = SGX_CAST(ms_t_global_init_ecall_t*, pms); + sgx_status_t status = SGX_SUCCESS; + const uint8_t* _tmp_path = ms->ms_path; + size_t _tmp_len = ms->ms_len; + size_t _len_path = _tmp_len; + uint8_t* _in_path = NULL; + + CHECK_UNIQUE_POINTER(_tmp_path, _len_path); + + // + // fence after pointer checks + // + sgx_lfence(); + + if (_tmp_path != NULL && _len_path != 0) { + if ( _len_path % sizeof(*_tmp_path) != 0) + { + status = SGX_ERROR_INVALID_PARAMETER; + goto err; + } + _in_path = (uint8_t*)malloc(_len_path); + if (_in_path == NULL) { + status = SGX_ERROR_OUT_OF_MEMORY; + goto err; + } + + if (memcpy_s(_in_path, _len_path, _tmp_path, _len_path)) { + status = SGX_ERROR_UNEXPECTED; + goto err; + } + + } + + t_global_init_ecall(ms->ms_id, (const uint8_t*)_in_path, _tmp_len); + +err: + if (_in_path) free(_in_path); + return status; +} + +static sgx_status_t SGX_CDECL sgx_t_global_exit_ecall(void* pms) +{ + sgx_status_t status = SGX_SUCCESS; + if (pms != NULL) return SGX_ERROR_INVALID_PARAMETER; + t_global_exit_ecall(); + return status; +} + +SGX_EXTERNC const struct { + size_t nr_ecall; + struct {void* ecall_addr; uint8_t is_priv; uint8_t is_switchless;} ecall_table[3]; +} g_ecall_table = { + 3, + { + {(void*)(uintptr_t)sgx_ecall_test, 0, 0}, + {(void*)(uintptr_t)sgx_t_global_init_ecall, 0, 0}, + {(void*)(uintptr_t)sgx_t_global_exit_ecall, 0, 0}, + } +}; + +SGX_EXTERNC const struct { + size_t nr_ocall; + uint8_t entry_table[56][3]; +} g_dyn_entry_table = { + 56, + { + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + } +}; + + +sgx_status_t SGX_CDECL u_thread_set_event_ocall(int* retval, int* error, const void* tcs) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_thread_set_event_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_thread_set_event_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_thread_set_event_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_thread_set_event_ocall_t)); + ocalloc_size -= sizeof(ms_u_thread_set_event_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_tcs = tcs; + status = sgx_ocall(0, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_thread_wait_event_ocall(int* retval, int* error, const void* tcs, const struct timespec* timeout) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_timeout = sizeof(struct timespec); + + ms_u_thread_wait_event_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_thread_wait_event_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(timeout, _len_timeout); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (timeout != NULL) ? _len_timeout : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_thread_wait_event_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_thread_wait_event_ocall_t)); + ocalloc_size -= sizeof(ms_u_thread_wait_event_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_tcs = tcs; + if (timeout != NULL) { + ms->ms_timeout = (const struct timespec*)__tmp; + if (memcpy_s(__tmp, ocalloc_size, timeout, _len_timeout)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_timeout); + ocalloc_size -= _len_timeout; + } else { + ms->ms_timeout = NULL; + } + + status = sgx_ocall(1, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_thread_set_multiple_events_ocall(int* retval, int* error, const void** tcss, int total) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_tcss = total * sizeof(void*); + + ms_u_thread_set_multiple_events_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_thread_set_multiple_events_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(tcss, _len_tcss); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (tcss != NULL) ? _len_tcss : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_thread_set_multiple_events_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_thread_set_multiple_events_ocall_t)); + ocalloc_size -= sizeof(ms_u_thread_set_multiple_events_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (tcss != NULL) { + ms->ms_tcss = (const void**)__tmp; + if (_len_tcss % sizeof(*tcss) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, tcss, _len_tcss)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_tcss); + ocalloc_size -= _len_tcss; + } else { + ms->ms_tcss = NULL; + } + + ms->ms_total = total; + status = sgx_ocall(2, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_thread_setwait_events_ocall(int* retval, int* error, const void* waiter_tcs, const void* self_tcs, const struct timespec* timeout) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_timeout = sizeof(struct timespec); + + ms_u_thread_setwait_events_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_thread_setwait_events_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(timeout, _len_timeout); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (timeout != NULL) ? _len_timeout : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_thread_setwait_events_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_thread_setwait_events_ocall_t)); + ocalloc_size -= sizeof(ms_u_thread_setwait_events_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_waiter_tcs = waiter_tcs; + ms->ms_self_tcs = self_tcs; + if (timeout != NULL) { + ms->ms_timeout = (const struct timespec*)__tmp; + if (memcpy_s(__tmp, ocalloc_size, timeout, _len_timeout)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_timeout); + ocalloc_size -= _len_timeout; + } else { + ms->ms_timeout = NULL; + } + + status = sgx_ocall(3, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_clock_gettime_ocall(int* retval, int* error, int clk_id, struct timespec* tp) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_tp = sizeof(struct timespec); + + ms_u_clock_gettime_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_clock_gettime_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_tp = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(tp, _len_tp); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (tp != NULL) ? _len_tp : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_clock_gettime_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_clock_gettime_ocall_t)); + ocalloc_size -= sizeof(ms_u_clock_gettime_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_clk_id = clk_id; + if (tp != NULL) { + ms->ms_tp = (struct timespec*)__tmp; + __tmp_tp = __tmp; + memset(__tmp_tp, 0, _len_tp); + __tmp = (void *)((size_t)__tmp + _len_tp); + ocalloc_size -= _len_tp; + } else { + ms->ms_tp = NULL; + } + + status = sgx_ocall(4, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (tp) { + if (memcpy_s((void*)tp, _len_tp, __tmp_tp, _len_tp)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_read_ocall(size_t* retval, int* error, int fd, void* buf, size_t count) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_read_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_read_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_read_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_read_ocall_t)); + ocalloc_size -= sizeof(ms_u_read_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_buf = buf; + ms->ms_count = count; + status = sgx_ocall(5, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_pread64_ocall(size_t* retval, int* error, int fd, void* buf, size_t count, int64_t offset) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_pread64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_pread64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_pread64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_pread64_ocall_t)); + ocalloc_size -= sizeof(ms_u_pread64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_buf = buf; + ms->ms_count = count; + ms->ms_offset = offset; + status = sgx_ocall(6, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_readv_ocall(size_t* retval, int* error, int fd, const struct iovec* iov, int iovcnt) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_iov = iovcnt * sizeof(struct iovec); + + ms_u_readv_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_readv_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(iov, _len_iov); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (iov != NULL) ? _len_iov : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_readv_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_readv_ocall_t)); + ocalloc_size -= sizeof(ms_u_readv_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + if (iov != NULL) { + ms->ms_iov = (const struct iovec*)__tmp; + if (memcpy_s(__tmp, ocalloc_size, iov, _len_iov)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_iov); + ocalloc_size -= _len_iov; + } else { + ms->ms_iov = NULL; + } + + ms->ms_iovcnt = iovcnt; + status = sgx_ocall(7, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_preadv64_ocall(size_t* retval, int* error, int fd, const struct iovec* iov, int iovcnt, int64_t offset) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_iov = iovcnt * sizeof(struct iovec); + + ms_u_preadv64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_preadv64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(iov, _len_iov); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (iov != NULL) ? _len_iov : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_preadv64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_preadv64_ocall_t)); + ocalloc_size -= sizeof(ms_u_preadv64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + if (iov != NULL) { + ms->ms_iov = (const struct iovec*)__tmp; + if (memcpy_s(__tmp, ocalloc_size, iov, _len_iov)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_iov); + ocalloc_size -= _len_iov; + } else { + ms->ms_iov = NULL; + } + + ms->ms_iovcnt = iovcnt; + ms->ms_offset = offset; + status = sgx_ocall(8, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_write_ocall(size_t* retval, int* error, int fd, const void* buf, size_t count) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_write_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_write_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_write_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_write_ocall_t)); + ocalloc_size -= sizeof(ms_u_write_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_buf = buf; + ms->ms_count = count; + status = sgx_ocall(9, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_pwrite64_ocall(size_t* retval, int* error, int fd, const void* buf, size_t count, int64_t offset) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_pwrite64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_pwrite64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_pwrite64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_pwrite64_ocall_t)); + ocalloc_size -= sizeof(ms_u_pwrite64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_buf = buf; + ms->ms_count = count; + ms->ms_offset = offset; + status = sgx_ocall(10, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_writev_ocall(size_t* retval, int* error, int fd, const struct iovec* iov, int iovcnt) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_iov = iovcnt * sizeof(struct iovec); + + ms_u_writev_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_writev_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(iov, _len_iov); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (iov != NULL) ? _len_iov : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_writev_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_writev_ocall_t)); + ocalloc_size -= sizeof(ms_u_writev_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + if (iov != NULL) { + ms->ms_iov = (const struct iovec*)__tmp; + if (memcpy_s(__tmp, ocalloc_size, iov, _len_iov)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_iov); + ocalloc_size -= _len_iov; + } else { + ms->ms_iov = NULL; + } + + ms->ms_iovcnt = iovcnt; + status = sgx_ocall(11, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_pwritev64_ocall(size_t* retval, int* error, int fd, const struct iovec* iov, int iovcnt, int64_t offset) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_iov = iovcnt * sizeof(struct iovec); + + ms_u_pwritev64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_pwritev64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(iov, _len_iov); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (iov != NULL) ? _len_iov : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_pwritev64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_pwritev64_ocall_t)); + ocalloc_size -= sizeof(ms_u_pwritev64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + if (iov != NULL) { + ms->ms_iov = (const struct iovec*)__tmp; + if (memcpy_s(__tmp, ocalloc_size, iov, _len_iov)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_iov); + ocalloc_size -= _len_iov; + } else { + ms->ms_iov = NULL; + } + + ms->ms_iovcnt = iovcnt; + ms->ms_offset = offset; + status = sgx_ocall(12, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_fcntl_arg0_ocall(int* retval, int* error, int fd, int cmd) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_fcntl_arg0_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_fcntl_arg0_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_fcntl_arg0_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_fcntl_arg0_ocall_t)); + ocalloc_size -= sizeof(ms_u_fcntl_arg0_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_cmd = cmd; + status = sgx_ocall(13, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_fcntl_arg1_ocall(int* retval, int* error, int fd, int cmd, int arg) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_fcntl_arg1_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_fcntl_arg1_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_fcntl_arg1_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_fcntl_arg1_ocall_t)); + ocalloc_size -= sizeof(ms_u_fcntl_arg1_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_cmd = cmd; + ms->ms_arg = arg; + status = sgx_ocall(14, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_ioctl_arg0_ocall(int* retval, int* error, int fd, int request) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_ioctl_arg0_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_ioctl_arg0_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_ioctl_arg0_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_ioctl_arg0_ocall_t)); + ocalloc_size -= sizeof(ms_u_ioctl_arg0_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_request = request; + status = sgx_ocall(15, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_ioctl_arg1_ocall(int* retval, int* error, int fd, int request, int* arg) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_arg = sizeof(int); + + ms_u_ioctl_arg1_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_ioctl_arg1_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_arg = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(arg, _len_arg); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (arg != NULL) ? _len_arg : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_ioctl_arg1_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_ioctl_arg1_ocall_t)); + ocalloc_size -= sizeof(ms_u_ioctl_arg1_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_request = request; + if (arg != NULL) { + ms->ms_arg = (int*)__tmp; + __tmp_arg = __tmp; + if (_len_arg % sizeof(*arg) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, arg, _len_arg)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_arg); + ocalloc_size -= _len_arg; + } else { + ms->ms_arg = NULL; + } + + status = sgx_ocall(16, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (arg) { + if (memcpy_s((void*)arg, _len_arg, __tmp_arg, _len_arg)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_close_ocall(int* retval, int* error, int fd) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_close_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_close_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_close_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_close_ocall_t)); + ocalloc_size -= sizeof(ms_u_close_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + status = sgx_ocall(17, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_malloc_ocall(void** retval, int* error, size_t size) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_malloc_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_malloc_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_malloc_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_malloc_ocall_t)); + ocalloc_size -= sizeof(ms_u_malloc_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_size = size; + status = sgx_ocall(18, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_free_ocall(void* p) +{ + sgx_status_t status = SGX_SUCCESS; + + ms_u_free_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_free_ocall_t); + void *__tmp = NULL; + + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_free_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_free_ocall_t)); + ocalloc_size -= sizeof(ms_u_free_ocall_t); + + ms->ms_p = p; + status = sgx_ocall(19, ms); + + if (status == SGX_SUCCESS) { + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_mmap_ocall(void** retval, int* error, void* start, size_t length, int prot, int flags, int fd, int64_t offset) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_mmap_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_mmap_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_mmap_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_mmap_ocall_t)); + ocalloc_size -= sizeof(ms_u_mmap_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_start = start; + ms->ms_length = length; + ms->ms_prot = prot; + ms->ms_flags = flags; + ms->ms_fd = fd; + ms->ms_offset = offset; + status = sgx_ocall(20, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_munmap_ocall(int* retval, int* error, void* start, size_t length) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_munmap_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_munmap_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_munmap_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_munmap_ocall_t)); + ocalloc_size -= sizeof(ms_u_munmap_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_start = start; + ms->ms_length = length; + status = sgx_ocall(21, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_msync_ocall(int* retval, int* error, void* addr, size_t length, int flags) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_msync_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_msync_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_msync_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_msync_ocall_t)); + ocalloc_size -= sizeof(ms_u_msync_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_addr = addr; + ms->ms_length = length; + ms->ms_flags = flags; + status = sgx_ocall(22, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_mprotect_ocall(int* retval, int* error, void* addr, size_t length, int prot) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_mprotect_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_mprotect_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_mprotect_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_mprotect_ocall_t)); + ocalloc_size -= sizeof(ms_u_mprotect_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_addr = addr; + ms->ms_length = length; + ms->ms_prot = prot; + status = sgx_ocall(23, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_open_ocall(int* retval, int* error, const char* pathname, int flags) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_pathname = pathname ? strlen(pathname) + 1 : 0; + + ms_u_open_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_open_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(pathname, _len_pathname); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (pathname != NULL) ? _len_pathname : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_open_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_open_ocall_t)); + ocalloc_size -= sizeof(ms_u_open_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (pathname != NULL) { + ms->ms_pathname = (const char*)__tmp; + if (_len_pathname % sizeof(*pathname) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, pathname, _len_pathname)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_pathname); + ocalloc_size -= _len_pathname; + } else { + ms->ms_pathname = NULL; + } + + ms->ms_flags = flags; + status = sgx_ocall(24, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_open64_ocall(int* retval, int* error, const char* path, int oflag, int mode) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + + ms_u_open64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_open64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_open64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_open64_ocall_t)); + ocalloc_size -= sizeof(ms_u_open64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + ms->ms_oflag = oflag; + ms->ms_mode = mode; + status = sgx_ocall(25, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_fstat_ocall(int* retval, int* error, int fd, struct stat_t* buf) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_buf = sizeof(struct stat_t); + + ms_u_fstat_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_fstat_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_fstat_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_fstat_ocall_t)); + ocalloc_size -= sizeof(ms_u_fstat_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + if (buf != NULL) { + ms->ms_buf = (struct stat_t*)__tmp; + __tmp_buf = __tmp; + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + status = sgx_ocall(26, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_fstat64_ocall(int* retval, int* error, int fd, struct stat64_t* buf) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_buf = sizeof(struct stat64_t); + + ms_u_fstat64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_fstat64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_fstat64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_fstat64_ocall_t)); + ocalloc_size -= sizeof(ms_u_fstat64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + if (buf != NULL) { + ms->ms_buf = (struct stat64_t*)__tmp; + __tmp_buf = __tmp; + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + status = sgx_ocall(27, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_stat_ocall(int* retval, int* error, const char* path, struct stat_t* buf) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + size_t _len_buf = sizeof(struct stat_t); + + ms_u_stat_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_stat_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_stat_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_stat_ocall_t)); + ocalloc_size -= sizeof(ms_u_stat_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + if (buf != NULL) { + ms->ms_buf = (struct stat_t*)__tmp; + __tmp_buf = __tmp; + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + status = sgx_ocall(28, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_stat64_ocall(int* retval, int* error, const char* path, struct stat64_t* buf) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + size_t _len_buf = sizeof(struct stat64_t); + + ms_u_stat64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_stat64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_stat64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_stat64_ocall_t)); + ocalloc_size -= sizeof(ms_u_stat64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + if (buf != NULL) { + ms->ms_buf = (struct stat64_t*)__tmp; + __tmp_buf = __tmp; + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + status = sgx_ocall(29, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_lstat_ocall(int* retval, int* error, const char* path, struct stat_t* buf) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + size_t _len_buf = sizeof(struct stat_t); + + ms_u_lstat_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_lstat_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_lstat_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_lstat_ocall_t)); + ocalloc_size -= sizeof(ms_u_lstat_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + if (buf != NULL) { + ms->ms_buf = (struct stat_t*)__tmp; + __tmp_buf = __tmp; + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + status = sgx_ocall(30, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_lstat64_ocall(int* retval, int* error, const char* path, struct stat64_t* buf) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + size_t _len_buf = sizeof(struct stat64_t); + + ms_u_lstat64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_lstat64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_lstat64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_lstat64_ocall_t)); + ocalloc_size -= sizeof(ms_u_lstat64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + if (buf != NULL) { + ms->ms_buf = (struct stat64_t*)__tmp; + __tmp_buf = __tmp; + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + status = sgx_ocall(31, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_lseek_ocall(uint64_t* retval, int* error, int fd, int64_t offset, int whence) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_lseek_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_lseek_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_lseek_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_lseek_ocall_t)); + ocalloc_size -= sizeof(ms_u_lseek_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_offset = offset; + ms->ms_whence = whence; + status = sgx_ocall(32, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_lseek64_ocall(int64_t* retval, int* error, int fd, int64_t offset, int whence) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_lseek64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_lseek64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_lseek64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_lseek64_ocall_t)); + ocalloc_size -= sizeof(ms_u_lseek64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_offset = offset; + ms->ms_whence = whence; + status = sgx_ocall(33, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_ftruncate_ocall(int* retval, int* error, int fd, int64_t length) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_ftruncate_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_ftruncate_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_ftruncate_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_ftruncate_ocall_t)); + ocalloc_size -= sizeof(ms_u_ftruncate_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_length = length; + status = sgx_ocall(34, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_ftruncate64_ocall(int* retval, int* error, int fd, int64_t length) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_ftruncate64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_ftruncate64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_ftruncate64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_ftruncate64_ocall_t)); + ocalloc_size -= sizeof(ms_u_ftruncate64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_length = length; + status = sgx_ocall(35, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_truncate_ocall(int* retval, int* error, const char* path, int64_t length) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + + ms_u_truncate_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_truncate_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_truncate_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_truncate_ocall_t)); + ocalloc_size -= sizeof(ms_u_truncate_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + ms->ms_length = length; + status = sgx_ocall(36, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_truncate64_ocall(int* retval, int* error, const char* path, int64_t length) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + + ms_u_truncate64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_truncate64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_truncate64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_truncate64_ocall_t)); + ocalloc_size -= sizeof(ms_u_truncate64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + ms->ms_length = length; + status = sgx_ocall(37, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_fsync_ocall(int* retval, int* error, int fd) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_fsync_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_fsync_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_fsync_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_fsync_ocall_t)); + ocalloc_size -= sizeof(ms_u_fsync_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + status = sgx_ocall(38, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_fdatasync_ocall(int* retval, int* error, int fd) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_fdatasync_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_fdatasync_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_fdatasync_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_fdatasync_ocall_t)); + ocalloc_size -= sizeof(ms_u_fdatasync_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + status = sgx_ocall(39, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_fchmod_ocall(int* retval, int* error, int fd, uint32_t mode) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_fchmod_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_fchmod_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_fchmod_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_fchmod_ocall_t)); + ocalloc_size -= sizeof(ms_u_fchmod_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_mode = mode; + status = sgx_ocall(40, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_unlink_ocall(int* retval, int* error, const char* pathname) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_pathname = pathname ? strlen(pathname) + 1 : 0; + + ms_u_unlink_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_unlink_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(pathname, _len_pathname); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (pathname != NULL) ? _len_pathname : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_unlink_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_unlink_ocall_t)); + ocalloc_size -= sizeof(ms_u_unlink_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (pathname != NULL) { + ms->ms_pathname = (const char*)__tmp; + if (_len_pathname % sizeof(*pathname) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, pathname, _len_pathname)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_pathname); + ocalloc_size -= _len_pathname; + } else { + ms->ms_pathname = NULL; + } + + status = sgx_ocall(41, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_link_ocall(int* retval, int* error, const char* oldpath, const char* newpath) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_oldpath = oldpath ? strlen(oldpath) + 1 : 0; + size_t _len_newpath = newpath ? strlen(newpath) + 1 : 0; + + ms_u_link_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_link_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(oldpath, _len_oldpath); + CHECK_ENCLAVE_POINTER(newpath, _len_newpath); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (oldpath != NULL) ? _len_oldpath : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (newpath != NULL) ? _len_newpath : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_link_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_link_ocall_t)); + ocalloc_size -= sizeof(ms_u_link_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (oldpath != NULL) { + ms->ms_oldpath = (const char*)__tmp; + if (_len_oldpath % sizeof(*oldpath) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, oldpath, _len_oldpath)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_oldpath); + ocalloc_size -= _len_oldpath; + } else { + ms->ms_oldpath = NULL; + } + + if (newpath != NULL) { + ms->ms_newpath = (const char*)__tmp; + if (_len_newpath % sizeof(*newpath) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, newpath, _len_newpath)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_newpath); + ocalloc_size -= _len_newpath; + } else { + ms->ms_newpath = NULL; + } + + status = sgx_ocall(42, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_linkat_ocall(int* retval, int* error, int olddirfd, const char* oldpath, int newdirfd, const char* newpath, int flags) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_oldpath = oldpath ? strlen(oldpath) + 1 : 0; + size_t _len_newpath = newpath ? strlen(newpath) + 1 : 0; + + ms_u_linkat_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_linkat_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(oldpath, _len_oldpath); + CHECK_ENCLAVE_POINTER(newpath, _len_newpath); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (oldpath != NULL) ? _len_oldpath : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (newpath != NULL) ? _len_newpath : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_linkat_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_linkat_ocall_t)); + ocalloc_size -= sizeof(ms_u_linkat_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_olddirfd = olddirfd; + if (oldpath != NULL) { + ms->ms_oldpath = (const char*)__tmp; + if (_len_oldpath % sizeof(*oldpath) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, oldpath, _len_oldpath)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_oldpath); + ocalloc_size -= _len_oldpath; + } else { + ms->ms_oldpath = NULL; + } + + ms->ms_newdirfd = newdirfd; + if (newpath != NULL) { + ms->ms_newpath = (const char*)__tmp; + if (_len_newpath % sizeof(*newpath) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, newpath, _len_newpath)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_newpath); + ocalloc_size -= _len_newpath; + } else { + ms->ms_newpath = NULL; + } + + ms->ms_flags = flags; + status = sgx_ocall(43, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_rename_ocall(int* retval, int* error, const char* oldpath, const char* newpath) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_oldpath = oldpath ? strlen(oldpath) + 1 : 0; + size_t _len_newpath = newpath ? strlen(newpath) + 1 : 0; + + ms_u_rename_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_rename_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(oldpath, _len_oldpath); + CHECK_ENCLAVE_POINTER(newpath, _len_newpath); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (oldpath != NULL) ? _len_oldpath : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (newpath != NULL) ? _len_newpath : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_rename_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_rename_ocall_t)); + ocalloc_size -= sizeof(ms_u_rename_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (oldpath != NULL) { + ms->ms_oldpath = (const char*)__tmp; + if (_len_oldpath % sizeof(*oldpath) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, oldpath, _len_oldpath)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_oldpath); + ocalloc_size -= _len_oldpath; + } else { + ms->ms_oldpath = NULL; + } + + if (newpath != NULL) { + ms->ms_newpath = (const char*)__tmp; + if (_len_newpath % sizeof(*newpath) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, newpath, _len_newpath)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_newpath); + ocalloc_size -= _len_newpath; + } else { + ms->ms_newpath = NULL; + } + + status = sgx_ocall(44, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_chmod_ocall(int* retval, int* error, const char* path, uint32_t mode) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + + ms_u_chmod_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_chmod_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_chmod_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_chmod_ocall_t)); + ocalloc_size -= sizeof(ms_u_chmod_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + ms->ms_mode = mode; + status = sgx_ocall(45, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_readlink_ocall(size_t* retval, int* error, const char* path, char* buf, size_t bufsz) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + size_t _len_buf = bufsz; + + ms_u_readlink_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_readlink_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_readlink_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_readlink_ocall_t)); + ocalloc_size -= sizeof(ms_u_readlink_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + if (buf != NULL) { + ms->ms_buf = (char*)__tmp; + __tmp_buf = __tmp; + if (_len_buf % sizeof(*buf) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + ms->ms_bufsz = bufsz; + status = sgx_ocall(46, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_symlink_ocall(int* retval, int* error, const char* path1, const char* path2) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path1 = path1 ? strlen(path1) + 1 : 0; + size_t _len_path2 = path2 ? strlen(path2) + 1 : 0; + + ms_u_symlink_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_symlink_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path1, _len_path1); + CHECK_ENCLAVE_POINTER(path2, _len_path2); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path1 != NULL) ? _len_path1 : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path2 != NULL) ? _len_path2 : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_symlink_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_symlink_ocall_t)); + ocalloc_size -= sizeof(ms_u_symlink_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path1 != NULL) { + ms->ms_path1 = (const char*)__tmp; + if (_len_path1 % sizeof(*path1) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path1, _len_path1)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path1); + ocalloc_size -= _len_path1; + } else { + ms->ms_path1 = NULL; + } + + if (path2 != NULL) { + ms->ms_path2 = (const char*)__tmp; + if (_len_path2 % sizeof(*path2) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path2, _len_path2)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path2); + ocalloc_size -= _len_path2; + } else { + ms->ms_path2 = NULL; + } + + status = sgx_ocall(47, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_realpath_ocall(char** retval, int* error, const char* pathname) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_pathname = pathname ? strlen(pathname) + 1 : 0; + + ms_u_realpath_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_realpath_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(pathname, _len_pathname); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (pathname != NULL) ? _len_pathname : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_realpath_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_realpath_ocall_t)); + ocalloc_size -= sizeof(ms_u_realpath_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (pathname != NULL) { + ms->ms_pathname = (const char*)__tmp; + if (_len_pathname % sizeof(*pathname) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, pathname, _len_pathname)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_pathname); + ocalloc_size -= _len_pathname; + } else { + ms->ms_pathname = NULL; + } + + status = sgx_ocall(48, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_mkdir_ocall(int* retval, int* error, const char* pathname, uint32_t mode) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_pathname = pathname ? strlen(pathname) + 1 : 0; + + ms_u_mkdir_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_mkdir_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(pathname, _len_pathname); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (pathname != NULL) ? _len_pathname : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_mkdir_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_mkdir_ocall_t)); + ocalloc_size -= sizeof(ms_u_mkdir_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (pathname != NULL) { + ms->ms_pathname = (const char*)__tmp; + if (_len_pathname % sizeof(*pathname) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, pathname, _len_pathname)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_pathname); + ocalloc_size -= _len_pathname; + } else { + ms->ms_pathname = NULL; + } + + ms->ms_mode = mode; + status = sgx_ocall(49, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_rmdir_ocall(int* retval, int* error, const char* pathname) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_pathname = pathname ? strlen(pathname) + 1 : 0; + + ms_u_rmdir_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_rmdir_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(pathname, _len_pathname); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (pathname != NULL) ? _len_pathname : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_rmdir_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_rmdir_ocall_t)); + ocalloc_size -= sizeof(ms_u_rmdir_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (pathname != NULL) { + ms->ms_pathname = (const char*)__tmp; + if (_len_pathname % sizeof(*pathname) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, pathname, _len_pathname)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_pathname); + ocalloc_size -= _len_pathname; + } else { + ms->ms_pathname = NULL; + } + + status = sgx_ocall(50, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_opendir_ocall(void** retval, int* error, const char* pathname) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_pathname = pathname ? strlen(pathname) + 1 : 0; + + ms_u_opendir_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_opendir_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(pathname, _len_pathname); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (pathname != NULL) ? _len_pathname : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_opendir_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_opendir_ocall_t)); + ocalloc_size -= sizeof(ms_u_opendir_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (pathname != NULL) { + ms->ms_pathname = (const char*)__tmp; + if (_len_pathname % sizeof(*pathname) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, pathname, _len_pathname)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_pathname); + ocalloc_size -= _len_pathname; + } else { + ms->ms_pathname = NULL; + } + + status = sgx_ocall(51, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_readdir64_r_ocall(int* retval, void* dirp, struct dirent64_t* entry, struct dirent64_t** result) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_entry = sizeof(struct dirent64_t); + size_t _len_result = sizeof(struct dirent64_t*); + + ms_u_readdir64_r_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_readdir64_r_ocall_t); + void *__tmp = NULL; + + void *__tmp_entry = NULL; + void *__tmp_result = NULL; + + CHECK_ENCLAVE_POINTER(entry, _len_entry); + CHECK_ENCLAVE_POINTER(result, _len_result); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (entry != NULL) ? _len_entry : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (result != NULL) ? _len_result : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_readdir64_r_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_readdir64_r_ocall_t)); + ocalloc_size -= sizeof(ms_u_readdir64_r_ocall_t); + + ms->ms_dirp = dirp; + if (entry != NULL) { + ms->ms_entry = (struct dirent64_t*)__tmp; + __tmp_entry = __tmp; + if (memcpy_s(__tmp, ocalloc_size, entry, _len_entry)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_entry); + ocalloc_size -= _len_entry; + } else { + ms->ms_entry = NULL; + } + + if (result != NULL) { + ms->ms_result = (struct dirent64_t**)__tmp; + __tmp_result = __tmp; + if (_len_result % sizeof(*result) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_result, 0, _len_result); + __tmp = (void *)((size_t)__tmp + _len_result); + ocalloc_size -= _len_result; + } else { + ms->ms_result = NULL; + } + + status = sgx_ocall(52, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (entry) { + if (memcpy_s((void*)entry, _len_entry, __tmp_entry, _len_entry)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (result) { + if (memcpy_s((void*)result, _len_result, __tmp_result, _len_result)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_closedir_ocall(int* retval, int* error, void* dirp) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_closedir_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_closedir_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_closedir_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_closedir_ocall_t)); + ocalloc_size -= sizeof(ms_u_closedir_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_dirp = dirp; + status = sgx_ocall(53, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_dirfd_ocall(int* retval, int* error, void* dirp) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_dirfd_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_dirfd_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_dirfd_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_dirfd_ocall_t)); + ocalloc_size -= sizeof(ms_u_dirfd_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_dirp = dirp; + status = sgx_ocall(54, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_fstatat64_ocall(int* retval, int* error, int dirfd, const char* pathname, struct stat64_t* buf, int flags) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_pathname = pathname ? strlen(pathname) + 1 : 0; + size_t _len_buf = sizeof(struct stat64_t); + + ms_u_fstatat64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_fstatat64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(pathname, _len_pathname); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (pathname != NULL) ? _len_pathname : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_fstatat64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_fstatat64_ocall_t)); + ocalloc_size -= sizeof(ms_u_fstatat64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_dirfd = dirfd; + if (pathname != NULL) { + ms->ms_pathname = (const char*)__tmp; + if (_len_pathname % sizeof(*pathname) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, pathname, _len_pathname)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_pathname); + ocalloc_size -= _len_pathname; + } else { + ms->ms_pathname = NULL; + } + + if (buf != NULL) { + ms->ms_buf = (struct stat64_t*)__tmp; + __tmp_buf = __tmp; + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + ms->ms_flags = flags; + status = sgx_ocall(55, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + diff --git a/rust-sgx-workspace/projects/ntc-tee-server/enclave/codegen/Enclave_t.h b/rust-sgx-workspace/projects/ntc-tee-server/enclave/codegen/Enclave_t.h new file mode 100644 index 0000000..5c5a7db --- /dev/null +++ b/rust-sgx-workspace/projects/ntc-tee-server/enclave/codegen/Enclave_t.h @@ -0,0 +1,88 @@ +#ifndef ENCLAVE_T_H__ +#define ENCLAVE_T_H__ + +#include +#include +#include +#include "sgx_edger8r.h" /* for sgx_ocall etc. */ + +#include "time.h" +#include "inc/stat.h" +#include "sys/uio.h" +#include "inc/stat.h" +#include "inc/dirent.h" + +#include /* for size_t */ + +#define SGX_CAST(type, item) ((type)(item)) + +#ifdef __cplusplus +extern "C" { +#endif + +sgx_status_t ecall_test(const uint8_t* some_string, size_t len); +void t_global_init_ecall(uint64_t id, const uint8_t* path, size_t len); +void t_global_exit_ecall(void); + +sgx_status_t SGX_CDECL u_thread_set_event_ocall(int* retval, int* error, const void* tcs); +sgx_status_t SGX_CDECL u_thread_wait_event_ocall(int* retval, int* error, const void* tcs, const struct timespec* timeout); +sgx_status_t SGX_CDECL u_thread_set_multiple_events_ocall(int* retval, int* error, const void** tcss, int total); +sgx_status_t SGX_CDECL u_thread_setwait_events_ocall(int* retval, int* error, const void* waiter_tcs, const void* self_tcs, const struct timespec* timeout); +sgx_status_t SGX_CDECL u_clock_gettime_ocall(int* retval, int* error, int clk_id, struct timespec* tp); +sgx_status_t SGX_CDECL u_read_ocall(size_t* retval, int* error, int fd, void* buf, size_t count); +sgx_status_t SGX_CDECL u_pread64_ocall(size_t* retval, int* error, int fd, void* buf, size_t count, int64_t offset); +sgx_status_t SGX_CDECL u_readv_ocall(size_t* retval, int* error, int fd, const struct iovec* iov, int iovcnt); +sgx_status_t SGX_CDECL u_preadv64_ocall(size_t* retval, int* error, int fd, const struct iovec* iov, int iovcnt, int64_t offset); +sgx_status_t SGX_CDECL u_write_ocall(size_t* retval, int* error, int fd, const void* buf, size_t count); +sgx_status_t SGX_CDECL u_pwrite64_ocall(size_t* retval, int* error, int fd, const void* buf, size_t count, int64_t offset); +sgx_status_t SGX_CDECL u_writev_ocall(size_t* retval, int* error, int fd, const struct iovec* iov, int iovcnt); +sgx_status_t SGX_CDECL u_pwritev64_ocall(size_t* retval, int* error, int fd, const struct iovec* iov, int iovcnt, int64_t offset); +sgx_status_t SGX_CDECL u_fcntl_arg0_ocall(int* retval, int* error, int fd, int cmd); +sgx_status_t SGX_CDECL u_fcntl_arg1_ocall(int* retval, int* error, int fd, int cmd, int arg); +sgx_status_t SGX_CDECL u_ioctl_arg0_ocall(int* retval, int* error, int fd, int request); +sgx_status_t SGX_CDECL u_ioctl_arg1_ocall(int* retval, int* error, int fd, int request, int* arg); +sgx_status_t SGX_CDECL u_close_ocall(int* retval, int* error, int fd); +sgx_status_t SGX_CDECL u_malloc_ocall(void** retval, int* error, size_t size); +sgx_status_t SGX_CDECL u_free_ocall(void* p); +sgx_status_t SGX_CDECL u_mmap_ocall(void** retval, int* error, void* start, size_t length, int prot, int flags, int fd, int64_t offset); +sgx_status_t SGX_CDECL u_munmap_ocall(int* retval, int* error, void* start, size_t length); +sgx_status_t SGX_CDECL u_msync_ocall(int* retval, int* error, void* addr, size_t length, int flags); +sgx_status_t SGX_CDECL u_mprotect_ocall(int* retval, int* error, void* addr, size_t length, int prot); +sgx_status_t SGX_CDECL u_open_ocall(int* retval, int* error, const char* pathname, int flags); +sgx_status_t SGX_CDECL u_open64_ocall(int* retval, int* error, const char* path, int oflag, int mode); +sgx_status_t SGX_CDECL u_fstat_ocall(int* retval, int* error, int fd, struct stat_t* buf); +sgx_status_t SGX_CDECL u_fstat64_ocall(int* retval, int* error, int fd, struct stat64_t* buf); +sgx_status_t SGX_CDECL u_stat_ocall(int* retval, int* error, const char* path, struct stat_t* buf); +sgx_status_t SGX_CDECL u_stat64_ocall(int* retval, int* error, const char* path, struct stat64_t* buf); +sgx_status_t SGX_CDECL u_lstat_ocall(int* retval, int* error, const char* path, struct stat_t* buf); +sgx_status_t SGX_CDECL u_lstat64_ocall(int* retval, int* error, const char* path, struct stat64_t* buf); +sgx_status_t SGX_CDECL u_lseek_ocall(uint64_t* retval, int* error, int fd, int64_t offset, int whence); +sgx_status_t SGX_CDECL u_lseek64_ocall(int64_t* retval, int* error, int fd, int64_t offset, int whence); +sgx_status_t SGX_CDECL u_ftruncate_ocall(int* retval, int* error, int fd, int64_t length); +sgx_status_t SGX_CDECL u_ftruncate64_ocall(int* retval, int* error, int fd, int64_t length); +sgx_status_t SGX_CDECL u_truncate_ocall(int* retval, int* error, const char* path, int64_t length); +sgx_status_t SGX_CDECL u_truncate64_ocall(int* retval, int* error, const char* path, int64_t length); +sgx_status_t SGX_CDECL u_fsync_ocall(int* retval, int* error, int fd); +sgx_status_t SGX_CDECL u_fdatasync_ocall(int* retval, int* error, int fd); +sgx_status_t SGX_CDECL u_fchmod_ocall(int* retval, int* error, int fd, uint32_t mode); +sgx_status_t SGX_CDECL u_unlink_ocall(int* retval, int* error, const char* pathname); +sgx_status_t SGX_CDECL u_link_ocall(int* retval, int* error, const char* oldpath, const char* newpath); +sgx_status_t SGX_CDECL u_linkat_ocall(int* retval, int* error, int olddirfd, const char* oldpath, int newdirfd, const char* newpath, int flags); +sgx_status_t SGX_CDECL u_rename_ocall(int* retval, int* error, const char* oldpath, const char* newpath); +sgx_status_t SGX_CDECL u_chmod_ocall(int* retval, int* error, const char* path, uint32_t mode); +sgx_status_t SGX_CDECL u_readlink_ocall(size_t* retval, int* error, const char* path, char* buf, size_t bufsz); +sgx_status_t SGX_CDECL u_symlink_ocall(int* retval, int* error, const char* path1, const char* path2); +sgx_status_t SGX_CDECL u_realpath_ocall(char** retval, int* error, const char* pathname); +sgx_status_t SGX_CDECL u_mkdir_ocall(int* retval, int* error, const char* pathname, uint32_t mode); +sgx_status_t SGX_CDECL u_rmdir_ocall(int* retval, int* error, const char* pathname); +sgx_status_t SGX_CDECL u_opendir_ocall(void** retval, int* error, const char* pathname); +sgx_status_t SGX_CDECL u_readdir64_r_ocall(int* retval, void* dirp, struct dirent64_t* entry, struct dirent64_t** result); +sgx_status_t SGX_CDECL u_closedir_ocall(int* retval, int* error, void* dirp); +sgx_status_t SGX_CDECL u_dirfd_ocall(int* retval, int* error, void* dirp); +sgx_status_t SGX_CDECL u_fstatat64_ocall(int* retval, int* error, int dirfd, const char* pathname, struct stat64_t* buf, int flags); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/rust-sgx-workspace/projects/ntc-tee-server/enclave/src/lib.rs b/rust-sgx-workspace/projects/ntc-tee-server/enclave/src/lib.rs new file mode 100644 index 0000000..d18f06d --- /dev/null +++ b/rust-sgx-workspace/projects/ntc-tee-server/enclave/src/lib.rs @@ -0,0 +1,25 @@ +#![deny(unsafe_op_in_unsafe_fn)] +#![no_std] + +extern crate sgx_types; +#[macro_use] +extern crate sgx_tstd as std; + +use std::io::{self, Write}; +use std::slice; + +use sgx_types::sgx_status_t; + +/// Does a test ecall +/// +/// # Safety +/// Caller needs to ensure that `some_string` points to a valid slice of length `some_len` +#[no_mangle] +pub unsafe extern "C" fn ecall_test(some_string: *const u8, some_len: usize) -> sgx_status_t { + let str_slice = unsafe { slice::from_raw_parts(some_string, some_len) }; + let _ = io::stdout().write(str_slice); + + println!("Message from the enclave"); + + sgx_status_t::SGX_SUCCESS +} diff --git a/rust-sgx-workspace/rust-toolchain.toml b/rust-sgx-workspace/rust-toolchain.toml new file mode 100644 index 0000000..ff277a1 --- /dev/null +++ b/rust-sgx-workspace/rust-toolchain.toml @@ -0,0 +1,4 @@ +# Docs: https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file +[toolchain] +# See README-SGX.md +channel = "nightly-2021-11-01" diff --git a/rust-sgx-workspace/rustfmt.toml b/rust-sgx-workspace/rustfmt.toml new file mode 100644 index 0000000..437afce --- /dev/null +++ b/rust-sgx-workspace/rustfmt.toml @@ -0,0 +1,6 @@ +# https://rust-lang.github.io/rustfmt/ +# Use "cargo +nightly fmt" to take advantage of the group_imports feature. + +imports_layout = "HorizontalVertical" +imports_granularity = "Module" +group_imports = "StdExternalCrate" From 1521f59e5a265ea1fc463396df277228de41ff78 Mon Sep 17 00:00:00 2001 From: Jean-Pierre de Villiers Date: Wed, 4 May 2022 09:21:42 +0200 Subject: [PATCH 03/22] license: relicense to AGPL-3.0 (#17) --- LICENSE | 862 +++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 661 insertions(+), 201 deletions(-) diff --git a/LICENSE b/LICENSE index 261eeb9..0ad25db 100644 --- a/LICENSE +++ b/LICENSE @@ -1,201 +1,661 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. From 356aa48209126fe8357ea40d3ab320a9ec326642 Mon Sep 17 00:00:00 2001 From: Jean-Pierre de Villiers Date: Thu, 14 Jul 2022 12:57:29 +0200 Subject: [PATCH 04/22] ci: use ntls-io fork of rust-sgx-sdk-env (#39) Co-authored-by: Jean-Pierre de Villiers --- .github/workflows/rust-sgx-workspace-check.yaml | 6 +++--- .github/workflows/rust-sgx-workspace-test.yaml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/rust-sgx-workspace-check.yaml b/.github/workflows/rust-sgx-workspace-check.yaml index 4f9bcff..c462522 100644 --- a/.github/workflows/rust-sgx-workspace-check.yaml +++ b/.github/workflows/rust-sgx-workspace-check.yaml @@ -26,7 +26,7 @@ jobs: name: Checkout rust-sgx-sdk-dev-env uses: actions/checkout@v3 with: - repository: PiDelport/rust-sgx-sdk-dev-env + repository: ntls-io/rust-sgx-sdk-dev-env path: _temp/rust-sgx-sdk-dev-env - name: Prepare SGX environment @@ -66,7 +66,7 @@ jobs: name: Checkout rust-sgx-sdk-dev-env uses: actions/checkout@v3 with: - repository: PiDelport/rust-sgx-sdk-dev-env + repository: ntls-io/rust-sgx-sdk-dev-env path: _temp/rust-sgx-sdk-dev-env - name: Prepare SGX environment @@ -118,7 +118,7 @@ jobs: name: Checkout rust-sgx-sdk-dev-env uses: actions/checkout@v3 with: - repository: PiDelport/rust-sgx-sdk-dev-env + repository: ntls-io/rust-sgx-sdk-dev-env path: _temp/rust-sgx-sdk-dev-env - name: Prepare SGX environment diff --git a/.github/workflows/rust-sgx-workspace-test.yaml b/.github/workflows/rust-sgx-workspace-test.yaml index 376811a..4fd82c5 100644 --- a/.github/workflows/rust-sgx-workspace-test.yaml +++ b/.github/workflows/rust-sgx-workspace-test.yaml @@ -33,7 +33,7 @@ jobs: name: Checkout rust-sgx-sdk-dev-env uses: actions/checkout@v3 with: - repository: PiDelport/rust-sgx-sdk-dev-env + repository: ntls-io/rust-sgx-sdk-dev-env path: _temp/rust-sgx-sdk-dev-env - name: Prepare SGX environment From 5a5bfa78342c82984a007a99ac30c5be6ce5cca1 Mon Sep 17 00:00:00 2001 From: Bill Guo Date: Thu, 14 Jul 2022 13:12:15 +0200 Subject: [PATCH 05/22] feat: create oracle-node API (#18) * feat(ntc-oracle-node): connect to PureStake Indexer using algonaut * feat(ntc-oracle-node): add config crate * feat(ntc-oracle-node): add initial server with axum * feat(ntc-oracle-node): implement get_auth_data * feat(ntc-oracle-node): use ed25519 to sign AuthData with ring-compat * style(ntc-oracle-node): apply rustfmt.toml * refactor(ntc-oracle-node): move auth_data functions into handler * feat(ntc-oracle-node): add anyhow error handling * feat(ntc-oracle-node): add unit test for sign_auth_data * feat(ntc-oracle-node): use serde_with to base64 encode SignedAuthData response * refactor(ntc-oracle-node): use cfg(test) in place of allow(dead_code) --- rust-workspace/.gitignore | 1 + rust-workspace/Cargo.lock | 1530 ++++++++++++++++- .../crates/ntc-oracle-node/Cargo.toml | 24 + .../ntc-oracle-node/config/default.toml | 3 + .../crates/ntc-oracle-node/src/errors.rs | 30 + .../ntc-oracle-node/src/handlers/auth_data.rs | 205 +++ .../ntc-oracle-node/src/handlers/mod.rs | 3 + .../crates/ntc-oracle-node/src/helpers.rs | 15 + .../crates/ntc-oracle-node/src/main.rs | 31 + .../crates/ntc-oracle-node/src/settings.rs | 30 + .../crates/ntc-oracle-node/src/signer.rs | 43 + 11 files changed, 1826 insertions(+), 89 deletions(-) create mode 100644 rust-workspace/crates/ntc-oracle-node/Cargo.toml create mode 100644 rust-workspace/crates/ntc-oracle-node/config/default.toml create mode 100644 rust-workspace/crates/ntc-oracle-node/src/errors.rs create mode 100644 rust-workspace/crates/ntc-oracle-node/src/handlers/auth_data.rs create mode 100644 rust-workspace/crates/ntc-oracle-node/src/handlers/mod.rs create mode 100644 rust-workspace/crates/ntc-oracle-node/src/helpers.rs create mode 100644 rust-workspace/crates/ntc-oracle-node/src/main.rs create mode 100644 rust-workspace/crates/ntc-oracle-node/src/settings.rs create mode 100644 rust-workspace/crates/ntc-oracle-node/src/signer.rs diff --git a/rust-workspace/.gitignore b/rust-workspace/.gitignore index 2f7896d..8d84b60 100644 --- a/rust-workspace/.gitignore +++ b/rust-workspace/.gitignore @@ -1 +1,2 @@ target/ +local.toml diff --git a/rust-workspace/Cargo.lock b/rust-workspace/Cargo.lock index 31bd13e..00cf752 100644 --- a/rust-workspace/Cargo.lock +++ b/rust-workspace/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "aead" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" +dependencies = [ + "generic-array", +] + [[package]] name = "ahash" version = "0.7.6" @@ -23,6 +32,147 @@ dependencies = [ "memchr", ] +[[package]] +name = "algonaut" +version = "0.3.0" +source = "git+https://github.com/manuelmauro/algonaut?rev=30a251e438df9bb7af8b3aafc53bb9945a74c963#30a251e438df9bb7af8b3aafc53bb9945a74c963" +dependencies = [ + "algonaut_abi", + "algonaut_client", + "algonaut_core", + "algonaut_crypto", + "algonaut_encoding", + "algonaut_model", + "algonaut_transaction", + "data-encoding", + "futures-timer", + "gloo-timers", + "instant", + "num-bigint 0.4.3", + "num-traits", + "rmp-serde", + "sha2", + "thiserror", +] + +[[package]] +name = "algonaut_abi" +version = "0.3.0" +source = "git+https://github.com/manuelmauro/algonaut?rev=30a251e438df9bb7af8b3aafc53bb9945a74c963#30a251e438df9bb7af8b3aafc53bb9945a74c963" +dependencies = [ + "algonaut_core", + "derive_more", + "lazy_static", + "num-bigint 0.4.3", + "regex", + "serde", + "sha2", + "thiserror", +] + +[[package]] +name = "algonaut_client" +version = "0.3.0" +source = "git+https://github.com/manuelmauro/algonaut?rev=30a251e438df9bb7af8b3aafc53bb9945a74c963#30a251e438df9bb7af8b3aafc53bb9945a74c963" +dependencies = [ + "algonaut_core", + "algonaut_crypto", + "algonaut_encoding", + "algonaut_model", + "async-trait", + "data-encoding", + "derive_more", + "reqwest", + "serde", + "serde_json", + "thiserror", + "url", +] + +[[package]] +name = "algonaut_core" +version = "0.3.0" +source = "git+https://github.com/manuelmauro/algonaut?rev=30a251e438df9bb7af8b3aafc53bb9945a74c963#30a251e438df9bb7af8b3aafc53bb9945a74c963" +dependencies = [ + "algonaut_crypto", + "algonaut_encoding", + "data-encoding", + "derive_more", + "ring", + "rmp-serde", + "serde", + "sha2", + "static_assertions", + "thiserror", +] + +[[package]] +name = "algonaut_crypto" +version = "0.3.0" +source = "git+https://github.com/manuelmauro/algonaut?rev=30a251e438df9bb7af8b3aafc53bb9945a74c963#30a251e438df9bb7af8b3aafc53bb9945a74c963" +dependencies = [ + "algonaut_encoding", + "data-encoding", + "derive_more", + "indexmap", + "lazy_static", + "ring", + "serde", + "sha2", + "static_assertions", + "thiserror", +] + +[[package]] +name = "algonaut_encoding" +version = "0.3.0" +source = "git+https://github.com/manuelmauro/algonaut?rev=30a251e438df9bb7af8b3aafc53bb9945a74c963#30a251e438df9bb7af8b3aafc53bb9945a74c963" +dependencies = [ + "data-encoding", + "serde", +] + +[[package]] +name = "algonaut_model" +version = "0.3.0" +source = "git+https://github.com/manuelmauro/algonaut?rev=30a251e438df9bb7af8b3aafc53bb9945a74c963#30a251e438df9bb7af8b3aafc53bb9945a74c963" +dependencies = [ + "algonaut_core", + "algonaut_crypto", + "algonaut_encoding", + "data-encoding", + "serde", + "serde_bytes", + "serde_json", + "serde_with", +] + +[[package]] +name = "algonaut_transaction" +version = "0.3.0" +source = "git+https://github.com/manuelmauro/algonaut?rev=30a251e438df9bb7af8b3aafc53bb9945a74c963#30a251e438df9bb7af8b3aafc53bb9945a74c963" +dependencies = [ + "algonaut_abi", + "algonaut_core", + "algonaut_crypto", + "algonaut_encoding", + "algonaut_model", + "data-encoding", + "derive_more", + "getrandom", + "num-bigint 0.4.3", + "num-traits", + "rand", + "ring", + "rmp-serde", + "serde", + "serde_bytes", + "sha2", + "thiserror", + "url", + "urlencoding", +] + [[package]] name = "anyhow" version = "1.0.57" @@ -43,6 +193,17 @@ dependencies = [ "wait-timeout", ] +[[package]] +name = "async-trait" +version = "0.1.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96cf8829f67d2eab0b2dfa42c5d0ef737e0724e4a82b01b3e292456202b19716" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "atty" version = "0.2.14" @@ -60,6 +221,57 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "axum" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab2504b827a8bef941ba3dd64bdffe9cf56ca182908a147edd6189c95fbcae7d" +dependencies = [ + "async-trait", + "axum-core", + "bitflags", + "bytes", + "futures-util", + "http", + "http-body", + "hyper", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tower", + "tower-http", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da31c0ed7b4690e2c78fe4b880d21cd7db04a346ebc658b4270251b695437f17" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http", + "http-body", + "mime", +] + +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + [[package]] name = "base64" version = "0.13.0" @@ -87,6 +299,15 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "block-buffer" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" +dependencies = [ + "generic-array", +] + [[package]] name = "bstr" version = "0.2.17" @@ -98,11 +319,35 @@ dependencies = [ "regex-automata", ] +[[package]] +name = "bumpalo" +version = "3.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3" + [[package]] name = "bytecount" -version = "0.6.2" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c676a478f63e9fa2dd5368a42f28bba0d6c560b775f38583c8bbaa7fcd67c9c" + +[[package]] +name = "byteorder" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72feb31ffc86498dacdbd0fcebb56138e7177a8cc5cea4516031d15ae85a742e" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" + +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" [[package]] name = "cfg-if" @@ -112,9 +357,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "3.1.12" +version = "3.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c167e37342afc5f33fd87bbc870cedd020d2a6dffa05d45ccd9241fbdd146db" +checksum = "d2dbdf4bdacb33466e854ce889eee8dfd5729abf7ccd7664d0a2d60cd384440b" dependencies = [ "atty", "bitflags", @@ -129,9 +374,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "3.1.7" +version = "3.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3aab4734e083b809aaf5794e14e756d1c798d2c69c7f7de7a09a2f5214993c1" +checksum = "25320346e922cffe59c0bbc5410c8d8784509efb321488971081313cb1e1a33c" dependencies = [ "heck", "proc-macro-error", @@ -142,9 +387,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "189ddd3b5d32a70b35e7686054371742a937b0d99128e76dde6340210e966669" +checksum = "a37c35f1112dad5e6e0b1adaff798507497a18fceeb30cceb3bae7d1427b9213" dependencies = [ "os_str_bytes", ] @@ -160,6 +405,20 @@ dependencies = [ "winapi", ] +[[package]] +name = "config" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ea917b74b6edfb5024e3b55d3c8f710b5f4ed92646429601a42e96f0812b31b" +dependencies = [ + "async-trait", + "lazy_static", + "nom", + "pathdiff", + "serde", + "toml", +] + [[package]] name = "confy" version = "0.4.0" @@ -171,6 +430,71 @@ dependencies = [ "toml", ] +[[package]] +name = "const-oid" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3" + +[[package]] +name = "const-oid" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "722e23542a15cea1f65d4a1419c4cfd7a26706c70871a13a04238ca3f40f1661" + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "cpufeatures" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-bigint" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03c6a1d5fa1de37e071642dfa44ec552ca5b299adb128fab16138e24b548fd21" +dependencies = [ + "generic-array", + "rand_core", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" +dependencies = [ + "generic-array", + "typenum", +] + [[package]] name = "darling" version = "0.13.4" @@ -206,6 +530,43 @@ dependencies = [ "syn", ] +[[package]] +name = "data-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" + +[[package]] +name = "der" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c" +dependencies = [ + "const-oid 0.7.1", +] + +[[package]] +name = "der" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13dd2ae565c0a381dde7fade45fce95984c568bdcb4700a4fdbe3175e0380b2f" +dependencies = [ + "const-oid 0.9.0", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn", +] + [[package]] name = "diff" version = "0.1.12" @@ -218,6 +579,25 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" +dependencies = [ + "block-buffer", + "crypto-common", +] + [[package]] name = "directories-next" version = "2.0.0" @@ -245,12 +625,68 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" +[[package]] +name = "ecdsa" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0d69ae62e0ce582d56380743515fefaf1a8c70cec685d9677636d7e30ae9dc9" +dependencies = [ + "der 0.5.1", + "elliptic-curve", + "signature", +] + +[[package]] +name = "ed25519" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9c280362032ea4203659fc489832d0204ef09f247a0506f170dafcac08c369" +dependencies = [ + "pkcs8", + "serde", + "serde_bytes", + "signature", +] + [[package]] name = "either" version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +[[package]] +name = "elliptic-curve" +version = "0.11.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25b477563c2bfed38a3b7a60964c49e058b2510ad3f12ba3483fd8f62c2306d6" +dependencies = [ + "base16ct", + "crypto-bigint", + "der 0.5.1", + "generic-array", + "rand_core", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "encoding_rs" +version = "0.8.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "env-var-helpers" +version = "0.1.0" +source = "git+https://github.com/PiDelport/rust-env-var-helpers#8aed1f58daf2e68b880e2dc0defa3650987e69c6" +dependencies = [ + "thiserror", +] + [[package]] name = "fancy-regex" version = "0.8.0" @@ -276,6 +712,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.0.1" @@ -296,6 +747,61 @@ dependencies = [ "num", ] +[[package]] +name = "futures-channel" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" + +[[package]] +name = "futures-sink" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" + +[[package]] +name = "futures-task" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" + +[[package]] +name = "futures-timer" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" + +[[package]] +name = "futures-util" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "generic-array" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "getrandom" version = "0.2.6" @@ -303,8 +809,41 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" dependencies = [ "cfg-if", + "js-sys", "libc", - "wasi", + "wasi 0.10.2+wasi-snapshot-preview1", + "wasm-bindgen", +] + +[[package]] +name = "gloo-timers" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fb7d06c1c8cc2a29bee7ec961009a0b2caa0793ee4900c2ffb348734ba1c8f9" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "h2" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37a82c6d637fc9515a4694bbf1cb2457b79d81ce52b3108bdeea58b07dd34a57" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", ] [[package]] @@ -328,6 +867,83 @@ dependencies = [ "libc", ] +[[package]] +name = "http" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "http-range-header" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29" + +[[package]] +name = "httparse" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "496ce29bb5a52785b44e0f7ca2847ae0bb839c9bd28f69acac9b99d461c0c04c" + +[[package]] +name = "httpdate" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" + +[[package]] +name = "hyper" +version = "0.14.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42dc3c131584288d375f2d07f822b0cb012d8c6fb899a5b9fdb3cb7eb9b6004f" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -353,9 +969,9 @@ checksum = "4161ceaf2f41b6cd3f6502f5da085d4ad4393a51e0c70ed2fce1d5698d798fae" [[package]] name = "indexmap" -version = "1.8.1" +version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f647032dfaa1f8b6dc29bd3edb7bbef4861b8b8007ebb118d6db284fd59f6ee" +checksum = "e6012d540c5baa3589337a98ce73408de9b5a25ec9fc2c6fd6be8f0d39e0ca5a" dependencies = [ "autocfg", "hashbrown", @@ -368,13 +984,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", ] +[[package]] +name = "ipnet" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" + [[package]] name = "iso8601" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a59a3f2be6271b2a844cd0dd13bf8ccc88a9540482d872c7ce58ab1c4db9fab" +checksum = "e5b94fbeb759754d87e1daea745bc8efd3037cd16980331fe1d1524c9a79ce96" dependencies = [ "nom", ] @@ -390,9 +1015,18 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.1" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" + +[[package]] +name = "js-sys" +version = "0.3.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" +checksum = "671a26f820db17c2a2750743f1dd03bafd15b98c9f30c7c2628c024c05d73397" +dependencies = [ + "wasm-bindgen", +] [[package]] name = "jsonschema" @@ -446,9 +1080,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.124" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a41fed9d98f27ab1c6d161da622a4fa35e8a54a8adc24bbf3ddd0ef70b0e50" +checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" [[package]] name = "lock_api" @@ -460,17 +1094,38 @@ dependencies = [ "scopeguard", ] +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + [[package]] name = "matches" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" +[[package]] +name = "matchit" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73cbba799671b762df5a175adf59ce145165747bb891505c43d09aefbbf38beb" + [[package]] name = "memchr" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" [[package]] name = "minimal-lexical" @@ -478,6 +1133,36 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" +[[package]] +name = "mio" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "713d550d9b44d89174e066b7a6217ae06234c10cb47819a88290d2b353c31799" +dependencies = [ + "libc", + "log", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys", +] + +[[package]] +name = "native-tls" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd7e2f3618557f980e0b17e8856252eee3c97fa12c54dff0ca290fb6266ca4a9" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "nom" version = "7.1.1" @@ -501,6 +1186,27 @@ dependencies = [ "thiserror", ] +[[package]] +name = "ntc-oracle-node" +version = "0.1.0" +dependencies = [ + "algonaut", + "algonaut_client", + "anyhow", + "axum", + "base64", + "config", + "ed25519", + "env-var-helpers", + "ring-compat", + "serde", + "serde_derive", + "serde_json", + "serde_with", + "tokio", + "tower-http", +] + [[package]] name = "ntc-vault-cli" version = "0.1.0" @@ -526,7 +1232,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8536030f9fea7127f841b45bb6243b27255787fb4eb83958aa1ef9d2fdc0c36" dependencies = [ - "num-bigint", + "num-bigint 0.2.6", "num-complex", "num-integer", "num-iter", @@ -545,6 +1251,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-cmp" version = "0.1.0" @@ -563,9 +1280,9 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" dependencies = [ "autocfg", "num-traits", @@ -589,46 +1306,129 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" dependencies = [ "autocfg", - "num-bigint", + "num-bigint 0.2.6", "num-integer", "num-traits", ] [[package]] name = "num-traits" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", ] +[[package]] +name = "num_cpus" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +dependencies = [ + "hermit-abi", + "libc", +] + [[package]] name = "num_threads" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aba1801fb138d8e85e11d0fc70baf4fe1cdfffda7c6cd34a854905df588e5ed0" +checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" dependencies = [ "libc", ] [[package]] name = "once_cell" -version = "1.10.0" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "openssl" +version = "0.10.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb81a6430ac911acb25fe5ac8f1d2af1b4ea8a4fdfda0f1ee4292af2e2d8eb0e" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835363342df5fba8354c5b453325b110ffd54044e588c539cf2f20a8014e4cb1" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] [[package]] name = "os_str_bytes" -version = "6.0.0" +version = "6.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa" + +[[package]] +name = "p256" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" +checksum = "19736d80675fbe9fe33426268150b951a3fb8f5cfca2a23a17c85ef3adb24e3b" +dependencies = [ + "ecdsa", + "elliptic-curve", + "sec1", +] + +[[package]] +name = "p384" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "755d8266e41f57bd8562ed9b6e93cdcf73ead050e1e8c3a27ea3871b6643a20c" +dependencies = [ + "ecdsa", + "elliptic-curve", + "sec1", +] [[package]] name = "parking_lot" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", "parking_lot_core", @@ -636,9 +1436,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "995f667a6c822200b0433ac218e05582f0e2efa1b922a3fd2fbaadc5f87bab37" +checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" dependencies = [ "cfg-if", "libc", @@ -647,12 +1447,72 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "paste" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc" + +[[package]] +name = "pathdiff" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" + [[package]] name = "percent-encoding" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +[[package]] +name = "pin-project" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58ad3879ad3baf4e44784bc6a718a8698867bb991f8ce24d1bcbe2cfb4c3a75e" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "744b6f092ba29c3650faf274db506afd39944f48420f6c86b17cfe0ee1cb36bb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkcs8" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +dependencies = [ + "der 0.6.0", + "spki", +] + +[[package]] +name = "pkg-config" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" + [[package]] name = "ppv-lite86" version = "0.2.16" @@ -712,11 +1572,11 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.37" +version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1" +checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] @@ -780,41 +1640,134 @@ dependencies = [ [[package]] name = "regex" -version = "1.5.5" +version = "1.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" + +[[package]] +name = "regex-syntax" +version = "0.6.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "reqwest" +version = "0.11.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46a1f7aa4f35e5e8b4160449f51afc758f0ce6454315a9fa7d0d113e958c41eb" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "lazy_static", + "log", + "mime", + "native-tls", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-native-tls", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] +name = "ring" +version = "0.16.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", + "cc", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi", ] [[package]] -name = "regex-automata" -version = "0.1.10" +name = "ring-compat" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +checksum = "6242f589b69a0555addb0bb759f81e5cba40485d38b36f780ab3a588b2bdf064" +dependencies = [ + "aead", + "digest 0.9.0", + "ecdsa", + "ed25519", + "generic-array", + "opaque-debug", + "p256", + "p384", + "ring", +] [[package]] -name = "regex-syntax" -version = "0.6.25" +name = "rmp" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" +checksum = "44519172358fd6d58656c86ab8e7fbc9e1490c3e8f14d35ed78ca0dd07403c9f" +dependencies = [ + "byteorder", + "num-traits", + "paste", +] [[package]] -name = "remove_dir_all" -version = "0.5.3" +name = "rmp-serde" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +checksum = "25786b0d276110195fa3d6f3f31299900cf71dfbd6c28450f3f58a0e7f7a347e" dependencies = [ - "winapi", + "byteorder", + "rmp", + "serde", ] [[package]] -name = "rustversion" -version = "1.0.6" +name = "rustc_version" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] [[package]] name = "rusty-sodalite" @@ -826,9 +1779,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" +checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" [[package]] name = "same-file" @@ -839,26 +1792,86 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "schannel" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" +dependencies = [ + "lazy_static", + "windows-sys", +] + [[package]] name = "scopeguard" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "sec1" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08da66b8b0965a5555b6bd6639e68ccba85e1e2506f5fbb089e93f8a04e1a2d1" +dependencies = [ + "der 0.5.1", + "generic-array", + "subtle", + "zeroize", +] + +[[package]] +name = "security-framework" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dc14f172faf8a0194a3aded622712b0de276821addc574fa54fc0a1167e10dc" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cb243bdfdb5936c8dc3c45762a19d12ab4550cdc753bc247637d4ec35a040fd" + [[package]] name = "serde" -version = "1.0.136" +version = "1.0.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" +checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" dependencies = [ "serde_derive", ] +[[package]] +name = "serde_bytes" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "212e73464ebcde48d723aa02eb270ba62eff38a9b732df31f33f1b4e145f3a54" +dependencies = [ + "serde", +] + [[package]] name = "serde_derive" -version = "1.0.136" +version = "1.0.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" +checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" dependencies = [ "proc-macro2", "quote", @@ -867,10 +1880,22 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.79" +version = "1.0.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ + "form_urlencoded", "itoa", "ryu", "serde", @@ -878,12 +1903,11 @@ dependencies = [ [[package]] name = "serde_with" -version = "1.13.0" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b827f2113224f3f19a665136f006709194bdfdcb1fdc1e4b2b5cbac8e0cced54" +checksum = "678b5a069e50bf00ecd22d0cd8ddf7c236f68581b03db652061ed5eb13a312ff" dependencies = [ "base64", - "rustversion", "serde", "serde_with_macros", ] @@ -900,12 +1924,48 @@ dependencies = [ "syn", ] +[[package]] +name = "sha2" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.3", +] + +[[package]] +name = "signature" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02658e48d89f2bec991f9a78e69cfa4c316f8d6a6c4ec12fae1aeb263d486788" +dependencies = [ + "rand_core", +] + +[[package]] +name = "slab" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32" + [[package]] name = "smallvec" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" +[[package]] +name = "socket2" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "sodalite" version = "0.4.0" @@ -915,23 +1975,56 @@ dependencies = [ "index-fixed", ] +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "spki" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +dependencies = [ + "der 0.6.0", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "strsim" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + [[package]] name = "syn" -version = "1.0.91" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b683b2b825c8eef438b77c36a06dc262294da3d5a5813fac20da149241dcd44d" +checksum = "0748dd251e24453cb8717f0354206b91557e4ec8703673a4b30208f2abaf1ebf" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20518fe4a4c9acf048008599e464deb21beeae3d3578418951a189c235a7a9a8" + [[package]] name = "tempfile" version = "3.3.0" @@ -979,18 +2072,18 @@ checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" [[package]] name = "thiserror" -version = "1.0.30" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" +checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.30" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" +checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" dependencies = [ "proc-macro2", "quote", @@ -1029,6 +2122,59 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +[[package]] +name = "tokio" +version = "1.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c51a52ed6686dd62c320f9b89299e9dfb46f730c7a48e635c19f21d116cb1439" +dependencies = [ + "bytes", + "libc", + "memchr", + "mio", + "num_cpus", + "once_cell", + "pin-project-lite", + "socket2", + "tokio-macros", + "winapi", +] + +[[package]] +name = "tokio-macros" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc463cd8deddc3770d20f9852143d50bf6094e640b485cb2e189a2099085ff45" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + [[package]] name = "toml" version = "0.5.9" @@ -1038,12 +2184,99 @@ dependencies = [ "serde", ] +[[package]] +name = "tower" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a89fd63ad6adf737582df5db40d286574513c69a11dac5214dc3b5603d6713e" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-http" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c530c8675c1dbf98facee631536fa116b5fb6382d7dd6dc1b118d970eafe3ba" +dependencies = [ + "bitflags", + "bytes", + "futures-core", + "futures-util", + "http", + "http-body", + "http-range-header", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "343bc9466d3fe6b0f960ef45960509f84480bf4fd96f92901afe7ff3df9d3a62" + +[[package]] +name = "tower-service" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" + +[[package]] +name = "tracing" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0ecdcb44a79f0fe9844f0c4f33a342cbcbb5117de8001e6ba0dc2351327d09" +dependencies = [ + "cfg-if", + "log", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7709595b8878a4965ce5e87ebf880a7d39c9afc6837721b21a5a816a8117d921" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" + +[[package]] +name = "typenum" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" + [[package]] name = "unicode-bidi" version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" +[[package]] +name = "unicode-ident" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" + [[package]] name = "unicode-normalization" version = "0.1.19" @@ -1054,10 +2287,10 @@ dependencies = [ ] [[package]] -name = "unicode-xid" -version = "0.2.2" +name = "untrusted" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" @@ -1071,12 +2304,24 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "urlencoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68b90931029ab9b034b300b797048cf23723400aa757e8a2bfb9d748102f9821" + [[package]] name = "uuid" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" version = "0.9.4" @@ -1103,12 +2348,104 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + [[package]] name = "wasi" version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53e04185bfa3a779273da532f5025e33398409573f348985af9a1cbf3774d3f4" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f741de44b75e14c35df886aff5f1eb73aa114fa5d4d00dcd37b5e01259bf3b2" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17cae7ff784d7e83a2fe7611cfe766ecf034111b49deb850a3dc7699c08251f5" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99ec0dc7a4756fffc231aab1b9f2f578d23cd391390ab27f952ae0c9b3ece20b" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744" + +[[package]] +name = "web-sys" +version = "0.3.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b17e741662c70c8bd24ac5c5b18de314a2c26c32bf8346ee1e6f53de919c283" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "winapi" version = "0.3.9" @@ -1142,9 +2479,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" -version = "0.34.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5acdd78cb4ba54c0045ac14f62d8f94a03d10047904ae2a40afa1e99d8f70825" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" dependencies = [ "windows_aarch64_msvc", "windows_i686_gnu", @@ -1155,30 +2492,45 @@ dependencies = [ [[package]] name = "windows_aarch64_msvc" -version = "0.34.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17cffbe740121affb56fad0fc0e421804adf0ae00891205213b5cecd30db881d" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" [[package]] name = "windows_i686_gnu" -version = "0.34.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2564fde759adb79129d9b4f54be42b32c89970c18ebf93124ca8870a498688ed" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" [[package]] name = "windows_i686_msvc" -version = "0.34.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cd9d32ba70453522332c14d38814bceeb747d80b3958676007acadd7e166956" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" [[package]] name = "windows_x86_64_gnu" -version = "0.34.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfce6deae227ee8d356d19effc141a509cc503dfd1f850622ec4b0f84428e1f4" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" [[package]] name = "windows_x86_64_msvc" -version = "0.34.0" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] + +[[package]] +name = "zeroize" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d19538ccc21819d01deaf88d6a17eae6596a12e9aafdbb97916fb49896d89de9" +checksum = "94693807d016b2f2d2e14420eb3bfcca689311ff775dcf113d74ea624b7cdf07" diff --git a/rust-workspace/crates/ntc-oracle-node/Cargo.toml b/rust-workspace/crates/ntc-oracle-node/Cargo.toml new file mode 100644 index 0000000..b0ebf77 --- /dev/null +++ b/rust-workspace/crates/ntc-oracle-node/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "ntc-oracle-node" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +algonaut = { git = "https://github.com/manuelmauro/algonaut", rev = "30a251e438df9bb7af8b3aafc53bb9945a74c963" } +algonaut_client = { git = "https://github.com/manuelmauro/algonaut", rev = "30a251e438df9bb7af8b3aafc53bb9945a74c963" } +anyhow = "1.0" +axum = "0.5" +base64 = "0.13" +config = { version = "0.13", default-features = false, features = ["toml"] } +ed25519 = { version = "1.5", features = ["pkcs8", "serde_bytes"] } +ring-compat = "0.4" +serde = { version = "1.0", features = ["derive"] } +serde_derive = "1.0" +serde_json = "1.0" +serde_with = { version = "1.14", features = ["base64"]} +tokio = { version = "1", features = ["rt-multi-thread", "macros"] } +tower-http = { version = "0.3", features = ["cors"] } + +env-var-helpers = { git = "https://github.com/PiDelport/rust-env-var-helpers" } diff --git a/rust-workspace/crates/ntc-oracle-node/config/default.toml b/rust-workspace/crates/ntc-oracle-node/config/default.toml new file mode 100644 index 0000000..da5cf67 --- /dev/null +++ b/rust-workspace/crates/ntc-oracle-node/config/default.toml @@ -0,0 +1,3 @@ +[purestake] +indexer_url = "https://testnet-algorand.api.purestake.io/idx2/" +indexer_token = "purestake-token" diff --git a/rust-workspace/crates/ntc-oracle-node/src/errors.rs b/rust-workspace/crates/ntc-oracle-node/src/errors.rs new file mode 100644 index 0000000..6154644 --- /dev/null +++ b/rust-workspace/crates/ntc-oracle-node/src/errors.rs @@ -0,0 +1,30 @@ +//! Error representation helpers. + +use axum::http::StatusCode; +use axum::response::{IntoResponse, Response}; + +/// Represent arbitrary errors as Axum Error responses using [`anyhow`]. +#[repr(transparent)] +pub struct AnyhowErrorResponse(anyhow::Error); + +/// Convert `E` → [`anyhow::Error`] → [`AnyhowErrorResponse`]. +impl From for AnyhowErrorResponse +where + E: Into, +{ + fn from(err: E) -> Self { + Self(err.into()) + } +} + +/// Convert [`AnyhowErrorResponse`] → [`anyhow::Error`] → ([`StatusCode`], [`String`]) → [`Response`]. +/// +/// This will show an [`StatusCode::INTERNAL_SERVER_ERROR`] with an error message in [`anyhow::Error`]'s `{:#}` formatting. +impl IntoResponse for AnyhowErrorResponse { + fn into_response(self) -> Response { + let AnyhowErrorResponse(err) = self; + let message = format!("{:#}", err); + + (StatusCode::INTERNAL_SERVER_ERROR, message).into_response() + } +} diff --git a/rust-workspace/crates/ntc-oracle-node/src/handlers/auth_data.rs b/rust-workspace/crates/ntc-oracle-node/src/handlers/auth_data.rs new file mode 100644 index 0000000..fee0c8b --- /dev/null +++ b/rust-workspace/crates/ntc-oracle-node/src/handlers/auth_data.rs @@ -0,0 +1,205 @@ +use std::io::Error; +use std::path::Path; + +use algonaut::indexer::v2::Indexer; +use algonaut::model::indexer::v2::{QueryAssetTransaction, QueryAssetsInfo}; +use algonaut_client::Headers; +use anyhow::Context; +use axum::Json; +use ed25519::Signature; +use ring_compat::signature::ed25519::SigningKey; +use serde::{Deserialize, Serialize}; +use serde_with::base64::Base64; +use serde_with::serde_as; +use tokio::try_join; + +use crate::errors::AnyhowErrorResponse; +use crate::settings::Settings; +use crate::signer::AuthDataSigner; + +/// Request for [`auth_data`] +#[derive(Deserialize)] +pub(crate) struct AuthInput { + txn_id: String, + asset_id: u64, +} + +/// Response of [`auth_data`] +#[serde_as] +#[derive(Serialize)] +pub(crate) struct SignedAuthData { + #[serde_as(as = "Base64")] + auth_data: Vec, + #[serde_as(as = "Base64")] + signature: Signature, +} + +#[derive(Serialize)] +pub(crate) struct AuthData { + redeemed: bool, + drt_creator: String, + drt_redeemer: String, + binary: Vec, + data_package: Vec, + binary_url: String, + data_url: String, +} + +#[serde_as] +#[derive(Deserialize)] +struct DrtNote { + #[serde_as(as = "Base64")] + binary: Vec, + binary_url: String, + #[serde_as(as = "Base64")] + data_package: Vec, + data_url: String, +} + +/// Query authorization data for redeemed DRT. +/// +/// This will retrieve DRT information from Algorand blockchain, and return signed response. +pub(crate) async fn auth_data( + Json(auth_input): Json, +) -> Result, AnyhowErrorResponse> { + // Read key from PKCS#8 der file + let pkcs8_bytes = read_file(Path::new("/etc/ntc-oracle/pkcs8.der"))?; + let signing_key = SigningKey::from_pkcs8(pkcs8_bytes.as_ref())?; + + let auth_data = get_auth_data(auth_input).await?; + let auth_data_bytes = serde_json::to_vec(&auth_data)?; + let signed_auth_data = sign_auth_data(auth_data_bytes, signing_key); + Ok(Json(signed_auth_data)) +} + +fn sign_auth_data(auth_data: Vec, signing_key: SigningKey) -> SignedAuthData { + type RingAuthDataSigner = AuthDataSigner; + + let signer = RingAuthDataSigner { signing_key }; + let signature = signer.sign(&auth_data); + println!("Signature: {}", signature); + + SignedAuthData { + auth_data, + signature, + } +} + +async fn get_auth_data(auth_input: AuthInput) -> Result { + let indexer = init_purestake_indexer_client()?; + + let txn_id = auth_input.txn_id; + let asset_id = auth_input.asset_id; + + let query_assets_info = QueryAssetsInfo::default(); + let query_asset_transaction = QueryAssetTransaction::default(); + let (transaction_info, asset_info, asset_transactions) = try_join!( + indexer.transaction_info(&txn_id), + indexer.assets_info(asset_id, &query_assets_info), + indexer.asset_transactions(asset_id, &query_asset_transaction), + )?; + + // `redeemed` - check txn receiver is same as reserve address of DRT + let txn_receiver = transaction_info + .transaction + .asset_transfer_transaction + .context("Fail to get transaction information")? + .receiver; + println!("Transaction receiver: {}", txn_receiver); + let asset_reserve_addr = asset_info + .asset + .params + .reserve + .context("Fail to get asset reserve address")?; + println!("Reserve address: {}", asset_reserve_addr); + let redeemed = txn_receiver == asset_reserve_addr; + + // `drt_creator` - management address of DRT + let drt_creator = asset_info + .asset + .params + .manager + .context("Fail to get asset management address")? + .to_string(); + println!("Manager address: {}", drt_creator); + + // `drt_redeemer` + let drt_redeemer = transaction_info.transaction.sender; + println!("Transaction sender: {}", drt_redeemer); + + // Get information encoded in the DRT + // Find first config transaction for DRT to get Note field + let config_transaction = asset_transactions.transactions; + let note_base64 = config_transaction[0] + .clone() + .note + .context("Fail to get note of config transaction for DRT")?; + let note = base64::decode(note_base64)?; + let DrtNote { + binary, + binary_url, + data_package, + data_url, + } = serde_json::from_slice(note.as_slice())?; + + Ok(AuthData { + redeemed, + drt_creator, + drt_redeemer, + binary, + data_package, + binary_url, + data_url, + }) +} + +fn init_purestake_indexer_client() -> Result { + // load PureStake configuration settings + let settings = Settings::new()?; + + // connect v2 indexer client using algonaut + let indexer_header: Headers = vec![("X-API-Key", settings.purestake.indexer_token.as_str())]; + let indexer = Indexer::with_headers(settings.purestake.indexer_url.as_str(), indexer_header)?; + Ok(indexer) +} + +fn read_file(path: &Path) -> Result, Error> { + use std::io::Read; + + let mut file = std::fs::File::open(path)?; + let mut contents: Vec = Vec::new(); + file.read_to_end(&mut contents)?; + Ok(contents) +} + +#[cfg(test)] +mod tests { + use ring_compat::signature::ed25519::VerifyingKey; + + use super::*; + use crate::signer::AuthDataVerifier; + + #[test] + fn test_sign_auth_data_success() { + // Setup dummy serialized auth data + let auth_data = vec![7u8; 32]; + + // Create signing key + let seed = &[2u8; 32]; + let signing_key = SigningKey::from_seed(seed).unwrap(); + + // Create verifying key and verifier + let verify_key = signing_key.verify_key(); + type RingAuthDataVerifier = AuthDataVerifier; + let verifier = RingAuthDataVerifier { verify_key }; + + // Run sign_auth_data function + let signed_auth_data = sign_auth_data(auth_data.clone(), signing_key); + + // Asserts + assert_eq!(auth_data, signed_auth_data.auth_data); + assert!(verifier + .verify(&auth_data, &signed_auth_data.signature) + .is_ok()); + } +} diff --git a/rust-workspace/crates/ntc-oracle-node/src/handlers/mod.rs b/rust-workspace/crates/ntc-oracle-node/src/handlers/mod.rs new file mode 100644 index 0000000..bb9c84e --- /dev/null +++ b/rust-workspace/crates/ntc-oracle-node/src/handlers/mod.rs @@ -0,0 +1,3 @@ +//! HTTP handlers. + +pub(crate) mod auth_data; diff --git a/rust-workspace/crates/ntc-oracle-node/src/helpers.rs b/rust-workspace/crates/ntc-oracle-node/src/helpers.rs new file mode 100644 index 0000000..00c8a71 --- /dev/null +++ b/rust-workspace/crates/ntc-oracle-node/src/helpers.rs @@ -0,0 +1,15 @@ +use std::io; +use std::net::SocketAddr; +use std::str::FromStr; + +use env_var_helpers::env_vars; + +pub fn bind_addr_from_env() -> io::Result { + let value = env_vars::var_default("BIND_ADDR", "127.0.0.1:8081")?; + SocketAddr::from_str(&value).map_err(|parse_err| { + io::Error::new( + io::ErrorKind::InvalidInput, + format!("invalid BIND_ADDR value <{}>: {}", value, parse_err), + ) + }) +} diff --git a/rust-workspace/crates/ntc-oracle-node/src/main.rs b/rust-workspace/crates/ntc-oracle-node/src/main.rs new file mode 100644 index 0000000..68c7593 --- /dev/null +++ b/rust-workspace/crates/ntc-oracle-node/src/main.rs @@ -0,0 +1,31 @@ +mod errors; +mod handlers; +mod helpers; +mod settings; +mod signer; + +use std::error::Error; + +use axum::routing::get; +use axum::Router; +use tower_http::cors::CorsLayer; + +use crate::helpers::bind_addr_from_env; + +#[tokio::main] +async fn main() -> Result<(), Box> { + let bind_addr = bind_addr_from_env()?; + + // CORS: + let cors_layer = CorsLayer::permissive(); + + let axum_app = Router::new() + .route("/auth_data", get(handlers::auth_data::auth_data)) + // The CORS layer must come after the wrapped resources, for correct response headers. + .layer(cors_layer); + let axum_server = axum::Server::bind(&bind_addr).serve(axum_app.into_make_service()); + println!("listening on http://{}", bind_addr); + axum_server.await?; + + Ok(()) +} diff --git a/rust-workspace/crates/ntc-oracle-node/src/settings.rs b/rust-workspace/crates/ntc-oracle-node/src/settings.rs new file mode 100644 index 0000000..7495c5d --- /dev/null +++ b/rust-workspace/crates/ntc-oracle-node/src/settings.rs @@ -0,0 +1,30 @@ +// https://github.com/mehcode/config-rs/blob/master/examples/hierarchical-env/settings.rs + +use config::{Config, ConfigError, File}; +use serde_derive::Deserialize; + +#[derive(Debug, Deserialize)] +pub struct Purestake { + pub indexer_url: String, + pub indexer_token: String, +} + +#[derive(Debug, Deserialize)] +pub struct Settings { + pub purestake: Purestake, +} + +impl Settings { + pub fn new() -> Result { + let s = Config::builder() + // Start off by merging in the "default" configuration file + .add_source(File::with_name("config/default.toml")) + // Add in a local configuration file + // This file shouldn't be checked in to git + .add_source(File::with_name("config/local.toml").required(false)) + .build()?; + + // You can deserialize (and thus freeze) the entire configuration as + s.try_deserialize() + } +} diff --git a/rust-workspace/crates/ntc-oracle-node/src/signer.rs b/rust-workspace/crates/ntc-oracle-node/src/signer.rs new file mode 100644 index 0000000..ebd8165 --- /dev/null +++ b/rust-workspace/crates/ntc-oracle-node/src/signer.rs @@ -0,0 +1,43 @@ +use ed25519::signature::Signer; + +pub(crate) struct AuthDataSigner +where + S: Signer, +{ + pub signing_key: S, +} + +impl AuthDataSigner +where + S: Signer, +{ + pub(crate) fn sign(&self, auth_data: &[u8]) -> ed25519::Signature { + // NOTE: use `try_sign` if you'd like to be able to handle + // errors from external signing services/devices (e.g. HSM/KMS) + // + self.signing_key.sign(auth_data) + } +} + +#[cfg(test)] +use ed25519::signature::Verifier; + +#[cfg(test)] +pub(crate) struct AuthDataVerifier { + pub verify_key: V, +} + +#[cfg(test)] +impl AuthDataVerifier +where + V: Verifier, +{ + #[cfg(test)] + pub(crate) fn verify( + &self, + auth_data: &[u8], + signature: &ed25519::Signature, + ) -> Result<(), ed25519::Error> { + self.verify_key.verify(auth_data, signature) + } +} From 3a12a821ae90246af72a24359cce611238b7df5c Mon Sep 17 00:00:00 2001 From: Bill Guo Date: Mon, 5 Sep 2022 13:00:46 +0200 Subject: [PATCH 06/22] feat: add Vault backend (#61) * feat(web-server): copy web-server from Nautilus Wallet * docs(web-server): fix comments in rust-toolchain and rustfmt toml files * refactor: move http-service-impl and sgx-helpers into rust-sgx-workspace * refactor: move sgx-wallet-impl into rust-sgx-workspace but exclude as member * refactor: move sgx-wallet into rust-sgx-workspace but exclude as member * refactor: move sgx-wallet-test into rust-sgx-workspace but exclude as member * refactor: remove web-server * docs(http-service-impl): fix sgx-wallet-impl broken intra doc link * fix(sgx-wallet): fix path to sgx-wallet-impl in Makefile --- rust-sgx-workspace/Cargo.lock | 1357 +++- rust-sgx-workspace/Cargo.toml | 9 +- .../crates/http-service-impl/.gitignore | 1 + .../crates/http-service-impl/Cargo.toml | 25 + .../crates/http-service-impl/src/actors.rs | 50 + .../crates/http-service-impl/src/lib.rs | 6 + .../src/resources/enclave_report.rs | 125 + .../http-service-impl/src/resources/mod.rs | 2 + .../src/resources/wallet_operation.rs | 32 + .../crates/http-service-impl/src/server.rs | 42 + .../crates/http-service-impl/src/traits.rs | 45 + .../crates/sgx-helpers/.gitignore | 1 + .../crates/sgx-helpers/Cargo.toml | 9 + .../crates/sgx-helpers/src/lib.rs | 1 + .../crates/sgx-helpers/src/status.rs | 49 + .../crates/sgx-wallet-impl/.gitignore | 1 + .../crates/sgx-wallet-impl/Cargo.lock | 1027 +++ .../crates/sgx-wallet-impl/Cargo.toml | 42 + .../sgx-wallet-impl/src/ecall_helpers.rs | 15 + .../src/ecalls/enclave_create_report.rs | 49 + .../crates/sgx-wallet-impl/src/ecalls/mod.rs | 4 + .../src/ecalls/wallet_operation.rs | 62 + .../crates/sgx-wallet-impl/src/lib.rs | 11 + .../sgx-wallet-impl/src/ported/attestation.rs | 21 + .../sgx-wallet-impl/src/ported/crypto.rs | 205 + .../src/ported/kv_store/fs/mod.rs | 136 + .../src/ported/kv_store/fs/sgx_filer.rs | 44 + .../src/ported/kv_store/mod.rs | 69 + .../crates/sgx-wallet-impl/src/ported/mod.rs | 5 + .../sgx-wallet-impl/src/schema/actions.rs | 301 + .../sgx-wallet-impl/src/schema/entities.rs | 206 + .../crates/sgx-wallet-impl/src/schema/mod.rs | 28 + .../sgx-wallet-impl/src/schema/msgpack.rs | 42 + .../sgx-wallet-impl/src/schema/sealing.rs | 115 + .../src/schema/serde_bytes_array.rs | 27 + .../sgx-wallet-impl/src/schema/types.rs | 77 + .../src/wallet_operations/create_wallet.rs | 30 + .../src/wallet_operations/dispatch.rs | 115 + .../src/wallet_operations/errors.rs | 52 + .../wallet_operations/load_onfido_check.rs | 14 + .../src/wallet_operations/mod.rs | 12 + .../src/wallet_operations/open_wallet.rs | 12 + .../wallet_operations/save_onfido_check.rs | 21 + .../src/wallet_operations/sign_transaction.rs | 41 + .../sign_transaction_algorand.rs | 108 + .../sign_transaction_xrpl.rs | 8 + .../src/wallet_operations/store.rs | 90 + .../projects/ntc-tee-server/Makefile | 6 +- .../projects/ntc-tee-server/app/Cargo.toml | 4 +- .../ntc-tee-server/app/codegen/Enclave_u.rs | 2 +- .../ntc-tee-server/enclave/Cargo.toml | 4 +- .../projects/sgx-wallet-test/.gitignore | 2 + .../projects/sgx-wallet-test/Makefile | 50 + .../projects/sgx-wallet-test/Makefile.toml | 5 + .../projects/sgx-wallet-test/app/.gitignore | 1 + .../projects/sgx-wallet-test/app/Cargo.lock | 31 + .../projects/sgx-wallet-test/app/Cargo.toml | 12 + .../projects/sgx-wallet-test/app/Makefile | 99 + .../projects/sgx-wallet-test/app/build.rs | 21 + .../sgx-wallet-test/app/codegen/Enclave_u.c | 1307 ++++ .../sgx-wallet-test/app/codegen/Enclave_u.h | 350 + .../sgx-wallet-test/app/codegen/Enclave_u.rs | 7 + .../projects/sgx-wallet-test/app/src/main.rs | 49 + .../sgx-wallet-test/app/src/safe_ecalls.rs | 13 + .../projects/sgx-wallet-test/buildenv.mk | 167 + .../projects/sgx-wallet-test/buildenv_sgx.mk | 49 + .../sgx-wallet-test/enclave/.gitignore | 1 + .../sgx-wallet-test/enclave/Cargo.lock | 1204 ++++ .../sgx-wallet-test/enclave/Cargo.toml | 44 + .../enclave/Enclave.config.xml | 12 + .../sgx-wallet-test/enclave/Enclave.edl | 12 + .../sgx-wallet-test/enclave/Enclave.lds | 9 + .../projects/sgx-wallet-test/enclave/Makefile | 117 + .../enclave/codegen/Enclave_t.c | 5937 ++++++++++++++++ .../enclave/codegen/Enclave_t.h | 112 + .../enclave/src/helpers/algonaut.rs | 32 + .../enclave/src/helpers/mod.rs | 3 + .../enclave/src/helpers/temp_dir.rs | 33 + .../enclave/src/helpers/wallet_store.rs | 57 + .../sgx-wallet-test/enclave/src/lib.rs | 57 + .../enclave/src/ported/kv_store/tests.rs | 31 + .../sgx-wallet-test/enclave/src/ported/mod.rs | 5 + .../enclave/src/ported/proptest_crypto.rs | 47 + .../enclave/src/ported/test_attestation.rs | 17 + .../enclave/src/ported/test_crypto.rs | 79 + .../enclave/src/ported/test_kv_store.rs | 63 + .../enclave/src/ported/test_kv_store_fs.rs | 33 + .../sgx-wallet-test/enclave/src/schema/mod.rs | 2 + .../enclave/src/schema/test_sealing.rs | 56 + .../enclave/src/schema/test_types.rs | 20 + .../enclave/src/wallet_operations/mod.rs | 9 + .../wallet_operations/test_create_wallet.rs | 37 + .../src/wallet_operations/test_dispatch.rs | 40 + .../test_load_onfido_check.rs | 63 + .../src/wallet_operations/test_open_wallet.rs | 50 + .../test_save_onfido_check.rs | 63 + .../test_sign_transaction.rs | 116 + .../test_sign_transaction_msgpack.rs | 78 + .../test_sign_transaction_xrpl.rs | 32 + .../src/wallet_operations/test_store.rs | 37 + .../projects/sgx-wallet/.gitignore | 2 + .../projects/sgx-wallet/Makefile | 50 + .../projects/sgx-wallet/Makefile.toml | 5 + .../projects/sgx-wallet/app/.gitignore | 1 + .../projects/sgx-wallet/app/Cargo.lock | 1560 +++++ .../projects/sgx-wallet/app/Cargo.toml | 20 + .../projects/sgx-wallet/app/Makefile | 100 + .../projects/sgx-wallet/app/build.rs | 21 + .../sgx-wallet/app/codegen/Enclave_u.c | 1336 ++++ .../sgx-wallet/app/codegen/Enclave_u.h | 352 + .../sgx-wallet/app/codegen/Enclave_u.rs | 24 + .../projects/sgx-wallet/app/src/main.rs | 60 + .../sgx-wallet/app/src/safe_ecalls.rs | 58 + .../sgx-wallet/app/src/trait_impls.rs | 32 + .../projects/sgx-wallet/buildenv.mk | 167 + .../projects/sgx-wallet/buildenv_sgx.mk | 49 + .../projects/sgx-wallet/enclave/.gitignore | 1 + .../projects/sgx-wallet/enclave/Cargo.lock | 1048 +++ .../projects/sgx-wallet/enclave/Cargo.toml | 25 + .../sgx-wallet/enclave/Enclave.config.xml | 12 + .../projects/sgx-wallet/enclave/Enclave.edl | 26 + .../projects/sgx-wallet/enclave/Enclave.lds | 9 + .../projects/sgx-wallet/enclave/Makefile | 117 + .../sgx-wallet/enclave/codegen/Enclave_t.c | 6122 +++++++++++++++++ .../sgx-wallet/enclave/codegen/Enclave_t.h | 114 + .../projects/sgx-wallet/enclave/src/lib.rs | 7 + 126 files changed, 26719 insertions(+), 30 deletions(-) create mode 100644 rust-sgx-workspace/crates/http-service-impl/.gitignore create mode 100644 rust-sgx-workspace/crates/http-service-impl/Cargo.toml create mode 100644 rust-sgx-workspace/crates/http-service-impl/src/actors.rs create mode 100644 rust-sgx-workspace/crates/http-service-impl/src/lib.rs create mode 100644 rust-sgx-workspace/crates/http-service-impl/src/resources/enclave_report.rs create mode 100644 rust-sgx-workspace/crates/http-service-impl/src/resources/mod.rs create mode 100644 rust-sgx-workspace/crates/http-service-impl/src/resources/wallet_operation.rs create mode 100644 rust-sgx-workspace/crates/http-service-impl/src/server.rs create mode 100644 rust-sgx-workspace/crates/http-service-impl/src/traits.rs create mode 100644 rust-sgx-workspace/crates/sgx-helpers/.gitignore create mode 100644 rust-sgx-workspace/crates/sgx-helpers/Cargo.toml create mode 100644 rust-sgx-workspace/crates/sgx-helpers/src/lib.rs create mode 100644 rust-sgx-workspace/crates/sgx-helpers/src/status.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/.gitignore create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/Cargo.lock create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/Cargo.toml create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/ecall_helpers.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/ecalls/enclave_create_report.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/ecalls/mod.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/ecalls/wallet_operation.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/lib.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/attestation.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/crypto.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/kv_store/fs/mod.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/kv_store/fs/sgx_filer.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/kv_store/mod.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/mod.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/actions.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/entities.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/mod.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/msgpack.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/sealing.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/serde_bytes_array.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/types.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/create_wallet.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/dispatch.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/errors.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/load_onfido_check.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/mod.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/open_wallet.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/save_onfido_check.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/sign_transaction.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/sign_transaction_algorand.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/sign_transaction_xrpl.rs create mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/store.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/.gitignore create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/Makefile create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/Makefile.toml create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/app/.gitignore create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/app/Cargo.lock create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/app/Cargo.toml create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/app/Makefile create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/app/build.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/app/codegen/Enclave_u.c create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/app/codegen/Enclave_u.h create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/app/codegen/Enclave_u.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/app/src/main.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/app/src/safe_ecalls.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/buildenv.mk create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/buildenv_sgx.mk create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/.gitignore create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/Cargo.lock create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/Cargo.toml create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/Enclave.config.xml create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/Enclave.edl create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/Enclave.lds create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/Makefile create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/codegen/Enclave_t.c create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/codegen/Enclave_t.h create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/algonaut.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/mod.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/temp_dir.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/wallet_store.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/lib.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/kv_store/tests.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/mod.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/proptest_crypto.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_attestation.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_crypto.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_kv_store.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_kv_store_fs.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/schema/mod.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/schema/test_sealing.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/schema/test_types.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/mod.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_create_wallet.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_dispatch.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_load_onfido_check.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_open_wallet.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_save_onfido_check.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_sign_transaction.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_sign_transaction_msgpack.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_sign_transaction_xrpl.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_store.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet/.gitignore create mode 100644 rust-sgx-workspace/projects/sgx-wallet/Makefile create mode 100644 rust-sgx-workspace/projects/sgx-wallet/Makefile.toml create mode 100644 rust-sgx-workspace/projects/sgx-wallet/app/.gitignore create mode 100644 rust-sgx-workspace/projects/sgx-wallet/app/Cargo.lock create mode 100644 rust-sgx-workspace/projects/sgx-wallet/app/Cargo.toml create mode 100644 rust-sgx-workspace/projects/sgx-wallet/app/Makefile create mode 100644 rust-sgx-workspace/projects/sgx-wallet/app/build.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet/app/codegen/Enclave_u.c create mode 100644 rust-sgx-workspace/projects/sgx-wallet/app/codegen/Enclave_u.h create mode 100644 rust-sgx-workspace/projects/sgx-wallet/app/codegen/Enclave_u.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet/app/src/main.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet/app/src/safe_ecalls.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet/app/src/trait_impls.rs create mode 100644 rust-sgx-workspace/projects/sgx-wallet/buildenv.mk create mode 100644 rust-sgx-workspace/projects/sgx-wallet/buildenv_sgx.mk create mode 100644 rust-sgx-workspace/projects/sgx-wallet/enclave/.gitignore create mode 100644 rust-sgx-workspace/projects/sgx-wallet/enclave/Cargo.lock create mode 100644 rust-sgx-workspace/projects/sgx-wallet/enclave/Cargo.toml create mode 100644 rust-sgx-workspace/projects/sgx-wallet/enclave/Enclave.config.xml create mode 100644 rust-sgx-workspace/projects/sgx-wallet/enclave/Enclave.edl create mode 100644 rust-sgx-workspace/projects/sgx-wallet/enclave/Enclave.lds create mode 100644 rust-sgx-workspace/projects/sgx-wallet/enclave/Makefile create mode 100644 rust-sgx-workspace/projects/sgx-wallet/enclave/codegen/Enclave_t.c create mode 100644 rust-sgx-workspace/projects/sgx-wallet/enclave/codegen/Enclave_t.h create mode 100644 rust-sgx-workspace/projects/sgx-wallet/enclave/src/lib.rs diff --git a/rust-sgx-workspace/Cargo.lock b/rust-sgx-workspace/Cargo.lock index e607395..6049739 100644 --- a/rust-sgx-workspace/Cargo.lock +++ b/rust-sgx-workspace/Cargo.lock @@ -2,48 +2,1057 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "actix" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3720d0064a0ce5c0de7bd93bdb0a6caebab2a9b5668746145d7b3b0c5da02914" +dependencies = [ + "actix-rt", + "actix_derive", + "bitflags", + "bytes", + "crossbeam-channel", + "futures-core", + "futures-sink", + "futures-task", + "futures-util", + "log", + "once_cell", + "parking_lot 0.11.2", + "pin-project-lite", + "smallvec", + "tokio", + "tokio-util 0.6.10", +] + +[[package]] +name = "actix-codec" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57a7559404a7f3573127aab53c08ce37a6c6a315c374a31070f3c91cd1b4a7fe" +dependencies = [ + "bitflags", + "bytes", + "futures-core", + "futures-sink", + "log", + "memchr", + "pin-project-lite", + "tokio", + "tokio-util 0.7.3", +] + +[[package]] +name = "actix-cors" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02a0adcaabb68f1dfe8880cb3c5f049261c68f5d69ce06b6f3a930f31710838e" +dependencies = [ + "actix-utils", + "actix-web", + "derive_more", + "futures-util", + "log", + "once_cell", + "smallvec", +] + +[[package]] +name = "actix-http" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f9ffb6db08c1c3a1f4aef540f1a63193adc73c4fbd40b75a95fc8c5258f6e51" +dependencies = [ + "actix-codec", + "actix-rt", + "actix-service", + "actix-utils", + "ahash", + "base64", + "bitflags", + "brotli", + "bytes", + "bytestring", + "derive_more", + "encoding_rs", + "flate2", + "futures-core", + "h2", + "http", + "httparse", + "httpdate", + "itoa", + "language-tags", + "local-channel", + "mime", + "percent-encoding", + "pin-project-lite", + "rand", + "sha1", + "smallvec", + "tracing", + "zstd", +] + +[[package]] +name = "actix-macros" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "actix-router" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb60846b52c118f2f04a56cc90880a274271c489b2498623d58176f8ca21fa80" +dependencies = [ + "bytestring", + "firestorm", + "http", + "log", + "regex", + "serde", +] + +[[package]] +name = "actix-rt" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ea16c295198e958ef31930a6ef37d0fb64e9ca3b6116e6b93a8bdae96ee1000" +dependencies = [ + "futures-core", + "tokio", +] + +[[package]] +name = "actix-server" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0da34f8e659ea1b077bb4637948b815cd3768ad5a188fdcd74ff4d84240cd824" +dependencies = [ + "actix-rt", + "actix-service", + "actix-utils", + "futures-core", + "futures-util", + "mio", + "num_cpus", + "socket2", + "tokio", + "tracing", +] + +[[package]] +name = "actix-service" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b894941f818cfdc7ccc4b9e60fa7e53b5042a2e8567270f9147d5591893373a" +dependencies = [ + "futures-core", + "paste", + "pin-project-lite", +] + +[[package]] +name = "actix-utils" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e491cbaac2e7fc788dfff99ff48ef317e23b3cf63dbaf7aaab6418f40f92aa94" +dependencies = [ + "local-waker", + "pin-project-lite", +] + +[[package]] +name = "actix-web" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a27e8fe9ba4ae613c21f677c2cfaf0696c3744030c6f485b34634e502d6bb379" +dependencies = [ + "actix-codec", + "actix-http", + "actix-macros", + "actix-router", + "actix-rt", + "actix-server", + "actix-service", + "actix-utils", + "actix-web-codegen", + "ahash", + "bytes", + "bytestring", + "cfg-if", + "cookie", + "derive_more", + "encoding_rs", + "futures-core", + "futures-util", + "itoa", + "language-tags", + "log", + "mime", + "once_cell", + "pin-project-lite", + "regex", + "serde", + "serde_json", + "serde_urlencoded", + "smallvec", + "socket2", + "time", + "url", +] + +[[package]] +name = "actix-web-codegen" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f270541caec49c15673b0af0e9a00143421ad4f118d2df7edcb68b627632f56" +dependencies = [ + "actix-router", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "actix_derive" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d44b8fee1ced9671ba043476deddef739dd0959bf77030b26b738cc591737a7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +dependencies = [ + "memchr", +] + +[[package]] +name = "alloc-no-stdlib" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35ef4730490ad1c4eae5c4325b2a95f521d023e5c885853ff7aca0a6a1631db3" + +[[package]] +name = "alloc-stdlib" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "697ed7edc0f1711de49ce108c541623a0af97c6c60b2f6e2b65229847ac843c2" +dependencies = [ + "alloc-no-stdlib", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base64" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "block-buffer" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" +dependencies = [ + "generic-array", +] + +[[package]] +name = "brotli" +version = "3.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1a0b1dbcc8ae29329621f8d4f0d835787c1c38bb1401979b49d13b0b305ff68" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor", +] + +[[package]] +name = "brotli-decompressor" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ad2d4653bf5ca36ae797b1f4bb4dbddb60ce49ca4aed8a2ce4829f60425b80" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", +] + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" + +[[package]] +name = "bytestring" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b6a75fd3048808ef06af5cd79712be8111960adaf89d90250974b38fc3928a" +dependencies = [ + "bytes", +] + [[package]] name = "cc" version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +dependencies = [ + "jobserver", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "cookie" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94d4706de1b0fa5b132270cddffa8585166037822e260a944fe161acd137ca05" +dependencies = [ + "percent-encoding", + "time", + "version_check", +] + +[[package]] +name = "cpufeatures" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc948ebb96241bb40ab73effeb80d9f93afaad49359d159a5e61be51619fe813" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn", +] + +[[package]] +name = "digest" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "encoding_rs" +version = "0.8.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "firestorm" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c5f6c2c942da57e2aaaa84b8a521489486f14e75e7fa91dab70aba913975f98" + +[[package]] +name = "flate2" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +dependencies = [ + "matches", + "percent-encoding", +] + +[[package]] +name = "futures-core" +version = "0.3.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2acedae88d38235936c3922476b10fced7b2b68136f5e3c03c2d5be348a1115" + +[[package]] +name = "futures-sink" +version = "0.3.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca0bae1fe9752cf7fd9b0064c674ae63f97b37bc714d745cbde0afb7ec4e6765" + +[[package]] +name = "futures-task" +version = "0.3.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "842fc63b931f4056a24d59de13fb1272134ce261816e063e634ad0c15cdc5306" + +[[package]] +name = "futures-util" +version = "0.3.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0828a5471e340229c11c77ca80017937ce3c58cb788a17e5f1c2d5c485a9577" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "h2" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca32592cf21ac7ccab1825cd87f6c9b3d9022c44d086172ed0966bec8af30be" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util 0.7.3", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown_tstd" +version = "0.11.2" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "http" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-service-impl" +version = "0.1.0" +dependencies = [ + "actix", + "actix-cors", + "actix-web", + "rmp-serde", + "serde", + "sgx_types", +] + +[[package]] +name = "httparse" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "496ce29bb5a52785b44e0f7ca2847ae0bb839c9bd28f69acac9b99d461c0c04c" + +[[package]] +name = "httpdate" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" + +[[package]] +name = "idna" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "itoa" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" + +[[package]] +name = "jobserver" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" +dependencies = [ + "libc", +] + +[[package]] +name = "language-tags" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" + +[[package]] +name = "libc" +version = "0.2.132" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" + +[[package]] +name = "local-channel" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f303ec0e94c6c54447f84f3b0ef7af769858a9c4ef56ef2a986d3dcd4c3fc9c" +dependencies = [ + "futures-core", + "futures-sink", + "futures-util", + "local-waker", +] + +[[package]] +name = "local-waker" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e34f76eb3611940e0e7d53a9aaa4e6a3151f69541a282fd0dad5571420c53ff1" + +[[package]] +name = "lock_api" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "matches" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + +[[package]] +name = "miniz_oxide" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys", +] + +[[package]] +name = "ntc-tee-server-app" +version = "0.1.0" +dependencies = [ + "sgx_types", + "sgx_urts", +] + +[[package]] +name = "ntc-tee-server-enclave" +version = "0.1.0" +dependencies = [ + "sgx_tstd", + "sgx_types", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "num_threads" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" +dependencies = [ + "libc", +] + +[[package]] +name = "once_cell" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "074864da206b4973b84eb91683020dbefd6a8c3f0f38e054d93954e891935e4e" + +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core 0.8.5", +] + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core 0.9.3", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] [[package]] -name = "hashbrown_tstd" -version = "0.11.2" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +name = "parking_lot_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys", +] [[package]] -name = "libc" -version = "0.2.119" +name = "paste" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4" +checksum = "9423e2b32f7a043629287a536f21951e8c6a82482d0acb1eeebfc90bc2225b22" [[package]] -name = "ntc-tee-server-app" +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "ppv-lite86" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" + +[[package]] +name = "proc-macro2" +version = "1.0.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" dependencies = [ - "sgx_types", - "sgx_urts", + "unicode-ident", ] [[package]] -name = "ntc-tee-server-enclave" +name = "quote" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" + +[[package]] +name = "rmp" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44519172358fd6d58656c86ab8e7fbc9e1490c3e8f14d35ed78ca0dd07403c9f" +dependencies = [ + "byteorder", + "num-traits", + "paste", +] + +[[package]] +name = "rmp-serde" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "723ecff9ad04f4ad92fe1c8ca6c20d2196d9286e9c60727c4cb5511629260e9d" +dependencies = [ + "byteorder", + "rmp", + "serde", +] + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "ryu" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "semver" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93f6841e709003d68bb2deee8c343572bf446003ec20a583e76f7b15cebf3711" + +[[package]] +name = "serde" +version = "1.0.144" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f747710de3dcd43b88c9168773254e809d8ddbdf9653b84e2554ab219f17860" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.144" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94ed3a816fb1d101812f83e789f888322c34e291f894f19590dc310963e87a00" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sgx-helpers" version = "0.1.0" dependencies = [ - "sgx_tstd", "sgx_types", ] [[package]] name = "sgx_alloc" version = "1.1.4" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" [[package]] name = "sgx_backtrace_sys" version = "1.1.4" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" dependencies = [ "cc", "sgx_build_helper", @@ -53,17 +1062,17 @@ dependencies = [ [[package]] name = "sgx_build_helper" version = "1.1.4" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" [[package]] name = "sgx_demangle" version = "1.1.4" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" [[package]] name = "sgx_libc" version = "1.1.4" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" dependencies = [ "sgx_types", ] @@ -71,7 +1080,7 @@ dependencies = [ [[package]] name = "sgx_tprotected_fs" version = "1.1.4" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" dependencies = [ "sgx_trts", "sgx_types", @@ -80,7 +1089,7 @@ dependencies = [ [[package]] name = "sgx_trts" version = "1.1.4" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" dependencies = [ "sgx_libc", "sgx_types", @@ -89,7 +1098,7 @@ dependencies = [ [[package]] name = "sgx_tstd" version = "1.1.4" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" dependencies = [ "hashbrown_tstd", "sgx_alloc", @@ -105,12 +1114,12 @@ dependencies = [ [[package]] name = "sgx_types" version = "1.1.4" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" [[package]] name = "sgx_unwind" version = "1.1.4" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" dependencies = [ "sgx_build_helper", ] @@ -118,8 +1127,310 @@ dependencies = [ [[package]] name = "sgx_urts" version = "1.1.4" -source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" dependencies = [ "libc", "sgx_types", ] + +[[package]] +name = "sha1" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c77f4e7f65455545c2153c1253d25056825e77ee2533f0e41deb65a93a34852f" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" + +[[package]] +name = "socket2" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "syn" +version = "1.0.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "time" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db76ff9fa4b1458b3c7f077f3ff9887394058460d21e634355b273aaf11eea45" +dependencies = [ + "itoa", + "libc", + "num_threads", + "time-macros", +] + +[[package]] +name = "time-macros" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792" + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "tokio" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a8325f63a7d4774dd041e363b2409ed1c5cbbd0f867795e661df066b2b0a581" +dependencies = [ + "autocfg", + "bytes", + "libc", + "memchr", + "mio", + "once_cell", + "parking_lot 0.12.1", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "winapi", +] + +[[package]] +name = "tokio-util" +version = "0.6.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc463cd8deddc3770d20f9852143d50bf6094e640b485cb2e189a2099085ff45" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "tracing" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fce9567bd60a67d08a16488756721ba392f24f29006402881e43b19aac64307" +dependencies = [ + "cfg-if", + "log", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aeea4303076558a00714b823f9ad67d58a3bbda1df83d8827d21193156e22f7" +dependencies = [ + "once_cell", +] + +[[package]] +name = "typenum" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" + +[[package]] +name = "unicode-bidi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" + +[[package]] +name = "unicode-ident" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" + +[[package]] +name = "unicode-normalization" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "854cbdc4f7bc6ae19c820d44abdc3277ac3e1b2b93db20a636825d9322fb60e6" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "url" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" +dependencies = [ + "form_urlencoded", + "idna", + "matches", + "percent-encoding", +] + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +dependencies = [ + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + +[[package]] +name = "windows_i686_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + +[[package]] +name = "windows_i686_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + +[[package]] +name = "zstd" +version = "0.11.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "5.0.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.1+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fd07cbbc53846d9145dbffdf6dd09a7a0aa52be46741825f5c97bdd4f73f12b" +dependencies = [ + "cc", + "libc", +] diff --git a/rust-sgx-workspace/Cargo.toml b/rust-sgx-workspace/Cargo.toml index c55b651..df34409 100644 --- a/rust-sgx-workspace/Cargo.toml +++ b/rust-sgx-workspace/Cargo.toml @@ -1,8 +1,15 @@ [workspace] members = [ -# 'crates/*', + 'crates/*', 'projects/*/app', 'projects/*/enclave', ] +exclude = [ + 'crates/sgx-wallet-impl', + 'projects/sgx-wallet/app', + 'projects/sgx-wallet/enclave', + 'projects/sgx-wallet-test/app', + 'projects/sgx-wallet-test/enclave', +] [patch.'https://github.com/apache/teaclave-sgx-sdk.git'] diff --git a/rust-sgx-workspace/crates/http-service-impl/.gitignore b/rust-sgx-workspace/crates/http-service-impl/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/rust-sgx-workspace/crates/http-service-impl/.gitignore @@ -0,0 +1 @@ +/target diff --git a/rust-sgx-workspace/crates/http-service-impl/Cargo.toml b/rust-sgx-workspace/crates/http-service-impl/Cargo.toml new file mode 100644 index 0000000..7d4b082 --- /dev/null +++ b/rust-sgx-workspace/crates/http-service-impl/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "http-service-impl" +version = "0.1.0" +edition = "2021" +description = "HTTP endpoints for enclave communication" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[features] +# Enable verbose debug output. +# (DO NOT enable outside of testing: This may expose enclave-sealed data.) +verbose-debug-logging = [] + +[dependencies] +actix = "0.12" +actix-web = "4.0.0-beta.8" +actix-cors = "0.6.0-beta.2" + +# XXX: Stop-gap +rmp-serde = "0.15.5" +serde = { version = "1.0", features=["derive"] } + + +# SGX SDK +sgx_types = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } diff --git a/rust-sgx-workspace/crates/http-service-impl/src/actors.rs b/rust-sgx-workspace/crates/http-service-impl/src/actors.rs new file mode 100644 index 0000000..8b5d065 --- /dev/null +++ b/rust-sgx-workspace/crates/http-service-impl/src/actors.rs @@ -0,0 +1,50 @@ +use actix::{Actor, Context, Handler, Message}; +use sgx_types::{sgx_report_t, sgx_target_info_t, SgxResult}; + +use crate::traits::WalletEnclave; + +/// This actor lets [`crate::resources`] interact with the wallet enclave. +pub(crate) struct WalletEnclaveActor { + pub(crate) wallet_enclave: Box, +} + +impl Actor for WalletEnclaveActor { + type Context = Context; +} + +// CreateReport message: + +pub(crate) struct CreateReportMessage { + pub(crate) target_info: sgx_target_info_t, +} + +impl Message for CreateReportMessage { + type Result = SgxResult>; +} + +impl Handler for WalletEnclaveActor { + type Result = ::Result; + + fn handle(&mut self, msg: CreateReportMessage, _ctx: &mut Self::Context) -> Self::Result { + self.wallet_enclave.create_report(msg.target_info) + } +} + +// WalletOperation message: + +pub(crate) struct WalletOperationMessage { + pub(crate) sealed_request_bytes: Box<[u8]>, +} + +impl Message for WalletOperationMessage { + type Result = SgxResult>>; +} + +impl Handler for WalletEnclaveActor { + type Result = ::Result; + + fn handle(&mut self, msg: WalletOperationMessage, _ctx: &mut Self::Context) -> Self::Result { + self.wallet_enclave + .wallet_operation_with_retry(&msg.sealed_request_bytes) + } +} diff --git a/rust-sgx-workspace/crates/http-service-impl/src/lib.rs b/rust-sgx-workspace/crates/http-service-impl/src/lib.rs new file mode 100644 index 0000000..123208b --- /dev/null +++ b/rust-sgx-workspace/crates/http-service-impl/src/lib.rs @@ -0,0 +1,6 @@ +extern crate alloc; + +mod actors; +mod resources; +pub mod server; +pub mod traits; diff --git a/rust-sgx-workspace/crates/http-service-impl/src/resources/enclave_report.rs b/rust-sgx-workspace/crates/http-service-impl/src/resources/enclave_report.rs new file mode 100644 index 0000000..842b59e --- /dev/null +++ b/rust-sgx-workspace/crates/http-service-impl/src/resources/enclave_report.rs @@ -0,0 +1,125 @@ +use actix_web::{error, get, web}; + +use crate::actors::CreateReportMessage; +use crate::resources::enclave_report::attestation_report::{to_msgpack, AttestationReport}; +use crate::server::AppState; + +#[get("/enclave-report")] +pub(crate) async fn get_enclave_report( + app_state: web::Data, +) -> actix_web::Result { + let message = CreateReportMessage { + target_info: Default::default(), + }; + let (report, enclave_data) = app_state + .wallet_enclave_addr + .send(message) + .await + .map_err(|mailbox_error| { + error::ErrorInternalServerError(format!("Failed to reach actor: {:?}", mailbox_error)) + })? + .map_err(|sgx_error| { + error::ErrorInternalServerError(format!("Failed to call enclave: {:?}", sgx_error)) + })? + .map_err(|sgx_error| { + error::ErrorInternalServerError(format!("enclave_create_report failed: {}", sgx_error)) + })?; + + let attestation_report = &AttestationReport { + report: report.into(), + enclave_public_key: enclave_data, + }; + let response_body = to_msgpack(attestation_report) + .map(Vec::from) + .map_err(|err| { + error::ErrorInternalServerError(format!( + "failed to serialize AttestationReport: {}", + err + )) + })?; + Ok(actix_web::HttpResponse::Ok() + .content_type("application/x-msgpack") + .body(response_body)) +} + +/// XXX: Stop-gap + +mod attestation_report { + use rmp_serde::{encode, Serializer}; + use serde::{Deserialize, Serialize}; + use sgx_types::*; + + /// See [`../../crates/sgx_wallet_impl::schema::msgpack::ToMessagePack::to_msgpack`] + pub(crate) fn to_msgpack(message: &impl Serialize) -> Result, encode::Error> { + // XXX: Like rmp_serde::to_vec_named, but we need string variants too. + let mut wr = Vec::with_capacity(128); + let mut se = Serializer::new(&mut wr) + .with_struct_map() + .with_string_variants(); + message.serialize(&mut se)?; + Ok(wr.into_boxed_slice()) + } + + type PublicKey = [u8; 32]; + + #[derive(Clone, Eq, PartialEq, Debug)] // core + #[derive(Deserialize, Serialize)] // serde + pub struct AttestationReport { + pub report: SgxReport, + pub enclave_public_key: PublicKey, + } + + #[derive(Clone, Eq, PartialEq, Debug)] // core + #[derive(Deserialize, Serialize)] // serde + pub struct SgxReport { + pub body: SgxReportBody, + pub key_id: [uint8_t; SGX_KEYID_SIZE], + pub mac: sgx_mac_t, + } + + impl From for SgxReport { + fn from(report: sgx_report_t) -> Self { + Self { + body: report.body.into(), + key_id: report.key_id.id, + mac: report.mac, + } + } + } + + #[derive(Clone, Eq, PartialEq, Debug)] // core + #[derive(Deserialize, Serialize)] // serde + pub struct SgxReportBody { + pub cpu_svn: [uint8_t; SGX_CPUSVN_SIZE], + pub isv_ext_prod_id: sgx_isvext_prod_id_t, + pub attributes_flags: uint64_t, + pub attributes_xfrm: uint64_t, + pub mr_enclave: [uint8_t; SGX_HASH_SIZE], + pub mr_signer: [uint8_t; SGX_HASH_SIZE], + pub config_id: Box<[uint8_t]>, // XXX [uint8_t; SGX_CONFIGID_SIZE] + pub isv_prod_id: sgx_prod_id_t, + pub isv_svn: sgx_isv_svn_t, + pub config_svn: sgx_config_svn_t, + pub isv_family_id: sgx_isvfamily_id_t, + pub report_data: Box<[uint8_t]>, // XXX [uint8_t; SGX_REPORT_DATA_SIZE] + } + + impl From for SgxReportBody { + fn from(body: sgx_report_body_t) -> Self { + Self { + cpu_svn: body.cpu_svn.svn, + isv_ext_prod_id: body.isv_ext_prod_id, + attributes_flags: body.attributes.flags, + attributes_xfrm: body.attributes.xfrm, + mr_enclave: body.mr_enclave.m, + mr_signer: body.mr_signer.m, + config_id: body.config_id.into(), + isv_prod_id: body.isv_prod_id, + isv_svn: body.isv_svn, + config_svn: body.config_svn, + isv_family_id: body.isv_family_id, + report_data: body.report_data.d.into(), + } + } + } +} diff --git a/rust-sgx-workspace/crates/http-service-impl/src/resources/mod.rs b/rust-sgx-workspace/crates/http-service-impl/src/resources/mod.rs new file mode 100644 index 0000000..30c0f65 --- /dev/null +++ b/rust-sgx-workspace/crates/http-service-impl/src/resources/mod.rs @@ -0,0 +1,2 @@ +pub(crate) mod enclave_report; +pub(crate) mod wallet_operation; diff --git a/rust-sgx-workspace/crates/http-service-impl/src/resources/wallet_operation.rs b/rust-sgx-workspace/crates/http-service-impl/src/resources/wallet_operation.rs new file mode 100644 index 0000000..ba588f9 --- /dev/null +++ b/rust-sgx-workspace/crates/http-service-impl/src/resources/wallet_operation.rs @@ -0,0 +1,32 @@ +use actix_web::{error, post, web}; + +use crate::actors::WalletOperationMessage; +use crate::server::AppState; + +#[post("/wallet-operation")] +pub(crate) async fn post_wallet_operation( + app_state: web::Data, + request_body: web::Bytes, +) -> actix_web::Result { + let sealed_request_bytes = request_body.to_vec().into_boxed_slice(); + let message = WalletOperationMessage { + sealed_request_bytes, + }; + let sealed_response_bytes = app_state + .wallet_enclave_addr + .send(message) + .await + .map_err(|mailbox_error| { + error::ErrorInternalServerError(format!("Failed to reach actor: {:?}", mailbox_error)) + })? + .map_err(|sgx_error| { + error::ErrorInternalServerError(format!("Failed to call enclave: {:?}", sgx_error)) + })? + .map_err(|sgx_error| { + error::ErrorInternalServerError(format!("wallet_operation failed: {}", sgx_error)) + })?; + let response_body = sealed_response_bytes.into_vec(); + Ok(actix_web::HttpResponse::Ok() + .content_type("application/x-msgpack") + .body(response_body)) +} diff --git a/rust-sgx-workspace/crates/http-service-impl/src/server.rs b/rust-sgx-workspace/crates/http-service-impl/src/server.rs new file mode 100644 index 0000000..1eed1c8 --- /dev/null +++ b/rust-sgx-workspace/crates/http-service-impl/src/server.rs @@ -0,0 +1,42 @@ +use std::net::ToSocketAddrs; + +use actix::{Actor, Addr, Arbiter}; +use actix_cors::Cors; +use actix_web::{web, App, HttpServer}; + +use crate::actors::WalletEnclaveActor; +use crate::resources; +use crate::traits::WalletEnclave; + +#[derive(Clone)] +pub(crate) struct AppState { + pub(crate) wallet_enclave_addr: Addr, +} + +/// Run the server on the given address. +pub async fn run_server( + wallet_enclave: Box, + bind_addr: Addr, +) -> std::io::Result<()> +where + Addr: ToSocketAddrs, +{ + let enclave_arbiter = Arbiter::new(); + let wallet_enclave_addr = Actor::start_in_arbiter(&enclave_arbiter.handle(), |_ctx| { + WalletEnclaveActor { wallet_enclave } + }); + + // TODO: Test coverage + let server = HttpServer::new(move || { + let app_state = AppState { + wallet_enclave_addr: wallet_enclave_addr.clone(), + }; + let cors = Cors::permissive(); // TODO: Tighten this a bit more? + App::new() + .wrap(cors) + .app_data(web::Data::new(app_state)) + .service(resources::enclave_report::get_enclave_report) + .service(resources::wallet_operation::post_wallet_operation) + }); + server.bind(bind_addr)?.run().await +} diff --git a/rust-sgx-workspace/crates/http-service-impl/src/traits.rs b/rust-sgx-workspace/crates/http-service-impl/src/traits.rs new file mode 100644 index 0000000..35aa74d --- /dev/null +++ b/rust-sgx-workspace/crates/http-service-impl/src/traits.rs @@ -0,0 +1,45 @@ +use sgx_types::{sgx_report_t, sgx_status_t, sgx_target_info_t, SgxResult}; + +/// Interface for working with wallet enclave. +pub trait WalletEnclave: Send + 'static { + fn create_report( + &self, + target_info: sgx_target_info_t, + ) -> SgxResult>; + + fn wallet_operation( + &self, + sealed_request: &[u8], + sealed_response_capacity: usize, + ) -> SgxResult>>; + + /// Wrapper: Retry [`Self::wallet_operation`] with increasing capacity. + fn wallet_operation_with_retry( + &self, + sealed_request: &[u8], + ) -> SgxResult>> { + // Attempt sizes: 1 KiB, 64 KiB, 1 MiB + for &sealed_response_capacity in &[1 << 10, 1 << 16, 1 << 20] { + let result = self.wallet_operation(sealed_request, sealed_response_capacity); + match result { + Ok(Err(sgx_status_t::SGX_ERROR_FAAS_BUFFER_TOO_SHORT)) => { + println!( + "DEBUG: wallet_operation_with_retry: capacity={} too short, retrying…", + sealed_response_capacity + ) + } + result => { + if cfg!(feature = "verbose-debug-logging") { + println!( + "DEBUG: wallet_operation_with_retry: capacity={} returning {:?}", + sealed_response_capacity, result + ); + } + return result; + } + } + } + println!("DEBUG: wallet_operation_with_retry: giving up!",); + Ok(Err(sgx_status_t::SGX_ERROR_FAAS_BUFFER_TOO_SHORT)) + } +} diff --git a/rust-sgx-workspace/crates/sgx-helpers/.gitignore b/rust-sgx-workspace/crates/sgx-helpers/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-helpers/.gitignore @@ -0,0 +1 @@ +/target diff --git a/rust-sgx-workspace/crates/sgx-helpers/Cargo.toml b/rust-sgx-workspace/crates/sgx-helpers/Cargo.toml new file mode 100644 index 0000000..554ed8d --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-helpers/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "sgx-helpers" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +sgx_types = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } diff --git a/rust-sgx-workspace/crates/sgx-helpers/src/lib.rs b/rust-sgx-workspace/crates/sgx-helpers/src/lib.rs new file mode 100644 index 0000000..822c729 --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-helpers/src/lib.rs @@ -0,0 +1 @@ +pub mod status; diff --git a/rust-sgx-workspace/crates/sgx-helpers/src/status.rs b/rust-sgx-workspace/crates/sgx-helpers/src/status.rs new file mode 100644 index 0000000..a054820 --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-helpers/src/status.rs @@ -0,0 +1,49 @@ +//! Helpers for working with [`sgx_status_t`] and [`SgxResult`] + +use sgx_types::{sgx_status_t, SgxResult}; + +pub fn sgx_success_and(status: sgx_status_t, value: T) -> SgxResult { + match status { + sgx_status_t::SGX_SUCCESS => Ok(value), + error => Err(error), + } +} + +pub fn sgx_success_and_then(status: sgx_status_t, f: F) -> SgxResult +where + F: FnOnce() -> T, +{ + match status { + sgx_status_t::SGX_SUCCESS => Ok(f()), + error => Err(error), + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn sgx_success_and_works() { + assert_eq!( + sgx_success_and(sgx_status_t::SGX_SUCCESS, "success"), + Ok("success") + ); + assert_eq!( + sgx_success_and(sgx_status_t::SGX_ERROR_INVALID_PARAMETER, "failure"), + Err(sgx_status_t::SGX_ERROR_INVALID_PARAMETER) + ); + } + + #[test] + fn sgx_success_and_then_works() { + assert_eq!( + sgx_success_and_then(sgx_status_t::SGX_SUCCESS, || "success"), + Ok("success") + ); + assert_eq!( + sgx_success_and_then(sgx_status_t::SGX_ERROR_INVALID_PARAMETER, || "failure"), + Err(sgx_status_t::SGX_ERROR_INVALID_PARAMETER) + ); + } +} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/.gitignore b/rust-sgx-workspace/crates/sgx-wallet-impl/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/.gitignore @@ -0,0 +1 @@ +/target diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/Cargo.lock b/rust-sgx-workspace/crates/sgx-wallet-impl/Cargo.lock new file mode 100644 index 0000000..dff1b07 --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/Cargo.lock @@ -0,0 +1,1027 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "algonaut" +version = "0.3.0" +source = "git+https://github.com/registreerocks/algonaut-sgx?branch=main-sgx#4c2a24f5ba08e6623f0103853396f417b10d097b" +dependencies = [ + "algonaut_core", + "algonaut_crypto", + "algonaut_encoding", + "algonaut_transaction", +] + +[[package]] +name = "algonaut_core" +version = "0.3.0" +source = "git+https://github.com/registreerocks/algonaut-sgx?branch=main-sgx#4c2a24f5ba08e6623f0103853396f417b10d097b" +dependencies = [ + "algonaut_crypto", + "algonaut_encoding", + "data-encoding", + "derive_more", + "rmp-serde", + "serde", + "sgx_tstd", + "sha2 0.9.9", + "static_assertions", + "thiserror", +] + +[[package]] +name = "algonaut_crypto" +version = "0.3.0" +source = "git+https://github.com/registreerocks/algonaut-sgx?branch=main-sgx#4c2a24f5ba08e6623f0103853396f417b10d097b" +dependencies = [ + "algonaut_encoding", + "data-encoding", + "derive_more", + "indexmap", + "lazy_static", + "ring", + "serde", + "sgx_tstd", + "sha2 0.9.9", + "static_assertions", + "thiserror", +] + +[[package]] +name = "algonaut_encoding" +version = "0.3.0" +source = "git+https://github.com/registreerocks/algonaut-sgx?branch=main-sgx#4c2a24f5ba08e6623f0103853396f417b10d097b" +dependencies = [ + "data-encoding", + "serde", + "sgx_tstd", +] + +[[package]] +name = "algonaut_transaction" +version = "0.3.0" +source = "git+https://github.com/registreerocks/algonaut-sgx?branch=main-sgx#4c2a24f5ba08e6623f0103853396f417b10d097b" +dependencies = [ + "algonaut_core", + "algonaut_crypto", + "algonaut_encoding", + "data-encoding", + "derive_more", + "getrandom 0.2.7", + "num-traits", + "rand", + "ring", + "rmp-serde", + "serde", + "serde_bytes", + "sgx_tstd", + "sha2 0.9.9", + "thiserror", + "url", +] + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "autocfg" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78" +dependencies = [ + "autocfg 1.1.0", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base-x" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" + +[[package]] +name = "base64" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" + +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "git+https://github.com/mesalock-linux/rustcrypto-utils-sgx#07ebf780554e018037f750186d61ea9bdc031148" +dependencies = [ + "block-padding", + "byte-tools", + "byteorder", + "generic-array 0.12.4", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array 0.14.6", +] + +[[package]] +name = "block-padding" +version = "0.1.4" +source = "git+https://github.com/mesalock-linux/rustcrypto-utils-sgx#07ebf780554e018037f750186d61ea9bdc031148" +dependencies = [ + "byte-tools", +] + +[[package]] +name = "bumpalo" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d" + +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "git+https://github.com/mesalock-linux/rustcrypto-utils-sgx#07ebf780554e018037f750186d61ea9bdc031148" + +[[package]] +name = "byteorder" +version = "1.3.4" +source = "git+https://github.com/mesalock-linux/byteorder-sgx#325f392dcd294109eb05f0a3c45e4141514c7784" +dependencies = [ + "sgx_tstd", +] + +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "cpufeatures" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc948ebb96241bb40ab73effeb80d9f93afaad49359d159a5e61be51619fe813" +dependencies = [ + "libc", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "git+https://github.com/mesalock-linux/rustcrypto-traits-sgx#7a5cb154f438c2401b3d8e37de96dd0acf8f493e" +dependencies = [ + "generic-array 0.12.4", + "subtle", +] + +[[package]] +name = "data-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn", +] + +[[package]] +name = "digest" +version = "0.8.1" +source = "git+https://github.com/mesalock-linux/rustcrypto-traits-sgx#7a5cb154f438c2401b3d8e37de96dd0acf8f493e" +dependencies = [ + "generic-array 0.12.4", + "sgx_tstd", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array 0.14.6", +] + +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.14" +source = "git+https://github.com/mesalock-linux/getrandom-sgx#0aa9cc20c7dea713ccaac2c44430d625a395ebae" +dependencies = [ + "cfg-if 0.1.10", + "sgx_libc", + "sgx_trts", + "sgx_tstd", +] + +[[package]] +name = "getrandom" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +dependencies = [ + "cfg-if 1.0.0", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "hashbrown" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" + +[[package]] +name = "hashbrown_tstd" +version = "0.11.2" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.7.1" +source = "git+https://github.com/mesalock-linux/rustcrypto-MACs-sgx#e8e1410b9c82d2e59da42fa8b0d8ed38e80a203c" +dependencies = [ + "crypto-mac", + "digest 0.8.1", +] + +[[package]] +name = "hmac-drbg" +version = "0.1.2" +source = "git+https://github.com/mesalock-linux/hmac-drbg-rs-sgx#89d6b0113157599417af867a8d2b4afd5c6f1946" +dependencies = [ + "generic-array 0.12.4", + "hmac", +] + +[[package]] +name = "idna" +version = "0.2.0" +source = "git+https://github.com/mesalock-linux/rust-url-sgx#23832f3191456c2d4a0faab10952e1747be58ca8" +dependencies = [ + "matches", + "sgx_tstd", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "index-fixed" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161ceaf2f41b6cd3f6502f5da085d4ad4393a51e0c70ed2fce1d5698d798fae" + +[[package]] +name = "indexmap" +version = "1.6.1" +source = "git+https://github.com/mesalock-linux/indexmap-sgx#19f52458ba64dd7349a5d3a62227619a17e4db85" +dependencies = [ + "autocfg 1.1.0", + "hashbrown", + "sgx_tstd", +] + +[[package]] +name = "itoa" +version = "0.4.5" +source = "git+https://github.com/mesalock-linux/itoa-sgx#295ee451f5ec74f25c299552b481beb445ea3eb7" +dependencies = [ + "sgx_tstd", +] + +[[package]] +name = "js-sys" +version = "0.3.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "258451ab10b34f8af53416d1fdab72c22e805f0c92a1136d59470ec0b11138b2" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin", +] + +[[package]] +name = "libc" +version = "0.2.132" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" + +[[package]] +name = "libsecp256k1" +version = "0.3.5" +source = "git+https://github.com/ntls-io/libsecp256k1-rs-sgx#2a6c35a1876b3553486d34142155b89eaae77965" +dependencies = [ + "arrayref", + "crunchy", + "digest 0.8.1", + "hmac-drbg", + "rand", + "sgx_tstd", + "sha2 0.8.0", + "subtle", + "typenum", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "matches" +version = "0.1.8" +source = "git+https://github.com/mesalock-linux/rust-std-candidates-sgx#5747bcf37f3e18687758838da0339ff0f2c83924" + +[[package]] +name = "num-bigint" +version = "0.2.5" +source = "git+https://github.com/mesalock-linux/num-bigint-sgx#76a5bed94dc31c32bd1670dbf72877abcf9bbc09" +dependencies = [ + "autocfg 1.1.0", + "num-integer", + "num-traits", + "sgx_tstd", +] + +[[package]] +name = "num-integer" +version = "0.1.41" +source = "git+https://github.com/mesalock-linux/num-integer-sgx#404c50e5378ca635261688b080dee328ff42b6bd" +dependencies = [ + "autocfg 0.1.8", + "num-traits", + "sgx_tstd", +] + +[[package]] +name = "num-traits" +version = "0.2.10" +source = "git+https://github.com/mesalock-linux/num-traits-sgx#af046e0b15c594c960007418097dd4ff37ec3f7a" +dependencies = [ + "autocfg 0.1.8", + "sgx_tstd", +] + +[[package]] +name = "once_cell" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "074864da206b4973b84eb91683020dbefd6a8c3f0f38e054d93954e891935e4e" + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "git+https://github.com/mesalock-linux/rust-url-sgx#23832f3191456c2d4a0faab10952e1747be58ca8" + +[[package]] +name = "ppv-lite86" +version = "0.2.6" +source = "git+https://github.com/mesalock-linux/cryptocorrosion-sgx#32d7de50b5f03a10fe5a42167410be2dd3c2e389" + +[[package]] +name = "proc-macro2" +version = "1.0.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "git+https://github.com/mesalock-linux/rand-sgx#83583f073de3b4f75c3c3ef5e174d484ed941f85" +dependencies = [ + "getrandom 0.1.14", + "rand_chacha", + "rand_core", + "sgx_tstd", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "git+https://github.com/mesalock-linux/rand-sgx#83583f073de3b4f75c3c3ef5e174d484ed941f85" +dependencies = [ + "ppv-lite86", + "rand_core", + "sgx_tstd", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "git+https://github.com/mesalock-linux/rand-sgx#83583f073de3b4f75c3c3ef5e174d484ed941f85" +dependencies = [ + "getrandom 0.1.14", + "sgx_tstd", +] + +[[package]] +name = "ring" +version = "0.16.19" +source = "git+https://github.com/mesalock-linux/ring-sgx#844efe271ed78a399d803b2579f5f2424d543c9f" +dependencies = [ + "cc", + "sgx_tstd", + "spin", + "untrusted", +] + +[[package]] +name = "ripemd160" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eca4ecc81b7f313189bf73ce724400a07da2a6dac19588b03c8bd76a2dcc251" +dependencies = [ + "block-buffer 0.9.0", + "digest 0.9.0", + "opaque-debug 0.3.0", +] + +[[package]] +name = "ripple-address-codec" +version = "0.1.1" +source = "git+https://github.com/ntls-io/ripple-address-codec-rust-sgx?branch=v0.1.1-sgx#e2b03486a9e0627bbc922681863b4661be8a4e3b" +dependencies = [ + "base-x", + "ring", + "sgx_tstd", +] + +[[package]] +name = "ripple-keypairs" +version = "0.1.0" +source = "git+https://github.com/ntls-io/ripple-keypairs-rust-sgx?branch=v0.1.0-sgx#ef55261e2f0aa6b5c54cac43abc4c57b4f97b286" +dependencies = [ + "base-x", + "hex", + "libsecp256k1", + "num-bigint", + "ring", + "ripemd160", + "ripple-address-codec", + "sgx_tstd", +] + +[[package]] +name = "rmp" +version = "0.8.9" +source = "git+https://github.com/mesalock-linux/msgpack-rust-sgx#55273d79a63a08bdfe06d744e635296875307b22" +dependencies = [ + "byteorder", + "num-traits", + "sgx_tstd", +] + +[[package]] +name = "rmp-serde" +version = "0.15.0" +source = "git+https://github.com/mesalock-linux/msgpack-rust-sgx#55273d79a63a08bdfe06d744e635296875307b22" +dependencies = [ + "byteorder", + "rmp", + "serde", + "sgx_tstd", +] + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "ryu" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" + +[[package]] +name = "secrecy" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bd1c54ea06cfd2f6b63219704de0b9b4f72dcc2b8fdef820be6cd799780e91e" +dependencies = [ + "zeroize", +] + +[[package]] +name = "semver" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93f6841e709003d68bb2deee8c343572bf446003ec20a583e76f7b15cebf3711" + +[[package]] +name = "serde" +version = "1.0.118" +source = "git+https://github.com/mesalock-linux/serde-sgx#db0226f1d5d70fca6b96af2c285851502204e21c" +dependencies = [ + "serde_derive", + "sgx_tstd", +] + +[[package]] +name = "serde_bytes" +version = "0.11.5" +source = "git+https://github.com/registreerocks/serde-bytes-sgx#0bdf5e0596258f8895ce60527d82b6b5961a2eae" +dependencies = [ + "serde", + "sgx_tstd", +] + +[[package]] +name = "serde_derive" +version = "1.0.118" +source = "git+https://github.com/mesalock-linux/serde-sgx#db0226f1d5d70fca6b96af2c285851502204e21c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.60" +source = "git+https://github.com/mesalock-linux/serde-json-sgx#380893814ad2a057758d825bab798aa117f7362a" +dependencies = [ + "itoa", + "ryu", + "serde", + "sgx_tstd", +] + +[[package]] +name = "sgx-wallet-impl" +version = "0.1.0" +dependencies = [ + "algonaut", + "base64", + "hex", + "rand", + "ripple-address-codec", + "ripple-keypairs", + "rmp-serde", + "secrecy", + "serde", + "serde_bytes", + "serde_json", + "sgx_tcrypto", + "sgx_trts", + "sgx_tse", + "sgx_tstd", + "sgx_types", + "sodalite", + "thiserror", + "zeroize", +] + +[[package]] +name = "sgx_alloc" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" + +[[package]] +name = "sgx_backtrace_sys" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "cc", + "sgx_build_helper", + "sgx_libc", +] + +[[package]] +name = "sgx_build_helper" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" + +[[package]] +name = "sgx_demangle" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" + +[[package]] +name = "sgx_libc" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "sgx_types", +] + +[[package]] +name = "sgx_tcrypto" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "sgx_types", +] + +[[package]] +name = "sgx_tprotected_fs" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "sgx_trts", + "sgx_types", +] + +[[package]] +name = "sgx_trts" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "sgx_libc", + "sgx_types", +] + +[[package]] +name = "sgx_tse" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "sgx_types", +] + +[[package]] +name = "sgx_tstd" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "hashbrown_tstd", + "sgx_alloc", + "sgx_backtrace_sys", + "sgx_demangle", + "sgx_libc", + "sgx_tprotected_fs", + "sgx_trts", + "sgx_types", + "sgx_unwind", +] + +[[package]] +name = "sgx_types" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" + +[[package]] +name = "sgx_unwind" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "sgx_build_helper", +] + +[[package]] +name = "sha2" +version = "0.8.0" +source = "git+https://github.com/mesalock-linux/rustcrypto-hashes-sgx#54ac4af765ec6b424add4e7559e82328bd052060" +dependencies = [ + "block-buffer 0.7.3", + "digest 0.8.1", + "fake-simd", + "opaque-debug 0.2.3", + "sgx_tstd", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.9.0", + "opaque-debug 0.3.0", +] + +[[package]] +name = "smallvec" +version = "1.6.1" +source = "git+https://github.com/mesalock-linux/rust-smallvec-sgx#b5925f10aa5bc3370a0fb339140ee063f5a888dd" +dependencies = [ + "sgx_tstd", +] + +[[package]] +name = "sodalite" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41784a359d15c58bba298cccb7f30a847a1a42d0620c9bdaa0aa42fdb3c280e0" +dependencies = [ + "index-fixed", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "subtle" +version = "2.2.2" +source = "git+https://github.com/mesalock-linux/subtle-sgx#8ee32fc0902a4594bd12e272357e2d76cde9dad1" +dependencies = [ + "sgx_tstd", +] + +[[package]] +name = "syn" +version = "1.0.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "thiserror" +version = "1.0.9" +source = "git+https://github.com/mesalock-linux/thiserror-sgx#c2f806b88616e06aab0af770366a76885d974fdc" +dependencies = [ + "sgx_tstd", + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.9" +source = "git+https://github.com/mesalock-linux/thiserror-sgx#c2f806b88616e06aab0af770366a76885d974fdc" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "typenum" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" + +[[package]] +name = "unicode-bidi" +version = "0.3.4" +source = "git+https://github.com/mesalock-linux/unicode-bidi-sgx#eb10728a635a046e75747849fbc680cbbb7832c7" +dependencies = [ + "matches", + "sgx_tstd", +] + +[[package]] +name = "unicode-ident" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" + +[[package]] +name = "unicode-normalization" +version = "0.1.12" +source = "git+https://github.com/mesalock-linux/unicode-normalization-sgx#c1b030611969f87d75782c1df77975167cbbd509" +dependencies = [ + "smallvec", +] + +[[package]] +name = "unicode-xid" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "url" +version = "2.1.1" +source = "git+https://github.com/mesalock-linux/rust-url-sgx#23832f3191456c2d4a0faab10952e1747be58ca8" +dependencies = [ + "idna", + "matches", + "percent-encoding", + "sgx_tstd", +] + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d" +dependencies = [ + "cfg-if 1.0.0", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "662cd44805586bd52971b9586b1df85cdbbd9112e4ef4d8f41559c334dc6ac3f" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b260f13d3012071dfb1512849c033b1925038373aea48ced3012c09df952c602" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be8e654bdd9b79216c2929ab90721aa82faf65c48cdf08bdc4e7f51357b80da" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6598dd0bd3c7d51095ff6531a5b23e02acdc81804e30d8f07afb77b7215a140a" + +[[package]] +name = "zeroize" +version = "1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f8f187641dad4f680d25c4bfc4225b418165984179f26ca76ec4fb6441d3a17" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/Cargo.toml b/rust-sgx-workspace/crates/sgx-wallet-impl/Cargo.toml new file mode 100644 index 0000000..0ad38b5 --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/Cargo.toml @@ -0,0 +1,42 @@ +[package] +name = "sgx-wallet-impl" +version = "0.1.0" +edition = "2021" +description= "Wallet enclave implementation" + +[lib] +bench = false +test = false + +[dependencies] +# no_std +base64 = { version = "0.13.0", default-features = false, features = ["alloc"] } +hex = { version = "0.4.3", default-features = false, features = ["alloc"] } +secrecy = "0.8.0" +sodalite = { version = "0.4.0", default-features = false } +zeroize = { version = "1.5.3", features = ["alloc", "zeroize_derive"] } + +# SGX SDK +sgx_tcrypto = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } +sgx_trts = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } +sgx_tse = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } +sgx_tstd = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } +sgx_types = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } + +# Community SGX forks +rand = { git = "https://github.com/mesalock-linux/rand-sgx" } +rmp-serde = { git = "https://github.com/mesalock-linux/msgpack-rust-sgx" } +serde = { git = "https://github.com/mesalock-linux/serde-sgx" } +serde_json = { git = "https://github.com/mesalock-linux/serde-json-sgx" } +thiserror = { git = "https://github.com/mesalock-linux/thiserror-sgx" } + +# Our SGX forks +algonaut = { git = "https://github.com/registreerocks/algonaut-sgx", branch = "main-sgx" } +serde_bytes = { version = "0.11.4", git = "https://github.com/registreerocks/serde-bytes-sgx" } # SGX: registreerocks fork for 0.11.4 +ripple-keypairs = { git = "https://github.com/ntls-io/ripple-keypairs-rust-sgx", branch = "v0.1.0-sgx" } +ripple-address-codec = { git = "https://github.com/ntls-io/ripple-address-codec-rust-sgx", branch = "v0.1.1-sgx" } + +[patch.'https://github.com/apache/teaclave-sgx-sdk.git'] +sgx_libc = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } +sgx_trts = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } +sgx_tstd = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } \ No newline at end of file diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/ecall_helpers.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/ecall_helpers.rs new file mode 100644 index 0000000..0ba2032 --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/ecall_helpers.rs @@ -0,0 +1,15 @@ +use std::panic; +use std::prelude::v1::String; + +/// Like [`panic::catch_unwind`], but unwrap the panic message, if any. +pub fn catch_unwind_message(f: F) -> Result> +where + F: FnOnce() -> R + panic::UnwindSafe, +{ + panic::catch_unwind(f).map_err(|panic_value| { + panic_value + .downcast::() + .map(|boxed_message| *boxed_message) + .ok() + }) +} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/ecalls/enclave_create_report.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/ecalls/enclave_create_report.rs new file mode 100644 index 0000000..749cd56 --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/ecalls/enclave_create_report.rs @@ -0,0 +1,49 @@ +use secrecy::Zeroize; +use sgx_types::{sgx_report_t, sgx_status_t, sgx_target_info_t}; + +use crate::ported::attestation::create_report_impl; + +/// ECALL wrapper for [`create_report_impl`]. +/// +/// # EDL +/// +/// ```edl +/// include "sgx_report.h" +/// ``` +/// +/// # Errors +/// +/// * [`sgx_status_t::SGX_ERROR_INVALID_PARAMETER`] - null pointer passed +/// +/// * [`sgx_status_t::SGX_ERROR_UNEXPECTED`] - unwinding panic occurred +/// +/// # Safety +/// +/// Expects to be called from SGX bridge, with validated input. +/// +#[no_mangle] +pub unsafe extern "C" fn enclave_create_report( + p_qe3_target: *const sgx_target_info_t, + p_report: *mut sgx_report_t, + enclave_pubkey: *mut [u8; 32], +) -> sgx_status_t { + if p_qe3_target.is_null() || enclave_pubkey.is_null() || p_report.is_null() { + return sgx_status_t::SGX_ERROR_INVALID_PARAMETER; + } + let qe_target_info = &unsafe { *p_qe3_target }; + let (key, report) = match create_report_impl(qe_target_info) { + Ok(res) => res, + Err(x) => { + unsafe { + (*enclave_pubkey).zeroize(); + } + return x; + } + }; + + unsafe { + *p_report = report; + (*enclave_pubkey).copy_from_slice(&key); + } + sgx_status_t::SGX_SUCCESS +} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/ecalls/mod.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/ecalls/mod.rs new file mode 100644 index 0000000..ff76c98 --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/ecalls/mod.rs @@ -0,0 +1,4 @@ +//! ECALL wrappers: these bridge from SGX to our safe Rust implementations. + +pub mod enclave_create_report; +pub mod wallet_operation; diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/ecalls/wallet_operation.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/ecalls/wallet_operation.rs new file mode 100644 index 0000000..7bc90c3 --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/ecalls/wallet_operation.rs @@ -0,0 +1,62 @@ +use std::prelude::v1::ToString; +use std::{ptr, slice}; + +use sgx_types::{sgx_status_t, size_t, uint8_t}; + +use crate::ecall_helpers::catch_unwind_message; +use crate::wallet_operations::dispatch::wallet_operation_impl; + +/// ECALL wrapper for [`wallet_operation_impl`]. +/// +/// # Errors +/// +/// * [`sgx_status_t::SGX_ERROR_INVALID_PARAMETER`] - received null or empty request or response buffers +/// +/// * [`sgx_status_t::SGX_ERROR_FAAS_BUFFER_TOO_SHORT`] - response exceeds buffer capacity +/// +/// * [`sgx_status_t::SGX_ERROR_UNEXPECTED`] - unwinding panic occurred +/// +/// # Safety +/// Expects to be called from SGX bridge, with validated input. +#[no_mangle] +pub unsafe extern "C" fn wallet_operation( + sealed_request_buffer: *const uint8_t, + sealed_request_size: size_t, + sealed_response_buffer: *mut uint8_t, + sealed_response_capacity: size_t, + sealed_response_used: *mut size_t, +) -> sgx_status_t { + if sealed_request_buffer.is_null() || sealed_response_buffer.is_null() { + return sgx_status_t::SGX_ERROR_INVALID_PARAMETER; + } + + // Get the request buffer as a slice. + let sealed_request = + unsafe { slice::from_raw_parts(sealed_request_buffer, sealed_request_size) }; + + let sealed_response = match catch_unwind_message(|| wallet_operation_impl(sealed_request)) { + Ok(ok) => ok, + Err(message) => { + println!( + "PANIC in wallet_operation_impl ECALL: {}", + message.unwrap_or_else(|| ("XXX").to_string()) + ); + return sgx_status_t::SGX_ERROR_UNEXPECTED; + } + }; + + // Check capacity, and copy the response buffer out. + if sealed_response.len() <= sealed_response_capacity { + unsafe { + ptr::copy_nonoverlapping( + sealed_response.as_ptr(), + sealed_response_buffer, + sealed_response.len(), + ); + *sealed_response_used = sealed_response.len(); + } + sgx_status_t::SGX_SUCCESS + } else { + sgx_status_t::SGX_ERROR_FAAS_BUFFER_TOO_SHORT + } +} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/lib.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/lib.rs new file mode 100644 index 0000000..5d67ebb --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/lib.rs @@ -0,0 +1,11 @@ +#![no_std] +#![warn(unsafe_op_in_unsafe_fn)] + +#[macro_use] +extern crate sgx_tstd as std; + +mod ecall_helpers; +pub mod ecalls; +pub mod ported; +pub mod schema; +pub mod wallet_operations; diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/attestation.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/attestation.rs new file mode 100644 index 0000000..705a9ee --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/attestation.rs @@ -0,0 +1,21 @@ +use sgx_tcrypto::rsgx_sha256_slice; +use sgx_tse::rsgx_create_report; +use sgx_types::{sgx_report_data_t, sgx_report_t, sgx_target_info_t, SgxResult}; + +use crate::ported::crypto::{PublicKey, SodaBoxCrypto}; + +/// XXX see `rtc_tenclave::enclave::create_report_impl` +pub fn create_report_impl( + qe_target_info: &sgx_target_info_t, +) -> SgxResult<(PublicKey, sgx_report_t)> { + let crypto = SodaBoxCrypto::new(); + let pubkey = crypto.get_pubkey(); + + let pubkey_hash = rsgx_sha256_slice(&pubkey)?; + + let mut p_data = sgx_report_data_t::default(); + p_data.d[0..32].copy_from_slice(&pubkey_hash); + + let report = rsgx_create_report(qe_target_info, &p_data)?; + Ok((pubkey, report)) +} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/crypto.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/crypto.rs new file mode 100644 index 0000000..77562d2 --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/crypto.rs @@ -0,0 +1,205 @@ +//! XXX see `rtc_tenclave::crypto` + +use std::boxed::Box; +use std::vec; +use std::vec::Vec; + +use rand::{Rng, RngCore}; +use secrecy::{ExposeSecret, Secret, Zeroize}; +use sgx_tse::{rsgx_get_key, rsgx_self_report}; +use sgx_types::*; +use thiserror::Error; + +/// XXX see `rtc_types::EncryptedMessage` +#[derive(Clone, Debug)] +pub struct EncryptedMessage { + pub ciphertext: Box<[u8]>, + pub nonce: [u8; 24], +} + +/// XXX see `rtc_types::CryptoError` +#[derive(Copy, Clone, PartialEq, Eq, Ord, PartialOrd, Debug, Error)] +pub enum CryptoError { + #[error("Crypto rng error: {}", .0)] + Rand(u32), + #[error("Unknown crypto error")] + Unknown, +} + +pub(crate) type PublicKey = [u8; 32]; +type PrivateKey = Secret<[u8; 32]>; +pub(crate) type Nonce = [u8; 24]; + +// FIXME: sodalite should expose these padding constants. +// Values referenced from https://tweetnacl.cr.yp.to/20140427/tweetnacl.h + +/// C NaCl Box API: Zero padding for plaintext. +pub const CRYPTO_BOX_ZEROBYTES: usize = 32; + +/// C NaCl Box API: Zero padding for ciphertext. +pub const CRYPTO_BOX_BOXZEROBYTES: usize = 16; + +pub type SecretBytes = Secret>; + +pub struct SodaBoxCrypto { + public_key: PublicKey, + private_key: PrivateKey, + rng: Box, +} + +impl Default for SodaBoxCrypto { + fn default() -> Self { + SodaBoxCrypto::new() + } +} + +impl SodaBoxCrypto { + pub fn new() -> Self { + let enclave_key = get_enclave_key(); + let mut seed = [0_u8; 32]; + let (left, right) = seed.split_at_mut(16); + + // This should never panic since the file_key is size 16 + // TODO: Guard against the panics + left.copy_from_slice(enclave_key.expose_secret()); + right.copy_from_slice(enclave_key.expose_secret()); + + SodaBoxCrypto::from_seed(seed) + } + + pub fn from_seed(mut seed: [u8; 32]) -> Self { + let mut pub_key = [0_u8; 32]; + let mut priv_key = [0_u8; 32]; + + // TODO: Create a PR to make the requirement for seed broader if possible + sodalite::box_keypair_seed(&mut pub_key, &mut priv_key, &seed); + + // Zero copies of enclave key + seed.zeroize(); + Self { + public_key: pub_key, + private_key: Secret::new(priv_key), + rng: Box::new(rand::thread_rng()), + } + } + + pub fn decrypt_message( + &self, + ciphertext: &[u8], + their_pk: &PublicKey, + nonce: &Nonce, + ) -> Result { + // It is the responsibility of the caller to pad ciphertext + // see: https://github.com/registreerocks/rtc-data/issues/51 + let padded_ciphertext = &[&[0u8; CRYPTO_BOX_BOXZEROBYTES] as &[u8], ciphertext].concat(); + let mut message = vec![0_u8; padded_ciphertext.len()]; + + // Docs: https://nacl.cr.yp.to/box.html + // + // "The caller must ensure, before calling the crypto_box_open function, + // that the first crypto_box_BOXZEROBYTES bytes of the ciphertext c are all 0. + // The crypto_box_open function ensures (in case of success) that + // the first crypto_box_ZEROBYTES bytes of the plaintext m are all 0." + // + match sodalite::box_open( + &mut message, + padded_ciphertext, + nonce, + their_pk, + self.private_key.expose_secret(), + ) { + Ok(_) => Ok(Secret::new( + drop_prefix(CRYPTO_BOX_ZEROBYTES, message).into_boxed_slice(), + )), + // TODO: return compound error type + Err(_) => Err(CryptoError::Unknown), + } + } + + pub fn encrypt_message( + &mut self, + message: &SecretBytes, + their_pk: &PublicKey, + ) -> Result { + let nonce = self.get_nonce()?; + // Length is padded here since the message needs to be padded with 32 `0_u8` + // at the front + let mut ciphertext = vec![0_u8; message.expose_secret().len() + CRYPTO_BOX_ZEROBYTES]; + + // Docs: https://nacl.cr.yp.to/box.html + // + // "The caller must ensure, before calling the C NaCl crypto_box function, + // that the first crypto_box_ZEROBYTES bytes of the message m are all 0. + // The crypto_box function ensures that the first crypto_box_BOXZEROBYTES + // bytes of the ciphertext c are all 0." + // + match sodalite::box_( + &mut ciphertext, + &[ + &[0u8; CRYPTO_BOX_ZEROBYTES] as &[u8], + message.expose_secret(), + ] + .concat(), + &nonce, + their_pk, + self.private_key.expose_secret(), + ) { + Ok(_) => Ok(EncryptedMessage { + ciphertext: drop_prefix(CRYPTO_BOX_BOXZEROBYTES, ciphertext).into_boxed_slice(), + nonce, + }), + Err(_) => Err(CryptoError::Unknown), + } + } + + pub fn get_pubkey(&self) -> PublicKey { + self.public_key + } + + fn get_nonce(&mut self) -> Result { + let mut nonce = [0_u8; 24]; + // TODO: don't use just random nonces, since it might not + // be applicable to all situations + match self.rng.try_fill(&mut nonce) { + Ok(_) => Ok(nonce), + // TODO: Better conversion from rand::Error? (See also data_upload.rs) + Err(err) => Err(CryptoError::Rand(err.code().map_or(0, |code| code.get()))), + } + } +} + +pub fn get_enclave_key() -> Secret { + // From my testing, this is deterministic if the environment and binary is the same + // TODO: Test in Azure VM using HW mode + // TODO: Find documentation that confirms that the effect is normative + let report = rsgx_self_report(); + let attribute_mask = sgx_attributes_t { + flags: TSEAL_DEFAULT_FLAGSMASK, + xfrm: 0, + }; + let key_id = sgx_key_id_t::default(); + + let key_request = sgx_key_request_t { + key_name: SGX_KEYSELECT_SEAL, + key_policy: SGX_KEYPOLICY_MRENCLAVE | SGX_KEYPOLICY_MRSIGNER, + isv_svn: report.body.isv_svn, + reserved1: 0_u16, + cpu_svn: report.body.cpu_svn, + attribute_mask, + key_id, + misc_mask: TSEAL_DEFAULT_MISCMASK, + config_svn: report.body.config_svn, + reserved2: [0_u8; SGX_KEY_REQUEST_RESERVED2_BYTES], + }; + + // This should never fail since the input values are constant + // TODO: remove unwrap and deal with error? + Secret::new(rsgx_get_key(&key_request).unwrap()) +} + +/// Drop the first `prefix_len` elements of `vec`, keeping the rest. +fn drop_prefix(prefix_len: usize, mut vec: Vec) -> Vec { + vec.rotate_left(prefix_len); + vec.truncate(vec.len() - prefix_len); + vec +} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/kv_store/fs/mod.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/kv_store/fs/mod.rs new file mode 100644 index 0000000..c7491e6 --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/kv_store/fs/mod.rs @@ -0,0 +1,136 @@ +//! Filesystem-based [`KvStore`] implementation +//! +//! XXX port note: Added phantom `value_type` to `FsStore`. + +pub mod sgx_filer; + +// sgx_tstd (v1.1.3) does not support `fs::read_dir`, so limit the following to tests, for now. +// +// See: https://github.com/apache/incubator-teaclave-sgx-sdk/blob/v1.1.3/release_notes.md#partially-supported-modstraits-in-sgx_tstd +use core::marker::PhantomData; +use std::io; +use std::path::{Path, PathBuf}; +use std::prelude::v1::*; + +use serde::de::DeserializeOwned; +use serde::Serialize; +pub use sgx_filer::SgxFiler; + +use super::KvStore; +use crate::ported::kv_store::Key; + +/// Simplified interface for reading and writing files. +pub trait Filer { + /// Read content of `path`, if any. + /// + /// Return [`None`] if `path` doesn't exist. + /// + fn get(&self, path: impl AsRef) -> io::Result>>; + + /// Write `content` to `path`. Discard any existing content. + fn put(&self, path: impl AsRef, content: impl AsRef<[u8]>) -> io::Result<()>; + + /// Delete `path`. Discard any existing content. + fn delete(&self, path: impl AsRef) -> io::Result<()>; +} + +/// [`KvStore`] using a file per key under `root_dir`. +pub struct FsStore +where + F: Filer, + V: Serialize + DeserializeOwned, +{ + pub(crate) root_dir: PathBuf, + pub(crate) filer: F, + value_type: PhantomData, +} + +impl FsStore +where + F: Filer, + V: Serialize + DeserializeOwned, +{ + /// # Note + /// + /// The caller must ensure that `root` exists as a directory. + /// + pub fn new(root: impl AsRef, filer: F) -> Self { + let root_dir = root.as_ref().to_path_buf(); + FsStore { + root_dir, + filer, + value_type: PhantomData, + } + } + + /// Resolve file name for the value of `key`. + fn value_path(&self, key: &Key) -> PathBuf { + let file_name = encode_to_fs_safe(key); + self.root_dir.join(file_name) + } +} + +impl KvStore for FsStore +where + F: Filer, + V: Serialize + DeserializeOwned, +{ + // XXX: More explicit handling of serde_json::Error? + type Error = io::Error; + + fn load(&self, key: &Key) -> Result, Self::Error> { + let value_file_name = self.value_path(key); + + // Note: Read all the data into memory first, then deserialize, for efficiency. + // See the docs for [`serde_json::de::from_reader`], + // and https://github.com/serde-rs/json/issues/160 + let loaded: Option> = self.filer.get(&value_file_name).map_err(|err| { + // XXX: Annotate err with some basic debugging context, for now. + Self::Error::new( + err.kind(), + format!("FsStore: read from {:?} failed: {}", value_file_name, err), + ) + })?; + let value: Option = loaded + .map(|serialised: Vec| serde_json::from_slice(serialised.as_slice())) + .transpose()?; + Ok(value) + } + + fn save(&mut self, key: &Key, value: &V) -> Result<(), Self::Error> { + let value_file_name = self.value_path(key); + let serialized: Vec = serde_json::to_vec(&value)?; + self.filer + .put(&value_file_name, serialized) + .map_err(|err| { + // XXX: Annotate err with some basic debugging context, for now. + Self::Error::new( + err.kind(), + format!("FsStore: write to {:?} failed: {}", value_file_name, err), + ) + })?; + Ok(()) + } + + fn delete(&mut self, key: &Key) -> Result<(), Self::Error> { + let path = self.value_path(key); + self.filer.delete(path)?; + Ok(()) + } +} + +/// Helper: Make `key` filesystem-safe. +pub fn encode_to_fs_safe(key: &Key) -> String { + let encoded = hex::encode(key); + format!("x{}", encoded) +} + +/// Inverse of [`encode_to_fs_safe`]. +// FIXME: Just use a generic String as the error type, for now. +pub fn decode_from_fs_safe(file_name: &str) -> Result, String> { + let encoded: &str = file_name + .strip_prefix('x') + .ok_or_else(|| format!("decode_from_fs_safe: missing x prefix for {:?}", file_name))?; + let bytes: Vec = hex::decode(encoded).map_err(|err| err.to_string())?; + Ok(bytes) +} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/kv_store/fs/sgx_filer.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/kv_store/fs/sgx_filer.rs new file mode 100644 index 0000000..de40bac --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/kv_store/fs/sgx_filer.rs @@ -0,0 +1,44 @@ +//! [`SgxFile`] support + +use std::io::ErrorKind::NotFound; +use std::io::{Result, Write}; +use std::path::Path; +use std::prelude::v1::Vec; + +use sgx_tstd::sgxfs; +use sgx_tstd::sgxfs::SgxFile; + +use super::Filer; + +/// TODO: key management policy +pub struct SgxFiler; + +// Default key management: +// +// * `protected_fs_file::generate_random_meta_data_key` +// https://github.com/intel/linux-sgx/blob/sgx_2.13.3/sdk/protected_fs/sgx_tprotected_fs/file_crypto.cpp#L197 +// +impl Filer for SgxFiler { + fn get(&self, path: impl AsRef) -> Result>> { + // TODO: Create `read_ex` to read file with key + match sgxfs::read(path) { + Ok(contents) => Ok(Some(contents)), + Err(error) if error.kind() == NotFound => Ok(None), + Err(error) => Err(error), + } + } + + fn put(&self, path: impl AsRef, content: impl AsRef<[u8]>) -> Result<()> { + let contents: &[u8] = content.as_ref(); + // TODO: create_ex with key + let mut value_file = SgxFile::create(path)?; + value_file.write_all(contents) + } + + fn delete(&self, path: impl AsRef) -> Result<()> { + match sgxfs::remove(path) { + Err(error) if error.kind() == NotFound => Ok(()), + result => result, + } + } +} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/kv_store/mod.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/kv_store/mod.rs new file mode 100644 index 0000000..27d98be --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/kv_store/mod.rs @@ -0,0 +1,69 @@ +//! Simple key-value store abstraction +//! +//! XXX port note: Key type changed from str to `[u8]`. + +pub mod fs; + +pub type Key = [u8]; + +/// A key-value store. +/// +/// These methods borrow key and value references, +/// to suit cloning / serialising implementations. +/// +pub trait KvStore { + type Error; + + /// Load the saved value for `key`, if any. + /// + /// Return [`None`] if `key` has no previous value. + /// + fn load(&self, key: &Key) -> Result, Self::Error>; + + /// Save a new value for `key`. + /// + /// This will replace any existing value. + /// + fn save(&mut self, key: &Key, value: &V) -> Result<(), Self::Error>; + + /// Delete the saved value for `key`. + fn delete(&mut self, key: &Key) -> Result<(), Self::Error>; + + /// Alter the value of `key`. + /// + /// This operation is a generalisation of [`Self::load`], [`Self::save`], and [`Self::delete`]. + /// + fn alter(&mut self, key: &Key, alter_fn: F) -> Result, Self::Error> + where + F: FnOnce(Option) -> Option, + { + let loaded: Option = self.load(key)?; + let altered: Option = alter_fn(loaded); + match &altered { + None => self.delete(key)?, + Some(value) => self.save(key, value)?, + }; + Ok(altered) + } + + /// Mutate the value of `key`. + /// + /// This is like [`Self::alter`], but only operates on existing values. + fn mutate(&mut self, key: &Key, mutate_fn: F) -> Result, Self::Error> + where + F: FnOnce(V) -> V, + { + self.alter(key, |opt_v| opt_v.map(mutate_fn)) + } + + /// Insert a value for `key`, if absent. If `key` already has a value, do nothing. + /// + /// Return the key's prior value (`None` if `value` was inserted) + fn try_insert(&mut self, key: &Key, value: &V) -> Result, Self::Error> { + let loaded = self.load(key)?; + if loaded.is_none() { + self.save(key, value)?; + } + Ok(loaded) + } +} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/mod.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/mod.rs new file mode 100644 index 0000000..1e363c2 --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/mod.rs @@ -0,0 +1,5 @@ +//! Code that's been ported from elsewhere. + +pub mod attestation; +pub mod crypto; +pub mod kv_store; diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/actions.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/actions.rs new file mode 100644 index 0000000..0989a4a --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/actions.rs @@ -0,0 +1,301 @@ +//! Core request / response message types. +//! +//! # Related +//! +//! * + +use std::io; +use std::prelude::v1::{String, ToString}; + +use serde::{Deserialize, Serialize}; +use zeroize::{Zeroize, ZeroizeOnDrop}; + +use crate::schema::entities::WalletDisplay; +use crate::schema::types::{Bytes, WalletId, WalletPin}; +use crate::wallet_operations::store::UnlockWalletError; + +#[derive(Clone, Eq, PartialEq, Debug)] // core +#[derive(Deserialize, Serialize)] // serde +#[derive(Zeroize, ZeroizeOnDrop)] // zeroize +pub struct CreateWallet { + pub owner_name: String, + pub auth_pin: WalletPin, + pub phone_number: Option, +} + +#[derive(Clone, Eq, PartialEq, Debug)] // core +#[derive(Deserialize, Serialize)] // serde +pub enum CreateWalletResult { + Created(WalletDisplay), + Failed(String), +} + +#[derive(Clone, Eq, PartialEq, Debug)] // core +#[derive(Deserialize, Serialize)] // serde +#[derive(Zeroize, ZeroizeOnDrop)] // zeroize +pub struct OpenWallet { + pub wallet_id: WalletId, + pub auth_pin: WalletPin, +} + +#[derive(Clone, Eq, PartialEq, Debug)] // core +#[derive(Deserialize, Serialize)] // serde +pub enum OpenWalletResult { + Opened(WalletDisplay), + InvalidAuth, + Failed(String), +} + +impl From for OpenWalletResult { + fn from(err: UnlockWalletError) -> Self { + use UnlockWalletError::*; + match err { + InvalidWalletId => Self::InvalidAuth, + InvalidAuthPin => Self::InvalidAuth, + IoError(err) => Self::Failed(err.to_string()), + } + } +} + +#[derive(Clone, Eq, PartialEq, Debug)] // core +#[derive(Deserialize, Serialize)] // serde +#[derive(Zeroize, ZeroizeOnDrop)] // zeroize +pub struct SignTransaction { + pub wallet_id: WalletId, + pub auth_pin: WalletPin, + + #[zeroize(skip)] + pub transaction_to_sign: TransactionToSign, +} + +impl From for SignTransactionResult { + fn from(err: UnlockWalletError) -> Self { + use UnlockWalletError::*; + match err { + InvalidWalletId => Self::InvalidAuth, + InvalidAuthPin => Self::InvalidAuth, + IoError(err) => Self::Failed(err.to_string()), + } + } +} + +/// For [`SignTransaction`]: A choice of type of transaction to sign. +#[derive(Clone, Eq, PartialEq, Debug)] // core +#[derive(Deserialize, Serialize)] // serde +pub enum TransactionToSign { + /// An unsigned Algorand transaction. + AlgorandTransaction { + #[serde(with = "serde_bytes")] + transaction_bytes: Bytes, + }, + + /// An unsigned XRPL transaction. + XrplTransaction { + #[serde(with = "serde_bytes")] + transaction_bytes: Bytes, + }, +} + +#[derive(Clone, Eq, PartialEq, Debug)] // core +#[derive(Deserialize, Serialize)] // serde +pub enum SignTransactionResult { + Signed(TransactionSigned), + InvalidAuth, + Failed(String), +} + +impl SignTransactionResult { + /// Unwrap [`Self::Signed`] or panic. + pub fn unwrap_signed(self) -> TransactionSigned { + match self { + SignTransactionResult::Signed(signed) => signed, + otherwise => panic!( + "called `SignTransactionResult::unwrap_signed` on: {:?}", + otherwise + ), + } + } +} + +/// For [`SignTransactionResult`]: The possible types of signed transactions. +#[derive(Clone, Eq, PartialEq, Debug)] // core +#[derive(Deserialize, Serialize)] // serde +pub enum TransactionSigned { + /// A signed Algorand transaction. + AlgorandTransactionSigned { + #[serde(with = "serde_bytes")] + signed_transaction_bytes: Bytes, + }, + + /// A signed XRPL transaction. + XrplTransactionSigned { + #[serde(with = "serde_bytes")] + signed_transaction_bytes: Bytes, + + #[serde(with = "serde_bytes")] + signature_bytes: Bytes, + }, +} + +impl TransactionSigned { + /// Create [`Self::AlgorandTransactionSigned`] from bytes. + pub fn from_algorand_bytes(signed_transaction_bytes: Bytes) -> Self { + Self::AlgorandTransactionSigned { + signed_transaction_bytes, + } + } + + /// Unwrap [`Self::AlgorandTransactionSigned`] or panic. + pub fn unwrap_algorand_bytes(self) -> Bytes { + match self { + TransactionSigned::AlgorandTransactionSigned { + signed_transaction_bytes, + } => signed_transaction_bytes, + otherwise => panic!( + "called `TransactionSigned::unwrap_algorand_bytes` on: {:?}", + otherwise + ), + } + } +} + +#[derive(Clone, Eq, PartialEq, Debug)] // core +#[derive(Deserialize, Serialize)] // serde +pub struct SaveOnfidoCheck { + pub wallet_id: WalletId, + pub auth_pin: WalletPin, + + pub check: OnfidoCheckResult, +} + +#[derive(Clone, Eq, PartialEq, Debug)] // core +#[derive(Deserialize, Serialize)] // serde +pub enum SaveOnfidoCheckResult { + Saved, + InvalidAuth, + Failed(String), +} + +impl From for SaveOnfidoCheckResult { + fn from(err: io::Error) -> Self { + Self::Failed(err.to_string()) + } +} + +impl From for SaveOnfidoCheckResult { + fn from(err: UnlockWalletError) -> Self { + use UnlockWalletError::*; + match err { + InvalidWalletId => Self::InvalidAuth, + InvalidAuthPin => Self::InvalidAuth, + IoError(err) => Self::from(err), + } + } +} + +#[derive(Clone, Eq, PartialEq, Debug)] // core +#[derive(Deserialize, Serialize)] // serde +pub struct LoadOnfidoCheck { + pub wallet_id: WalletId, + pub auth_pin: WalletPin, +} + +#[derive(Clone, Eq, PartialEq, Debug)] // core +#[derive(Deserialize, Serialize)] // serde +pub enum LoadOnfidoCheckResult { + Loaded(OnfidoCheckResult), + NotFound, + InvalidAuth, + Failed(String), +} + +impl From for LoadOnfidoCheckResult { + fn from(err: io::Error) -> Self { + Self::Failed(err.to_string()) + } +} + +impl From for LoadOnfidoCheckResult { + fn from(err: UnlockWalletError) -> Self { + use UnlockWalletError::*; + match err { + InvalidWalletId => Self::InvalidAuth, + InvalidAuthPin => Self::InvalidAuth, + IoError(err) => Self::from(err), + } + } +} + +/// Docs: https://documentation.onfido.com/v2/#report-object +#[derive(Clone, Eq, PartialEq, Debug)] // core +#[derive(Deserialize, Serialize)] // serde +pub struct OnfidoCheckResult { + pub id: String, + + pub href: String, + + /// Docs: + pub result: String, + + /// Docs: + pub sub_result: Option, +} + +/// Dispatching enum for action requests. +#[derive(Clone, Eq, PartialEq, Debug)] // core +#[derive(Deserialize, Serialize)] // serde +#[derive(Zeroize, ZeroizeOnDrop)] // zeroize +pub enum WalletRequest { + CreateWallet(CreateWallet), + OpenWallet(OpenWallet), + SignTransaction(SignTransaction), + + #[zeroize(skip)] + SaveOnfidoCheck(SaveOnfidoCheck), + + #[zeroize(skip)] + LoadOnfidoCheck(LoadOnfidoCheck), +} + +/// Dispatching enum for action results. +#[derive(Clone, Eq, PartialEq, Debug)] // core +#[derive(Deserialize, Serialize)] // serde +pub enum WalletResponse { + CreateWallet(CreateWalletResult), + OpenWallet(OpenWalletResult), + SignTransaction(SignTransactionResult), + SaveOnfidoCheck(SaveOnfidoCheckResult), + LoadOnfidoCheck(LoadOnfidoCheckResult), +} + +// Convenience conversions: + +impl From for WalletResponse { + fn from(result: CreateWalletResult) -> Self { + Self::CreateWallet(result) + } +} + +impl From for WalletResponse { + fn from(result: OpenWalletResult) -> Self { + Self::OpenWallet(result) + } +} + +impl From for WalletResponse { + fn from(result: SignTransactionResult) -> Self { + Self::SignTransaction(result) + } +} + +impl From for WalletResponse { + fn from(result: SaveOnfidoCheckResult) -> Self { + Self::SaveOnfidoCheck(result) + } +} + +impl From for WalletResponse { + fn from(result: LoadOnfidoCheckResult) -> Self { + Self::LoadOnfidoCheck(result) + } +} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/entities.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/entities.rs new file mode 100644 index 0000000..f2cb29b --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/entities.rs @@ -0,0 +1,206 @@ +//! Structures representing various entities. + +use std::prelude::v1::{String, ToOwned, ToString}; + +use algonaut::transaction::account::Account as AlgonautAccount; +use ripple_keypairs::{Entropy, EntropyArray, PrivateKey, PublicKey, Seed}; +use serde::{Deserialize, Serialize}; +use zeroize::{Zeroize, ZeroizeOnDrop}; + +use crate::schema::actions::OnfidoCheckResult; +use crate::schema::types::{ + AlgorandAccountSeedBytes, + AlgorandAddressBase32, + AlgorandAddressBytes, + WalletId, + WalletPin, + XrplAddressBase58, + XrplKeyType, + XrplPublicKeyHex, +}; + +/// A Nautilus wallet's basic displayable details. +/// +/// This is what gets sent to clients. +#[derive(Clone, Eq, PartialEq, Debug)] // core +#[derive(Deserialize, Serialize)] // serde +pub struct WalletDisplay { + pub wallet_id: WalletId, + pub owner_name: String, + pub phone_number: Option, + + // TODO(Pi): Decouple for multiple accounts per wallet. + pub algorand_address_base32: AlgorandAddressBase32, + + pub xrpl_account: XrplAccountDisplay, +} + +impl From for WalletDisplay { + fn from(storable: WalletStorable) -> Self { + Self { + wallet_id: storable.wallet_id.clone(), + owner_name: storable.owner_name.clone(), + phone_number: storable.phone_number.clone(), + + algorand_address_base32: storable.algorand_account.address_base32(), + xrpl_account: storable.xrpl_account.clone().into(), + } + } +} + +/// A Nautilus wallet's full details. +/// +/// This is everything that gets persisted in the wallet store. +#[derive(Clone, Eq, PartialEq, Debug)] // core +#[derive(Deserialize, Serialize)] // serde +#[derive(Zeroize, ZeroizeOnDrop)] // zeroize +pub struct WalletStorable { + pub wallet_id: WalletId, + pub auth_pin: WalletPin, + + pub owner_name: String, + pub phone_number: Option, + + pub algorand_account: AlgorandAccount, + pub xrpl_account: XrplAccount, + + #[zeroize(skip)] + pub onfido_check_result: Option, +} + +// Algorand entities: + +/// An Algorand account. +#[derive(Clone, Eq, PartialEq, Debug)] // core +#[derive(Deserialize, Serialize)] // serde +#[derive(Zeroize, ZeroizeOnDrop)] // zeroize +pub struct AlgorandAccount { + pub seed_bytes: AlgorandAccountSeedBytes, +} + +impl AlgorandAccount { + pub(crate) fn generate() -> Self { + Self { + // XXX performance: Or just use OsRng directly? + seed_bytes: AlgonautAccount::generate().seed(), + } + } + + // XXX performance: Repeated temporary conversions through AlgonautAccount? + pub(crate) fn as_algonaut_account(&self) -> AlgonautAccount { + AlgonautAccount::from_seed(self.seed_bytes) + } + + pub fn address_bytes(&self) -> AlgorandAddressBytes { + self.as_algonaut_account().address().0 + } + + pub fn address_base32(&self) -> AlgorandAddressBase32 { + self.as_algonaut_account().address().to_string() + } +} + +impl From for AlgonautAccount { + fn from(account: AlgorandAccount) -> Self { + account.as_algonaut_account() + } +} + +// XRPL entities: + +/// An XRPL account's displayable details. +#[derive(Clone, Eq, PartialEq, Debug)] // core +#[derive(Deserialize, Serialize)] // serde +pub struct XrplAccountDisplay { + pub key_type: XrplKeyType, + pub public_key_hex: XrplPublicKeyHex, + pub address_base58: XrplAddressBase58, +} + +impl From for XrplAccountDisplay { + fn from(xrpl_account: XrplAccount) -> Self { + Self { + key_type: xrpl_account.key_type, + public_key_hex: xrpl_account.to_public_key_hex(), + address_base58: xrpl_account.to_address_base58(), + } + } +} + +/// An XRPL account. +#[derive(Clone, Eq, PartialEq, Debug)] // core +#[derive(Deserialize, Serialize)] // serde +#[derive(Zeroize, ZeroizeOnDrop)] // zeroize +pub struct XrplAccount { + #[zeroize(skip)] + pub key_type: XrplKeyType, + + pub seed_bytes: EntropyArray, +} + +impl From for XrplAccount { + fn from(seed: Seed) -> Self { + let key_type = seed.as_kind().into(); + let seed_bytes = seed.as_entropy().to_owned(); + Self::new(key_type, seed_bytes) + } +} + +impl From for Seed { + fn from(xrpl_account: XrplAccount) -> Self { + let entropy = Entropy::Array(xrpl_account.seed_bytes); + let kind = xrpl_account.key_type.into(); + Seed::new(entropy, kind) + } +} + +impl XrplAccount { + pub(crate) fn new(key_type: XrplKeyType, seed_bytes: EntropyArray) -> Self { + Self { + key_type, + seed_bytes, + } + } + + /// Generate a new keypair of the given type. + pub(crate) fn generate_default() -> Self { + Self::generate(XrplKeyType::default()) + } + + /// Generate a new keypair of the given type. + pub(crate) fn generate(key_type: XrplKeyType) -> Self { + Seed::new(Entropy::Random, key_type.into()).into() + } + + pub(crate) fn to_seed(&self) -> Seed { + self.clone().into() + } + + pub(crate) fn to_keypair(&self) -> (PrivateKey, PublicKey) { + // XXX(Pi): Performance: Repeated key derivation? + self.to_seed() + .derive_keypair() + // Safety: This should not fail unless something is seriously wrong: treat as unrecoverable. + .expect("XrpAccount: derive_keypair failed!") + } + + pub(crate) fn to_private_key(&self) -> PrivateKey { + let (private_key, _) = self.to_keypair(); + private_key + } + + pub(crate) fn to_public_key(&self) -> PublicKey { + let (_, public_key) = self.to_keypair(); + public_key + } + + pub fn to_address_base58(&self) -> XrplAddressBase58 { + self.to_public_key().derive_address() + } + + // TODO: Support X-Address format? Docs: + + pub fn to_public_key_hex(&self) -> XrplPublicKeyHex { + self.to_public_key().to_string() + } +} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/mod.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/mod.rs new file mode 100644 index 0000000..e21070b --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/mod.rs @@ -0,0 +1,28 @@ +//! Data types and schema for communicating with the wallet enclave. +//! +//! Schema types should generally derive at least the following traits: +//! +//! ```compile_fail +//! #[derive(Clone, Eq, PartialEq, Debug)] // core +//! #[derive(Deserialize, Serialize)] // serde +//! ``` +//! +//! Types that contain sensitive data (roughly, anything that should not leave the enclave) +//! should also implement `Zeroize`: +//! +//! ```compile_fail +//! #[derive(Zeroize, ZeroizeOnDrop)] // zeroize +//! ``` +//! +//! TODO: Migrate these to a separate library crate that can be used from both std and SGX crates. +//! +//! # Related +//! +//! * + +pub mod actions; +pub mod entities; +pub mod msgpack; +pub mod sealing; +pub(crate) mod serde_bytes_array; +pub mod types; diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/msgpack.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/msgpack.rs new file mode 100644 index 0000000..37ff697 --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/msgpack.rs @@ -0,0 +1,42 @@ +//! MessagePack helper traits. + +use std::prelude::v1::{Box, Vec}; + +use rmp_serde::{decode, encode, Serializer}; +use serde::de::DeserializeOwned; +use serde::{Deserialize, Serialize}; + +pub trait FromMessagePack<'de>: Deserialize<'de> { + fn from_msgpack(bytes: &'de [u8]) -> Result { + rmp_serde::from_read_ref(bytes) + } +} + +pub trait FromMessagePackOwned: DeserializeOwned { + fn from_msgpack_owned(bytes: &[u8]) -> Result + where + Self: DeserializeOwned, + { + rmp_serde::from_read_ref(bytes) + } +} + +pub trait ToMessagePack: Serialize { + fn to_msgpack(&self) -> Result, encode::Error> { + // XXX: Like rmp_serde::to_vec_named, but we need string variants too. + let mut wr = Vec::with_capacity(128); + let mut se = Serializer::new(&mut wr) + .with_struct_map() + .with_string_variants(); + self.serialize(&mut se)?; + Ok(wr.into_boxed_slice()) + } +} + +// Blanket impls for serde types: + +impl<'de, T> FromMessagePack<'de> for T where T: Deserialize<'de> {} + +impl FromMessagePackOwned for T where T: DeserializeOwned {} + +impl ToMessagePack for T where T: Serialize {} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/sealing.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/sealing.rs new file mode 100644 index 0000000..aa20c77 --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/sealing.rs @@ -0,0 +1,115 @@ +//! [`SealedMessage`] sealing and unsealing. + +use std::error::Error; +use std::prelude::v1::Box; + +use secrecy::{ExposeSecret, Secret}; +use serde::{Deserialize, Serialize}; +use zeroize::Zeroize; + +use crate::ported::crypto::{CryptoError, Nonce, PublicKey, SecretBytes, SodaBoxCrypto}; +use crate::schema::msgpack::{FromMessagePack, FromMessagePackOwned, ToMessagePack}; +use crate::schema::serde_bytes_array; +use crate::schema::types::Bytes; + +/// A sealed message +#[derive(Debug)] // core +#[derive(Deserialize, Serialize)] // serde +pub struct SealedMessage { + #[serde(with = "serde_bytes")] + pub ciphertext: Bytes, + #[serde(with = "serde_bytes_array")] + pub nonce: Nonce, + #[serde(with = "serde_bytes_array")] + pub sender_public_key: PublicKey, +} + +/// Seal message bytes from `sender_crypto` to `receiver_public_key`. +pub fn seal( + message_bytes: &SecretBytes, + receiver_public_key: &PublicKey, + sender_crypto: &mut SodaBoxCrypto, +) -> Result { + let encrypted_message = sender_crypto.encrypt_message(message_bytes, receiver_public_key)?; + Ok(SealedMessage { + ciphertext: encrypted_message.ciphertext, + nonce: encrypted_message.nonce, + sender_public_key: sender_crypto.get_pubkey(), + }) +} + +/// Unseal message bytes to `receiver_crypto`. +pub fn unseal( + sealed_message: &SealedMessage, + receiver_crypto: &SodaBoxCrypto, +) -> Result { + let message_bytes = receiver_crypto.decrypt_message( + &sealed_message.ciphertext, + &sealed_message.sender_public_key, + &sealed_message.nonce, + )?; + Ok(message_bytes) +} + +/// [`seal] from the current enclave. +pub fn seal_from_enclave( + message_bytes: &SecretBytes, + receiver_public_key: &PublicKey, +) -> Result { + let mut enclave_crypto = SodaBoxCrypto::new(); + seal(message_bytes, receiver_public_key, &mut enclave_crypto) +} + +/// [`unseal`] to the current enclave. +pub fn unseal_to_enclave(sealed_message: &SealedMessage) -> Result { + let enclave_crypto = &SodaBoxCrypto::new(); + unseal(sealed_message, enclave_crypto) +} + +/// [`seal`] as MessagePack. +pub fn seal_msgpack( + message: &T, + receiver_public_key: &PublicKey, + sender_crypto: &mut SodaBoxCrypto, +) -> Result, Box> +where + T: ToMessagePack, +{ + let message_bytes = &SecretBytes::new(message.to_msgpack()?); + let sealed_message = seal(message_bytes, receiver_public_key, sender_crypto)?; + let sealed_message_bytes = sealed_message.to_msgpack()?; + Ok(sealed_message_bytes) +} + +/// [`unseal`] as MessagePack, for [`Secret`] values. +/// +/// See also: [`unseal_non_secret_msgpack`] +pub fn unseal_secret_msgpack( + sealed_message_bytes: &[u8], + receiver_crypto: &SodaBoxCrypto, +) -> Result, Box> +where + T: FromMessagePackOwned, + T: Zeroize, +{ + let sealed_message = &SealedMessage::from_msgpack(sealed_message_bytes)?; + let message_bytes = unseal(sealed_message, receiver_crypto)?; + let message = Secret::new(T::from_msgpack_owned(message_bytes.expose_secret())?); + Ok(message) +} + +/// [`unseal`] as MessagePack, for non-[`Secret`] values. +/// +/// See also: [`unseal_secret_msgpack`] +pub fn unseal_non_secret_msgpack( + sealed_message_bytes: &[u8], + receiver_crypto: &SodaBoxCrypto, +) -> Result> +where + T: FromMessagePackOwned, +{ + let sealed_message = &SealedMessage::from_msgpack(sealed_message_bytes)?; + let message_bytes = unseal(sealed_message, receiver_crypto)?; + let message = T::from_msgpack_owned(message_bytes.expose_secret())?; + Ok(message) +} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/serde_bytes_array.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/serde_bytes_array.rs new file mode 100644 index 0000000..a41e621 --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/serde_bytes_array.rs @@ -0,0 +1,27 @@ +//! Work around + +use core::convert::TryInto; + +use serde::de::Error; +use serde::{Deserializer, Serializer}; + +/// This just specializes [`serde_bytes::serialize`] to ``. +pub(crate) fn serialize(bytes: &[u8], serializer: S) -> Result +where + S: Serializer, +{ + serde_bytes::serialize(bytes, serializer) +} + +/// This takes the result of [`serde_bytes::deserialize`] from `[u8]` to `[u8; N]`. +pub(crate) fn deserialize<'de, D, const N: usize>(deserializer: D) -> Result<[u8; N], D::Error> +where + D: Deserializer<'de>, +{ + let slice: &[u8] = serde_bytes::deserialize(deserializer)?; + let array: [u8; N] = slice.try_into().map_err(|_| { + let expected = format!("[u8; {}]", N); + D::Error::invalid_length(slice.len(), &expected.as_str()) + })?; + Ok(array) +} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/types.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/types.rs new file mode 100644 index 0000000..bd3a662 --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/types.rs @@ -0,0 +1,77 @@ +//! Supporting data types. + +use std::boxed::Box; +use std::prelude::v1::String; + +use ripple_keypairs::{Algorithm, EntropyArray}; +use serde::{Deserialize, Serialize}; + +pub type Bytes = Box<[u8]>; + +/// Nautilus Wallet ID. +pub type WalletId = String; + +/// A wallet owner's authenticating PIN. +pub type WalletPin = String; + +/// Algorand account seed, as bytes. +pub type AlgorandAccountSeedBytes = [u8; 32]; + +/// Algorand account address, as bytes. +pub type AlgorandAddressBytes = [u8; 32]; + +/// Algorand account address, as base32 with checksum. +pub type AlgorandAddressBase32 = String; + +/// XRPL key type (signing algorithm). +/// +/// Docs: +#[derive(Copy, Clone, Eq, PartialEq, Debug)] // core +#[derive(Deserialize, Serialize)] // serde +#[serde(rename_all = "lowercase")] +pub enum XrplKeyType { + Secp256k1, + Ed25519, +} + +/// Default to `secp256k1`, like the XRP Ledger. +impl Default for XrplKeyType { + fn default() -> Self { + Self::Secp256k1 + } +} + +// Convert between our representation and ripple-keypairs. + +/// Convert from `&Algorithm`, as used by ripple-keypairs. +impl From<&Algorithm> for XrplKeyType { + fn from(algorithm: &Algorithm) -> Self { + match algorithm { + Algorithm::Secp256k1 => Self::Secp256k1, + Algorithm::Ed25519 => Self::Ed25519, + } + } +} + +/// Convert to `&'static Algorithm`, as expected by ripple-keypairs. +impl From for &'static Algorithm { + fn from(key_type: XrplKeyType) -> Self { + match key_type { + XrplKeyType::Secp256k1 => &Algorithm::Secp256k1, + XrplKeyType::Ed25519 => &Algorithm::Ed25519, + } + } +} + +/// XRP account seed, as bytes. +pub type XrplAccountSeedBytes = EntropyArray; + +/// XRP account address, as base58 with checksum ("Base58Check"). +/// +/// Docs: +pub type XrplAddressBase58 = String; + +/// XRP public key, as a hexadecimal string. Used to prepare unsigned transactions. +/// +/// Docs: +pub type XrplPublicKeyHex = String; diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/create_wallet.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/create_wallet.rs new file mode 100644 index 0000000..93a5f4d --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/create_wallet.rs @@ -0,0 +1,30 @@ +use std::prelude::v1::ToString; + +use crate::schema::actions::{CreateWallet, CreateWalletResult}; +use crate::schema::entities::{AlgorandAccount, WalletDisplay, WalletStorable, XrplAccount}; +use crate::wallet_operations::store::save_new_wallet; + +type Result = CreateWalletResult; + +pub fn create_wallet(request: &CreateWallet) -> Result { + // TODO(Pi): Pull account / keypair creation into a separate operation. + // For now, just generate both Algorand and XRP keypairs. + let new_algorand_account = AlgorandAccount::generate(); + let new_xrpl_account = XrplAccount::generate_default(); + + let storable = WalletStorable { + wallet_id: new_xrpl_account.to_address_base58(), + owner_name: request.owner_name.clone(), + auth_pin: request.auth_pin.clone(), + phone_number: request.phone_number.clone(), + + algorand_account: new_algorand_account, + xrpl_account: new_xrpl_account, + + onfido_check_result: None, + }; + match save_new_wallet(&storable) { + Ok(()) => Result::Created(WalletDisplay::from(storable)), + Err(err) => Result::Failed(err.to_string()), + } +} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/dispatch.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/dispatch.rs new file mode 100644 index 0000000..86f5eab --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/dispatch.rs @@ -0,0 +1,115 @@ +use std::error::Error; +use std::prelude::v1::Box; + +use secrecy::{ExposeSecret, Secret}; + +use crate::ported::crypto::SecretBytes; +use crate::schema::actions::{WalletRequest, WalletResponse}; +use crate::schema::msgpack::{FromMessagePack, ToMessagePack}; +use crate::schema::sealing::{seal_from_enclave, unseal_to_enclave, SealedMessage}; +use crate::wallet_operations::create_wallet::create_wallet; +use crate::wallet_operations::errors; +use crate::wallet_operations::load_onfido_check::load_onfido_check; +use crate::wallet_operations::open_wallet::open_wallet; +use crate::wallet_operations::save_onfido_check::save_onfido_check; +use crate::wallet_operations::sign_transaction::sign_transaction; + +/// Implementation for [`crate::ecalls::wallet_operation::wallet_operation`]. +/// +/// This processes an exchange of the following: +/// +/// Request: [`SealedMessage`] of [`WalletRequest`] +/// +/// Response: [`SealedMessage`] of [`WalletResponse`] +/// +pub fn wallet_operation_impl(sealed_request_bytes: &[u8]) -> Box<[u8]> { + match wallet_operation_impl_sealing(sealed_request_bytes) { + Ok(sealed_response_bytes) => sealed_response_bytes, + Err(error) => panic!("{}", error), // FIXME: better reporting + } +} + +/// Handle sealing and unsealing the exchange. +fn wallet_operation_impl_sealing(sealed_request_bytes: &[u8]) -> Result, Box> { + // Unseal request + let sealed_request = &SealedMessage::from_msgpack(sealed_request_bytes).map_err(|err| { + errors::message_with_base64( + "wallet_operation_impl_sealing", + "failed to unpack received sealed request", + err, + "sealed request msgpack", + sealed_request_bytes, + ) + })?; + let request_bytes = &unseal_to_enclave(sealed_request).map_err(|err| { + errors::message_with_debug_value( + "wallet_operation_impl_sealing", + "failed to unseal request", + err, + "sealed request", + sealed_request, + ) + })?; + let wallet_request = &Secret::new( + WalletRequest::from_msgpack(request_bytes.expose_secret()).map_err(|err| { + errors::message_with_base64( + "wallet_operation_impl_sealing", + "invalid WalletReq", + err, + "unsealed WalletRequest msgpack", + request_bytes.expose_secret(), + ) + })?, + ); + + // Dispatch + let wallet_response = wallet_operation_impl_dispatch(wallet_request.expose_secret()); + + // Seal response + let response_bytes = &SecretBytes::new(wallet_response.to_msgpack().map_err(|err| { + errors::message_with_debug_value( + "wallet_operation_impl_sealing", + "failed to msgpack WalletResponse-to-seal", + err, + "unsealed WalletResponse", + wallet_response, + ) + })?); + let sealed_response = seal_from_enclave(response_bytes, &sealed_request.sender_public_key) + .map_err(|err| { + errors::message_with_base64( + "wallet_operation_impl_sealing", + "failed to seal packed WalletResponse", + err, + "unsealed WalletResponse msgpack", + response_bytes.expose_secret(), + ) + })?; + let sealed_response_bytes = sealed_response.to_msgpack().map_err(|err| { + errors::message_with_debug_value( + "wallet_operation_impl_sealing", + "failed to msgpack sealed WalletRequest", + err, + "sealed response", + sealed_response, + ) + })?; + Ok(sealed_response_bytes) +} + +/// Handle dispatching the exchange. +fn wallet_operation_impl_dispatch(wallet_request: &WalletRequest) -> WalletResponse { + if cfg!(feature = "verbose-debug-logging") { + println!( + "DEBUG: wallet_operation_impl_dispatch: dispatching wallet_request = \n{:#?}", + wallet_request + ); + } + match wallet_request { + WalletRequest::CreateWallet(request) => create_wallet(request).into(), + WalletRequest::OpenWallet(request) => open_wallet(request).into(), + WalletRequest::SignTransaction(request) => sign_transaction(request).into(), + WalletRequest::SaveOnfidoCheck(request) => save_onfido_check(request).into(), + WalletRequest::LoadOnfidoCheck(request) => load_onfido_check(request).into(), + } +} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/errors.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/errors.rs new file mode 100644 index 0000000..5a7ef23 --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/errors.rs @@ -0,0 +1,52 @@ +//! Error handling helpers. + +use core::fmt::Display; +use std::fmt::Debug; +use std::prelude::v1::String; + +/// Error message with a pretty-printed debug value. +pub(crate) fn message_with_debug_value( + function: &str, + message: &str, + error: impl Display, + debug_label: &str, + debug_value: impl Debug, +) -> String { + message_with_extra( + function, + message, + error, + debug_label, + &format!("{:#?}", debug_value), + ) +} + +/// Error message with a base64 bytes dump, to help debug MessagePack-related problems. +pub(crate) fn message_with_base64( + function: &str, + message: &str, + error: impl Display, + base64_label: &str, + base64_bytes: impl AsRef<[u8]>, +) -> String { + message_with_extra( + function, + message, + error, + base64_label, + &base64::encode(base64_bytes), + ) +} + +pub(crate) fn message_with_extra( + function: &str, + message: &str, + error: impl Display, + extra_label: &str, + extra_value: &str, +) -> String { + format!( + "ERROR({}): {}\n( error = {} )\n[ {} = {} ]", + function, message, error, extra_label, extra_value, + ) +} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/load_onfido_check.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/load_onfido_check.rs new file mode 100644 index 0000000..fb3dec5 --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/load_onfido_check.rs @@ -0,0 +1,14 @@ +use crate::schema::actions::{LoadOnfidoCheck, LoadOnfidoCheckResult}; +use crate::wallet_operations::store::unlock_wallet; + +pub fn load_onfido_check(request: &LoadOnfidoCheck) -> LoadOnfidoCheckResult { + let stored = match unlock_wallet(&request.wallet_id, &request.auth_pin) { + Ok(stored) => stored, + Err(err) => return err.into(), + }; + + stored.onfido_check_result.clone().map_or( + LoadOnfidoCheckResult::NotFound, + LoadOnfidoCheckResult::Loaded, + ) +} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/mod.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/mod.rs new file mode 100644 index 0000000..d7b79c1 --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/mod.rs @@ -0,0 +1,12 @@ +//! Wallet operation implementations. + +pub mod create_wallet; +pub mod dispatch; +pub(crate) mod errors; +pub mod load_onfido_check; +pub mod open_wallet; +pub mod save_onfido_check; +pub mod sign_transaction; +pub mod sign_transaction_algorand; +pub(crate) mod sign_transaction_xrpl; +pub mod store; diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/open_wallet.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/open_wallet.rs new file mode 100644 index 0000000..1990be7 --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/open_wallet.rs @@ -0,0 +1,12 @@ +use crate::schema::actions::{OpenWallet, OpenWalletResult}; +use crate::schema::entities::WalletDisplay; +use crate::wallet_operations::store::unlock_wallet; + +pub fn open_wallet(request: &OpenWallet) -> OpenWalletResult { + let stored = match unlock_wallet(&request.wallet_id, &request.auth_pin) { + Ok(stored) => stored, + Err(err) => return err.into(), + }; + + OpenWalletResult::Opened(WalletDisplay::from(stored)) +} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/save_onfido_check.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/save_onfido_check.rs new file mode 100644 index 0000000..73d8eb8 --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/save_onfido_check.rs @@ -0,0 +1,21 @@ +use crate::schema::actions::{SaveOnfidoCheck, SaveOnfidoCheckResult}; +use crate::wallet_operations::store::{mutate_wallet, unlock_wallet}; + +pub fn save_onfido_check(request: &SaveOnfidoCheck) -> SaveOnfidoCheckResult { + let stored = match unlock_wallet(&request.wallet_id, &request.auth_pin) { + Ok(ok) => ok, + Err(err) => return err.into(), + }; + + match mutate_wallet(&stored.wallet_id, |mut stored| { + // FIXME: Avoid mut? + stored.onfido_check_result = Some(request.check.clone()); + stored + }) { + Ok(ok) => ok, + Err(err) => return err.into(), + } + .expect("save_onfido_check: wallet disappeared!"); + + SaveOnfidoCheckResult::Saved +} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/sign_transaction.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/sign_transaction.rs new file mode 100644 index 0000000..1962acd --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/sign_transaction.rs @@ -0,0 +1,41 @@ +//! Implement [`SignTransaction`]. + +use std::prelude::v1::String; + +use crate::schema::actions::{ + SignTransaction, + SignTransactionResult, + TransactionSigned, + TransactionToSign, +}; +use crate::wallet_operations::sign_transaction_algorand::sign_algorand; +use crate::wallet_operations::sign_transaction_xrpl::sign_xrpl; +use crate::wallet_operations::store::unlock_wallet; + +pub fn sign_transaction(request: &SignTransaction) -> SignTransactionResult { + let stored = match unlock_wallet(&request.wallet_id, &request.auth_pin) { + Ok(stored) => stored, + Err(err) => return err.into(), + }; + + let sign_result: Result = match &request.transaction_to_sign { + TransactionToSign::AlgorandTransaction { transaction_bytes } => { + sign_algorand(&stored.algorand_account, transaction_bytes) + .map(TransactionSigned::from_algorand_bytes) + } + + TransactionToSign::XrplTransaction { transaction_bytes } => { + let signature_bytes = sign_xrpl(&stored.xrpl_account, transaction_bytes); + Ok(TransactionSigned::XrplTransactionSigned { + signed_transaction_bytes: transaction_bytes.clone(), + signature_bytes, + }) + } + }; + + // `Result` → `SignTransactionResult` + match sign_result { + Ok(signed) => SignTransactionResult::Signed(signed), + Err(message) => SignTransactionResult::Failed(message), + } +} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/sign_transaction_algorand.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/sign_transaction_algorand.rs new file mode 100644 index 0000000..01057df --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/sign_transaction_algorand.rs @@ -0,0 +1,108 @@ +//! Implement transaction signing for Algorand. + +use std::prelude::v1::String; + +use crate::schema::entities::AlgorandAccount; +use crate::schema::types::Bytes; +use crate::wallet_operations::errors; + +pub(crate) fn sign_algorand( + signing_account: &AlgorandAccount, + transaction_bytes: &Bytes, +) -> Result { + // Safety: `split_at` panics if len < mid. + if transaction_bytes.len() < 2 { + return Err(errors::message_with_base64( + "sign_transaction", + "transaction too short", + format!("len = {}", transaction_bytes.len()), + "unsigned transaction msgpack", + transaction_bytes, + )); + } + + // Check and strip the "TX" prefix tag + let transaction_bytes_without_prefix = match transaction_bytes.split_at(2) { + (b"TX", rest) => rest, + (unrecognised, _rest) => { + return Err(errors::message_with_base64( + "sign_transaction", + "transaction prefix tag not recognised", + format!("expected TX, got {:?}", unrecognised), + "unsigned transaction msgpack", + transaction_bytes, + )) + } + }; + + let transaction_to_sign = + &match algorand_network_compatible::from_msgpack(transaction_bytes_without_prefix) { + Ok(ok) => ok, + Err(err) => { + return Err(errors::message_with_base64( + "sign_transaction", + "failed to unpack received transaction-to-be-signed", + err, + "unsigned transaction msgpack", + transaction_bytes, + )) + } + }; + + let signed_transaction = &match signing_account + .as_algonaut_account() + .sign_transaction(transaction_to_sign) + { + Ok(ok) => ok, + Err(err) => { + return Err(errors::message_with_debug_value( + "sign_transaction", + "algonaut error while signing transaction", + err, + "unsigned transaction", + transaction_to_sign, + )) + } + }; + + // Note: Intentionally serialize with algonaut's `to_msg_pack` helper, not ours. + let signed_transaction_bytes = match algorand_network_compatible::to_msgpack(signed_transaction) + { + Ok(ok) => ok, + Err(err) => { + return Err(errors::message_with_debug_value( + "sign_transaction", + "failed to pack signed", + err, + "signed transaction msgpack", + signed_transaction, + )) + } + }; + + Ok(signed_transaction_bytes) +} + +/// Algorand network-compatible MessagePack serialization and deserialization. +/// +/// This is important to get right: variations will lead to data that's not valid for Algorand. +pub mod algorand_network_compatible { + use std::prelude::v1::{Box, Vec}; + + use algonaut::core::ToMsgPack; + use serde::Deserialize; + + /// For serialization, we use algonaut's [`ToMsgPack`] trait. + pub fn to_msgpack(value: &impl ToMsgPack) -> Result, rmp_serde::encode::Error> { + value.to_msg_pack().map(Vec::into_boxed_slice) + } + + /// For deserialization, we use `rmp_serde::from_read_ref`, which algonaut currently uses. + pub fn from_msgpack<'de, D, R>(bytes: &'de R) -> Result + where + D: Deserialize<'de>, + R: AsRef<[u8]> + ?Sized, + { + rmp_serde::from_read_ref(bytes) + } +} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/sign_transaction_xrpl.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/sign_transaction_xrpl.rs new file mode 100644 index 0000000..f1c1da5 --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/sign_transaction_xrpl.rs @@ -0,0 +1,8 @@ +use crate::schema::entities::XrplAccount; +use crate::schema::types::Bytes; + +pub(crate) fn sign_xrpl(signing_account: &XrplAccount, transaction_bytes: &Bytes) -> Bytes { + let signature = signing_account.to_private_key().sign(transaction_bytes); + let signature_bytes = Bytes::from(signature.as_ref()); + signature_bytes +} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/store.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/store.rs new file mode 100644 index 0000000..78c3c0b --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/store.rs @@ -0,0 +1,90 @@ +use std::io; +use std::prelude::v1::Box; + +use sgx_trts::memeq::ConsttimeMemEq; +use thiserror::Error; + +use crate::ported::kv_store::fs::{FsStore, SgxFiler}; +use crate::ported::kv_store::{Key, KvStore}; +use crate::schema::entities::WalletStorable; + +type WalletStore = FsStore; + +// FIXME: Hardcoded +pub const WALLET_STORE_DIR: &str = "wallet_store"; + +pub fn wallet_store() -> WalletStore { + FsStore::new(WALLET_STORE_DIR, SgxFiler) +} + +pub fn save_new_wallet(new_wallet: &WalletStorable) -> Result<(), io::Error> { + let mut store = wallet_store(); + let key = &key_from_id(&new_wallet.wallet_id)?; + match store.try_insert(key, new_wallet)? { + None => Ok(()), + Some(existing) => panic!( + "save_wallet: key conflict! key = {:?}, existing owner = {:?}, new owner = {:?}", + key, existing.owner_name, new_wallet.owner_name + ), + } +} + +/// Return `None` if `wallet_id` not found. +pub fn load_wallet(wallet_id: &str) -> Result, io::Error> { + let store = wallet_store(); + let key = &key_from_id(wallet_id)?; + store.load(key) +} + +pub fn key_from_id(wallet_id: &str) -> Result, io::Error> { + // XXX: Assume XRP address, for now. + let address = ripple_address_codec::decode_account_id(wallet_id).map_err(|err| { + io::Error::new( + io::ErrorKind::InvalidInput, + format!( + "key_from_id failed for wallet_id = {:?}: {}", + wallet_id, err + ), + ) + })?; + Ok(address.into()) +} + +/// Load and authenticate access to a wallet. +pub fn unlock_wallet(wallet_id: &str, auth_pin: &str) -> Result { + let stored: WalletStorable = + load_wallet(wallet_id)?.ok_or(UnlockWalletError::InvalidWalletId)?; + + match ConsttimeMemEq::consttime_memeq(stored.auth_pin.as_bytes(), auth_pin.as_bytes()) { + true => Ok(stored), + false => Err(UnlockWalletError::InvalidAuthPin), + } +} + +/// [`unlock_wallet`] failed. +/// +/// # Security note +/// +/// This representation distinguishes `InvalidWalletId` and `InvalidAuthPin`, +/// but this distinction should be limited to internal interfaces: +/// public interfaces should combine invalid authentication cases to avoid information leakage. +#[derive(Debug, Error)] +pub enum UnlockWalletError { + #[error("invalid wallet ID provided")] + InvalidWalletId, + + #[error("invalid authentication PIN provided")] + InvalidAuthPin, + + #[error("I/O error while opening wallet")] + IoError(#[from] io::Error), +} + +pub fn mutate_wallet( + wallet_id: &str, + mutate_fn: impl FnOnce(WalletStorable) -> WalletStorable, +) -> Result, io::Error> { + let mut store = wallet_store(); + let key = &key_from_id(wallet_id)?; + store.mutate(key, mutate_fn) +} diff --git a/rust-sgx-workspace/projects/ntc-tee-server/Makefile b/rust-sgx-workspace/projects/ntc-tee-server/Makefile index 1955bdd..f1d3903 100644 --- a/rust-sgx-workspace/projects/ntc-tee-server/Makefile +++ b/rust-sgx-workspace/projects/ntc-tee-server/Makefile @@ -43,4 +43,8 @@ re: fclean all # Dummy rules to let make know that those rules are not files. -.PHONY: host enclave clean clean_host clean_enclave fclean_host fclean_enclave fclean re re_host re_enclave \ No newline at end of file +.PHONY: host enclave clean clean_host clean_enclave fclean_host fclean_enclave fclean re re_host re_enclave + +.PHONY: run +run: all + @(cd build/bin && ./ntc-tee-server-app) \ No newline at end of file diff --git a/rust-sgx-workspace/projects/ntc-tee-server/app/Cargo.toml b/rust-sgx-workspace/projects/ntc-tee-server/app/Cargo.toml index 7dfbe89..f1013d7 100644 --- a/rust-sgx-workspace/projects/ntc-tee-server/app/Cargo.toml +++ b/rust-sgx-workspace/projects/ntc-tee-server/app/Cargo.toml @@ -6,5 +6,5 @@ edition = "2021" build = "build.rs" [dependencies] -sgx_types = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk" } -sgx_urts = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk" } +sgx_types = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } +sgx_urts = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } diff --git a/rust-sgx-workspace/projects/ntc-tee-server/app/codegen/Enclave_u.rs b/rust-sgx-workspace/projects/ntc-tee-server/app/codegen/Enclave_u.rs index 06883f4..fdf8412 100644 --- a/rust-sgx-workspace/projects/ntc-tee-server/app/codegen/Enclave_u.rs +++ b/rust-sgx-workspace/projects/ntc-tee-server/app/codegen/Enclave_u.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.59.1 */ +/* automatically generated by rust-bindgen 0.59.2 */ use sgx_types::*; diff --git a/rust-sgx-workspace/projects/ntc-tee-server/enclave/Cargo.toml b/rust-sgx-workspace/projects/ntc-tee-server/enclave/Cargo.toml index 70772aa..0d3a345 100644 --- a/rust-sgx-workspace/projects/ntc-tee-server/enclave/Cargo.toml +++ b/rust-sgx-workspace/projects/ntc-tee-server/enclave/Cargo.toml @@ -12,5 +12,5 @@ test = false default = [] [dependencies] -sgx_types = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk" } -sgx_tstd = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", features = ["backtrace"] } +sgx_types = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } +sgx_tstd = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", features = ["backtrace"], rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/.gitignore b/rust-sgx-workspace/projects/sgx-wallet-test/.gitignore new file mode 100644 index 0000000..438fbf5 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/.gitignore @@ -0,0 +1,2 @@ +/build +/keys diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/Makefile b/rust-sgx-workspace/projects/sgx-wallet-test/Makefile new file mode 100644 index 0000000..56fe048 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/Makefile @@ -0,0 +1,50 @@ +# Dummy makefile, will call the host and enclave makefile when requested. + +SRC_U = app/ +SRC_T = enclave/ + +# Compilation process, will call the appropriate makefiles. + +all: host enclave + +host: + @echo "\033[32mRequest to compile the host part...\033[0m" + @make -C $(SRC_U) + +enclave: + @echo "\033[32mRequest to compile the enclave part...\033[0m" + @make -C $(SRC_T) + +clean: + @make -C $(SRC_U) clean + @make -C $(SRC_T) clean + +fclean: + @make -C $(SRC_U) fclean + @make -C $(SRC_T) fclean + +clean_host: + @make -C $(SRC_U) clean + +clean_enclave: + @make -C $(SRC_T) clean + +fclean_host: + @make -C $(SRC_U) fclean + +fclean_enclave: + @make -C $(SRC_T) fclean + +re_host: fclean_host host + +re_enclave: fclean_enclave enclave + +re: fclean all + +# Dummy rules to let make know that those rules are not files. + +.PHONY: host enclave clean clean_host clean_enclave fclean_host fclean_enclave fclean re re_host re_enclave + +.PHONY: run +run: all + @(cd build/bin && ./sgx-wallet-test-app) diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/Makefile.toml b/rust-sgx-workspace/projects/sgx-wallet-test/Makefile.toml new file mode 100644 index 0000000..6d7ad18 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/Makefile.toml @@ -0,0 +1,5 @@ +[env] + +# https://github.com/sagiegurari/cargo-make#workspace-emulation +CARGO_MAKE_WORKSPACE_EMULATION = true +CARGO_MAKE_CRATE_WORKSPACE_MEMBERS = ["app", "enclave"] diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/app/.gitignore b/rust-sgx-workspace/projects/sgx-wallet-test/app/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/app/.gitignore @@ -0,0 +1 @@ +/target diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/app/Cargo.lock b/rust-sgx-workspace/projects/sgx-wallet-test/app/Cargo.lock new file mode 100644 index 0000000..42f5325 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/app/Cargo.lock @@ -0,0 +1,31 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "libc" +version = "0.2.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790" + +[[package]] +name = "sgx-wallet-test-app" +version = "0.1.0" +dependencies = [ + "sgx_types", + "sgx_urts", +] + +[[package]] +name = "sgx_types" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" + +[[package]] +name = "sgx_urts" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "libc", + "sgx_types", +] diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/app/Cargo.toml b/rust-sgx-workspace/projects/sgx-wallet-test/app/Cargo.toml new file mode 100644 index 0000000..562563f --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/app/Cargo.toml @@ -0,0 +1,12 @@ +[package] +# name matches APP_U in Makefile +name = "sgx-wallet-test-app" +version = "0.1.0" +edition = "2021" +build = "build.rs" + +[dependencies] +sgx_types = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } +sgx_urts = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } + +[patch.'https://github.com/apache/teaclave-sgx-sdk.git'] diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/app/Makefile b/rust-sgx-workspace/projects/sgx-wallet-test/app/Makefile new file mode 100644 index 0000000..926a771 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/app/Makefile @@ -0,0 +1,99 @@ +# Makefile settings - Host part + +LIB = ../build/lib/ +BIN = ../build/bin/ +# APP_U matches name in Cargo.toml +APP_U = sgx-wallet-test-app +APP_T = enclave.so +NAME_U = libEnclave_u.a +SRC_U = ./ +CODEGEN_U = $(SRC_U)/codegen/ +SRC_T = ../enclave/ +OBJ_U = ../build/obj/ +FLAGS = -Wall -Wextra +GCC_STEP1_U = -I $(CODEGEN_U) -I./include -I$(SGX_SDK)/include -I$(CUSTOM_EDL_PATH) -fPIC -Wno-attributes $(SGX_COMMON_CFLAGS) +FILES_U = Enclave_u.c +FILES_U_H = Enclave_u.h +SGX_ARCH = x64 +TRTS_LIB = sgx_trts +SERVICE_LIB = sgx_tservice +# Addprefix dependant variables, no need to change those +OUTPUT_U = $(FILES_U:.c=.o) +BIN_U = $(addprefix $(BIN), $(APP_U)) +NAME_U_D = $(addprefix $(LIB), $(NAME_U)) +FILES_U_F=$(addprefix $(CODEGEN_U), $(FILES_U)) +FILES_U_H_F=$(addprefix $(CODEGEN_U), $(FILES_U_H)) +OUTPUT_W_FU=$(addprefix $(OBJ_U), $(OUTPUT_U)) + +# All Rust and other source files that the Cargo build depends on. +FILES_RUST_F = Cargo.toml Cargo.lock build.rs $(shell find src -name '*.rs') $(CODEGEN_U)Enclave_u.rs + +# Contains compilation rules for the enclave part + +include ../buildenv.mk +include ../buildenv_sgx.mk + +# Custom libraries, EDL paths. Needs to be specified with make (CUSTOM_EDL_PATH) (CUSTOM_COMMON_PATH) + +# Compilation process, we set up all the dependencies needed to have the correct order of build, and avoid relink + +all: $(BIN_U) + +$(FILES_U_F): $(SGX_EDGER8R) $(SRC_T)/Enclave.edl + @echo "\033[32mGenerating untrusted SGX C edl files...\033[0m" + @$(SGX_EDGER8R) --untrusted $(SRC_T)/Enclave.edl --search-path $(SGX_SDK)/include --search-path $(CUSTOM_EDL_PATH) --untrusted-dir $(CODEGEN_U) + +$(NAME_U_D): $(FILES_U_F) $(OUTPUT_W_FU) + @echo "\033[32mBuilding untrusted C edl static library...\033[0m" + @mkdir -p $(LIB) + @$(AR) rcsD $@ $(OUTPUT_W_FU) + +$(OBJ_U)%.o:$(CODEGEN_U)%.c + @mkdir -p $(OBJ_U) + @echo "\033[32m$?: Build in progress...\033[0m" + @$(CC) $(FLAGS) $(GCC_STEP1_U) -o $@ -c $? + +# We print the compilation mode we're in (hardware/software mode), just as a reminder. + +$(BIN_U): $(NAME_U_D) $(FILES_RUST_F) $(FILES_U_H_F) +ifeq ($(SGX_MODE), SW) + @echo "\033[32mSoftware / Simulation mode\033[0m" +else + @echo "\033[32mHardware mode\033[0m" +endif + @echo "\033[32mStarting cargo to build the host...\033[0m" + @cd $(SRC_U) && SGX_SDK=$(SGX_SDK) cargo build --release + @echo "\033[32mCopying the host to the correct location... ($(BIN_U))\033[0m" + @mkdir -p $(BIN) + @cp $(SRC_U)/target/release/$(APP_U) $(BIN) + +$(CODEGEN_U)Enclave_u.rs: $(CODEGEN_U)Enclave_u.h + @echo "\033[32mGenerating Rust bindings: $@\033[0m" + @bindgen \ + --no-recursive-allowlist \ + --raw-line 'use sgx_types::*;' \ + --allowlist-function 'run_tests_ecall' \ + --output $@ \ + $? \ + -- -I$(SGX_SDK)/include -I$(CUSTOM_EDL_PATH) + +clean: c_clean + @rm -rf $(OBJ_U) + @echo "\033[32mObject files deleted\033[0m" + +fclean: clean fclean_host + +fclean_host: + @echo "\033[32mBinary file $(BIN_U) deleted\033[0m" + @rm -f $(BIN_U) + @rm -f $(NAME_U_D) + @cargo clean + +c_clean: + @echo "\033[32mC edl generated files deleted\033[0m" + @rm -rf $(FILES_U_F) + @rm -rf $(FILES_U_H_F) + +re: fclean all + +.PHONY: all clean c_clean fclean re fclean_host diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/app/build.rs b/rust-sgx-workspace/projects/sgx-wallet-test/app/build.rs new file mode 100644 index 0000000..8cb97aa --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/app/build.rs @@ -0,0 +1,21 @@ +use std::env; + +fn main() { + println!("cargo:rerun-if-env-changed=SGX_SDK"); + println!("cargo:rerun-if-env-changed=SGX_MODE"); + + let sdk_dir = env::var("SGX_SDK").unwrap_or_else(|_| "/opt/sgxsdk".to_string()); + let is_sim = env::var("SGX_MODE").unwrap_or_else(|_| "HW".to_string()); + + println!("cargo:rustc-link-search=native=../build/lib"); + println!("cargo:rustc-link-lib=static=Enclave_u"); + + println!("cargo:rustc-link-search=native={}/lib64", sdk_dir); + match is_sim.as_ref() { + "SW" => println!("cargo:rustc-link-lib=dylib=sgx_urts_sim"), + "HW" => println!("cargo:rustc-link-lib=dylib=sgx_urts"), + _ => println!("cargo:rustc-link-lib=dylib=sgx_urts"), // Treat undefined as HW + } + + println!("cargo:rustc-link-lib=dylib=sgx_uprotected_fs"); +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/app/codegen/Enclave_u.c b/rust-sgx-workspace/projects/sgx-wallet-test/app/codegen/Enclave_u.c new file mode 100644 index 0000000..ac39911 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/app/codegen/Enclave_u.c @@ -0,0 +1,1307 @@ +#include "Enclave_u.h" +#include + +typedef struct ms_run_tests_ecall_t { + size_t ms_retval; +} ms_run_tests_ecall_t; + +typedef struct ms_t_global_init_ecall_t { + uint64_t ms_id; + const uint8_t* ms_path; + size_t ms_len; +} ms_t_global_init_ecall_t; + +typedef struct ms_u_thread_set_event_ocall_t { + int ms_retval; + int* ms_error; + const void* ms_tcs; +} ms_u_thread_set_event_ocall_t; + +typedef struct ms_u_thread_wait_event_ocall_t { + int ms_retval; + int* ms_error; + const void* ms_tcs; + const struct timespec* ms_timeout; +} ms_u_thread_wait_event_ocall_t; + +typedef struct ms_u_thread_set_multiple_events_ocall_t { + int ms_retval; + int* ms_error; + const void** ms_tcss; + int ms_total; +} ms_u_thread_set_multiple_events_ocall_t; + +typedef struct ms_u_thread_setwait_events_ocall_t { + int ms_retval; + int* ms_error; + const void* ms_waiter_tcs; + const void* ms_self_tcs; + const struct timespec* ms_timeout; +} ms_u_thread_setwait_events_ocall_t; + +typedef struct ms_u_clock_gettime_ocall_t { + int ms_retval; + int* ms_error; + int ms_clk_id; + struct timespec* ms_tp; +} ms_u_clock_gettime_ocall_t; + +typedef struct ms_u_read_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + void* ms_buf; + size_t ms_count; +} ms_u_read_ocall_t; + +typedef struct ms_u_pread64_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + void* ms_buf; + size_t ms_count; + int64_t ms_offset; +} ms_u_pread64_ocall_t; + +typedef struct ms_u_readv_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const struct iovec* ms_iov; + int ms_iovcnt; +} ms_u_readv_ocall_t; + +typedef struct ms_u_preadv64_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const struct iovec* ms_iov; + int ms_iovcnt; + int64_t ms_offset; +} ms_u_preadv64_ocall_t; + +typedef struct ms_u_write_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const void* ms_buf; + size_t ms_count; +} ms_u_write_ocall_t; + +typedef struct ms_u_pwrite64_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const void* ms_buf; + size_t ms_count; + int64_t ms_offset; +} ms_u_pwrite64_ocall_t; + +typedef struct ms_u_writev_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const struct iovec* ms_iov; + int ms_iovcnt; +} ms_u_writev_ocall_t; + +typedef struct ms_u_pwritev64_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const struct iovec* ms_iov; + int ms_iovcnt; + int64_t ms_offset; +} ms_u_pwritev64_ocall_t; + +typedef struct ms_u_fcntl_arg0_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int ms_cmd; +} ms_u_fcntl_arg0_ocall_t; + +typedef struct ms_u_fcntl_arg1_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int ms_cmd; + int ms_arg; +} ms_u_fcntl_arg1_ocall_t; + +typedef struct ms_u_ioctl_arg0_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int ms_request; +} ms_u_ioctl_arg0_ocall_t; + +typedef struct ms_u_ioctl_arg1_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int ms_request; + int* ms_arg; +} ms_u_ioctl_arg1_ocall_t; + +typedef struct ms_u_close_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; +} ms_u_close_ocall_t; + +typedef struct ms_u_malloc_ocall_t { + void* ms_retval; + int* ms_error; + size_t ms_size; +} ms_u_malloc_ocall_t; + +typedef struct ms_u_free_ocall_t { + void* ms_p; +} ms_u_free_ocall_t; + +typedef struct ms_u_mmap_ocall_t { + void* ms_retval; + int* ms_error; + void* ms_start; + size_t ms_length; + int ms_prot; + int ms_flags; + int ms_fd; + int64_t ms_offset; +} ms_u_mmap_ocall_t; + +typedef struct ms_u_munmap_ocall_t { + int ms_retval; + int* ms_error; + void* ms_start; + size_t ms_length; +} ms_u_munmap_ocall_t; + +typedef struct ms_u_msync_ocall_t { + int ms_retval; + int* ms_error; + void* ms_addr; + size_t ms_length; + int ms_flags; +} ms_u_msync_ocall_t; + +typedef struct ms_u_mprotect_ocall_t { + int ms_retval; + int* ms_error; + void* ms_addr; + size_t ms_length; + int ms_prot; +} ms_u_mprotect_ocall_t; + +typedef struct ms_u_open_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_pathname; + int ms_flags; +} ms_u_open_ocall_t; + +typedef struct ms_u_open64_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + int ms_oflag; + int ms_mode; +} ms_u_open64_ocall_t; + +typedef struct ms_u_fstat_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + struct stat_t* ms_buf; +} ms_u_fstat_ocall_t; + +typedef struct ms_u_fstat64_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + struct stat64_t* ms_buf; +} ms_u_fstat64_ocall_t; + +typedef struct ms_u_stat_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + struct stat_t* ms_buf; +} ms_u_stat_ocall_t; + +typedef struct ms_u_stat64_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + struct stat64_t* ms_buf; +} ms_u_stat64_ocall_t; + +typedef struct ms_u_lstat_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + struct stat_t* ms_buf; +} ms_u_lstat_ocall_t; + +typedef struct ms_u_lstat64_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + struct stat64_t* ms_buf; +} ms_u_lstat64_ocall_t; + +typedef struct ms_u_lseek_ocall_t { + uint64_t ms_retval; + int* ms_error; + int ms_fd; + int64_t ms_offset; + int ms_whence; +} ms_u_lseek_ocall_t; + +typedef struct ms_u_lseek64_ocall_t { + int64_t ms_retval; + int* ms_error; + int ms_fd; + int64_t ms_offset; + int ms_whence; +} ms_u_lseek64_ocall_t; + +typedef struct ms_u_ftruncate_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int64_t ms_length; +} ms_u_ftruncate_ocall_t; + +typedef struct ms_u_ftruncate64_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int64_t ms_length; +} ms_u_ftruncate64_ocall_t; + +typedef struct ms_u_truncate_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + int64_t ms_length; +} ms_u_truncate_ocall_t; + +typedef struct ms_u_truncate64_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + int64_t ms_length; +} ms_u_truncate64_ocall_t; + +typedef struct ms_u_fsync_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; +} ms_u_fsync_ocall_t; + +typedef struct ms_u_fdatasync_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; +} ms_u_fdatasync_ocall_t; + +typedef struct ms_u_fchmod_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + uint32_t ms_mode; +} ms_u_fchmod_ocall_t; + +typedef struct ms_u_unlink_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_pathname; +} ms_u_unlink_ocall_t; + +typedef struct ms_u_link_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_oldpath; + const char* ms_newpath; +} ms_u_link_ocall_t; + +typedef struct ms_u_linkat_ocall_t { + int ms_retval; + int* ms_error; + int ms_olddirfd; + const char* ms_oldpath; + int ms_newdirfd; + const char* ms_newpath; + int ms_flags; +} ms_u_linkat_ocall_t; + +typedef struct ms_u_rename_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_oldpath; + const char* ms_newpath; +} ms_u_rename_ocall_t; + +typedef struct ms_u_chmod_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + uint32_t ms_mode; +} ms_u_chmod_ocall_t; + +typedef struct ms_u_readlink_ocall_t { + size_t ms_retval; + int* ms_error; + const char* ms_path; + char* ms_buf; + size_t ms_bufsz; +} ms_u_readlink_ocall_t; + +typedef struct ms_u_symlink_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path1; + const char* ms_path2; +} ms_u_symlink_ocall_t; + +typedef struct ms_u_realpath_ocall_t { + char* ms_retval; + int* ms_error; + const char* ms_pathname; +} ms_u_realpath_ocall_t; + +typedef struct ms_u_mkdir_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_pathname; + uint32_t ms_mode; +} ms_u_mkdir_ocall_t; + +typedef struct ms_u_rmdir_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_pathname; +} ms_u_rmdir_ocall_t; + +typedef struct ms_u_opendir_ocall_t { + void* ms_retval; + int* ms_error; + const char* ms_pathname; +} ms_u_opendir_ocall_t; + +typedef struct ms_u_readdir64_r_ocall_t { + int ms_retval; + void* ms_dirp; + struct dirent64_t* ms_entry; + struct dirent64_t** ms_result; +} ms_u_readdir64_r_ocall_t; + +typedef struct ms_u_closedir_ocall_t { + int ms_retval; + int* ms_error; + void* ms_dirp; +} ms_u_closedir_ocall_t; + +typedef struct ms_u_dirfd_ocall_t { + int ms_retval; + int* ms_error; + void* ms_dirp; +} ms_u_dirfd_ocall_t; + +typedef struct ms_u_fstatat64_ocall_t { + int ms_retval; + int* ms_error; + int ms_dirfd; + const char* ms_pathname; + struct stat64_t* ms_buf; + int ms_flags; +} ms_u_fstatat64_ocall_t; + +typedef struct ms_u_environ_ocall_t { + char** ms_retval; +} ms_u_environ_ocall_t; + +typedef struct ms_u_getenv_ocall_t { + char* ms_retval; + const char* ms_name; +} ms_u_getenv_ocall_t; + +typedef struct ms_u_setenv_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_name; + const char* ms_value; + int ms_overwrite; +} ms_u_setenv_ocall_t; + +typedef struct ms_u_unsetenv_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_name; +} ms_u_unsetenv_ocall_t; + +typedef struct ms_u_chdir_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_dir; +} ms_u_chdir_ocall_t; + +typedef struct ms_u_getcwd_ocall_t { + char* ms_retval; + int* ms_error; + char* ms_buf; + size_t ms_buflen; +} ms_u_getcwd_ocall_t; + +typedef struct ms_u_getpwuid_r_ocall_t { + int ms_retval; + unsigned int ms_uid; + struct passwd* ms_pwd; + char* ms_buf; + size_t ms_buflen; + struct passwd** ms_passwd_result; +} ms_u_getpwuid_r_ocall_t; + +typedef struct ms_u_getuid_ocall_t { + unsigned int ms_retval; +} ms_u_getuid_ocall_t; + +typedef struct ms_u_sgxprotectedfs_exclusive_file_open_t { + void* ms_retval; + const char* ms_filename; + uint8_t ms_read_only; + int64_t* ms_file_size; + int32_t* ms_error_code; +} ms_u_sgxprotectedfs_exclusive_file_open_t; + +typedef struct ms_u_sgxprotectedfs_check_if_file_exists_t { + uint8_t ms_retval; + const char* ms_filename; +} ms_u_sgxprotectedfs_check_if_file_exists_t; + +typedef struct ms_u_sgxprotectedfs_fread_node_t { + int32_t ms_retval; + void* ms_f; + uint64_t ms_node_number; + uint8_t* ms_buffer; + uint32_t ms_node_size; +} ms_u_sgxprotectedfs_fread_node_t; + +typedef struct ms_u_sgxprotectedfs_fwrite_node_t { + int32_t ms_retval; + void* ms_f; + uint64_t ms_node_number; + uint8_t* ms_buffer; + uint32_t ms_node_size; +} ms_u_sgxprotectedfs_fwrite_node_t; + +typedef struct ms_u_sgxprotectedfs_fclose_t { + int32_t ms_retval; + void* ms_f; +} ms_u_sgxprotectedfs_fclose_t; + +typedef struct ms_u_sgxprotectedfs_fflush_t { + uint8_t ms_retval; + void* ms_f; +} ms_u_sgxprotectedfs_fflush_t; + +typedef struct ms_u_sgxprotectedfs_remove_t { + int32_t ms_retval; + const char* ms_filename; +} ms_u_sgxprotectedfs_remove_t; + +typedef struct ms_u_sgxprotectedfs_recovery_file_open_t { + void* ms_retval; + const char* ms_filename; +} ms_u_sgxprotectedfs_recovery_file_open_t; + +typedef struct ms_u_sgxprotectedfs_fwrite_recovery_node_t { + uint8_t ms_retval; + void* ms_f; + uint8_t* ms_data; + uint32_t ms_data_length; +} ms_u_sgxprotectedfs_fwrite_recovery_node_t; + +typedef struct ms_u_sgxprotectedfs_do_file_recovery_t { + int32_t ms_retval; + const char* ms_filename; + const char* ms_recovery_filename; + uint32_t ms_node_size; +} ms_u_sgxprotectedfs_do_file_recovery_t; + +typedef struct ms_sgx_oc_cpuidex_t { + int* ms_cpuinfo; + int ms_leaf; + int ms_subleaf; +} ms_sgx_oc_cpuidex_t; + +typedef struct ms_sgx_thread_wait_untrusted_event_ocall_t { + int ms_retval; + const void* ms_self; +} ms_sgx_thread_wait_untrusted_event_ocall_t; + +typedef struct ms_sgx_thread_set_untrusted_event_ocall_t { + int ms_retval; + const void* ms_waiter; +} ms_sgx_thread_set_untrusted_event_ocall_t; + +typedef struct ms_sgx_thread_setwait_untrusted_events_ocall_t { + int ms_retval; + const void* ms_waiter; + const void* ms_self; +} ms_sgx_thread_setwait_untrusted_events_ocall_t; + +typedef struct ms_sgx_thread_set_multiple_untrusted_events_ocall_t { + int ms_retval; + const void** ms_waiters; + size_t ms_total; +} ms_sgx_thread_set_multiple_untrusted_events_ocall_t; + +static sgx_status_t SGX_CDECL Enclave_u_thread_set_event_ocall(void* pms) +{ + ms_u_thread_set_event_ocall_t* ms = SGX_CAST(ms_u_thread_set_event_ocall_t*, pms); + ms->ms_retval = u_thread_set_event_ocall(ms->ms_error, ms->ms_tcs); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_thread_wait_event_ocall(void* pms) +{ + ms_u_thread_wait_event_ocall_t* ms = SGX_CAST(ms_u_thread_wait_event_ocall_t*, pms); + ms->ms_retval = u_thread_wait_event_ocall(ms->ms_error, ms->ms_tcs, ms->ms_timeout); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_thread_set_multiple_events_ocall(void* pms) +{ + ms_u_thread_set_multiple_events_ocall_t* ms = SGX_CAST(ms_u_thread_set_multiple_events_ocall_t*, pms); + ms->ms_retval = u_thread_set_multiple_events_ocall(ms->ms_error, ms->ms_tcss, ms->ms_total); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_thread_setwait_events_ocall(void* pms) +{ + ms_u_thread_setwait_events_ocall_t* ms = SGX_CAST(ms_u_thread_setwait_events_ocall_t*, pms); + ms->ms_retval = u_thread_setwait_events_ocall(ms->ms_error, ms->ms_waiter_tcs, ms->ms_self_tcs, ms->ms_timeout); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_clock_gettime_ocall(void* pms) +{ + ms_u_clock_gettime_ocall_t* ms = SGX_CAST(ms_u_clock_gettime_ocall_t*, pms); + ms->ms_retval = u_clock_gettime_ocall(ms->ms_error, ms->ms_clk_id, ms->ms_tp); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_read_ocall(void* pms) +{ + ms_u_read_ocall_t* ms = SGX_CAST(ms_u_read_ocall_t*, pms); + ms->ms_retval = u_read_ocall(ms->ms_error, ms->ms_fd, ms->ms_buf, ms->ms_count); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_pread64_ocall(void* pms) +{ + ms_u_pread64_ocall_t* ms = SGX_CAST(ms_u_pread64_ocall_t*, pms); + ms->ms_retval = u_pread64_ocall(ms->ms_error, ms->ms_fd, ms->ms_buf, ms->ms_count, ms->ms_offset); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_readv_ocall(void* pms) +{ + ms_u_readv_ocall_t* ms = SGX_CAST(ms_u_readv_ocall_t*, pms); + ms->ms_retval = u_readv_ocall(ms->ms_error, ms->ms_fd, ms->ms_iov, ms->ms_iovcnt); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_preadv64_ocall(void* pms) +{ + ms_u_preadv64_ocall_t* ms = SGX_CAST(ms_u_preadv64_ocall_t*, pms); + ms->ms_retval = u_preadv64_ocall(ms->ms_error, ms->ms_fd, ms->ms_iov, ms->ms_iovcnt, ms->ms_offset); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_write_ocall(void* pms) +{ + ms_u_write_ocall_t* ms = SGX_CAST(ms_u_write_ocall_t*, pms); + ms->ms_retval = u_write_ocall(ms->ms_error, ms->ms_fd, ms->ms_buf, ms->ms_count); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_pwrite64_ocall(void* pms) +{ + ms_u_pwrite64_ocall_t* ms = SGX_CAST(ms_u_pwrite64_ocall_t*, pms); + ms->ms_retval = u_pwrite64_ocall(ms->ms_error, ms->ms_fd, ms->ms_buf, ms->ms_count, ms->ms_offset); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_writev_ocall(void* pms) +{ + ms_u_writev_ocall_t* ms = SGX_CAST(ms_u_writev_ocall_t*, pms); + ms->ms_retval = u_writev_ocall(ms->ms_error, ms->ms_fd, ms->ms_iov, ms->ms_iovcnt); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_pwritev64_ocall(void* pms) +{ + ms_u_pwritev64_ocall_t* ms = SGX_CAST(ms_u_pwritev64_ocall_t*, pms); + ms->ms_retval = u_pwritev64_ocall(ms->ms_error, ms->ms_fd, ms->ms_iov, ms->ms_iovcnt, ms->ms_offset); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_fcntl_arg0_ocall(void* pms) +{ + ms_u_fcntl_arg0_ocall_t* ms = SGX_CAST(ms_u_fcntl_arg0_ocall_t*, pms); + ms->ms_retval = u_fcntl_arg0_ocall(ms->ms_error, ms->ms_fd, ms->ms_cmd); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_fcntl_arg1_ocall(void* pms) +{ + ms_u_fcntl_arg1_ocall_t* ms = SGX_CAST(ms_u_fcntl_arg1_ocall_t*, pms); + ms->ms_retval = u_fcntl_arg1_ocall(ms->ms_error, ms->ms_fd, ms->ms_cmd, ms->ms_arg); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_ioctl_arg0_ocall(void* pms) +{ + ms_u_ioctl_arg0_ocall_t* ms = SGX_CAST(ms_u_ioctl_arg0_ocall_t*, pms); + ms->ms_retval = u_ioctl_arg0_ocall(ms->ms_error, ms->ms_fd, ms->ms_request); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_ioctl_arg1_ocall(void* pms) +{ + ms_u_ioctl_arg1_ocall_t* ms = SGX_CAST(ms_u_ioctl_arg1_ocall_t*, pms); + ms->ms_retval = u_ioctl_arg1_ocall(ms->ms_error, ms->ms_fd, ms->ms_request, ms->ms_arg); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_close_ocall(void* pms) +{ + ms_u_close_ocall_t* ms = SGX_CAST(ms_u_close_ocall_t*, pms); + ms->ms_retval = u_close_ocall(ms->ms_error, ms->ms_fd); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_malloc_ocall(void* pms) +{ + ms_u_malloc_ocall_t* ms = SGX_CAST(ms_u_malloc_ocall_t*, pms); + ms->ms_retval = u_malloc_ocall(ms->ms_error, ms->ms_size); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_free_ocall(void* pms) +{ + ms_u_free_ocall_t* ms = SGX_CAST(ms_u_free_ocall_t*, pms); + u_free_ocall(ms->ms_p); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_mmap_ocall(void* pms) +{ + ms_u_mmap_ocall_t* ms = SGX_CAST(ms_u_mmap_ocall_t*, pms); + ms->ms_retval = u_mmap_ocall(ms->ms_error, ms->ms_start, ms->ms_length, ms->ms_prot, ms->ms_flags, ms->ms_fd, ms->ms_offset); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_munmap_ocall(void* pms) +{ + ms_u_munmap_ocall_t* ms = SGX_CAST(ms_u_munmap_ocall_t*, pms); + ms->ms_retval = u_munmap_ocall(ms->ms_error, ms->ms_start, ms->ms_length); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_msync_ocall(void* pms) +{ + ms_u_msync_ocall_t* ms = SGX_CAST(ms_u_msync_ocall_t*, pms); + ms->ms_retval = u_msync_ocall(ms->ms_error, ms->ms_addr, ms->ms_length, ms->ms_flags); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_mprotect_ocall(void* pms) +{ + ms_u_mprotect_ocall_t* ms = SGX_CAST(ms_u_mprotect_ocall_t*, pms); + ms->ms_retval = u_mprotect_ocall(ms->ms_error, ms->ms_addr, ms->ms_length, ms->ms_prot); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_open_ocall(void* pms) +{ + ms_u_open_ocall_t* ms = SGX_CAST(ms_u_open_ocall_t*, pms); + ms->ms_retval = u_open_ocall(ms->ms_error, ms->ms_pathname, ms->ms_flags); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_open64_ocall(void* pms) +{ + ms_u_open64_ocall_t* ms = SGX_CAST(ms_u_open64_ocall_t*, pms); + ms->ms_retval = u_open64_ocall(ms->ms_error, ms->ms_path, ms->ms_oflag, ms->ms_mode); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_fstat_ocall(void* pms) +{ + ms_u_fstat_ocall_t* ms = SGX_CAST(ms_u_fstat_ocall_t*, pms); + ms->ms_retval = u_fstat_ocall(ms->ms_error, ms->ms_fd, ms->ms_buf); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_fstat64_ocall(void* pms) +{ + ms_u_fstat64_ocall_t* ms = SGX_CAST(ms_u_fstat64_ocall_t*, pms); + ms->ms_retval = u_fstat64_ocall(ms->ms_error, ms->ms_fd, ms->ms_buf); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_stat_ocall(void* pms) +{ + ms_u_stat_ocall_t* ms = SGX_CAST(ms_u_stat_ocall_t*, pms); + ms->ms_retval = u_stat_ocall(ms->ms_error, ms->ms_path, ms->ms_buf); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_stat64_ocall(void* pms) +{ + ms_u_stat64_ocall_t* ms = SGX_CAST(ms_u_stat64_ocall_t*, pms); + ms->ms_retval = u_stat64_ocall(ms->ms_error, ms->ms_path, ms->ms_buf); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_lstat_ocall(void* pms) +{ + ms_u_lstat_ocall_t* ms = SGX_CAST(ms_u_lstat_ocall_t*, pms); + ms->ms_retval = u_lstat_ocall(ms->ms_error, ms->ms_path, ms->ms_buf); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_lstat64_ocall(void* pms) +{ + ms_u_lstat64_ocall_t* ms = SGX_CAST(ms_u_lstat64_ocall_t*, pms); + ms->ms_retval = u_lstat64_ocall(ms->ms_error, ms->ms_path, ms->ms_buf); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_lseek_ocall(void* pms) +{ + ms_u_lseek_ocall_t* ms = SGX_CAST(ms_u_lseek_ocall_t*, pms); + ms->ms_retval = u_lseek_ocall(ms->ms_error, ms->ms_fd, ms->ms_offset, ms->ms_whence); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_lseek64_ocall(void* pms) +{ + ms_u_lseek64_ocall_t* ms = SGX_CAST(ms_u_lseek64_ocall_t*, pms); + ms->ms_retval = u_lseek64_ocall(ms->ms_error, ms->ms_fd, ms->ms_offset, ms->ms_whence); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_ftruncate_ocall(void* pms) +{ + ms_u_ftruncate_ocall_t* ms = SGX_CAST(ms_u_ftruncate_ocall_t*, pms); + ms->ms_retval = u_ftruncate_ocall(ms->ms_error, ms->ms_fd, ms->ms_length); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_ftruncate64_ocall(void* pms) +{ + ms_u_ftruncate64_ocall_t* ms = SGX_CAST(ms_u_ftruncate64_ocall_t*, pms); + ms->ms_retval = u_ftruncate64_ocall(ms->ms_error, ms->ms_fd, ms->ms_length); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_truncate_ocall(void* pms) +{ + ms_u_truncate_ocall_t* ms = SGX_CAST(ms_u_truncate_ocall_t*, pms); + ms->ms_retval = u_truncate_ocall(ms->ms_error, ms->ms_path, ms->ms_length); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_truncate64_ocall(void* pms) +{ + ms_u_truncate64_ocall_t* ms = SGX_CAST(ms_u_truncate64_ocall_t*, pms); + ms->ms_retval = u_truncate64_ocall(ms->ms_error, ms->ms_path, ms->ms_length); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_fsync_ocall(void* pms) +{ + ms_u_fsync_ocall_t* ms = SGX_CAST(ms_u_fsync_ocall_t*, pms); + ms->ms_retval = u_fsync_ocall(ms->ms_error, ms->ms_fd); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_fdatasync_ocall(void* pms) +{ + ms_u_fdatasync_ocall_t* ms = SGX_CAST(ms_u_fdatasync_ocall_t*, pms); + ms->ms_retval = u_fdatasync_ocall(ms->ms_error, ms->ms_fd); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_fchmod_ocall(void* pms) +{ + ms_u_fchmod_ocall_t* ms = SGX_CAST(ms_u_fchmod_ocall_t*, pms); + ms->ms_retval = u_fchmod_ocall(ms->ms_error, ms->ms_fd, ms->ms_mode); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_unlink_ocall(void* pms) +{ + ms_u_unlink_ocall_t* ms = SGX_CAST(ms_u_unlink_ocall_t*, pms); + ms->ms_retval = u_unlink_ocall(ms->ms_error, ms->ms_pathname); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_link_ocall(void* pms) +{ + ms_u_link_ocall_t* ms = SGX_CAST(ms_u_link_ocall_t*, pms); + ms->ms_retval = u_link_ocall(ms->ms_error, ms->ms_oldpath, ms->ms_newpath); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_linkat_ocall(void* pms) +{ + ms_u_linkat_ocall_t* ms = SGX_CAST(ms_u_linkat_ocall_t*, pms); + ms->ms_retval = u_linkat_ocall(ms->ms_error, ms->ms_olddirfd, ms->ms_oldpath, ms->ms_newdirfd, ms->ms_newpath, ms->ms_flags); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_rename_ocall(void* pms) +{ + ms_u_rename_ocall_t* ms = SGX_CAST(ms_u_rename_ocall_t*, pms); + ms->ms_retval = u_rename_ocall(ms->ms_error, ms->ms_oldpath, ms->ms_newpath); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_chmod_ocall(void* pms) +{ + ms_u_chmod_ocall_t* ms = SGX_CAST(ms_u_chmod_ocall_t*, pms); + ms->ms_retval = u_chmod_ocall(ms->ms_error, ms->ms_path, ms->ms_mode); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_readlink_ocall(void* pms) +{ + ms_u_readlink_ocall_t* ms = SGX_CAST(ms_u_readlink_ocall_t*, pms); + ms->ms_retval = u_readlink_ocall(ms->ms_error, ms->ms_path, ms->ms_buf, ms->ms_bufsz); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_symlink_ocall(void* pms) +{ + ms_u_symlink_ocall_t* ms = SGX_CAST(ms_u_symlink_ocall_t*, pms); + ms->ms_retval = u_symlink_ocall(ms->ms_error, ms->ms_path1, ms->ms_path2); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_realpath_ocall(void* pms) +{ + ms_u_realpath_ocall_t* ms = SGX_CAST(ms_u_realpath_ocall_t*, pms); + ms->ms_retval = u_realpath_ocall(ms->ms_error, ms->ms_pathname); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_mkdir_ocall(void* pms) +{ + ms_u_mkdir_ocall_t* ms = SGX_CAST(ms_u_mkdir_ocall_t*, pms); + ms->ms_retval = u_mkdir_ocall(ms->ms_error, ms->ms_pathname, ms->ms_mode); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_rmdir_ocall(void* pms) +{ + ms_u_rmdir_ocall_t* ms = SGX_CAST(ms_u_rmdir_ocall_t*, pms); + ms->ms_retval = u_rmdir_ocall(ms->ms_error, ms->ms_pathname); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_opendir_ocall(void* pms) +{ + ms_u_opendir_ocall_t* ms = SGX_CAST(ms_u_opendir_ocall_t*, pms); + ms->ms_retval = u_opendir_ocall(ms->ms_error, ms->ms_pathname); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_readdir64_r_ocall(void* pms) +{ + ms_u_readdir64_r_ocall_t* ms = SGX_CAST(ms_u_readdir64_r_ocall_t*, pms); + ms->ms_retval = u_readdir64_r_ocall(ms->ms_dirp, ms->ms_entry, ms->ms_result); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_closedir_ocall(void* pms) +{ + ms_u_closedir_ocall_t* ms = SGX_CAST(ms_u_closedir_ocall_t*, pms); + ms->ms_retval = u_closedir_ocall(ms->ms_error, ms->ms_dirp); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_dirfd_ocall(void* pms) +{ + ms_u_dirfd_ocall_t* ms = SGX_CAST(ms_u_dirfd_ocall_t*, pms); + ms->ms_retval = u_dirfd_ocall(ms->ms_error, ms->ms_dirp); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_fstatat64_ocall(void* pms) +{ + ms_u_fstatat64_ocall_t* ms = SGX_CAST(ms_u_fstatat64_ocall_t*, pms); + ms->ms_retval = u_fstatat64_ocall(ms->ms_error, ms->ms_dirfd, ms->ms_pathname, ms->ms_buf, ms->ms_flags); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_environ_ocall(void* pms) +{ + ms_u_environ_ocall_t* ms = SGX_CAST(ms_u_environ_ocall_t*, pms); + ms->ms_retval = u_environ_ocall(); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_getenv_ocall(void* pms) +{ + ms_u_getenv_ocall_t* ms = SGX_CAST(ms_u_getenv_ocall_t*, pms); + ms->ms_retval = u_getenv_ocall(ms->ms_name); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_setenv_ocall(void* pms) +{ + ms_u_setenv_ocall_t* ms = SGX_CAST(ms_u_setenv_ocall_t*, pms); + ms->ms_retval = u_setenv_ocall(ms->ms_error, ms->ms_name, ms->ms_value, ms->ms_overwrite); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_unsetenv_ocall(void* pms) +{ + ms_u_unsetenv_ocall_t* ms = SGX_CAST(ms_u_unsetenv_ocall_t*, pms); + ms->ms_retval = u_unsetenv_ocall(ms->ms_error, ms->ms_name); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_chdir_ocall(void* pms) +{ + ms_u_chdir_ocall_t* ms = SGX_CAST(ms_u_chdir_ocall_t*, pms); + ms->ms_retval = u_chdir_ocall(ms->ms_error, ms->ms_dir); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_getcwd_ocall(void* pms) +{ + ms_u_getcwd_ocall_t* ms = SGX_CAST(ms_u_getcwd_ocall_t*, pms); + ms->ms_retval = u_getcwd_ocall(ms->ms_error, ms->ms_buf, ms->ms_buflen); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_getpwuid_r_ocall(void* pms) +{ + ms_u_getpwuid_r_ocall_t* ms = SGX_CAST(ms_u_getpwuid_r_ocall_t*, pms); + ms->ms_retval = u_getpwuid_r_ocall(ms->ms_uid, ms->ms_pwd, ms->ms_buf, ms->ms_buflen, ms->ms_passwd_result); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_getuid_ocall(void* pms) +{ + ms_u_getuid_ocall_t* ms = SGX_CAST(ms_u_getuid_ocall_t*, pms); + ms->ms_retval = u_getuid_ocall(); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_sgxprotectedfs_exclusive_file_open(void* pms) +{ + ms_u_sgxprotectedfs_exclusive_file_open_t* ms = SGX_CAST(ms_u_sgxprotectedfs_exclusive_file_open_t*, pms); + ms->ms_retval = u_sgxprotectedfs_exclusive_file_open(ms->ms_filename, ms->ms_read_only, ms->ms_file_size, ms->ms_error_code); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_sgxprotectedfs_check_if_file_exists(void* pms) +{ + ms_u_sgxprotectedfs_check_if_file_exists_t* ms = SGX_CAST(ms_u_sgxprotectedfs_check_if_file_exists_t*, pms); + ms->ms_retval = u_sgxprotectedfs_check_if_file_exists(ms->ms_filename); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_sgxprotectedfs_fread_node(void* pms) +{ + ms_u_sgxprotectedfs_fread_node_t* ms = SGX_CAST(ms_u_sgxprotectedfs_fread_node_t*, pms); + ms->ms_retval = u_sgxprotectedfs_fread_node(ms->ms_f, ms->ms_node_number, ms->ms_buffer, ms->ms_node_size); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_sgxprotectedfs_fwrite_node(void* pms) +{ + ms_u_sgxprotectedfs_fwrite_node_t* ms = SGX_CAST(ms_u_sgxprotectedfs_fwrite_node_t*, pms); + ms->ms_retval = u_sgxprotectedfs_fwrite_node(ms->ms_f, ms->ms_node_number, ms->ms_buffer, ms->ms_node_size); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_sgxprotectedfs_fclose(void* pms) +{ + ms_u_sgxprotectedfs_fclose_t* ms = SGX_CAST(ms_u_sgxprotectedfs_fclose_t*, pms); + ms->ms_retval = u_sgxprotectedfs_fclose(ms->ms_f); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_sgxprotectedfs_fflush(void* pms) +{ + ms_u_sgxprotectedfs_fflush_t* ms = SGX_CAST(ms_u_sgxprotectedfs_fflush_t*, pms); + ms->ms_retval = u_sgxprotectedfs_fflush(ms->ms_f); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_sgxprotectedfs_remove(void* pms) +{ + ms_u_sgxprotectedfs_remove_t* ms = SGX_CAST(ms_u_sgxprotectedfs_remove_t*, pms); + ms->ms_retval = u_sgxprotectedfs_remove(ms->ms_filename); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_sgxprotectedfs_recovery_file_open(void* pms) +{ + ms_u_sgxprotectedfs_recovery_file_open_t* ms = SGX_CAST(ms_u_sgxprotectedfs_recovery_file_open_t*, pms); + ms->ms_retval = u_sgxprotectedfs_recovery_file_open(ms->ms_filename); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_sgxprotectedfs_fwrite_recovery_node(void* pms) +{ + ms_u_sgxprotectedfs_fwrite_recovery_node_t* ms = SGX_CAST(ms_u_sgxprotectedfs_fwrite_recovery_node_t*, pms); + ms->ms_retval = u_sgxprotectedfs_fwrite_recovery_node(ms->ms_f, ms->ms_data, ms->ms_data_length); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_sgxprotectedfs_do_file_recovery(void* pms) +{ + ms_u_sgxprotectedfs_do_file_recovery_t* ms = SGX_CAST(ms_u_sgxprotectedfs_do_file_recovery_t*, pms); + ms->ms_retval = u_sgxprotectedfs_do_file_recovery(ms->ms_filename, ms->ms_recovery_filename, ms->ms_node_size); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_sgx_oc_cpuidex(void* pms) +{ + ms_sgx_oc_cpuidex_t* ms = SGX_CAST(ms_sgx_oc_cpuidex_t*, pms); + sgx_oc_cpuidex(ms->ms_cpuinfo, ms->ms_leaf, ms->ms_subleaf); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_sgx_thread_wait_untrusted_event_ocall(void* pms) +{ + ms_sgx_thread_wait_untrusted_event_ocall_t* ms = SGX_CAST(ms_sgx_thread_wait_untrusted_event_ocall_t*, pms); + ms->ms_retval = sgx_thread_wait_untrusted_event_ocall(ms->ms_self); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_sgx_thread_set_untrusted_event_ocall(void* pms) +{ + ms_sgx_thread_set_untrusted_event_ocall_t* ms = SGX_CAST(ms_sgx_thread_set_untrusted_event_ocall_t*, pms); + ms->ms_retval = sgx_thread_set_untrusted_event_ocall(ms->ms_waiter); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_sgx_thread_setwait_untrusted_events_ocall(void* pms) +{ + ms_sgx_thread_setwait_untrusted_events_ocall_t* ms = SGX_CAST(ms_sgx_thread_setwait_untrusted_events_ocall_t*, pms); + ms->ms_retval = sgx_thread_setwait_untrusted_events_ocall(ms->ms_waiter, ms->ms_self); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_sgx_thread_set_multiple_untrusted_events_ocall(void* pms) +{ + ms_sgx_thread_set_multiple_untrusted_events_ocall_t* ms = SGX_CAST(ms_sgx_thread_set_multiple_untrusted_events_ocall_t*, pms); + ms->ms_retval = sgx_thread_set_multiple_untrusted_events_ocall(ms->ms_waiters, ms->ms_total); + + return SGX_SUCCESS; +} + +static const struct { + size_t nr_ocall; + void * table[79]; +} ocall_table_Enclave = { + 79, + { + (void*)Enclave_u_thread_set_event_ocall, + (void*)Enclave_u_thread_wait_event_ocall, + (void*)Enclave_u_thread_set_multiple_events_ocall, + (void*)Enclave_u_thread_setwait_events_ocall, + (void*)Enclave_u_clock_gettime_ocall, + (void*)Enclave_u_read_ocall, + (void*)Enclave_u_pread64_ocall, + (void*)Enclave_u_readv_ocall, + (void*)Enclave_u_preadv64_ocall, + (void*)Enclave_u_write_ocall, + (void*)Enclave_u_pwrite64_ocall, + (void*)Enclave_u_writev_ocall, + (void*)Enclave_u_pwritev64_ocall, + (void*)Enclave_u_fcntl_arg0_ocall, + (void*)Enclave_u_fcntl_arg1_ocall, + (void*)Enclave_u_ioctl_arg0_ocall, + (void*)Enclave_u_ioctl_arg1_ocall, + (void*)Enclave_u_close_ocall, + (void*)Enclave_u_malloc_ocall, + (void*)Enclave_u_free_ocall, + (void*)Enclave_u_mmap_ocall, + (void*)Enclave_u_munmap_ocall, + (void*)Enclave_u_msync_ocall, + (void*)Enclave_u_mprotect_ocall, + (void*)Enclave_u_open_ocall, + (void*)Enclave_u_open64_ocall, + (void*)Enclave_u_fstat_ocall, + (void*)Enclave_u_fstat64_ocall, + (void*)Enclave_u_stat_ocall, + (void*)Enclave_u_stat64_ocall, + (void*)Enclave_u_lstat_ocall, + (void*)Enclave_u_lstat64_ocall, + (void*)Enclave_u_lseek_ocall, + (void*)Enclave_u_lseek64_ocall, + (void*)Enclave_u_ftruncate_ocall, + (void*)Enclave_u_ftruncate64_ocall, + (void*)Enclave_u_truncate_ocall, + (void*)Enclave_u_truncate64_ocall, + (void*)Enclave_u_fsync_ocall, + (void*)Enclave_u_fdatasync_ocall, + (void*)Enclave_u_fchmod_ocall, + (void*)Enclave_u_unlink_ocall, + (void*)Enclave_u_link_ocall, + (void*)Enclave_u_linkat_ocall, + (void*)Enclave_u_rename_ocall, + (void*)Enclave_u_chmod_ocall, + (void*)Enclave_u_readlink_ocall, + (void*)Enclave_u_symlink_ocall, + (void*)Enclave_u_realpath_ocall, + (void*)Enclave_u_mkdir_ocall, + (void*)Enclave_u_rmdir_ocall, + (void*)Enclave_u_opendir_ocall, + (void*)Enclave_u_readdir64_r_ocall, + (void*)Enclave_u_closedir_ocall, + (void*)Enclave_u_dirfd_ocall, + (void*)Enclave_u_fstatat64_ocall, + (void*)Enclave_u_environ_ocall, + (void*)Enclave_u_getenv_ocall, + (void*)Enclave_u_setenv_ocall, + (void*)Enclave_u_unsetenv_ocall, + (void*)Enclave_u_chdir_ocall, + (void*)Enclave_u_getcwd_ocall, + (void*)Enclave_u_getpwuid_r_ocall, + (void*)Enclave_u_getuid_ocall, + (void*)Enclave_u_sgxprotectedfs_exclusive_file_open, + (void*)Enclave_u_sgxprotectedfs_check_if_file_exists, + (void*)Enclave_u_sgxprotectedfs_fread_node, + (void*)Enclave_u_sgxprotectedfs_fwrite_node, + (void*)Enclave_u_sgxprotectedfs_fclose, + (void*)Enclave_u_sgxprotectedfs_fflush, + (void*)Enclave_u_sgxprotectedfs_remove, + (void*)Enclave_u_sgxprotectedfs_recovery_file_open, + (void*)Enclave_u_sgxprotectedfs_fwrite_recovery_node, + (void*)Enclave_u_sgxprotectedfs_do_file_recovery, + (void*)Enclave_sgx_oc_cpuidex, + (void*)Enclave_sgx_thread_wait_untrusted_event_ocall, + (void*)Enclave_sgx_thread_set_untrusted_event_ocall, + (void*)Enclave_sgx_thread_setwait_untrusted_events_ocall, + (void*)Enclave_sgx_thread_set_multiple_untrusted_events_ocall, + } +}; +sgx_status_t run_tests_ecall(sgx_enclave_id_t eid, size_t* retval) +{ + sgx_status_t status; + ms_run_tests_ecall_t ms; + status = sgx_ecall(eid, 0, &ocall_table_Enclave, &ms); + if (status == SGX_SUCCESS && retval) *retval = ms.ms_retval; + return status; +} + +sgx_status_t t_global_init_ecall(sgx_enclave_id_t eid, uint64_t id, const uint8_t* path, size_t len) +{ + sgx_status_t status; + ms_t_global_init_ecall_t ms; + ms.ms_id = id; + ms.ms_path = path; + ms.ms_len = len; + status = sgx_ecall(eid, 1, &ocall_table_Enclave, &ms); + return status; +} + +sgx_status_t t_global_exit_ecall(sgx_enclave_id_t eid) +{ + sgx_status_t status; + status = sgx_ecall(eid, 2, &ocall_table_Enclave, NULL); + return status; +} + diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/app/codegen/Enclave_u.h b/rust-sgx-workspace/projects/sgx-wallet-test/app/codegen/Enclave_u.h new file mode 100644 index 0000000..cb2f545 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/app/codegen/Enclave_u.h @@ -0,0 +1,350 @@ +#ifndef ENCLAVE_U_H__ +#define ENCLAVE_U_H__ + +#include +#include +#include +#include +#include "sgx_edger8r.h" /* for sgx_status_t etc. */ + +#include "time.h" +#include "inc/stat.h" +#include "sys/uio.h" +#include "inc/stat.h" +#include "inc/dirent.h" +#include "pwd.h" + +#include /* for size_t */ + +#define SGX_CAST(type, item) ((type)(item)) + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef U_THREAD_SET_EVENT_OCALL_DEFINED__ +#define U_THREAD_SET_EVENT_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_thread_set_event_ocall, (int* error, const void* tcs)); +#endif +#ifndef U_THREAD_WAIT_EVENT_OCALL_DEFINED__ +#define U_THREAD_WAIT_EVENT_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_thread_wait_event_ocall, (int* error, const void* tcs, const struct timespec* timeout)); +#endif +#ifndef U_THREAD_SET_MULTIPLE_EVENTS_OCALL_DEFINED__ +#define U_THREAD_SET_MULTIPLE_EVENTS_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_thread_set_multiple_events_ocall, (int* error, const void** tcss, int total)); +#endif +#ifndef U_THREAD_SETWAIT_EVENTS_OCALL_DEFINED__ +#define U_THREAD_SETWAIT_EVENTS_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_thread_setwait_events_ocall, (int* error, const void* waiter_tcs, const void* self_tcs, const struct timespec* timeout)); +#endif +#ifndef U_CLOCK_GETTIME_OCALL_DEFINED__ +#define U_CLOCK_GETTIME_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_clock_gettime_ocall, (int* error, int clk_id, struct timespec* tp)); +#endif +#ifndef U_READ_OCALL_DEFINED__ +#define U_READ_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_read_ocall, (int* error, int fd, void* buf, size_t count)); +#endif +#ifndef U_PREAD64_OCALL_DEFINED__ +#define U_PREAD64_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_pread64_ocall, (int* error, int fd, void* buf, size_t count, int64_t offset)); +#endif +#ifndef U_READV_OCALL_DEFINED__ +#define U_READV_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_readv_ocall, (int* error, int fd, const struct iovec* iov, int iovcnt)); +#endif +#ifndef U_PREADV64_OCALL_DEFINED__ +#define U_PREADV64_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_preadv64_ocall, (int* error, int fd, const struct iovec* iov, int iovcnt, int64_t offset)); +#endif +#ifndef U_WRITE_OCALL_DEFINED__ +#define U_WRITE_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_write_ocall, (int* error, int fd, const void* buf, size_t count)); +#endif +#ifndef U_PWRITE64_OCALL_DEFINED__ +#define U_PWRITE64_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_pwrite64_ocall, (int* error, int fd, const void* buf, size_t count, int64_t offset)); +#endif +#ifndef U_WRITEV_OCALL_DEFINED__ +#define U_WRITEV_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_writev_ocall, (int* error, int fd, const struct iovec* iov, int iovcnt)); +#endif +#ifndef U_PWRITEV64_OCALL_DEFINED__ +#define U_PWRITEV64_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_pwritev64_ocall, (int* error, int fd, const struct iovec* iov, int iovcnt, int64_t offset)); +#endif +#ifndef U_FCNTL_ARG0_OCALL_DEFINED__ +#define U_FCNTL_ARG0_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_fcntl_arg0_ocall, (int* error, int fd, int cmd)); +#endif +#ifndef U_FCNTL_ARG1_OCALL_DEFINED__ +#define U_FCNTL_ARG1_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_fcntl_arg1_ocall, (int* error, int fd, int cmd, int arg)); +#endif +#ifndef U_IOCTL_ARG0_OCALL_DEFINED__ +#define U_IOCTL_ARG0_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_ioctl_arg0_ocall, (int* error, int fd, int request)); +#endif +#ifndef U_IOCTL_ARG1_OCALL_DEFINED__ +#define U_IOCTL_ARG1_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_ioctl_arg1_ocall, (int* error, int fd, int request, int* arg)); +#endif +#ifndef U_CLOSE_OCALL_DEFINED__ +#define U_CLOSE_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_close_ocall, (int* error, int fd)); +#endif +#ifndef U_MALLOC_OCALL_DEFINED__ +#define U_MALLOC_OCALL_DEFINED__ +void* SGX_UBRIDGE(SGX_NOCONVENTION, u_malloc_ocall, (int* error, size_t size)); +#endif +#ifndef U_FREE_OCALL_DEFINED__ +#define U_FREE_OCALL_DEFINED__ +void SGX_UBRIDGE(SGX_NOCONVENTION, u_free_ocall, (void* p)); +#endif +#ifndef U_MMAP_OCALL_DEFINED__ +#define U_MMAP_OCALL_DEFINED__ +void* SGX_UBRIDGE(SGX_NOCONVENTION, u_mmap_ocall, (int* error, void* start, size_t length, int prot, int flags, int fd, int64_t offset)); +#endif +#ifndef U_MUNMAP_OCALL_DEFINED__ +#define U_MUNMAP_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_munmap_ocall, (int* error, void* start, size_t length)); +#endif +#ifndef U_MSYNC_OCALL_DEFINED__ +#define U_MSYNC_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_msync_ocall, (int* error, void* addr, size_t length, int flags)); +#endif +#ifndef U_MPROTECT_OCALL_DEFINED__ +#define U_MPROTECT_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_mprotect_ocall, (int* error, void* addr, size_t length, int prot)); +#endif +#ifndef U_OPEN_OCALL_DEFINED__ +#define U_OPEN_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_open_ocall, (int* error, const char* pathname, int flags)); +#endif +#ifndef U_OPEN64_OCALL_DEFINED__ +#define U_OPEN64_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_open64_ocall, (int* error, const char* path, int oflag, int mode)); +#endif +#ifndef U_FSTAT_OCALL_DEFINED__ +#define U_FSTAT_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_fstat_ocall, (int* error, int fd, struct stat_t* buf)); +#endif +#ifndef U_FSTAT64_OCALL_DEFINED__ +#define U_FSTAT64_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_fstat64_ocall, (int* error, int fd, struct stat64_t* buf)); +#endif +#ifndef U_STAT_OCALL_DEFINED__ +#define U_STAT_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_stat_ocall, (int* error, const char* path, struct stat_t* buf)); +#endif +#ifndef U_STAT64_OCALL_DEFINED__ +#define U_STAT64_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_stat64_ocall, (int* error, const char* path, struct stat64_t* buf)); +#endif +#ifndef U_LSTAT_OCALL_DEFINED__ +#define U_LSTAT_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_lstat_ocall, (int* error, const char* path, struct stat_t* buf)); +#endif +#ifndef U_LSTAT64_OCALL_DEFINED__ +#define U_LSTAT64_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_lstat64_ocall, (int* error, const char* path, struct stat64_t* buf)); +#endif +#ifndef U_LSEEK_OCALL_DEFINED__ +#define U_LSEEK_OCALL_DEFINED__ +uint64_t SGX_UBRIDGE(SGX_NOCONVENTION, u_lseek_ocall, (int* error, int fd, int64_t offset, int whence)); +#endif +#ifndef U_LSEEK64_OCALL_DEFINED__ +#define U_LSEEK64_OCALL_DEFINED__ +int64_t SGX_UBRIDGE(SGX_NOCONVENTION, u_lseek64_ocall, (int* error, int fd, int64_t offset, int whence)); +#endif +#ifndef U_FTRUNCATE_OCALL_DEFINED__ +#define U_FTRUNCATE_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_ftruncate_ocall, (int* error, int fd, int64_t length)); +#endif +#ifndef U_FTRUNCATE64_OCALL_DEFINED__ +#define U_FTRUNCATE64_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_ftruncate64_ocall, (int* error, int fd, int64_t length)); +#endif +#ifndef U_TRUNCATE_OCALL_DEFINED__ +#define U_TRUNCATE_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_truncate_ocall, (int* error, const char* path, int64_t length)); +#endif +#ifndef U_TRUNCATE64_OCALL_DEFINED__ +#define U_TRUNCATE64_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_truncate64_ocall, (int* error, const char* path, int64_t length)); +#endif +#ifndef U_FSYNC_OCALL_DEFINED__ +#define U_FSYNC_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_fsync_ocall, (int* error, int fd)); +#endif +#ifndef U_FDATASYNC_OCALL_DEFINED__ +#define U_FDATASYNC_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_fdatasync_ocall, (int* error, int fd)); +#endif +#ifndef U_FCHMOD_OCALL_DEFINED__ +#define U_FCHMOD_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_fchmod_ocall, (int* error, int fd, uint32_t mode)); +#endif +#ifndef U_UNLINK_OCALL_DEFINED__ +#define U_UNLINK_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_unlink_ocall, (int* error, const char* pathname)); +#endif +#ifndef U_LINK_OCALL_DEFINED__ +#define U_LINK_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_link_ocall, (int* error, const char* oldpath, const char* newpath)); +#endif +#ifndef U_LINKAT_OCALL_DEFINED__ +#define U_LINKAT_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_linkat_ocall, (int* error, int olddirfd, const char* oldpath, int newdirfd, const char* newpath, int flags)); +#endif +#ifndef U_RENAME_OCALL_DEFINED__ +#define U_RENAME_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_rename_ocall, (int* error, const char* oldpath, const char* newpath)); +#endif +#ifndef U_CHMOD_OCALL_DEFINED__ +#define U_CHMOD_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_chmod_ocall, (int* error, const char* path, uint32_t mode)); +#endif +#ifndef U_READLINK_OCALL_DEFINED__ +#define U_READLINK_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_readlink_ocall, (int* error, const char* path, char* buf, size_t bufsz)); +#endif +#ifndef U_SYMLINK_OCALL_DEFINED__ +#define U_SYMLINK_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_symlink_ocall, (int* error, const char* path1, const char* path2)); +#endif +#ifndef U_REALPATH_OCALL_DEFINED__ +#define U_REALPATH_OCALL_DEFINED__ +char* SGX_UBRIDGE(SGX_NOCONVENTION, u_realpath_ocall, (int* error, const char* pathname)); +#endif +#ifndef U_MKDIR_OCALL_DEFINED__ +#define U_MKDIR_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_mkdir_ocall, (int* error, const char* pathname, uint32_t mode)); +#endif +#ifndef U_RMDIR_OCALL_DEFINED__ +#define U_RMDIR_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_rmdir_ocall, (int* error, const char* pathname)); +#endif +#ifndef U_OPENDIR_OCALL_DEFINED__ +#define U_OPENDIR_OCALL_DEFINED__ +void* SGX_UBRIDGE(SGX_NOCONVENTION, u_opendir_ocall, (int* error, const char* pathname)); +#endif +#ifndef U_READDIR64_R_OCALL_DEFINED__ +#define U_READDIR64_R_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_readdir64_r_ocall, (void* dirp, struct dirent64_t* entry, struct dirent64_t** result)); +#endif +#ifndef U_CLOSEDIR_OCALL_DEFINED__ +#define U_CLOSEDIR_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_closedir_ocall, (int* error, void* dirp)); +#endif +#ifndef U_DIRFD_OCALL_DEFINED__ +#define U_DIRFD_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_dirfd_ocall, (int* error, void* dirp)); +#endif +#ifndef U_FSTATAT64_OCALL_DEFINED__ +#define U_FSTATAT64_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_fstatat64_ocall, (int* error, int dirfd, const char* pathname, struct stat64_t* buf, int flags)); +#endif +#ifndef U_ENVIRON_OCALL_DEFINED__ +#define U_ENVIRON_OCALL_DEFINED__ +char** SGX_UBRIDGE(SGX_NOCONVENTION, u_environ_ocall, (void)); +#endif +#ifndef U_GETENV_OCALL_DEFINED__ +#define U_GETENV_OCALL_DEFINED__ +char* SGX_UBRIDGE(SGX_NOCONVENTION, u_getenv_ocall, (const char* name)); +#endif +#ifndef U_SETENV_OCALL_DEFINED__ +#define U_SETENV_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_setenv_ocall, (int* error, const char* name, const char* value, int overwrite)); +#endif +#ifndef U_UNSETENV_OCALL_DEFINED__ +#define U_UNSETENV_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_unsetenv_ocall, (int* error, const char* name)); +#endif +#ifndef U_CHDIR_OCALL_DEFINED__ +#define U_CHDIR_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_chdir_ocall, (int* error, const char* dir)); +#endif +#ifndef U_GETCWD_OCALL_DEFINED__ +#define U_GETCWD_OCALL_DEFINED__ +char* SGX_UBRIDGE(SGX_NOCONVENTION, u_getcwd_ocall, (int* error, char* buf, size_t buflen)); +#endif +#ifndef U_GETPWUID_R_OCALL_DEFINED__ +#define U_GETPWUID_R_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_getpwuid_r_ocall, (unsigned int uid, struct passwd* pwd, char* buf, size_t buflen, struct passwd** passwd_result)); +#endif +#ifndef U_GETUID_OCALL_DEFINED__ +#define U_GETUID_OCALL_DEFINED__ +unsigned int SGX_UBRIDGE(SGX_NOCONVENTION, u_getuid_ocall, (void)); +#endif +#ifndef U_SGXPROTECTEDFS_EXCLUSIVE_FILE_OPEN_DEFINED__ +#define U_SGXPROTECTEDFS_EXCLUSIVE_FILE_OPEN_DEFINED__ +void* SGX_UBRIDGE(SGX_NOCONVENTION, u_sgxprotectedfs_exclusive_file_open, (const char* filename, uint8_t read_only, int64_t* file_size, int32_t* error_code)); +#endif +#ifndef U_SGXPROTECTEDFS_CHECK_IF_FILE_EXISTS_DEFINED__ +#define U_SGXPROTECTEDFS_CHECK_IF_FILE_EXISTS_DEFINED__ +uint8_t SGX_UBRIDGE(SGX_NOCONVENTION, u_sgxprotectedfs_check_if_file_exists, (const char* filename)); +#endif +#ifndef U_SGXPROTECTEDFS_FREAD_NODE_DEFINED__ +#define U_SGXPROTECTEDFS_FREAD_NODE_DEFINED__ +int32_t SGX_UBRIDGE(SGX_NOCONVENTION, u_sgxprotectedfs_fread_node, (void* f, uint64_t node_number, uint8_t* buffer, uint32_t node_size)); +#endif +#ifndef U_SGXPROTECTEDFS_FWRITE_NODE_DEFINED__ +#define U_SGXPROTECTEDFS_FWRITE_NODE_DEFINED__ +int32_t SGX_UBRIDGE(SGX_NOCONVENTION, u_sgxprotectedfs_fwrite_node, (void* f, uint64_t node_number, uint8_t* buffer, uint32_t node_size)); +#endif +#ifndef U_SGXPROTECTEDFS_FCLOSE_DEFINED__ +#define U_SGXPROTECTEDFS_FCLOSE_DEFINED__ +int32_t SGX_UBRIDGE(SGX_NOCONVENTION, u_sgxprotectedfs_fclose, (void* f)); +#endif +#ifndef U_SGXPROTECTEDFS_FFLUSH_DEFINED__ +#define U_SGXPROTECTEDFS_FFLUSH_DEFINED__ +uint8_t SGX_UBRIDGE(SGX_NOCONVENTION, u_sgxprotectedfs_fflush, (void* f)); +#endif +#ifndef U_SGXPROTECTEDFS_REMOVE_DEFINED__ +#define U_SGXPROTECTEDFS_REMOVE_DEFINED__ +int32_t SGX_UBRIDGE(SGX_NOCONVENTION, u_sgxprotectedfs_remove, (const char* filename)); +#endif +#ifndef U_SGXPROTECTEDFS_RECOVERY_FILE_OPEN_DEFINED__ +#define U_SGXPROTECTEDFS_RECOVERY_FILE_OPEN_DEFINED__ +void* SGX_UBRIDGE(SGX_NOCONVENTION, u_sgxprotectedfs_recovery_file_open, (const char* filename)); +#endif +#ifndef U_SGXPROTECTEDFS_FWRITE_RECOVERY_NODE_DEFINED__ +#define U_SGXPROTECTEDFS_FWRITE_RECOVERY_NODE_DEFINED__ +uint8_t SGX_UBRIDGE(SGX_NOCONVENTION, u_sgxprotectedfs_fwrite_recovery_node, (void* f, uint8_t* data, uint32_t data_length)); +#endif +#ifndef U_SGXPROTECTEDFS_DO_FILE_RECOVERY_DEFINED__ +#define U_SGXPROTECTEDFS_DO_FILE_RECOVERY_DEFINED__ +int32_t SGX_UBRIDGE(SGX_NOCONVENTION, u_sgxprotectedfs_do_file_recovery, (const char* filename, const char* recovery_filename, uint32_t node_size)); +#endif +#ifndef SGX_OC_CPUIDEX_DEFINED__ +#define SGX_OC_CPUIDEX_DEFINED__ +void SGX_UBRIDGE(SGX_CDECL, sgx_oc_cpuidex, (int cpuinfo[4], int leaf, int subleaf)); +#endif +#ifndef SGX_THREAD_WAIT_UNTRUSTED_EVENT_OCALL_DEFINED__ +#define SGX_THREAD_WAIT_UNTRUSTED_EVENT_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_CDECL, sgx_thread_wait_untrusted_event_ocall, (const void* self)); +#endif +#ifndef SGX_THREAD_SET_UNTRUSTED_EVENT_OCALL_DEFINED__ +#define SGX_THREAD_SET_UNTRUSTED_EVENT_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_CDECL, sgx_thread_set_untrusted_event_ocall, (const void* waiter)); +#endif +#ifndef SGX_THREAD_SETWAIT_UNTRUSTED_EVENTS_OCALL_DEFINED__ +#define SGX_THREAD_SETWAIT_UNTRUSTED_EVENTS_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_CDECL, sgx_thread_setwait_untrusted_events_ocall, (const void* waiter, const void* self)); +#endif +#ifndef SGX_THREAD_SET_MULTIPLE_UNTRUSTED_EVENTS_OCALL_DEFINED__ +#define SGX_THREAD_SET_MULTIPLE_UNTRUSTED_EVENTS_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_CDECL, sgx_thread_set_multiple_untrusted_events_ocall, (const void** waiters, size_t total)); +#endif + +sgx_status_t run_tests_ecall(sgx_enclave_id_t eid, size_t* retval); +sgx_status_t t_global_init_ecall(sgx_enclave_id_t eid, uint64_t id, const uint8_t* path, size_t len); +sgx_status_t t_global_exit_ecall(sgx_enclave_id_t eid); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/app/codegen/Enclave_u.rs b/rust-sgx-workspace/projects/sgx-wallet-test/app/codegen/Enclave_u.rs new file mode 100644 index 0000000..e539576 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/app/codegen/Enclave_u.rs @@ -0,0 +1,7 @@ +/* automatically generated by rust-bindgen 0.59.2 */ + +use sgx_types::*; + +extern "C" { + pub fn run_tests_ecall(eid: sgx_enclave_id_t, retval: *mut size_t) -> sgx_status_t; +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/app/src/main.rs b/rust-sgx-workspace/projects/sgx-wallet-test/app/src/main.rs new file mode 100644 index 0000000..45effdf --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/app/src/main.rs @@ -0,0 +1,49 @@ +#[path = "../codegen/Enclave_u.rs"] +mod enclave_u; +mod safe_ecalls; + +use std::fs::create_dir_all; + +use sgx_types::{sgx_attributes_t, sgx_launch_token_t, sgx_misc_attribute_t, SgxResult}; +use sgx_urts::SgxEnclave; + +use crate::safe_ecalls::safe_run_tests_ecall; + +static ENCLAVE_FILE: &str = "enclave.signed.so"; + +fn init_enclave() -> SgxResult { + let mut launch_token: sgx_launch_token_t = [0; 1024]; + let mut launch_token_updated: i32 = 0; + // call sgx_create_enclave to initialize an enclave instance + // Debug Support: set 2nd parameter to 1 + let debug = 1; + let mut misc_attr = sgx_misc_attribute_t { + secs_attr: sgx_attributes_t { flags: 0, xfrm: 0 }, + misc_select: 0, + }; + SgxEnclave::create( + ENCLAVE_FILE, + debug, + &mut launch_token, + &mut launch_token_updated, + &mut misc_attr, + ) +} + +fn main() -> Result<(), String> { + let enclave = init_enclave().map_err(|err| format!("init_enclave failed: {:?}", err))?; + + // FIXME: See WALLET_STORE_DIR + create_dir_all("wallet_store") + .map_err(|err| format!("failed to create test wallet_store directory: {:?}", err))?; + + let failed_tests = safe_run_tests_ecall(enclave.geteid()) + .map_err(|err| format!("run_tests_ecall failed: {:?}", err))?; + + enclave.destroy(); + + match failed_tests { + 0 => Ok(()), + _ => Err(format!("{} tests failed", failed_tests)), + } +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/app/src/safe_ecalls.rs b/rust-sgx-workspace/projects/sgx-wallet-test/app/src/safe_ecalls.rs new file mode 100644 index 0000000..b4de870 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/app/src/safe_ecalls.rs @@ -0,0 +1,13 @@ +//! Safe Rust wrappers around [`enclave_u`]. + +use sgx_types::{sgx_enclave_id_t, sgx_status_t, size_t, SgxResult}; + +use crate::enclave_u; + +pub(crate) fn safe_run_tests_ecall(eid: sgx_enclave_id_t) -> SgxResult { + let mut retval = size_t::MAX; + match unsafe { enclave_u::run_tests_ecall(eid, &mut retval) } { + sgx_status_t::SGX_SUCCESS => Ok(retval), + err => Err(err), + } +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/buildenv.mk b/rust-sgx-workspace/projects/sgx-wallet-test/buildenv.mk new file mode 100644 index 0000000..a86675e --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/buildenv.mk @@ -0,0 +1,167 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License.. +# +# + +CP := /bin/cp -f +MKDIR := mkdir -p +STRIP := strip +OBJCOPY := objcopy + +# clean the content of 'INCLUDE' - this variable will be set by vcvars32.bat +# thus it will cause build error when this variable is used by our Makefile, +# when compiling the code under Cygwin tainted by MSVC environment settings. +INCLUDE := + +# turn on stack protector for SDK +COMMON_FLAGS += -fstack-protector + +ifdef DEBUG + COMMON_FLAGS += -O0 -g -DDEBUG -UNDEBUG +else + COMMON_FLAGS += -O2 -D_FORTIFY_SOURCE=2 -UDEBUG -DNDEBUG +endif + +# turn on compiler warnings as much as possible +COMMON_FLAGS += -Wall -Wextra -Winit-self -Wpointer-arith -Wreturn-type \ + -Waddress -Wsequence-point -Wformat-security \ + -Wmissing-include-dirs -Wfloat-equal -Wundef -Wshadow \ + -Wcast-align -Wconversion -Wredundant-decls + +# additional warnings flags for C +CFLAGS += -Wjump-misses-init -Wstrict-prototypes -Wunsuffixed-float-constants + +# additional warnings flags for C++ +CXXFLAGS += -Wnon-virtual-dtor + +# for static_assert() +CXXFLAGS += -std=c++0x + +.DEFAULT_GOAL := all +# this turns off the RCS / SCCS implicit rules of GNU Make +% : RCS/%,v +% : RCS/% +% : %,v +% : s.% +% : SCCS/s.% + +# If a rule fails, delete $@. +.DELETE_ON_ERROR: + +HOST_FILE_PROGRAM := file + +UNAME := $(shell uname -m) +ifneq (,$(findstring 86,$(UNAME))) + HOST_ARCH := x86 + ifneq (,$(shell $(HOST_FILE_PROGRAM) -L $(SHELL) | grep 'x86[_-]64')) + HOST_ARCH := x86_64 + endif +else + $(info Unknown host CPU arhitecture $(UNAME)) + $(error Aborting) +endif + + +ifeq "$(findstring __INTEL_COMPILER, $(shell $(CC) -E -dM -xc /dev/null))" "__INTEL_COMPILER" + ifeq ($(shell test -f /usr/bin/dpkg; echo $$?), 0) + ADDED_INC := -I /usr/include/$(shell dpkg-architecture -qDEB_BUILD_MULTIARCH) + endif +endif + +ARCH := $(HOST_ARCH) +ifeq "$(findstring -m32, $(CXXFLAGS))" "-m32" + ARCH := x86 +endif + +ifeq ($(ARCH), x86) +COMMON_FLAGS += -DITT_ARCH_IA32 +else +COMMON_FLAGS += -DITT_ARCH_IA64 +endif + +CFLAGS += $(COMMON_FLAGS) +CXXFLAGS += $(COMMON_FLAGS) + +# Enable the security flags +COMMON_LDFLAGS := -Wl,-z,relro,-z,now,-z,noexecstack + +# mitigation options +MITIGATION_INDIRECT ?= 0 +MITIGATION_RET ?= 0 +MITIGATION_C ?= 0 +MITIGATION_ASM ?= 0 +MITIGATION_AFTERLOAD ?= 0 +MITIGATION_LIB_PATH := + +ifeq ($(MITIGATION-CVE-2020-0551), LOAD) + MITIGATION_C := 1 + MITIGATION_ASM := 1 + MITIGATION_INDIRECT := 1 + MITIGATION_RET := 1 + MITIGATION_AFTERLOAD := 1 + MITIGATION_LIB_PATH := cve_2020_0551_load +else ifeq ($(MITIGATION-CVE-2020-0551), CF) + MITIGATION_C := 1 + MITIGATION_ASM := 1 + MITIGATION_INDIRECT := 1 + MITIGATION_RET := 1 + MITIGATION_AFTERLOAD := 0 + MITIGATION_LIB_PATH := cve_2020_0551_cf +endif + +MITIGATION_CFLAGS := +MITIGATION_ASFLAGS := +ifeq ($(MITIGATION_C), 1) +ifeq ($(MITIGATION_INDIRECT), 1) + MITIGATION_CFLAGS += -mindirect-branch-register +endif +ifeq ($(MITIGATION_RET), 1) + MITIGATION_CFLAGS += -mfunction-return=thunk-extern +endif +endif + +ifeq ($(MITIGATION_ASM), 1) + MITIGATION_ASFLAGS += -fno-plt +ifeq ($(MITIGATION_AFTERLOAD), 1) + MITIGATION_ASFLAGS += -Wa,-mlfence-after-load=yes +else + MITIGATION_ASFLAGS += -Wa,-mlfence-before-indirect-branch=register +endif +ifeq ($(MITIGATION_RET), 1) + MITIGATION_ASFLAGS += -Wa,-mlfence-before-ret=not +endif +endif + +MITIGATION_CFLAGS += $(MITIGATION_ASFLAGS) + +# Compiler and linker options for an Enclave +# +# We are using '--export-dynamic' so that `g_global_data_sim' etc. +# will be exported to dynamic symbol table. +# +# When `pie' is enabled, the linker (both BFD and Gold) under Ubuntu 14.04 +# will hide all symbols from dynamic symbol table even if they are marked +# as `global' in the LD version script. +ENCLAVE_CFLAGS = -ffreestanding -nostdinc -fvisibility=hidden -fpie -fno-strict-overflow -fno-delete-null-pointer-checks +ENCLAVE_CXXFLAGS = $(ENCLAVE_CFLAGS) -nostdinc++ +ENCLAVE_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined \ + -Wl,-pie,-eenclave_entry -Wl,--export-dynamic \ + -Wl,--gc-sections \ + -Wl,--defsym,__ImageBase=0 + +ENCLAVE_CFLAGS += $(MITIGATION_CFLAGS) +ENCLAVE_ASFLAGS = $(MITIGATION_ASFLAGS) \ No newline at end of file diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/buildenv_sgx.mk b/rust-sgx-workspace/projects/sgx-wallet-test/buildenv_sgx.mk new file mode 100644 index 0000000..4ec0119 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/buildenv_sgx.mk @@ -0,0 +1,49 @@ +SGX_SDK ?= /opt/sgxsdk + +# Directly imported from the original Intel SGX samples, helpful to detect the system architecture + +ifeq ($(shell getconf LONG_BIT), 32) + SGX_ARCH := x86 +else ifeq ($(findstring -m32, $(CXXFLAGS)), -m32) + SGX_ARCH := x86 +endif + +ifeq ($(SGX_ARCH), x86) + SGX_COMMON_CFLAGS := -m32 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x86/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x86/sgx_edger8r +else + SGX_COMMON_CFLAGS := -m64 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib64 + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x64/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x64/sgx_edger8r +endif + +# If specified, software / simulation mode. Otherwise, hardware mode no matter what. + +ifeq ($(SGX_MODE), SW) + TRTS_LIB := sgx_trts_sim + SERVICE_LIB := sgx_tservice_sim +endif + +# If debug mode, we can set up extra options such as the debug flags + +ifeq ($(SGX_DEBUG), 1) + SGX_COMMON_CFLAGS += -O0 -g +else + SGX_COMMON_CFLAGS += -O2 +endif + +# Show helpful error messages if main environment variables are not set. + +$(SGX_EDGER8R): + $(error "$@" does not exist. (Is SGX_SDK set correctly?)) + +ifndef CUSTOM_EDL_PATH +$(error CUSTOM_EDL_PATH not set) +endif + +ifndef CUSTOM_COMMON_PATH +$(error CUSTOM_COMMON_PATH not set) +endif diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/.gitignore b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/.gitignore @@ -0,0 +1 @@ +/target diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Cargo.lock b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Cargo.lock new file mode 100644 index 0000000..c5d0123 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Cargo.lock @@ -0,0 +1,1204 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "algonaut" +version = "0.3.0" +source = "git+https://github.com/registreerocks/algonaut-sgx?branch=main-sgx#4c2a24f5ba08e6623f0103853396f417b10d097b" +dependencies = [ + "algonaut_core", + "algonaut_crypto", + "algonaut_encoding", + "algonaut_transaction", +] + +[[package]] +name = "algonaut_core" +version = "0.3.0" +source = "git+https://github.com/registreerocks/algonaut-sgx?branch=main-sgx#4c2a24f5ba08e6623f0103853396f417b10d097b" +dependencies = [ + "algonaut_crypto", + "algonaut_encoding", + "data-encoding", + "derive_more", + "rmp-serde", + "serde", + "sgx_tstd", + "sha2 0.9.5", + "static_assertions", + "thiserror", +] + +[[package]] +name = "algonaut_crypto" +version = "0.3.0" +source = "git+https://github.com/registreerocks/algonaut-sgx?branch=main-sgx#4c2a24f5ba08e6623f0103853396f417b10d097b" +dependencies = [ + "algonaut_encoding", + "data-encoding", + "derive_more", + "indexmap", + "lazy_static", + "ring", + "serde", + "sgx_tstd", + "sha2 0.9.5", + "static_assertions", + "thiserror", +] + +[[package]] +name = "algonaut_encoding" +version = "0.3.0" +source = "git+https://github.com/registreerocks/algonaut-sgx?branch=main-sgx#4c2a24f5ba08e6623f0103853396f417b10d097b" +dependencies = [ + "data-encoding", + "serde", + "sgx_tstd", +] + +[[package]] +name = "algonaut_transaction" +version = "0.3.0" +source = "git+https://github.com/registreerocks/algonaut-sgx?branch=main-sgx#4c2a24f5ba08e6623f0103853396f417b10d097b" +dependencies = [ + "algonaut_core", + "algonaut_crypto", + "algonaut_encoding", + "data-encoding", + "derive_more", + "getrandom 0.2.3", + "num-traits 0.2.10", + "rand 0.7.3", + "ring", + "rmp-serde", + "serde", + "serde_bytes", + "sgx_tstd", + "sha2 0.9.5", + "thiserror", + "url", +] + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "autocfg" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "base-x" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" + +[[package]] +name = "base64" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" + +[[package]] +name = "bit_field" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4" + +[[package]] +name = "bitflags" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2da1976d75adbe5fbc88130ecd119529cf1cc6a93ae1546d8696ee66f0d21af1" + +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "git+https://github.com/mesalock-linux/rustcrypto-utils-sgx#07ebf780554e018037f750186d61ea9bdc031148" +dependencies = [ + "block-padding", + "byte-tools", + "byteorder 1.3.4", + "generic-array 0.12.4", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array 0.14.4", +] + +[[package]] +name = "block-padding" +version = "0.1.4" +source = "git+https://github.com/mesalock-linux/rustcrypto-utils-sgx#07ebf780554e018037f750186d61ea9bdc031148" +dependencies = [ + "byte-tools", +] + +[[package]] +name = "bumpalo" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631" + +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "git+https://github.com/mesalock-linux/rustcrypto-utils-sgx#07ebf780554e018037f750186d61ea9bdc031148" + +[[package]] +name = "byteorder" +version = "1.3.4" +source = "git+https://github.com/mesalock-linux/byteorder-sgx#325f392dcd294109eb05f0a3c45e4141514c7784" +dependencies = [ + "sgx_tstd", +] + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "cc" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "cpufeatures" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef" +dependencies = [ + "libc", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "git+https://github.com/mesalock-linux/rustcrypto-traits-sgx#7a5cb154f438c2401b3d8e37de96dd0acf8f493e" +dependencies = [ + "generic-array 0.12.4", + "subtle", +] + +[[package]] +name = "data-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" + +[[package]] +name = "derive_more" +version = "0.99.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40eebddd2156ce1bb37b20bbe5151340a31828b1f2d22ba4141f3531710e38df" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version 0.3.3", + "syn", +] + +[[package]] +name = "digest" +version = "0.8.1" +source = "git+https://github.com/mesalock-linux/rustcrypto-traits-sgx#7a5cb154f438c2401b3d8e37de96dd0acf8f493e" +dependencies = [ + "generic-array 0.12.4", + "sgx_tstd", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array 0.14.4", +] + +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.14" +source = "git+https://github.com/mesalock-linux/getrandom-sgx#0aa9cc20c7dea713ccaac2c44430d625a395ebae" +dependencies = [ + "cfg-if 0.1.10", + "sgx_libc", + "sgx_trts", + "sgx_tstd", +] + +[[package]] +name = "getrandom" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +dependencies = [ + "cfg-if 1.0.0", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "hashbrown" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" + +[[package]] +name = "hashbrown_tstd" +version = "0.11.2" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.7.1" +source = "git+https://github.com/mesalock-linux/rustcrypto-MACs-sgx#e8e1410b9c82d2e59da42fa8b0d8ed38e80a203c" +dependencies = [ + "crypto-mac", + "digest 0.8.1", +] + +[[package]] +name = "hmac-drbg" +version = "0.1.2" +source = "git+https://github.com/mesalock-linux/hmac-drbg-rs-sgx#89d6b0113157599417af867a8d2b4afd5c6f1946" +dependencies = [ + "generic-array 0.12.4", + "hmac", +] + +[[package]] +name = "idna" +version = "0.2.0" +source = "git+https://github.com/mesalock-linux/rust-url-sgx#23832f3191456c2d4a0faab10952e1747be58ca8" +dependencies = [ + "matches", + "sgx_tstd", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "index-fixed" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161ceaf2f41b6cd3f6502f5da085d4ad4393a51e0c70ed2fce1d5698d798fae" + +[[package]] +name = "indexmap" +version = "1.6.1" +source = "git+https://github.com/mesalock-linux/indexmap-sgx#19f52458ba64dd7349a5d3a62227619a17e4db85" +dependencies = [ + "autocfg 1.0.1", + "hashbrown", + "sgx_tstd", +] + +[[package]] +name = "itoa" +version = "0.4.5" +source = "git+https://github.com/mesalock-linux/itoa-sgx#295ee451f5ec74f25c299552b481beb445ea3eb7" +dependencies = [ + "sgx_tstd", +] + +[[package]] +name = "js-sys" +version = "0.3.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce791b7ca6638aae45be056e068fc756d871eb3b3b10b8efa62d1c9cec616752" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin", +] + +[[package]] +name = "libc" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7f823d141fe0a24df1e23b4af4e3c7ba9e5966ec514ea068c93024aa7deb765" + +[[package]] +name = "libsecp256k1" +version = "0.3.5" +source = "git+https://github.com/ntls-io/libsecp256k1-rs-sgx#2a6c35a1876b3553486d34142155b89eaae77965" +dependencies = [ + "arrayref", + "crunchy", + "digest 0.8.1", + "hmac-drbg", + "rand 0.7.3", + "sgx_tstd", + "sha2 0.8.0", + "subtle", + "typenum", +] + +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "matches" +version = "0.1.8" +source = "git+https://github.com/mesalock-linux/rust-std-candidates-sgx#5747bcf37f3e18687758838da0339ff0f2c83924" + +[[package]] +name = "num-bigint" +version = "0.2.5" +source = "git+https://github.com/mesalock-linux/num-bigint-sgx#76a5bed94dc31c32bd1670dbf72877abcf9bbc09" +dependencies = [ + "autocfg 1.0.1", + "num-integer", + "num-traits 0.2.10", + "sgx_tstd", +] + +[[package]] +name = "num-integer" +version = "0.1.41" +source = "git+https://github.com/mesalock-linux/num-integer-sgx#404c50e5378ca635261688b080dee328ff42b6bd" +dependencies = [ + "autocfg 0.1.7", + "num-traits 0.2.10", + "sgx_tstd", +] + +[[package]] +name = "num-traits" +version = "0.2.10" +source = "git+https://github.com/mesalock-linux/num-traits-sgx#af046e0b15c594c960007418097dd4ff37ec3f7a" +dependencies = [ + "autocfg 0.1.7", + "sgx_tstd", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg 1.0.1", +] + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "git+https://github.com/mesalock-linux/rust-url-sgx#23832f3191456c2d4a0faab10952e1747be58ca8" + +[[package]] +name = "pest" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +dependencies = [ + "ucd-trie", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.6" +source = "git+https://github.com/mesalock-linux/cryptocorrosion-sgx#32d7de50b5f03a10fe5a42167410be2dd3c2e389" + +[[package]] +name = "ppv-lite86" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" + +[[package]] +name = "proc-macro2" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proptest" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0d9cc07f18492d879586c92b485def06bc850da3118075cd45d50e9c95b0e5" +dependencies = [ + "bitflags", + "byteorder 1.4.3", + "num-traits 0.2.14", + "rand 0.8.4", + "rand_chacha 0.3.1", + "rand_xorshift", + "x86", +] + +[[package]] +name = "quote" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "git+https://github.com/mesalock-linux/rand-sgx#83583f073de3b4f75c3c3ef5e174d484ed941f85" +dependencies = [ + "getrandom 0.1.14", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "sgx_tstd", +] + +[[package]] +name = "rand" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" +dependencies = [ + "rand_core 0.6.3", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "git+https://github.com/mesalock-linux/rand-sgx#83583f073de3b4f75c3c3ef5e174d484ed941f85" +dependencies = [ + "ppv-lite86 0.2.6", + "rand_core 0.5.1", + "sgx_tstd", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86 0.2.10", + "rand_core 0.6.3", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "git+https://github.com/mesalock-linux/rand-sgx#83583f073de3b4f75c3c3ef5e174d484ed941f85" +dependencies = [ + "getrandom 0.1.14", + "sgx_tstd", +] + +[[package]] +name = "rand_core" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" + +[[package]] +name = "rand_xorshift" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" +dependencies = [ + "rand_core 0.6.3", +] + +[[package]] +name = "raw-cpuid" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e9c0f2091b865a94bc3c9d34896cc4bbda04453453c391f7eb224491be9ae1d" +dependencies = [ + "bitflags", + "cc", + "rustc_version 0.2.3", +] + +[[package]] +name = "ring" +version = "0.16.19" +source = "git+https://github.com/mesalock-linux/ring-sgx#844efe271ed78a399d803b2579f5f2424d543c9f" +dependencies = [ + "cc", + "sgx_tstd", + "spin", + "untrusted", +] + +[[package]] +name = "ripemd160" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eca4ecc81b7f313189bf73ce724400a07da2a6dac19588b03c8bd76a2dcc251" +dependencies = [ + "block-buffer 0.9.0", + "digest 0.9.0", + "opaque-debug 0.3.0", +] + +[[package]] +name = "ripple-address-codec" +version = "0.1.1" +source = "git+https://github.com/ntls-io/ripple-address-codec-rust-sgx?branch=v0.1.1-sgx#e2b03486a9e0627bbc922681863b4661be8a4e3b" +dependencies = [ + "base-x", + "ring", + "sgx_tstd", +] + +[[package]] +name = "ripple-keypairs" +version = "0.1.0" +source = "git+https://github.com/ntls-io/ripple-keypairs-rust-sgx?branch=v0.1.0-sgx#ef55261e2f0aa6b5c54cac43abc4c57b4f97b286" +dependencies = [ + "base-x", + "hex", + "libsecp256k1", + "num-bigint", + "ring", + "ripemd160", + "ripple-address-codec", + "sgx_tstd", +] + +[[package]] +name = "rmp" +version = "0.8.9" +source = "git+https://github.com/mesalock-linux/msgpack-rust-sgx#55273d79a63a08bdfe06d744e635296875307b22" +dependencies = [ + "byteorder 1.3.4", + "num-traits 0.2.10", + "sgx_tstd", +] + +[[package]] +name = "rmp-serde" +version = "0.15.0" +source = "git+https://github.com/mesalock-linux/msgpack-rust-sgx#55273d79a63a08bdfe06d744e635296875307b22" +dependencies = [ + "byteorder 1.3.4", + "rmp", + "serde", + "sgx_tstd", +] + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver 0.9.0", +] + +[[package]] +name = "rustc_version" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver 0.11.0", +] + +[[package]] +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + +[[package]] +name = "secrecy" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bd1c54ea06cfd2f6b63219704de0b9b4f72dcc2b8fdef820be6cd799780e91e" +dependencies = [ + "zeroize", +] + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser 0.7.0", +] + +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser 0.10.2", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + +[[package]] +name = "serde" +version = "1.0.118" +source = "git+https://github.com/mesalock-linux/serde-sgx#db0226f1d5d70fca6b96af2c285851502204e21c" +dependencies = [ + "serde_derive", + "sgx_tstd", +] + +[[package]] +name = "serde_bytes" +version = "0.11.5" +source = "git+https://github.com/registreerocks/serde-bytes-sgx#0bdf5e0596258f8895ce60527d82b6b5961a2eae" +dependencies = [ + "serde", + "sgx_tstd", +] + +[[package]] +name = "serde_derive" +version = "1.0.118" +source = "git+https://github.com/mesalock-linux/serde-sgx#db0226f1d5d70fca6b96af2c285851502204e21c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.60" +source = "git+https://github.com/mesalock-linux/serde-json-sgx#380893814ad2a057758d825bab798aa117f7362a" +dependencies = [ + "itoa", + "ryu", + "serde", + "sgx_tstd", +] + +[[package]] +name = "sgx-wallet-impl" +version = "0.1.0" +dependencies = [ + "algonaut", + "base64", + "hex", + "rand 0.7.3", + "ripple-address-codec", + "ripple-keypairs", + "rmp-serde", + "secrecy", + "serde", + "serde_bytes", + "serde_json", + "sgx_tcrypto", + "sgx_trts", + "sgx_tse", + "sgx_tstd", + "sgx_types", + "sodalite", + "thiserror", + "zeroize", +] + +[[package]] +name = "sgx-wallet-test-enclave" +version = "0.1.0" +dependencies = [ + "algonaut", + "proptest", + "rmp-serde", + "secrecy", + "serde", + "serde_json", + "sgx-wallet-impl", + "sgx_rand", + "sgx_tcrypto", + "sgx_tstd", + "sgx_tunittest", + "sgx_types", + "sodalite", +] + +[[package]] +name = "sgx_alloc" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" + +[[package]] +name = "sgx_backtrace_sys" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "cc", + "sgx_build_helper", + "sgx_libc", +] + +[[package]] +name = "sgx_build_helper" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" + +[[package]] +name = "sgx_demangle" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" + +[[package]] +name = "sgx_libc" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "sgx_types", +] + +[[package]] +name = "sgx_rand" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "sgx_trts", + "sgx_tstd", + "sgx_types", +] + +[[package]] +name = "sgx_tcrypto" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "sgx_types", +] + +[[package]] +name = "sgx_tprotected_fs" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "sgx_trts", + "sgx_types", +] + +[[package]] +name = "sgx_trts" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "sgx_libc", + "sgx_types", +] + +[[package]] +name = "sgx_tse" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "sgx_types", +] + +[[package]] +name = "sgx_tstd" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "hashbrown_tstd", + "sgx_alloc", + "sgx_backtrace_sys", + "sgx_demangle", + "sgx_libc", + "sgx_tprotected_fs", + "sgx_trts", + "sgx_types", + "sgx_unwind", +] + +[[package]] +name = "sgx_tunittest" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "sgx_tstd", +] + +[[package]] +name = "sgx_types" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" + +[[package]] +name = "sgx_unwind" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "sgx_build_helper", +] + +[[package]] +name = "sha2" +version = "0.8.0" +source = "git+https://github.com/mesalock-linux/rustcrypto-hashes-sgx#54ac4af765ec6b424add4e7559e82328bd052060" +dependencies = [ + "block-buffer 0.7.3", + "digest 0.8.1", + "fake-simd", + "opaque-debug 0.2.3", + "sgx_tstd", +] + +[[package]] +name = "sha2" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.9.0", + "opaque-debug 0.3.0", +] + +[[package]] +name = "smallvec" +version = "1.6.1" +source = "git+https://github.com/mesalock-linux/rust-smallvec-sgx#b5925f10aa5bc3370a0fb339140ee063f5a888dd" +dependencies = [ + "sgx_tstd", +] + +[[package]] +name = "sodalite" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41784a359d15c58bba298cccb7f30a847a1a42d0620c9bdaa0aa42fdb3c280e0" +dependencies = [ + "index-fixed", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "subtle" +version = "2.2.2" +source = "git+https://github.com/mesalock-linux/subtle-sgx#8ee32fc0902a4594bd12e272357e2d76cde9dad1" +dependencies = [ + "sgx_tstd", +] + +[[package]] +name = "syn" +version = "1.0.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1873d832550d4588c3dbc20f01361ab00bfe741048f71e3fecf145a7cc18b29c" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "synstructure" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "474aaa926faa1603c40b7885a9eaea29b444d1cb2850cb7c0e37bb1a4182f4fa" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "thiserror" +version = "1.0.9" +source = "git+https://github.com/mesalock-linux/thiserror-sgx#c2f806b88616e06aab0af770366a76885d974fdc" +dependencies = [ + "sgx_tstd", + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.9" +source = "git+https://github.com/mesalock-linux/thiserror-sgx#c2f806b88616e06aab0af770366a76885d974fdc" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "typenum" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" + +[[package]] +name = "ucd-trie" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" + +[[package]] +name = "unicode-bidi" +version = "0.3.4" +source = "git+https://github.com/mesalock-linux/unicode-bidi-sgx#eb10728a635a046e75747849fbc680cbbb7832c7" +dependencies = [ + "matches", + "sgx_tstd", +] + +[[package]] +name = "unicode-normalization" +version = "0.1.12" +source = "git+https://github.com/mesalock-linux/unicode-normalization-sgx#c1b030611969f87d75782c1df77975167cbbd509" +dependencies = [ + "smallvec", +] + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "url" +version = "2.1.1" +source = "git+https://github.com/mesalock-linux/rust-url-sgx#23832f3191456c2d4a0faab10952e1747be58ca8" +dependencies = [ + "idna", + "matches", + "percent-encoding", + "sgx_tstd", +] + +[[package]] +name = "version_check" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" + +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + +[[package]] +name = "wasm-bindgen" +version = "0.2.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b608ecc8f4198fe8680e2ed18eccab5f0cd4caaf3d83516fa5fb2e927fda2586" +dependencies = [ + "cfg-if 1.0.0", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "580aa3a91a63d23aac5b6b267e2d13cb4f363e31dce6c352fca4752ae12e479f" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "171ebf0ed9e1458810dfcb31f2e766ad6b3a89dbda42d8901f2b268277e5f09c" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c2657dd393f03aa2a659c25c6ae18a13a4048cebd220e147933ea837efc589f" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e0c4a743a309662d45f4ede961d7afa4ba4131a59a639f29b0069c3798bbcc2" + +[[package]] +name = "x86" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2786ac694ed572ab5d2bbcd9e188805dba26b3501973dd69718914fb3d4a5a69" +dependencies = [ + "bit_field", + "bitflags", + "raw-cpuid", +] + +[[package]] +name = "zeroize" +version = "1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eb5728b8afd3f280a869ce1d4c554ffaed35f45c231fc41bfbd0381bef50317" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f8f187641dad4f680d25c4bfc4225b418165984179f26ca76ec4fb6441d3a17" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Cargo.toml b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Cargo.toml new file mode 100644 index 0000000..c389a1a --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Cargo.toml @@ -0,0 +1,44 @@ +[package] +# name matches ENCLAVE_CARGO_LIB in Makefile +name = "sgx-wallet-test-enclave" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["staticlib"] +bench = false +test = false + +[features] +default = [] + +[dependencies] +# no_std +secrecy = "0.8.0" +sodalite = { version = "0.4.0", default-features = false } + +# SGX SDK +sgx_rand = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } +sgx_tcrypto = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } +sgx_tstd = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", features = ["backtrace"], rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } +sgx_tunittest = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } +sgx_types = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } + +# Community SGX forks +rmp-serde = { git = "https://github.com/mesalock-linux/msgpack-rust-sgx" } +serde = { git = "https://github.com/mesalock-linux/serde-sgx" } +serde_json = { git = "https://github.com/mesalock-linux/serde-json-sgx" } + +# Our SGX forks +algonaut = { git = "https://github.com/registreerocks/algonaut-sgx", branch = "main-sgx" } + +sgx-wallet-impl = { path = "../../../crates/sgx-wallet-impl" } + +# Test-only +# Docs: https://altsysrq.github.io/proptest-book/proptest/no-std.html +proptest = { version = "1.0.0", default-features = false, features = ["alloc", "hardware-rng"] } + +[patch.'https://github.com/apache/teaclave-sgx-sdk.git'] +sgx_libc = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } +sgx_trts = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } +sgx_tstd = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Enclave.config.xml b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Enclave.config.xml new file mode 100644 index 0000000..ee4c3f7 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Enclave.config.xml @@ -0,0 +1,12 @@ + + + 0 + 0 + 0x40000 + 0x100000 + 1 + 1 + 0 + 0 + 0xFFFFFFFF + diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Enclave.edl b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Enclave.edl new file mode 100644 index 0000000..83a3727 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Enclave.edl @@ -0,0 +1,12 @@ +enclave { + from "sgx_tstd.edl" import *; + from "sgx_backtrace.edl" import *; + + from "sgx_env.edl" import *; + from "sgx_tprotected_fs.edl" import *; + + trusted + { + public size_t run_tests_ecall(); + }; +}; diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Enclave.lds b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Enclave.lds new file mode 100644 index 0000000..e3d9d0e --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Enclave.lds @@ -0,0 +1,9 @@ +enclave.so +{ + global: + g_global_data_sim; + g_global_data; + enclave_entry; + local: + *; +}; diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Makefile b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Makefile new file mode 100644 index 0000000..2cafc8c --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Makefile @@ -0,0 +1,117 @@ +# Makefile settings + +APP_T_SIGNED = enclave.signed.so +KEYS = ../keys +LIB = ../build/lib/ +BIN = ../build/bin/ +APP_T = enclave.so +NAME_T = libenclave.a +SRC_U = ../app/ +SRC_T = ./ +CODEGEN_T = $(SRC_T)/codegen/ +OBJ_T = ../build/obj/ +FLAGS = -Wall -Wextra +GCC_STEP1_T = -fstack-protector -I$(CUSTOM_COMMON_PATH)/inc -I$(CUSTOM_EDL_PATH) -I$(SGX_SDK)/include \ + -I$(SGX_SDK)/include/tlibc -I$(SGX_SDK)/include/stlport -I$(SGX_SDK)/include/epid -I $(CODEGEN_T) \ + -L$(LIB) $(ENCLAVE_CFLAGS) $(SGX_COMMON_CFLAGS) +GCC_STEP2_T = -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L$(SGX_LIBRARY_PATH) \ + -Wl,--whole-archive -l$(TRTS_LIB) -Wl,--no-whole-archive \ + -Wl,--start-group -lsgx_tstdc -l$(SERVICE_LIB) -lsgx_tcrypto -lsgx_tcxx -lsgx_tprotected_fs -L$(LIB) -lenclave -Wl,--end-group \ + -Wl,--version-script=$(SRC_T)Enclave.lds $(ENCLAVE_LDFLAGS) +FILES_T = Enclave_t.c +FILES_T_H = Enclave_t.h +EDL_FILE = Enclave.edl +ENCLAVE_CONFIG = Enclave.config.xml +SGX_ARCH = x64 +TRTS_LIB = sgx_trts +SERVICE_LIB = sgx_tservice +# ENCLAVE_CARGO_LIB matches name in Cargo.toml +ENCLAVE_CARGO_LIB=libsgx_wallet_test_enclave.a +# Addprefix dependant variables, no need to change those +OUTPUT_T = $(FILES_T:.c=.o) +NAME = $(addprefix $(BIN), $(APP_T_SIGNED)) +BIN_T = $(addprefix $(BIN), $(APP_T)) +NAME_T_D = $(addprefix $(LIB), $(NAME_T)) +OUTPUT_W_FU=$(addprefix $(OBJ_U), $(OUTPUT_U)) +FILES_T_F=$(addprefix $(CODEGEN_T), $(FILES_T)) +FILES_T_H_F=$(addprefix $(CODEGEN_T), $(FILES_T_H)) +FILES_T_F_RUST=$(addprefix $(SRC_T), $(FILES_T_RUST)) +OUTPUT_W_FT=$(addprefix $(OBJ_T), $(OUTPUT_T)) + +# All Rust and other source files that the Cargo build depends on. +FILES_RUST_F = Cargo.toml Cargo.lock $(shell find src ../../../crates/sgx-wallet-impl/src -name '*.rs') + +# Contains compilation rules for the enclave part + +include ../buildenv.mk +include ../buildenv_sgx.mk + +# Custom header files and EDL paths needs to be specified with make (CUSTOM_EDL_PATH) (CUSTOM_COMMON_PATH) + +ifeq ($(MITIGATION-CVE-2020-0551), LOAD) +export MITIGATION_CVE_2020_0551=LOAD +else ifeq ($(MITIGATION-CVE-2020-0551), CF) +export MITIGATION_CVE_2020_0551=CF +endif + +# Compilation process, we set up all the dependencies needed to have the correct order of build, and avoid relink + +all: $(NAME) + +# We print the compilation mode we're in (hardware/software mode), just as a reminder. + +$(NAME): $(BIN_T) $(KEYS)/Enclave_private.pem +ifeq ($(SGX_MODE), SW) + @echo "\033[32mSoftware / Simulation mode\033[0m" +else + @echo "\033[32mHardware mode\033[0m" +endif + @echo "\033[32mSigning the enclave...\033[0m" + @mkdir -p $(BIN) + @$(SGX_ENCLAVE_SIGNER) sign -key $(KEYS)/Enclave_private.pem -enclave $(BIN_T) -out $@ -config $(SRC_T)Enclave.config.xml + +$(KEYS)/Enclave_private.pem $(KEYS)/Enclave_public.pem: + @echo "\033[32mGenerating keys...\033[0m" + @mkdir -p $(KEYS) + @openssl genrsa -out $(KEYS)/Enclave_private.pem -3 3072 + @openssl rsa -in $(KEYS)/Enclave_private.pem -pubout -out $(KEYS)/Enclave_public.pem + +$(BIN_T): $(NAME_T_D) + @echo "\033[32mBuilding the enclave...\033[0m" + @$(CXX) $(OUTPUT_W_FT) -o $@ $(GCC_STEP2_T) + +$(NAME_T_D): $(FILES_T_F) $(OUTPUT_W_FT) $(FILES_RUST_F) $(EDL_FILE) $(ENCLAVE_CONFIG) # We added as a reference the rust files, along with the EDL, the XML config file and the cargo.toml file, so Make can detect if any change was made + @echo "\033[32mBuilding enclave static library with Cargo...\033[0m" + @cargo build --release + @cp ./target/release/$(ENCLAVE_CARGO_LIB) $(LIB)libenclave.a + +$(FILES_T_F): $(SGX_EDGER8R) $(SRC_T)/Enclave.edl + @echo "\033[32mGenerating trusted SGX C edl files...\033[0m" + @$(SGX_EDGER8R) --trusted $(SRC_T)/Enclave.edl --search-path $(SGX_SDK)/include --search-path $(CUSTOM_EDL_PATH) --trusted-dir $(CODEGEN_T) + +$(OBJ_T)%.o:$(CODEGEN_T)%.c + @mkdir -p $(OBJ_T) + @echo "\033[32m$?: Build in progress...\033[0m" + @$(CC) $(FLAGS) $(GCC_STEP1_T) -o $@ -c $? + +clean: c_clean + @rm -rf $(OBJ_T) + @echo "\033[32mObject files deleted\033[0m" + +fclean: clean fclean_enclave + +fclean_enclave: + @echo "\033[32mBinary file $(NAME) deleted\033[0m" + @rm -f $(NAME) + @rm -f $(BIN_T) + @rm -f $(LIB)libenclave.a + @cargo clean + +c_clean: + @echo "\033[32mC edl generated files deleted\033[0m" + @rm -rf $(FILES_T_F) + @rm -f $(FILES_T_H_F) + +re: fclean all + +.PHONY: all clean c_clean fclean re fclean_enclave diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/codegen/Enclave_t.c b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/codegen/Enclave_t.c new file mode 100644 index 0000000..8e05472 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/codegen/Enclave_t.c @@ -0,0 +1,5937 @@ +#include "Enclave_t.h" + +#include "sgx_trts.h" /* for sgx_ocalloc, sgx_is_outside_enclave */ +#include "sgx_lfence.h" /* for sgx_lfence */ + +#include +#include /* for memcpy_s etc */ +#include /* for malloc/free etc */ + +#define CHECK_REF_POINTER(ptr, siz) do { \ + if (!(ptr) || ! sgx_is_outside_enclave((ptr), (siz))) \ + return SGX_ERROR_INVALID_PARAMETER;\ +} while (0) + +#define CHECK_UNIQUE_POINTER(ptr, siz) do { \ + if ((ptr) && ! sgx_is_outside_enclave((ptr), (siz))) \ + return SGX_ERROR_INVALID_PARAMETER;\ +} while (0) + +#define CHECK_ENCLAVE_POINTER(ptr, siz) do { \ + if ((ptr) && ! sgx_is_within_enclave((ptr), (siz))) \ + return SGX_ERROR_INVALID_PARAMETER;\ +} while (0) + +#define ADD_ASSIGN_OVERFLOW(a, b) ( \ + ((a) += (b)) < (b) \ +) + + +typedef struct ms_run_tests_ecall_t { + size_t ms_retval; +} ms_run_tests_ecall_t; + +typedef struct ms_t_global_init_ecall_t { + uint64_t ms_id; + const uint8_t* ms_path; + size_t ms_len; +} ms_t_global_init_ecall_t; + +typedef struct ms_u_thread_set_event_ocall_t { + int ms_retval; + int* ms_error; + const void* ms_tcs; +} ms_u_thread_set_event_ocall_t; + +typedef struct ms_u_thread_wait_event_ocall_t { + int ms_retval; + int* ms_error; + const void* ms_tcs; + const struct timespec* ms_timeout; +} ms_u_thread_wait_event_ocall_t; + +typedef struct ms_u_thread_set_multiple_events_ocall_t { + int ms_retval; + int* ms_error; + const void** ms_tcss; + int ms_total; +} ms_u_thread_set_multiple_events_ocall_t; + +typedef struct ms_u_thread_setwait_events_ocall_t { + int ms_retval; + int* ms_error; + const void* ms_waiter_tcs; + const void* ms_self_tcs; + const struct timespec* ms_timeout; +} ms_u_thread_setwait_events_ocall_t; + +typedef struct ms_u_clock_gettime_ocall_t { + int ms_retval; + int* ms_error; + int ms_clk_id; + struct timespec* ms_tp; +} ms_u_clock_gettime_ocall_t; + +typedef struct ms_u_read_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + void* ms_buf; + size_t ms_count; +} ms_u_read_ocall_t; + +typedef struct ms_u_pread64_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + void* ms_buf; + size_t ms_count; + int64_t ms_offset; +} ms_u_pread64_ocall_t; + +typedef struct ms_u_readv_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const struct iovec* ms_iov; + int ms_iovcnt; +} ms_u_readv_ocall_t; + +typedef struct ms_u_preadv64_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const struct iovec* ms_iov; + int ms_iovcnt; + int64_t ms_offset; +} ms_u_preadv64_ocall_t; + +typedef struct ms_u_write_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const void* ms_buf; + size_t ms_count; +} ms_u_write_ocall_t; + +typedef struct ms_u_pwrite64_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const void* ms_buf; + size_t ms_count; + int64_t ms_offset; +} ms_u_pwrite64_ocall_t; + +typedef struct ms_u_writev_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const struct iovec* ms_iov; + int ms_iovcnt; +} ms_u_writev_ocall_t; + +typedef struct ms_u_pwritev64_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const struct iovec* ms_iov; + int ms_iovcnt; + int64_t ms_offset; +} ms_u_pwritev64_ocall_t; + +typedef struct ms_u_fcntl_arg0_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int ms_cmd; +} ms_u_fcntl_arg0_ocall_t; + +typedef struct ms_u_fcntl_arg1_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int ms_cmd; + int ms_arg; +} ms_u_fcntl_arg1_ocall_t; + +typedef struct ms_u_ioctl_arg0_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int ms_request; +} ms_u_ioctl_arg0_ocall_t; + +typedef struct ms_u_ioctl_arg1_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int ms_request; + int* ms_arg; +} ms_u_ioctl_arg1_ocall_t; + +typedef struct ms_u_close_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; +} ms_u_close_ocall_t; + +typedef struct ms_u_malloc_ocall_t { + void* ms_retval; + int* ms_error; + size_t ms_size; +} ms_u_malloc_ocall_t; + +typedef struct ms_u_free_ocall_t { + void* ms_p; +} ms_u_free_ocall_t; + +typedef struct ms_u_mmap_ocall_t { + void* ms_retval; + int* ms_error; + void* ms_start; + size_t ms_length; + int ms_prot; + int ms_flags; + int ms_fd; + int64_t ms_offset; +} ms_u_mmap_ocall_t; + +typedef struct ms_u_munmap_ocall_t { + int ms_retval; + int* ms_error; + void* ms_start; + size_t ms_length; +} ms_u_munmap_ocall_t; + +typedef struct ms_u_msync_ocall_t { + int ms_retval; + int* ms_error; + void* ms_addr; + size_t ms_length; + int ms_flags; +} ms_u_msync_ocall_t; + +typedef struct ms_u_mprotect_ocall_t { + int ms_retval; + int* ms_error; + void* ms_addr; + size_t ms_length; + int ms_prot; +} ms_u_mprotect_ocall_t; + +typedef struct ms_u_open_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_pathname; + int ms_flags; +} ms_u_open_ocall_t; + +typedef struct ms_u_open64_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + int ms_oflag; + int ms_mode; +} ms_u_open64_ocall_t; + +typedef struct ms_u_fstat_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + struct stat_t* ms_buf; +} ms_u_fstat_ocall_t; + +typedef struct ms_u_fstat64_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + struct stat64_t* ms_buf; +} ms_u_fstat64_ocall_t; + +typedef struct ms_u_stat_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + struct stat_t* ms_buf; +} ms_u_stat_ocall_t; + +typedef struct ms_u_stat64_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + struct stat64_t* ms_buf; +} ms_u_stat64_ocall_t; + +typedef struct ms_u_lstat_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + struct stat_t* ms_buf; +} ms_u_lstat_ocall_t; + +typedef struct ms_u_lstat64_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + struct stat64_t* ms_buf; +} ms_u_lstat64_ocall_t; + +typedef struct ms_u_lseek_ocall_t { + uint64_t ms_retval; + int* ms_error; + int ms_fd; + int64_t ms_offset; + int ms_whence; +} ms_u_lseek_ocall_t; + +typedef struct ms_u_lseek64_ocall_t { + int64_t ms_retval; + int* ms_error; + int ms_fd; + int64_t ms_offset; + int ms_whence; +} ms_u_lseek64_ocall_t; + +typedef struct ms_u_ftruncate_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int64_t ms_length; +} ms_u_ftruncate_ocall_t; + +typedef struct ms_u_ftruncate64_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int64_t ms_length; +} ms_u_ftruncate64_ocall_t; + +typedef struct ms_u_truncate_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + int64_t ms_length; +} ms_u_truncate_ocall_t; + +typedef struct ms_u_truncate64_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + int64_t ms_length; +} ms_u_truncate64_ocall_t; + +typedef struct ms_u_fsync_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; +} ms_u_fsync_ocall_t; + +typedef struct ms_u_fdatasync_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; +} ms_u_fdatasync_ocall_t; + +typedef struct ms_u_fchmod_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + uint32_t ms_mode; +} ms_u_fchmod_ocall_t; + +typedef struct ms_u_unlink_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_pathname; +} ms_u_unlink_ocall_t; + +typedef struct ms_u_link_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_oldpath; + const char* ms_newpath; +} ms_u_link_ocall_t; + +typedef struct ms_u_linkat_ocall_t { + int ms_retval; + int* ms_error; + int ms_olddirfd; + const char* ms_oldpath; + int ms_newdirfd; + const char* ms_newpath; + int ms_flags; +} ms_u_linkat_ocall_t; + +typedef struct ms_u_rename_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_oldpath; + const char* ms_newpath; +} ms_u_rename_ocall_t; + +typedef struct ms_u_chmod_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + uint32_t ms_mode; +} ms_u_chmod_ocall_t; + +typedef struct ms_u_readlink_ocall_t { + size_t ms_retval; + int* ms_error; + const char* ms_path; + char* ms_buf; + size_t ms_bufsz; +} ms_u_readlink_ocall_t; + +typedef struct ms_u_symlink_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path1; + const char* ms_path2; +} ms_u_symlink_ocall_t; + +typedef struct ms_u_realpath_ocall_t { + char* ms_retval; + int* ms_error; + const char* ms_pathname; +} ms_u_realpath_ocall_t; + +typedef struct ms_u_mkdir_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_pathname; + uint32_t ms_mode; +} ms_u_mkdir_ocall_t; + +typedef struct ms_u_rmdir_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_pathname; +} ms_u_rmdir_ocall_t; + +typedef struct ms_u_opendir_ocall_t { + void* ms_retval; + int* ms_error; + const char* ms_pathname; +} ms_u_opendir_ocall_t; + +typedef struct ms_u_readdir64_r_ocall_t { + int ms_retval; + void* ms_dirp; + struct dirent64_t* ms_entry; + struct dirent64_t** ms_result; +} ms_u_readdir64_r_ocall_t; + +typedef struct ms_u_closedir_ocall_t { + int ms_retval; + int* ms_error; + void* ms_dirp; +} ms_u_closedir_ocall_t; + +typedef struct ms_u_dirfd_ocall_t { + int ms_retval; + int* ms_error; + void* ms_dirp; +} ms_u_dirfd_ocall_t; + +typedef struct ms_u_fstatat64_ocall_t { + int ms_retval; + int* ms_error; + int ms_dirfd; + const char* ms_pathname; + struct stat64_t* ms_buf; + int ms_flags; +} ms_u_fstatat64_ocall_t; + +typedef struct ms_u_environ_ocall_t { + char** ms_retval; +} ms_u_environ_ocall_t; + +typedef struct ms_u_getenv_ocall_t { + char* ms_retval; + const char* ms_name; +} ms_u_getenv_ocall_t; + +typedef struct ms_u_setenv_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_name; + const char* ms_value; + int ms_overwrite; +} ms_u_setenv_ocall_t; + +typedef struct ms_u_unsetenv_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_name; +} ms_u_unsetenv_ocall_t; + +typedef struct ms_u_chdir_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_dir; +} ms_u_chdir_ocall_t; + +typedef struct ms_u_getcwd_ocall_t { + char* ms_retval; + int* ms_error; + char* ms_buf; + size_t ms_buflen; +} ms_u_getcwd_ocall_t; + +typedef struct ms_u_getpwuid_r_ocall_t { + int ms_retval; + unsigned int ms_uid; + struct passwd* ms_pwd; + char* ms_buf; + size_t ms_buflen; + struct passwd** ms_passwd_result; +} ms_u_getpwuid_r_ocall_t; + +typedef struct ms_u_getuid_ocall_t { + unsigned int ms_retval; +} ms_u_getuid_ocall_t; + +typedef struct ms_u_sgxprotectedfs_exclusive_file_open_t { + void* ms_retval; + const char* ms_filename; + uint8_t ms_read_only; + int64_t* ms_file_size; + int32_t* ms_error_code; +} ms_u_sgxprotectedfs_exclusive_file_open_t; + +typedef struct ms_u_sgxprotectedfs_check_if_file_exists_t { + uint8_t ms_retval; + const char* ms_filename; +} ms_u_sgxprotectedfs_check_if_file_exists_t; + +typedef struct ms_u_sgxprotectedfs_fread_node_t { + int32_t ms_retval; + void* ms_f; + uint64_t ms_node_number; + uint8_t* ms_buffer; + uint32_t ms_node_size; +} ms_u_sgxprotectedfs_fread_node_t; + +typedef struct ms_u_sgxprotectedfs_fwrite_node_t { + int32_t ms_retval; + void* ms_f; + uint64_t ms_node_number; + uint8_t* ms_buffer; + uint32_t ms_node_size; +} ms_u_sgxprotectedfs_fwrite_node_t; + +typedef struct ms_u_sgxprotectedfs_fclose_t { + int32_t ms_retval; + void* ms_f; +} ms_u_sgxprotectedfs_fclose_t; + +typedef struct ms_u_sgxprotectedfs_fflush_t { + uint8_t ms_retval; + void* ms_f; +} ms_u_sgxprotectedfs_fflush_t; + +typedef struct ms_u_sgxprotectedfs_remove_t { + int32_t ms_retval; + const char* ms_filename; +} ms_u_sgxprotectedfs_remove_t; + +typedef struct ms_u_sgxprotectedfs_recovery_file_open_t { + void* ms_retval; + const char* ms_filename; +} ms_u_sgxprotectedfs_recovery_file_open_t; + +typedef struct ms_u_sgxprotectedfs_fwrite_recovery_node_t { + uint8_t ms_retval; + void* ms_f; + uint8_t* ms_data; + uint32_t ms_data_length; +} ms_u_sgxprotectedfs_fwrite_recovery_node_t; + +typedef struct ms_u_sgxprotectedfs_do_file_recovery_t { + int32_t ms_retval; + const char* ms_filename; + const char* ms_recovery_filename; + uint32_t ms_node_size; +} ms_u_sgxprotectedfs_do_file_recovery_t; + +typedef struct ms_sgx_oc_cpuidex_t { + int* ms_cpuinfo; + int ms_leaf; + int ms_subleaf; +} ms_sgx_oc_cpuidex_t; + +typedef struct ms_sgx_thread_wait_untrusted_event_ocall_t { + int ms_retval; + const void* ms_self; +} ms_sgx_thread_wait_untrusted_event_ocall_t; + +typedef struct ms_sgx_thread_set_untrusted_event_ocall_t { + int ms_retval; + const void* ms_waiter; +} ms_sgx_thread_set_untrusted_event_ocall_t; + +typedef struct ms_sgx_thread_setwait_untrusted_events_ocall_t { + int ms_retval; + const void* ms_waiter; + const void* ms_self; +} ms_sgx_thread_setwait_untrusted_events_ocall_t; + +typedef struct ms_sgx_thread_set_multiple_untrusted_events_ocall_t { + int ms_retval; + const void** ms_waiters; + size_t ms_total; +} ms_sgx_thread_set_multiple_untrusted_events_ocall_t; + +static sgx_status_t SGX_CDECL sgx_run_tests_ecall(void* pms) +{ + CHECK_REF_POINTER(pms, sizeof(ms_run_tests_ecall_t)); + // + // fence after pointer checks + // + sgx_lfence(); + ms_run_tests_ecall_t* ms = SGX_CAST(ms_run_tests_ecall_t*, pms); + sgx_status_t status = SGX_SUCCESS; + + + + ms->ms_retval = run_tests_ecall(); + + + return status; +} + +static sgx_status_t SGX_CDECL sgx_t_global_init_ecall(void* pms) +{ + CHECK_REF_POINTER(pms, sizeof(ms_t_global_init_ecall_t)); + // + // fence after pointer checks + // + sgx_lfence(); + ms_t_global_init_ecall_t* ms = SGX_CAST(ms_t_global_init_ecall_t*, pms); + sgx_status_t status = SGX_SUCCESS; + const uint8_t* _tmp_path = ms->ms_path; + size_t _tmp_len = ms->ms_len; + size_t _len_path = _tmp_len; + uint8_t* _in_path = NULL; + + CHECK_UNIQUE_POINTER(_tmp_path, _len_path); + + // + // fence after pointer checks + // + sgx_lfence(); + + if (_tmp_path != NULL && _len_path != 0) { + if ( _len_path % sizeof(*_tmp_path) != 0) + { + status = SGX_ERROR_INVALID_PARAMETER; + goto err; + } + _in_path = (uint8_t*)malloc(_len_path); + if (_in_path == NULL) { + status = SGX_ERROR_OUT_OF_MEMORY; + goto err; + } + + if (memcpy_s(_in_path, _len_path, _tmp_path, _len_path)) { + status = SGX_ERROR_UNEXPECTED; + goto err; + } + + } + + t_global_init_ecall(ms->ms_id, (const uint8_t*)_in_path, _tmp_len); + +err: + if (_in_path) free(_in_path); + return status; +} + +static sgx_status_t SGX_CDECL sgx_t_global_exit_ecall(void* pms) +{ + sgx_status_t status = SGX_SUCCESS; + if (pms != NULL) return SGX_ERROR_INVALID_PARAMETER; + t_global_exit_ecall(); + return status; +} + +SGX_EXTERNC const struct { + size_t nr_ecall; + struct {void* ecall_addr; uint8_t is_priv; uint8_t is_switchless;} ecall_table[3]; +} g_ecall_table = { + 3, + { + {(void*)(uintptr_t)sgx_run_tests_ecall, 0, 0}, + {(void*)(uintptr_t)sgx_t_global_init_ecall, 0, 0}, + {(void*)(uintptr_t)sgx_t_global_exit_ecall, 0, 0}, + } +}; + +SGX_EXTERNC const struct { + size_t nr_ocall; + uint8_t entry_table[79][3]; +} g_dyn_entry_table = { + 79, + { + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + {0, 0, 0, }, + } +}; + + +sgx_status_t SGX_CDECL u_thread_set_event_ocall(int* retval, int* error, const void* tcs) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_thread_set_event_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_thread_set_event_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_thread_set_event_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_thread_set_event_ocall_t)); + ocalloc_size -= sizeof(ms_u_thread_set_event_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_tcs = tcs; + status = sgx_ocall(0, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_thread_wait_event_ocall(int* retval, int* error, const void* tcs, const struct timespec* timeout) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_timeout = sizeof(struct timespec); + + ms_u_thread_wait_event_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_thread_wait_event_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(timeout, _len_timeout); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (timeout != NULL) ? _len_timeout : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_thread_wait_event_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_thread_wait_event_ocall_t)); + ocalloc_size -= sizeof(ms_u_thread_wait_event_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_tcs = tcs; + if (timeout != NULL) { + ms->ms_timeout = (const struct timespec*)__tmp; + if (memcpy_s(__tmp, ocalloc_size, timeout, _len_timeout)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_timeout); + ocalloc_size -= _len_timeout; + } else { + ms->ms_timeout = NULL; + } + + status = sgx_ocall(1, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_thread_set_multiple_events_ocall(int* retval, int* error, const void** tcss, int total) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_tcss = total * sizeof(void*); + + ms_u_thread_set_multiple_events_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_thread_set_multiple_events_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(tcss, _len_tcss); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (tcss != NULL) ? _len_tcss : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_thread_set_multiple_events_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_thread_set_multiple_events_ocall_t)); + ocalloc_size -= sizeof(ms_u_thread_set_multiple_events_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (tcss != NULL) { + ms->ms_tcss = (const void**)__tmp; + if (_len_tcss % sizeof(*tcss) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, tcss, _len_tcss)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_tcss); + ocalloc_size -= _len_tcss; + } else { + ms->ms_tcss = NULL; + } + + ms->ms_total = total; + status = sgx_ocall(2, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_thread_setwait_events_ocall(int* retval, int* error, const void* waiter_tcs, const void* self_tcs, const struct timespec* timeout) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_timeout = sizeof(struct timespec); + + ms_u_thread_setwait_events_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_thread_setwait_events_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(timeout, _len_timeout); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (timeout != NULL) ? _len_timeout : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_thread_setwait_events_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_thread_setwait_events_ocall_t)); + ocalloc_size -= sizeof(ms_u_thread_setwait_events_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_waiter_tcs = waiter_tcs; + ms->ms_self_tcs = self_tcs; + if (timeout != NULL) { + ms->ms_timeout = (const struct timespec*)__tmp; + if (memcpy_s(__tmp, ocalloc_size, timeout, _len_timeout)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_timeout); + ocalloc_size -= _len_timeout; + } else { + ms->ms_timeout = NULL; + } + + status = sgx_ocall(3, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_clock_gettime_ocall(int* retval, int* error, int clk_id, struct timespec* tp) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_tp = sizeof(struct timespec); + + ms_u_clock_gettime_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_clock_gettime_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_tp = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(tp, _len_tp); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (tp != NULL) ? _len_tp : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_clock_gettime_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_clock_gettime_ocall_t)); + ocalloc_size -= sizeof(ms_u_clock_gettime_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_clk_id = clk_id; + if (tp != NULL) { + ms->ms_tp = (struct timespec*)__tmp; + __tmp_tp = __tmp; + memset(__tmp_tp, 0, _len_tp); + __tmp = (void *)((size_t)__tmp + _len_tp); + ocalloc_size -= _len_tp; + } else { + ms->ms_tp = NULL; + } + + status = sgx_ocall(4, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (tp) { + if (memcpy_s((void*)tp, _len_tp, __tmp_tp, _len_tp)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_read_ocall(size_t* retval, int* error, int fd, void* buf, size_t count) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_read_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_read_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_read_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_read_ocall_t)); + ocalloc_size -= sizeof(ms_u_read_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_buf = buf; + ms->ms_count = count; + status = sgx_ocall(5, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_pread64_ocall(size_t* retval, int* error, int fd, void* buf, size_t count, int64_t offset) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_pread64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_pread64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_pread64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_pread64_ocall_t)); + ocalloc_size -= sizeof(ms_u_pread64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_buf = buf; + ms->ms_count = count; + ms->ms_offset = offset; + status = sgx_ocall(6, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_readv_ocall(size_t* retval, int* error, int fd, const struct iovec* iov, int iovcnt) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_iov = iovcnt * sizeof(struct iovec); + + ms_u_readv_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_readv_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(iov, _len_iov); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (iov != NULL) ? _len_iov : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_readv_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_readv_ocall_t)); + ocalloc_size -= sizeof(ms_u_readv_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + if (iov != NULL) { + ms->ms_iov = (const struct iovec*)__tmp; + if (memcpy_s(__tmp, ocalloc_size, iov, _len_iov)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_iov); + ocalloc_size -= _len_iov; + } else { + ms->ms_iov = NULL; + } + + ms->ms_iovcnt = iovcnt; + status = sgx_ocall(7, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_preadv64_ocall(size_t* retval, int* error, int fd, const struct iovec* iov, int iovcnt, int64_t offset) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_iov = iovcnt * sizeof(struct iovec); + + ms_u_preadv64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_preadv64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(iov, _len_iov); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (iov != NULL) ? _len_iov : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_preadv64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_preadv64_ocall_t)); + ocalloc_size -= sizeof(ms_u_preadv64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + if (iov != NULL) { + ms->ms_iov = (const struct iovec*)__tmp; + if (memcpy_s(__tmp, ocalloc_size, iov, _len_iov)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_iov); + ocalloc_size -= _len_iov; + } else { + ms->ms_iov = NULL; + } + + ms->ms_iovcnt = iovcnt; + ms->ms_offset = offset; + status = sgx_ocall(8, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_write_ocall(size_t* retval, int* error, int fd, const void* buf, size_t count) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_write_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_write_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_write_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_write_ocall_t)); + ocalloc_size -= sizeof(ms_u_write_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_buf = buf; + ms->ms_count = count; + status = sgx_ocall(9, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_pwrite64_ocall(size_t* retval, int* error, int fd, const void* buf, size_t count, int64_t offset) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_pwrite64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_pwrite64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_pwrite64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_pwrite64_ocall_t)); + ocalloc_size -= sizeof(ms_u_pwrite64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_buf = buf; + ms->ms_count = count; + ms->ms_offset = offset; + status = sgx_ocall(10, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_writev_ocall(size_t* retval, int* error, int fd, const struct iovec* iov, int iovcnt) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_iov = iovcnt * sizeof(struct iovec); + + ms_u_writev_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_writev_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(iov, _len_iov); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (iov != NULL) ? _len_iov : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_writev_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_writev_ocall_t)); + ocalloc_size -= sizeof(ms_u_writev_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + if (iov != NULL) { + ms->ms_iov = (const struct iovec*)__tmp; + if (memcpy_s(__tmp, ocalloc_size, iov, _len_iov)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_iov); + ocalloc_size -= _len_iov; + } else { + ms->ms_iov = NULL; + } + + ms->ms_iovcnt = iovcnt; + status = sgx_ocall(11, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_pwritev64_ocall(size_t* retval, int* error, int fd, const struct iovec* iov, int iovcnt, int64_t offset) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_iov = iovcnt * sizeof(struct iovec); + + ms_u_pwritev64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_pwritev64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(iov, _len_iov); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (iov != NULL) ? _len_iov : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_pwritev64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_pwritev64_ocall_t)); + ocalloc_size -= sizeof(ms_u_pwritev64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + if (iov != NULL) { + ms->ms_iov = (const struct iovec*)__tmp; + if (memcpy_s(__tmp, ocalloc_size, iov, _len_iov)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_iov); + ocalloc_size -= _len_iov; + } else { + ms->ms_iov = NULL; + } + + ms->ms_iovcnt = iovcnt; + ms->ms_offset = offset; + status = sgx_ocall(12, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_fcntl_arg0_ocall(int* retval, int* error, int fd, int cmd) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_fcntl_arg0_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_fcntl_arg0_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_fcntl_arg0_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_fcntl_arg0_ocall_t)); + ocalloc_size -= sizeof(ms_u_fcntl_arg0_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_cmd = cmd; + status = sgx_ocall(13, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_fcntl_arg1_ocall(int* retval, int* error, int fd, int cmd, int arg) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_fcntl_arg1_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_fcntl_arg1_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_fcntl_arg1_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_fcntl_arg1_ocall_t)); + ocalloc_size -= sizeof(ms_u_fcntl_arg1_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_cmd = cmd; + ms->ms_arg = arg; + status = sgx_ocall(14, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_ioctl_arg0_ocall(int* retval, int* error, int fd, int request) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_ioctl_arg0_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_ioctl_arg0_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_ioctl_arg0_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_ioctl_arg0_ocall_t)); + ocalloc_size -= sizeof(ms_u_ioctl_arg0_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_request = request; + status = sgx_ocall(15, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_ioctl_arg1_ocall(int* retval, int* error, int fd, int request, int* arg) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_arg = sizeof(int); + + ms_u_ioctl_arg1_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_ioctl_arg1_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_arg = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(arg, _len_arg); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (arg != NULL) ? _len_arg : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_ioctl_arg1_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_ioctl_arg1_ocall_t)); + ocalloc_size -= sizeof(ms_u_ioctl_arg1_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_request = request; + if (arg != NULL) { + ms->ms_arg = (int*)__tmp; + __tmp_arg = __tmp; + if (_len_arg % sizeof(*arg) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, arg, _len_arg)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_arg); + ocalloc_size -= _len_arg; + } else { + ms->ms_arg = NULL; + } + + status = sgx_ocall(16, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (arg) { + if (memcpy_s((void*)arg, _len_arg, __tmp_arg, _len_arg)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_close_ocall(int* retval, int* error, int fd) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_close_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_close_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_close_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_close_ocall_t)); + ocalloc_size -= sizeof(ms_u_close_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + status = sgx_ocall(17, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_malloc_ocall(void** retval, int* error, size_t size) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_malloc_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_malloc_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_malloc_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_malloc_ocall_t)); + ocalloc_size -= sizeof(ms_u_malloc_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_size = size; + status = sgx_ocall(18, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_free_ocall(void* p) +{ + sgx_status_t status = SGX_SUCCESS; + + ms_u_free_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_free_ocall_t); + void *__tmp = NULL; + + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_free_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_free_ocall_t)); + ocalloc_size -= sizeof(ms_u_free_ocall_t); + + ms->ms_p = p; + status = sgx_ocall(19, ms); + + if (status == SGX_SUCCESS) { + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_mmap_ocall(void** retval, int* error, void* start, size_t length, int prot, int flags, int fd, int64_t offset) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_mmap_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_mmap_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_mmap_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_mmap_ocall_t)); + ocalloc_size -= sizeof(ms_u_mmap_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_start = start; + ms->ms_length = length; + ms->ms_prot = prot; + ms->ms_flags = flags; + ms->ms_fd = fd; + ms->ms_offset = offset; + status = sgx_ocall(20, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_munmap_ocall(int* retval, int* error, void* start, size_t length) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_munmap_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_munmap_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_munmap_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_munmap_ocall_t)); + ocalloc_size -= sizeof(ms_u_munmap_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_start = start; + ms->ms_length = length; + status = sgx_ocall(21, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_msync_ocall(int* retval, int* error, void* addr, size_t length, int flags) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_msync_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_msync_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_msync_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_msync_ocall_t)); + ocalloc_size -= sizeof(ms_u_msync_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_addr = addr; + ms->ms_length = length; + ms->ms_flags = flags; + status = sgx_ocall(22, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_mprotect_ocall(int* retval, int* error, void* addr, size_t length, int prot) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_mprotect_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_mprotect_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_mprotect_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_mprotect_ocall_t)); + ocalloc_size -= sizeof(ms_u_mprotect_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_addr = addr; + ms->ms_length = length; + ms->ms_prot = prot; + status = sgx_ocall(23, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_open_ocall(int* retval, int* error, const char* pathname, int flags) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_pathname = pathname ? strlen(pathname) + 1 : 0; + + ms_u_open_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_open_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(pathname, _len_pathname); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (pathname != NULL) ? _len_pathname : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_open_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_open_ocall_t)); + ocalloc_size -= sizeof(ms_u_open_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (pathname != NULL) { + ms->ms_pathname = (const char*)__tmp; + if (_len_pathname % sizeof(*pathname) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, pathname, _len_pathname)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_pathname); + ocalloc_size -= _len_pathname; + } else { + ms->ms_pathname = NULL; + } + + ms->ms_flags = flags; + status = sgx_ocall(24, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_open64_ocall(int* retval, int* error, const char* path, int oflag, int mode) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + + ms_u_open64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_open64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_open64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_open64_ocall_t)); + ocalloc_size -= sizeof(ms_u_open64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + ms->ms_oflag = oflag; + ms->ms_mode = mode; + status = sgx_ocall(25, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_fstat_ocall(int* retval, int* error, int fd, struct stat_t* buf) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_buf = sizeof(struct stat_t); + + ms_u_fstat_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_fstat_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_fstat_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_fstat_ocall_t)); + ocalloc_size -= sizeof(ms_u_fstat_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + if (buf != NULL) { + ms->ms_buf = (struct stat_t*)__tmp; + __tmp_buf = __tmp; + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + status = sgx_ocall(26, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_fstat64_ocall(int* retval, int* error, int fd, struct stat64_t* buf) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_buf = sizeof(struct stat64_t); + + ms_u_fstat64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_fstat64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_fstat64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_fstat64_ocall_t)); + ocalloc_size -= sizeof(ms_u_fstat64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + if (buf != NULL) { + ms->ms_buf = (struct stat64_t*)__tmp; + __tmp_buf = __tmp; + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + status = sgx_ocall(27, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_stat_ocall(int* retval, int* error, const char* path, struct stat_t* buf) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + size_t _len_buf = sizeof(struct stat_t); + + ms_u_stat_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_stat_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_stat_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_stat_ocall_t)); + ocalloc_size -= sizeof(ms_u_stat_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + if (buf != NULL) { + ms->ms_buf = (struct stat_t*)__tmp; + __tmp_buf = __tmp; + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + status = sgx_ocall(28, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_stat64_ocall(int* retval, int* error, const char* path, struct stat64_t* buf) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + size_t _len_buf = sizeof(struct stat64_t); + + ms_u_stat64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_stat64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_stat64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_stat64_ocall_t)); + ocalloc_size -= sizeof(ms_u_stat64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + if (buf != NULL) { + ms->ms_buf = (struct stat64_t*)__tmp; + __tmp_buf = __tmp; + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + status = sgx_ocall(29, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_lstat_ocall(int* retval, int* error, const char* path, struct stat_t* buf) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + size_t _len_buf = sizeof(struct stat_t); + + ms_u_lstat_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_lstat_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_lstat_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_lstat_ocall_t)); + ocalloc_size -= sizeof(ms_u_lstat_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + if (buf != NULL) { + ms->ms_buf = (struct stat_t*)__tmp; + __tmp_buf = __tmp; + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + status = sgx_ocall(30, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_lstat64_ocall(int* retval, int* error, const char* path, struct stat64_t* buf) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + size_t _len_buf = sizeof(struct stat64_t); + + ms_u_lstat64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_lstat64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_lstat64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_lstat64_ocall_t)); + ocalloc_size -= sizeof(ms_u_lstat64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + if (buf != NULL) { + ms->ms_buf = (struct stat64_t*)__tmp; + __tmp_buf = __tmp; + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + status = sgx_ocall(31, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_lseek_ocall(uint64_t* retval, int* error, int fd, int64_t offset, int whence) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_lseek_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_lseek_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_lseek_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_lseek_ocall_t)); + ocalloc_size -= sizeof(ms_u_lseek_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_offset = offset; + ms->ms_whence = whence; + status = sgx_ocall(32, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_lseek64_ocall(int64_t* retval, int* error, int fd, int64_t offset, int whence) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_lseek64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_lseek64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_lseek64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_lseek64_ocall_t)); + ocalloc_size -= sizeof(ms_u_lseek64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_offset = offset; + ms->ms_whence = whence; + status = sgx_ocall(33, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_ftruncate_ocall(int* retval, int* error, int fd, int64_t length) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_ftruncate_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_ftruncate_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_ftruncate_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_ftruncate_ocall_t)); + ocalloc_size -= sizeof(ms_u_ftruncate_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_length = length; + status = sgx_ocall(34, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_ftruncate64_ocall(int* retval, int* error, int fd, int64_t length) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_ftruncate64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_ftruncate64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_ftruncate64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_ftruncate64_ocall_t)); + ocalloc_size -= sizeof(ms_u_ftruncate64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_length = length; + status = sgx_ocall(35, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_truncate_ocall(int* retval, int* error, const char* path, int64_t length) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + + ms_u_truncate_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_truncate_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_truncate_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_truncate_ocall_t)); + ocalloc_size -= sizeof(ms_u_truncate_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + ms->ms_length = length; + status = sgx_ocall(36, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_truncate64_ocall(int* retval, int* error, const char* path, int64_t length) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + + ms_u_truncate64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_truncate64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_truncate64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_truncate64_ocall_t)); + ocalloc_size -= sizeof(ms_u_truncate64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + ms->ms_length = length; + status = sgx_ocall(37, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_fsync_ocall(int* retval, int* error, int fd) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_fsync_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_fsync_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_fsync_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_fsync_ocall_t)); + ocalloc_size -= sizeof(ms_u_fsync_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + status = sgx_ocall(38, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_fdatasync_ocall(int* retval, int* error, int fd) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_fdatasync_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_fdatasync_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_fdatasync_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_fdatasync_ocall_t)); + ocalloc_size -= sizeof(ms_u_fdatasync_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + status = sgx_ocall(39, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_fchmod_ocall(int* retval, int* error, int fd, uint32_t mode) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_fchmod_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_fchmod_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_fchmod_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_fchmod_ocall_t)); + ocalloc_size -= sizeof(ms_u_fchmod_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_mode = mode; + status = sgx_ocall(40, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_unlink_ocall(int* retval, int* error, const char* pathname) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_pathname = pathname ? strlen(pathname) + 1 : 0; + + ms_u_unlink_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_unlink_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(pathname, _len_pathname); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (pathname != NULL) ? _len_pathname : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_unlink_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_unlink_ocall_t)); + ocalloc_size -= sizeof(ms_u_unlink_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (pathname != NULL) { + ms->ms_pathname = (const char*)__tmp; + if (_len_pathname % sizeof(*pathname) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, pathname, _len_pathname)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_pathname); + ocalloc_size -= _len_pathname; + } else { + ms->ms_pathname = NULL; + } + + status = sgx_ocall(41, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_link_ocall(int* retval, int* error, const char* oldpath, const char* newpath) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_oldpath = oldpath ? strlen(oldpath) + 1 : 0; + size_t _len_newpath = newpath ? strlen(newpath) + 1 : 0; + + ms_u_link_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_link_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(oldpath, _len_oldpath); + CHECK_ENCLAVE_POINTER(newpath, _len_newpath); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (oldpath != NULL) ? _len_oldpath : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (newpath != NULL) ? _len_newpath : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_link_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_link_ocall_t)); + ocalloc_size -= sizeof(ms_u_link_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (oldpath != NULL) { + ms->ms_oldpath = (const char*)__tmp; + if (_len_oldpath % sizeof(*oldpath) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, oldpath, _len_oldpath)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_oldpath); + ocalloc_size -= _len_oldpath; + } else { + ms->ms_oldpath = NULL; + } + + if (newpath != NULL) { + ms->ms_newpath = (const char*)__tmp; + if (_len_newpath % sizeof(*newpath) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, newpath, _len_newpath)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_newpath); + ocalloc_size -= _len_newpath; + } else { + ms->ms_newpath = NULL; + } + + status = sgx_ocall(42, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_linkat_ocall(int* retval, int* error, int olddirfd, const char* oldpath, int newdirfd, const char* newpath, int flags) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_oldpath = oldpath ? strlen(oldpath) + 1 : 0; + size_t _len_newpath = newpath ? strlen(newpath) + 1 : 0; + + ms_u_linkat_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_linkat_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(oldpath, _len_oldpath); + CHECK_ENCLAVE_POINTER(newpath, _len_newpath); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (oldpath != NULL) ? _len_oldpath : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (newpath != NULL) ? _len_newpath : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_linkat_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_linkat_ocall_t)); + ocalloc_size -= sizeof(ms_u_linkat_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_olddirfd = olddirfd; + if (oldpath != NULL) { + ms->ms_oldpath = (const char*)__tmp; + if (_len_oldpath % sizeof(*oldpath) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, oldpath, _len_oldpath)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_oldpath); + ocalloc_size -= _len_oldpath; + } else { + ms->ms_oldpath = NULL; + } + + ms->ms_newdirfd = newdirfd; + if (newpath != NULL) { + ms->ms_newpath = (const char*)__tmp; + if (_len_newpath % sizeof(*newpath) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, newpath, _len_newpath)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_newpath); + ocalloc_size -= _len_newpath; + } else { + ms->ms_newpath = NULL; + } + + ms->ms_flags = flags; + status = sgx_ocall(43, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_rename_ocall(int* retval, int* error, const char* oldpath, const char* newpath) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_oldpath = oldpath ? strlen(oldpath) + 1 : 0; + size_t _len_newpath = newpath ? strlen(newpath) + 1 : 0; + + ms_u_rename_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_rename_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(oldpath, _len_oldpath); + CHECK_ENCLAVE_POINTER(newpath, _len_newpath); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (oldpath != NULL) ? _len_oldpath : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (newpath != NULL) ? _len_newpath : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_rename_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_rename_ocall_t)); + ocalloc_size -= sizeof(ms_u_rename_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (oldpath != NULL) { + ms->ms_oldpath = (const char*)__tmp; + if (_len_oldpath % sizeof(*oldpath) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, oldpath, _len_oldpath)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_oldpath); + ocalloc_size -= _len_oldpath; + } else { + ms->ms_oldpath = NULL; + } + + if (newpath != NULL) { + ms->ms_newpath = (const char*)__tmp; + if (_len_newpath % sizeof(*newpath) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, newpath, _len_newpath)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_newpath); + ocalloc_size -= _len_newpath; + } else { + ms->ms_newpath = NULL; + } + + status = sgx_ocall(44, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_chmod_ocall(int* retval, int* error, const char* path, uint32_t mode) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + + ms_u_chmod_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_chmod_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_chmod_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_chmod_ocall_t)); + ocalloc_size -= sizeof(ms_u_chmod_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + ms->ms_mode = mode; + status = sgx_ocall(45, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_readlink_ocall(size_t* retval, int* error, const char* path, char* buf, size_t bufsz) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + size_t _len_buf = bufsz; + + ms_u_readlink_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_readlink_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_readlink_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_readlink_ocall_t)); + ocalloc_size -= sizeof(ms_u_readlink_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + if (buf != NULL) { + ms->ms_buf = (char*)__tmp; + __tmp_buf = __tmp; + if (_len_buf % sizeof(*buf) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + ms->ms_bufsz = bufsz; + status = sgx_ocall(46, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_symlink_ocall(int* retval, int* error, const char* path1, const char* path2) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path1 = path1 ? strlen(path1) + 1 : 0; + size_t _len_path2 = path2 ? strlen(path2) + 1 : 0; + + ms_u_symlink_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_symlink_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path1, _len_path1); + CHECK_ENCLAVE_POINTER(path2, _len_path2); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path1 != NULL) ? _len_path1 : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path2 != NULL) ? _len_path2 : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_symlink_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_symlink_ocall_t)); + ocalloc_size -= sizeof(ms_u_symlink_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path1 != NULL) { + ms->ms_path1 = (const char*)__tmp; + if (_len_path1 % sizeof(*path1) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path1, _len_path1)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path1); + ocalloc_size -= _len_path1; + } else { + ms->ms_path1 = NULL; + } + + if (path2 != NULL) { + ms->ms_path2 = (const char*)__tmp; + if (_len_path2 % sizeof(*path2) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path2, _len_path2)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path2); + ocalloc_size -= _len_path2; + } else { + ms->ms_path2 = NULL; + } + + status = sgx_ocall(47, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_realpath_ocall(char** retval, int* error, const char* pathname) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_pathname = pathname ? strlen(pathname) + 1 : 0; + + ms_u_realpath_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_realpath_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(pathname, _len_pathname); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (pathname != NULL) ? _len_pathname : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_realpath_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_realpath_ocall_t)); + ocalloc_size -= sizeof(ms_u_realpath_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (pathname != NULL) { + ms->ms_pathname = (const char*)__tmp; + if (_len_pathname % sizeof(*pathname) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, pathname, _len_pathname)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_pathname); + ocalloc_size -= _len_pathname; + } else { + ms->ms_pathname = NULL; + } + + status = sgx_ocall(48, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_mkdir_ocall(int* retval, int* error, const char* pathname, uint32_t mode) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_pathname = pathname ? strlen(pathname) + 1 : 0; + + ms_u_mkdir_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_mkdir_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(pathname, _len_pathname); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (pathname != NULL) ? _len_pathname : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_mkdir_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_mkdir_ocall_t)); + ocalloc_size -= sizeof(ms_u_mkdir_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (pathname != NULL) { + ms->ms_pathname = (const char*)__tmp; + if (_len_pathname % sizeof(*pathname) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, pathname, _len_pathname)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_pathname); + ocalloc_size -= _len_pathname; + } else { + ms->ms_pathname = NULL; + } + + ms->ms_mode = mode; + status = sgx_ocall(49, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_rmdir_ocall(int* retval, int* error, const char* pathname) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_pathname = pathname ? strlen(pathname) + 1 : 0; + + ms_u_rmdir_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_rmdir_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(pathname, _len_pathname); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (pathname != NULL) ? _len_pathname : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_rmdir_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_rmdir_ocall_t)); + ocalloc_size -= sizeof(ms_u_rmdir_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (pathname != NULL) { + ms->ms_pathname = (const char*)__tmp; + if (_len_pathname % sizeof(*pathname) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, pathname, _len_pathname)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_pathname); + ocalloc_size -= _len_pathname; + } else { + ms->ms_pathname = NULL; + } + + status = sgx_ocall(50, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_opendir_ocall(void** retval, int* error, const char* pathname) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_pathname = pathname ? strlen(pathname) + 1 : 0; + + ms_u_opendir_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_opendir_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(pathname, _len_pathname); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (pathname != NULL) ? _len_pathname : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_opendir_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_opendir_ocall_t)); + ocalloc_size -= sizeof(ms_u_opendir_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (pathname != NULL) { + ms->ms_pathname = (const char*)__tmp; + if (_len_pathname % sizeof(*pathname) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, pathname, _len_pathname)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_pathname); + ocalloc_size -= _len_pathname; + } else { + ms->ms_pathname = NULL; + } + + status = sgx_ocall(51, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_readdir64_r_ocall(int* retval, void* dirp, struct dirent64_t* entry, struct dirent64_t** result) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_entry = sizeof(struct dirent64_t); + size_t _len_result = sizeof(struct dirent64_t*); + + ms_u_readdir64_r_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_readdir64_r_ocall_t); + void *__tmp = NULL; + + void *__tmp_entry = NULL; + void *__tmp_result = NULL; + + CHECK_ENCLAVE_POINTER(entry, _len_entry); + CHECK_ENCLAVE_POINTER(result, _len_result); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (entry != NULL) ? _len_entry : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (result != NULL) ? _len_result : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_readdir64_r_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_readdir64_r_ocall_t)); + ocalloc_size -= sizeof(ms_u_readdir64_r_ocall_t); + + ms->ms_dirp = dirp; + if (entry != NULL) { + ms->ms_entry = (struct dirent64_t*)__tmp; + __tmp_entry = __tmp; + if (memcpy_s(__tmp, ocalloc_size, entry, _len_entry)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_entry); + ocalloc_size -= _len_entry; + } else { + ms->ms_entry = NULL; + } + + if (result != NULL) { + ms->ms_result = (struct dirent64_t**)__tmp; + __tmp_result = __tmp; + if (_len_result % sizeof(*result) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_result, 0, _len_result); + __tmp = (void *)((size_t)__tmp + _len_result); + ocalloc_size -= _len_result; + } else { + ms->ms_result = NULL; + } + + status = sgx_ocall(52, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (entry) { + if (memcpy_s((void*)entry, _len_entry, __tmp_entry, _len_entry)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (result) { + if (memcpy_s((void*)result, _len_result, __tmp_result, _len_result)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_closedir_ocall(int* retval, int* error, void* dirp) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_closedir_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_closedir_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_closedir_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_closedir_ocall_t)); + ocalloc_size -= sizeof(ms_u_closedir_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_dirp = dirp; + status = sgx_ocall(53, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_dirfd_ocall(int* retval, int* error, void* dirp) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_dirfd_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_dirfd_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_dirfd_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_dirfd_ocall_t)); + ocalloc_size -= sizeof(ms_u_dirfd_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_dirp = dirp; + status = sgx_ocall(54, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_fstatat64_ocall(int* retval, int* error, int dirfd, const char* pathname, struct stat64_t* buf, int flags) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_pathname = pathname ? strlen(pathname) + 1 : 0; + size_t _len_buf = sizeof(struct stat64_t); + + ms_u_fstatat64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_fstatat64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(pathname, _len_pathname); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (pathname != NULL) ? _len_pathname : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_fstatat64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_fstatat64_ocall_t)); + ocalloc_size -= sizeof(ms_u_fstatat64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_dirfd = dirfd; + if (pathname != NULL) { + ms->ms_pathname = (const char*)__tmp; + if (_len_pathname % sizeof(*pathname) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, pathname, _len_pathname)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_pathname); + ocalloc_size -= _len_pathname; + } else { + ms->ms_pathname = NULL; + } + + if (buf != NULL) { + ms->ms_buf = (struct stat64_t*)__tmp; + __tmp_buf = __tmp; + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + ms->ms_flags = flags; + status = sgx_ocall(55, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_environ_ocall(char*** retval) +{ + sgx_status_t status = SGX_SUCCESS; + + ms_u_environ_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_environ_ocall_t); + void *__tmp = NULL; + + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_environ_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_environ_ocall_t)); + ocalloc_size -= sizeof(ms_u_environ_ocall_t); + + status = sgx_ocall(56, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_getenv_ocall(char** retval, const char* name) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_name = name ? strlen(name) + 1 : 0; + + ms_u_getenv_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_getenv_ocall_t); + void *__tmp = NULL; + + + CHECK_ENCLAVE_POINTER(name, _len_name); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (name != NULL) ? _len_name : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_getenv_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_getenv_ocall_t)); + ocalloc_size -= sizeof(ms_u_getenv_ocall_t); + + if (name != NULL) { + ms->ms_name = (const char*)__tmp; + if (_len_name % sizeof(*name) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, name, _len_name)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_name); + ocalloc_size -= _len_name; + } else { + ms->ms_name = NULL; + } + + status = sgx_ocall(57, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_setenv_ocall(int* retval, int* error, const char* name, const char* value, int overwrite) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_name = name ? strlen(name) + 1 : 0; + size_t _len_value = value ? strlen(value) + 1 : 0; + + ms_u_setenv_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_setenv_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(name, _len_name); + CHECK_ENCLAVE_POINTER(value, _len_value); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (name != NULL) ? _len_name : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (value != NULL) ? _len_value : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_setenv_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_setenv_ocall_t)); + ocalloc_size -= sizeof(ms_u_setenv_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (name != NULL) { + ms->ms_name = (const char*)__tmp; + if (_len_name % sizeof(*name) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, name, _len_name)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_name); + ocalloc_size -= _len_name; + } else { + ms->ms_name = NULL; + } + + if (value != NULL) { + ms->ms_value = (const char*)__tmp; + if (_len_value % sizeof(*value) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, value, _len_value)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_value); + ocalloc_size -= _len_value; + } else { + ms->ms_value = NULL; + } + + ms->ms_overwrite = overwrite; + status = sgx_ocall(58, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_unsetenv_ocall(int* retval, int* error, const char* name) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_name = name ? strlen(name) + 1 : 0; + + ms_u_unsetenv_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_unsetenv_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(name, _len_name); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (name != NULL) ? _len_name : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_unsetenv_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_unsetenv_ocall_t)); + ocalloc_size -= sizeof(ms_u_unsetenv_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (name != NULL) { + ms->ms_name = (const char*)__tmp; + if (_len_name % sizeof(*name) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, name, _len_name)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_name); + ocalloc_size -= _len_name; + } else { + ms->ms_name = NULL; + } + + status = sgx_ocall(59, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_chdir_ocall(int* retval, int* error, const char* dir) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_dir = dir ? strlen(dir) + 1 : 0; + + ms_u_chdir_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_chdir_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(dir, _len_dir); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (dir != NULL) ? _len_dir : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_chdir_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_chdir_ocall_t)); + ocalloc_size -= sizeof(ms_u_chdir_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (dir != NULL) { + ms->ms_dir = (const char*)__tmp; + if (_len_dir % sizeof(*dir) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, dir, _len_dir)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_dir); + ocalloc_size -= _len_dir; + } else { + ms->ms_dir = NULL; + } + + status = sgx_ocall(60, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_getcwd_ocall(char** retval, int* error, char* buf, size_t buflen) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_buf = buflen; + + ms_u_getcwd_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_getcwd_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_getcwd_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_getcwd_ocall_t)); + ocalloc_size -= sizeof(ms_u_getcwd_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (buf != NULL) { + ms->ms_buf = (char*)__tmp; + __tmp_buf = __tmp; + if (_len_buf % sizeof(*buf) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + ms->ms_buflen = buflen; + status = sgx_ocall(61, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_getpwuid_r_ocall(int* retval, unsigned int uid, struct passwd* pwd, char* buf, size_t buflen, struct passwd** passwd_result) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_pwd = sizeof(struct passwd); + size_t _len_buf = buflen; + size_t _len_passwd_result = sizeof(struct passwd*); + + ms_u_getpwuid_r_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_getpwuid_r_ocall_t); + void *__tmp = NULL; + + void *__tmp_pwd = NULL; + void *__tmp_buf = NULL; + void *__tmp_passwd_result = NULL; + + CHECK_ENCLAVE_POINTER(pwd, _len_pwd); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + CHECK_ENCLAVE_POINTER(passwd_result, _len_passwd_result); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (pwd != NULL) ? _len_pwd : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (passwd_result != NULL) ? _len_passwd_result : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_getpwuid_r_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_getpwuid_r_ocall_t)); + ocalloc_size -= sizeof(ms_u_getpwuid_r_ocall_t); + + ms->ms_uid = uid; + if (pwd != NULL) { + ms->ms_pwd = (struct passwd*)__tmp; + __tmp_pwd = __tmp; + memset(__tmp_pwd, 0, _len_pwd); + __tmp = (void *)((size_t)__tmp + _len_pwd); + ocalloc_size -= _len_pwd; + } else { + ms->ms_pwd = NULL; + } + + if (buf != NULL) { + ms->ms_buf = (char*)__tmp; + __tmp_buf = __tmp; + if (_len_buf % sizeof(*buf) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + ms->ms_buflen = buflen; + if (passwd_result != NULL) { + ms->ms_passwd_result = (struct passwd**)__tmp; + __tmp_passwd_result = __tmp; + if (_len_passwd_result % sizeof(*passwd_result) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_passwd_result, 0, _len_passwd_result); + __tmp = (void *)((size_t)__tmp + _len_passwd_result); + ocalloc_size -= _len_passwd_result; + } else { + ms->ms_passwd_result = NULL; + } + + status = sgx_ocall(62, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (pwd) { + if (memcpy_s((void*)pwd, _len_pwd, __tmp_pwd, _len_pwd)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (passwd_result) { + if (memcpy_s((void*)passwd_result, _len_passwd_result, __tmp_passwd_result, _len_passwd_result)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_getuid_ocall(unsigned int* retval) +{ + sgx_status_t status = SGX_SUCCESS; + + ms_u_getuid_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_getuid_ocall_t); + void *__tmp = NULL; + + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_getuid_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_getuid_ocall_t)); + ocalloc_size -= sizeof(ms_u_getuid_ocall_t); + + status = sgx_ocall(63, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_sgxprotectedfs_exclusive_file_open(void** retval, const char* filename, uint8_t read_only, int64_t* file_size, int32_t* error_code) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_filename = filename ? strlen(filename) + 1 : 0; + size_t _len_file_size = sizeof(int64_t); + size_t _len_error_code = sizeof(int32_t); + + ms_u_sgxprotectedfs_exclusive_file_open_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_sgxprotectedfs_exclusive_file_open_t); + void *__tmp = NULL; + + void *__tmp_file_size = NULL; + void *__tmp_error_code = NULL; + + CHECK_ENCLAVE_POINTER(filename, _len_filename); + CHECK_ENCLAVE_POINTER(file_size, _len_file_size); + CHECK_ENCLAVE_POINTER(error_code, _len_error_code); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (filename != NULL) ? _len_filename : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (file_size != NULL) ? _len_file_size : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error_code != NULL) ? _len_error_code : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_sgxprotectedfs_exclusive_file_open_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_sgxprotectedfs_exclusive_file_open_t)); + ocalloc_size -= sizeof(ms_u_sgxprotectedfs_exclusive_file_open_t); + + if (filename != NULL) { + ms->ms_filename = (const char*)__tmp; + if (_len_filename % sizeof(*filename) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, filename, _len_filename)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_filename); + ocalloc_size -= _len_filename; + } else { + ms->ms_filename = NULL; + } + + ms->ms_read_only = read_only; + if (file_size != NULL) { + ms->ms_file_size = (int64_t*)__tmp; + __tmp_file_size = __tmp; + if (_len_file_size % sizeof(*file_size) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_file_size, 0, _len_file_size); + __tmp = (void *)((size_t)__tmp + _len_file_size); + ocalloc_size -= _len_file_size; + } else { + ms->ms_file_size = NULL; + } + + if (error_code != NULL) { + ms->ms_error_code = (int32_t*)__tmp; + __tmp_error_code = __tmp; + if (_len_error_code % sizeof(*error_code) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error_code, 0, _len_error_code); + __tmp = (void *)((size_t)__tmp + _len_error_code); + ocalloc_size -= _len_error_code; + } else { + ms->ms_error_code = NULL; + } + + status = sgx_ocall(64, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (file_size) { + if (memcpy_s((void*)file_size, _len_file_size, __tmp_file_size, _len_file_size)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (error_code) { + if (memcpy_s((void*)error_code, _len_error_code, __tmp_error_code, _len_error_code)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_sgxprotectedfs_check_if_file_exists(uint8_t* retval, const char* filename) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_filename = filename ? strlen(filename) + 1 : 0; + + ms_u_sgxprotectedfs_check_if_file_exists_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_sgxprotectedfs_check_if_file_exists_t); + void *__tmp = NULL; + + + CHECK_ENCLAVE_POINTER(filename, _len_filename); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (filename != NULL) ? _len_filename : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_sgxprotectedfs_check_if_file_exists_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_sgxprotectedfs_check_if_file_exists_t)); + ocalloc_size -= sizeof(ms_u_sgxprotectedfs_check_if_file_exists_t); + + if (filename != NULL) { + ms->ms_filename = (const char*)__tmp; + if (_len_filename % sizeof(*filename) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, filename, _len_filename)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_filename); + ocalloc_size -= _len_filename; + } else { + ms->ms_filename = NULL; + } + + status = sgx_ocall(65, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_sgxprotectedfs_fread_node(int32_t* retval, void* f, uint64_t node_number, uint8_t* buffer, uint32_t node_size) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_buffer = node_size; + + ms_u_sgxprotectedfs_fread_node_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_sgxprotectedfs_fread_node_t); + void *__tmp = NULL; + + void *__tmp_buffer = NULL; + + CHECK_ENCLAVE_POINTER(buffer, _len_buffer); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buffer != NULL) ? _len_buffer : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_sgxprotectedfs_fread_node_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_sgxprotectedfs_fread_node_t)); + ocalloc_size -= sizeof(ms_u_sgxprotectedfs_fread_node_t); + + ms->ms_f = f; + ms->ms_node_number = node_number; + if (buffer != NULL) { + ms->ms_buffer = (uint8_t*)__tmp; + __tmp_buffer = __tmp; + if (_len_buffer % sizeof(*buffer) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_buffer, 0, _len_buffer); + __tmp = (void *)((size_t)__tmp + _len_buffer); + ocalloc_size -= _len_buffer; + } else { + ms->ms_buffer = NULL; + } + + ms->ms_node_size = node_size; + status = sgx_ocall(66, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (buffer) { + if (memcpy_s((void*)buffer, _len_buffer, __tmp_buffer, _len_buffer)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_sgxprotectedfs_fwrite_node(int32_t* retval, void* f, uint64_t node_number, uint8_t* buffer, uint32_t node_size) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_buffer = node_size; + + ms_u_sgxprotectedfs_fwrite_node_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_sgxprotectedfs_fwrite_node_t); + void *__tmp = NULL; + + + CHECK_ENCLAVE_POINTER(buffer, _len_buffer); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buffer != NULL) ? _len_buffer : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_sgxprotectedfs_fwrite_node_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_sgxprotectedfs_fwrite_node_t)); + ocalloc_size -= sizeof(ms_u_sgxprotectedfs_fwrite_node_t); + + ms->ms_f = f; + ms->ms_node_number = node_number; + if (buffer != NULL) { + ms->ms_buffer = (uint8_t*)__tmp; + if (_len_buffer % sizeof(*buffer) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, buffer, _len_buffer)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_buffer); + ocalloc_size -= _len_buffer; + } else { + ms->ms_buffer = NULL; + } + + ms->ms_node_size = node_size; + status = sgx_ocall(67, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_sgxprotectedfs_fclose(int32_t* retval, void* f) +{ + sgx_status_t status = SGX_SUCCESS; + + ms_u_sgxprotectedfs_fclose_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_sgxprotectedfs_fclose_t); + void *__tmp = NULL; + + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_sgxprotectedfs_fclose_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_sgxprotectedfs_fclose_t)); + ocalloc_size -= sizeof(ms_u_sgxprotectedfs_fclose_t); + + ms->ms_f = f; + status = sgx_ocall(68, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_sgxprotectedfs_fflush(uint8_t* retval, void* f) +{ + sgx_status_t status = SGX_SUCCESS; + + ms_u_sgxprotectedfs_fflush_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_sgxprotectedfs_fflush_t); + void *__tmp = NULL; + + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_sgxprotectedfs_fflush_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_sgxprotectedfs_fflush_t)); + ocalloc_size -= sizeof(ms_u_sgxprotectedfs_fflush_t); + + ms->ms_f = f; + status = sgx_ocall(69, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_sgxprotectedfs_remove(int32_t* retval, const char* filename) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_filename = filename ? strlen(filename) + 1 : 0; + + ms_u_sgxprotectedfs_remove_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_sgxprotectedfs_remove_t); + void *__tmp = NULL; + + + CHECK_ENCLAVE_POINTER(filename, _len_filename); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (filename != NULL) ? _len_filename : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_sgxprotectedfs_remove_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_sgxprotectedfs_remove_t)); + ocalloc_size -= sizeof(ms_u_sgxprotectedfs_remove_t); + + if (filename != NULL) { + ms->ms_filename = (const char*)__tmp; + if (_len_filename % sizeof(*filename) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, filename, _len_filename)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_filename); + ocalloc_size -= _len_filename; + } else { + ms->ms_filename = NULL; + } + + status = sgx_ocall(70, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_sgxprotectedfs_recovery_file_open(void** retval, const char* filename) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_filename = filename ? strlen(filename) + 1 : 0; + + ms_u_sgxprotectedfs_recovery_file_open_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_sgxprotectedfs_recovery_file_open_t); + void *__tmp = NULL; + + + CHECK_ENCLAVE_POINTER(filename, _len_filename); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (filename != NULL) ? _len_filename : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_sgxprotectedfs_recovery_file_open_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_sgxprotectedfs_recovery_file_open_t)); + ocalloc_size -= sizeof(ms_u_sgxprotectedfs_recovery_file_open_t); + + if (filename != NULL) { + ms->ms_filename = (const char*)__tmp; + if (_len_filename % sizeof(*filename) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, filename, _len_filename)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_filename); + ocalloc_size -= _len_filename; + } else { + ms->ms_filename = NULL; + } + + status = sgx_ocall(71, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_sgxprotectedfs_fwrite_recovery_node(uint8_t* retval, void* f, uint8_t* data, uint32_t data_length) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_data = data_length * sizeof(uint8_t); + + ms_u_sgxprotectedfs_fwrite_recovery_node_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_sgxprotectedfs_fwrite_recovery_node_t); + void *__tmp = NULL; + + + CHECK_ENCLAVE_POINTER(data, _len_data); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (data != NULL) ? _len_data : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_sgxprotectedfs_fwrite_recovery_node_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_sgxprotectedfs_fwrite_recovery_node_t)); + ocalloc_size -= sizeof(ms_u_sgxprotectedfs_fwrite_recovery_node_t); + + ms->ms_f = f; + if (data != NULL) { + ms->ms_data = (uint8_t*)__tmp; + if (_len_data % sizeof(*data) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, data, _len_data)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_data); + ocalloc_size -= _len_data; + } else { + ms->ms_data = NULL; + } + + ms->ms_data_length = data_length; + status = sgx_ocall(72, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_sgxprotectedfs_do_file_recovery(int32_t* retval, const char* filename, const char* recovery_filename, uint32_t node_size) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_filename = filename ? strlen(filename) + 1 : 0; + size_t _len_recovery_filename = recovery_filename ? strlen(recovery_filename) + 1 : 0; + + ms_u_sgxprotectedfs_do_file_recovery_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_sgxprotectedfs_do_file_recovery_t); + void *__tmp = NULL; + + + CHECK_ENCLAVE_POINTER(filename, _len_filename); + CHECK_ENCLAVE_POINTER(recovery_filename, _len_recovery_filename); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (filename != NULL) ? _len_filename : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (recovery_filename != NULL) ? _len_recovery_filename : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_sgxprotectedfs_do_file_recovery_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_sgxprotectedfs_do_file_recovery_t)); + ocalloc_size -= sizeof(ms_u_sgxprotectedfs_do_file_recovery_t); + + if (filename != NULL) { + ms->ms_filename = (const char*)__tmp; + if (_len_filename % sizeof(*filename) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, filename, _len_filename)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_filename); + ocalloc_size -= _len_filename; + } else { + ms->ms_filename = NULL; + } + + if (recovery_filename != NULL) { + ms->ms_recovery_filename = (const char*)__tmp; + if (_len_recovery_filename % sizeof(*recovery_filename) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, recovery_filename, _len_recovery_filename)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_recovery_filename); + ocalloc_size -= _len_recovery_filename; + } else { + ms->ms_recovery_filename = NULL; + } + + ms->ms_node_size = node_size; + status = sgx_ocall(73, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL sgx_oc_cpuidex(int cpuinfo[4], int leaf, int subleaf) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_cpuinfo = 4 * sizeof(int); + + ms_sgx_oc_cpuidex_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_sgx_oc_cpuidex_t); + void *__tmp = NULL; + + void *__tmp_cpuinfo = NULL; + + CHECK_ENCLAVE_POINTER(cpuinfo, _len_cpuinfo); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (cpuinfo != NULL) ? _len_cpuinfo : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_sgx_oc_cpuidex_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_sgx_oc_cpuidex_t)); + ocalloc_size -= sizeof(ms_sgx_oc_cpuidex_t); + + if (cpuinfo != NULL) { + ms->ms_cpuinfo = (int*)__tmp; + __tmp_cpuinfo = __tmp; + if (_len_cpuinfo % sizeof(*cpuinfo) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_cpuinfo, 0, _len_cpuinfo); + __tmp = (void *)((size_t)__tmp + _len_cpuinfo); + ocalloc_size -= _len_cpuinfo; + } else { + ms->ms_cpuinfo = NULL; + } + + ms->ms_leaf = leaf; + ms->ms_subleaf = subleaf; + status = sgx_ocall(74, ms); + + if (status == SGX_SUCCESS) { + if (cpuinfo) { + if (memcpy_s((void*)cpuinfo, _len_cpuinfo, __tmp_cpuinfo, _len_cpuinfo)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL sgx_thread_wait_untrusted_event_ocall(int* retval, const void* self) +{ + sgx_status_t status = SGX_SUCCESS; + + ms_sgx_thread_wait_untrusted_event_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_sgx_thread_wait_untrusted_event_ocall_t); + void *__tmp = NULL; + + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_sgx_thread_wait_untrusted_event_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_sgx_thread_wait_untrusted_event_ocall_t)); + ocalloc_size -= sizeof(ms_sgx_thread_wait_untrusted_event_ocall_t); + + ms->ms_self = self; + status = sgx_ocall(75, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL sgx_thread_set_untrusted_event_ocall(int* retval, const void* waiter) +{ + sgx_status_t status = SGX_SUCCESS; + + ms_sgx_thread_set_untrusted_event_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_sgx_thread_set_untrusted_event_ocall_t); + void *__tmp = NULL; + + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_sgx_thread_set_untrusted_event_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_sgx_thread_set_untrusted_event_ocall_t)); + ocalloc_size -= sizeof(ms_sgx_thread_set_untrusted_event_ocall_t); + + ms->ms_waiter = waiter; + status = sgx_ocall(76, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL sgx_thread_setwait_untrusted_events_ocall(int* retval, const void* waiter, const void* self) +{ + sgx_status_t status = SGX_SUCCESS; + + ms_sgx_thread_setwait_untrusted_events_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_sgx_thread_setwait_untrusted_events_ocall_t); + void *__tmp = NULL; + + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_sgx_thread_setwait_untrusted_events_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_sgx_thread_setwait_untrusted_events_ocall_t)); + ocalloc_size -= sizeof(ms_sgx_thread_setwait_untrusted_events_ocall_t); + + ms->ms_waiter = waiter; + ms->ms_self = self; + status = sgx_ocall(77, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL sgx_thread_set_multiple_untrusted_events_ocall(int* retval, const void** waiters, size_t total) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_waiters = total * sizeof(void*); + + ms_sgx_thread_set_multiple_untrusted_events_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_sgx_thread_set_multiple_untrusted_events_ocall_t); + void *__tmp = NULL; + + + CHECK_ENCLAVE_POINTER(waiters, _len_waiters); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (waiters != NULL) ? _len_waiters : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_sgx_thread_set_multiple_untrusted_events_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_sgx_thread_set_multiple_untrusted_events_ocall_t)); + ocalloc_size -= sizeof(ms_sgx_thread_set_multiple_untrusted_events_ocall_t); + + if (waiters != NULL) { + ms->ms_waiters = (const void**)__tmp; + if (_len_waiters % sizeof(*waiters) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, waiters, _len_waiters)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_waiters); + ocalloc_size -= _len_waiters; + } else { + ms->ms_waiters = NULL; + } + + ms->ms_total = total; + status = sgx_ocall(78, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/codegen/Enclave_t.h b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/codegen/Enclave_t.h new file mode 100644 index 0000000..75ee22e --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/codegen/Enclave_t.h @@ -0,0 +1,112 @@ +#ifndef ENCLAVE_T_H__ +#define ENCLAVE_T_H__ + +#include +#include +#include +#include "sgx_edger8r.h" /* for sgx_ocall etc. */ + +#include "time.h" +#include "inc/stat.h" +#include "sys/uio.h" +#include "inc/stat.h" +#include "inc/dirent.h" +#include "pwd.h" + +#include /* for size_t */ + +#define SGX_CAST(type, item) ((type)(item)) + +#ifdef __cplusplus +extern "C" { +#endif + +size_t run_tests_ecall(void); +void t_global_init_ecall(uint64_t id, const uint8_t* path, size_t len); +void t_global_exit_ecall(void); + +sgx_status_t SGX_CDECL u_thread_set_event_ocall(int* retval, int* error, const void* tcs); +sgx_status_t SGX_CDECL u_thread_wait_event_ocall(int* retval, int* error, const void* tcs, const struct timespec* timeout); +sgx_status_t SGX_CDECL u_thread_set_multiple_events_ocall(int* retval, int* error, const void** tcss, int total); +sgx_status_t SGX_CDECL u_thread_setwait_events_ocall(int* retval, int* error, const void* waiter_tcs, const void* self_tcs, const struct timespec* timeout); +sgx_status_t SGX_CDECL u_clock_gettime_ocall(int* retval, int* error, int clk_id, struct timespec* tp); +sgx_status_t SGX_CDECL u_read_ocall(size_t* retval, int* error, int fd, void* buf, size_t count); +sgx_status_t SGX_CDECL u_pread64_ocall(size_t* retval, int* error, int fd, void* buf, size_t count, int64_t offset); +sgx_status_t SGX_CDECL u_readv_ocall(size_t* retval, int* error, int fd, const struct iovec* iov, int iovcnt); +sgx_status_t SGX_CDECL u_preadv64_ocall(size_t* retval, int* error, int fd, const struct iovec* iov, int iovcnt, int64_t offset); +sgx_status_t SGX_CDECL u_write_ocall(size_t* retval, int* error, int fd, const void* buf, size_t count); +sgx_status_t SGX_CDECL u_pwrite64_ocall(size_t* retval, int* error, int fd, const void* buf, size_t count, int64_t offset); +sgx_status_t SGX_CDECL u_writev_ocall(size_t* retval, int* error, int fd, const struct iovec* iov, int iovcnt); +sgx_status_t SGX_CDECL u_pwritev64_ocall(size_t* retval, int* error, int fd, const struct iovec* iov, int iovcnt, int64_t offset); +sgx_status_t SGX_CDECL u_fcntl_arg0_ocall(int* retval, int* error, int fd, int cmd); +sgx_status_t SGX_CDECL u_fcntl_arg1_ocall(int* retval, int* error, int fd, int cmd, int arg); +sgx_status_t SGX_CDECL u_ioctl_arg0_ocall(int* retval, int* error, int fd, int request); +sgx_status_t SGX_CDECL u_ioctl_arg1_ocall(int* retval, int* error, int fd, int request, int* arg); +sgx_status_t SGX_CDECL u_close_ocall(int* retval, int* error, int fd); +sgx_status_t SGX_CDECL u_malloc_ocall(void** retval, int* error, size_t size); +sgx_status_t SGX_CDECL u_free_ocall(void* p); +sgx_status_t SGX_CDECL u_mmap_ocall(void** retval, int* error, void* start, size_t length, int prot, int flags, int fd, int64_t offset); +sgx_status_t SGX_CDECL u_munmap_ocall(int* retval, int* error, void* start, size_t length); +sgx_status_t SGX_CDECL u_msync_ocall(int* retval, int* error, void* addr, size_t length, int flags); +sgx_status_t SGX_CDECL u_mprotect_ocall(int* retval, int* error, void* addr, size_t length, int prot); +sgx_status_t SGX_CDECL u_open_ocall(int* retval, int* error, const char* pathname, int flags); +sgx_status_t SGX_CDECL u_open64_ocall(int* retval, int* error, const char* path, int oflag, int mode); +sgx_status_t SGX_CDECL u_fstat_ocall(int* retval, int* error, int fd, struct stat_t* buf); +sgx_status_t SGX_CDECL u_fstat64_ocall(int* retval, int* error, int fd, struct stat64_t* buf); +sgx_status_t SGX_CDECL u_stat_ocall(int* retval, int* error, const char* path, struct stat_t* buf); +sgx_status_t SGX_CDECL u_stat64_ocall(int* retval, int* error, const char* path, struct stat64_t* buf); +sgx_status_t SGX_CDECL u_lstat_ocall(int* retval, int* error, const char* path, struct stat_t* buf); +sgx_status_t SGX_CDECL u_lstat64_ocall(int* retval, int* error, const char* path, struct stat64_t* buf); +sgx_status_t SGX_CDECL u_lseek_ocall(uint64_t* retval, int* error, int fd, int64_t offset, int whence); +sgx_status_t SGX_CDECL u_lseek64_ocall(int64_t* retval, int* error, int fd, int64_t offset, int whence); +sgx_status_t SGX_CDECL u_ftruncate_ocall(int* retval, int* error, int fd, int64_t length); +sgx_status_t SGX_CDECL u_ftruncate64_ocall(int* retval, int* error, int fd, int64_t length); +sgx_status_t SGX_CDECL u_truncate_ocall(int* retval, int* error, const char* path, int64_t length); +sgx_status_t SGX_CDECL u_truncate64_ocall(int* retval, int* error, const char* path, int64_t length); +sgx_status_t SGX_CDECL u_fsync_ocall(int* retval, int* error, int fd); +sgx_status_t SGX_CDECL u_fdatasync_ocall(int* retval, int* error, int fd); +sgx_status_t SGX_CDECL u_fchmod_ocall(int* retval, int* error, int fd, uint32_t mode); +sgx_status_t SGX_CDECL u_unlink_ocall(int* retval, int* error, const char* pathname); +sgx_status_t SGX_CDECL u_link_ocall(int* retval, int* error, const char* oldpath, const char* newpath); +sgx_status_t SGX_CDECL u_linkat_ocall(int* retval, int* error, int olddirfd, const char* oldpath, int newdirfd, const char* newpath, int flags); +sgx_status_t SGX_CDECL u_rename_ocall(int* retval, int* error, const char* oldpath, const char* newpath); +sgx_status_t SGX_CDECL u_chmod_ocall(int* retval, int* error, const char* path, uint32_t mode); +sgx_status_t SGX_CDECL u_readlink_ocall(size_t* retval, int* error, const char* path, char* buf, size_t bufsz); +sgx_status_t SGX_CDECL u_symlink_ocall(int* retval, int* error, const char* path1, const char* path2); +sgx_status_t SGX_CDECL u_realpath_ocall(char** retval, int* error, const char* pathname); +sgx_status_t SGX_CDECL u_mkdir_ocall(int* retval, int* error, const char* pathname, uint32_t mode); +sgx_status_t SGX_CDECL u_rmdir_ocall(int* retval, int* error, const char* pathname); +sgx_status_t SGX_CDECL u_opendir_ocall(void** retval, int* error, const char* pathname); +sgx_status_t SGX_CDECL u_readdir64_r_ocall(int* retval, void* dirp, struct dirent64_t* entry, struct dirent64_t** result); +sgx_status_t SGX_CDECL u_closedir_ocall(int* retval, int* error, void* dirp); +sgx_status_t SGX_CDECL u_dirfd_ocall(int* retval, int* error, void* dirp); +sgx_status_t SGX_CDECL u_fstatat64_ocall(int* retval, int* error, int dirfd, const char* pathname, struct stat64_t* buf, int flags); +sgx_status_t SGX_CDECL u_environ_ocall(char*** retval); +sgx_status_t SGX_CDECL u_getenv_ocall(char** retval, const char* name); +sgx_status_t SGX_CDECL u_setenv_ocall(int* retval, int* error, const char* name, const char* value, int overwrite); +sgx_status_t SGX_CDECL u_unsetenv_ocall(int* retval, int* error, const char* name); +sgx_status_t SGX_CDECL u_chdir_ocall(int* retval, int* error, const char* dir); +sgx_status_t SGX_CDECL u_getcwd_ocall(char** retval, int* error, char* buf, size_t buflen); +sgx_status_t SGX_CDECL u_getpwuid_r_ocall(int* retval, unsigned int uid, struct passwd* pwd, char* buf, size_t buflen, struct passwd** passwd_result); +sgx_status_t SGX_CDECL u_getuid_ocall(unsigned int* retval); +sgx_status_t SGX_CDECL u_sgxprotectedfs_exclusive_file_open(void** retval, const char* filename, uint8_t read_only, int64_t* file_size, int32_t* error_code); +sgx_status_t SGX_CDECL u_sgxprotectedfs_check_if_file_exists(uint8_t* retval, const char* filename); +sgx_status_t SGX_CDECL u_sgxprotectedfs_fread_node(int32_t* retval, void* f, uint64_t node_number, uint8_t* buffer, uint32_t node_size); +sgx_status_t SGX_CDECL u_sgxprotectedfs_fwrite_node(int32_t* retval, void* f, uint64_t node_number, uint8_t* buffer, uint32_t node_size); +sgx_status_t SGX_CDECL u_sgxprotectedfs_fclose(int32_t* retval, void* f); +sgx_status_t SGX_CDECL u_sgxprotectedfs_fflush(uint8_t* retval, void* f); +sgx_status_t SGX_CDECL u_sgxprotectedfs_remove(int32_t* retval, const char* filename); +sgx_status_t SGX_CDECL u_sgxprotectedfs_recovery_file_open(void** retval, const char* filename); +sgx_status_t SGX_CDECL u_sgxprotectedfs_fwrite_recovery_node(uint8_t* retval, void* f, uint8_t* data, uint32_t data_length); +sgx_status_t SGX_CDECL u_sgxprotectedfs_do_file_recovery(int32_t* retval, const char* filename, const char* recovery_filename, uint32_t node_size); +sgx_status_t SGX_CDECL sgx_oc_cpuidex(int cpuinfo[4], int leaf, int subleaf); +sgx_status_t SGX_CDECL sgx_thread_wait_untrusted_event_ocall(int* retval, const void* self); +sgx_status_t SGX_CDECL sgx_thread_set_untrusted_event_ocall(int* retval, const void* waiter); +sgx_status_t SGX_CDECL sgx_thread_setwait_untrusted_events_ocall(int* retval, const void* waiter, const void* self); +sgx_status_t SGX_CDECL sgx_thread_set_multiple_untrusted_events_ocall(int* retval, const void** waiters, size_t total); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/algonaut.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/algonaut.rs new file mode 100644 index 0000000..833adb6 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/algonaut.rs @@ -0,0 +1,32 @@ +use std::prelude::v1::ToString; + +use algonaut::core::{MicroAlgos, Round, SuggestedTransactionParams}; +use algonaut::crypto::HashDigest; +use algonaut::transaction::account::Account; +use algonaut::transaction::{Pay, Transaction, TxnBuilder}; + +pub(crate) fn create_test_transaction() -> Transaction { + let account = Account::generate(); + + let params = SuggestedTransactionParams { + genesis_id: "sandnet-v1".to_string(), + genesis_hash: HashDigest(Default::default()), + consensus_version: "https://github.com/algorandfoundation/specs/tree/65b4ab3266c52c56a0fa7d591754887d68faad0a".to_string(), + fee: MicroAlgos(0), + min_fee: MicroAlgos(1000), + first_valid: Round(1000), + last_valid: Round(2000), + }; + TxnBuilder::with( + params, + Pay::new( + account.address(), + "4MYUHDWHWXAKA5KA7U5PEN646VYUANBFXVJNONBK3TIMHEMWMD4UBOJBI4" + .parse() + .unwrap(), + MicroAlgos(123_456), + ) + .build(), + ) + .build() +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/mod.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/mod.rs new file mode 100644 index 0000000..90d64a1 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/mod.rs @@ -0,0 +1,3 @@ +pub(crate) mod algonaut; +pub(crate) mod temp_dir; +pub(crate) mod wallet_store; diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/temp_dir.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/temp_dir.rs new file mode 100644 index 0000000..ae00de3 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/temp_dir.rs @@ -0,0 +1,33 @@ +//! Based on: +//! +//! Note: Requires `sgx_env.edl` + +use std::env; +use std::path::{Path, PathBuf}; +use std::untrusted::fs; + +use sgx_rand::{Rng, SgxRng}; + +pub struct TempDir(PathBuf); + +impl TempDir { + pub(crate) fn create() -> Self { + let p = env::temp_dir(); + let mut r = SgxRng::new().unwrap(); + let ret = p.join(&format!("sgx_rust-{}", r.next_u32())); + fs::create_dir(&ret).unwrap(); + TempDir(ret) + } +} + +impl AsRef for TempDir { + fn as_ref(&self) -> &Path { + &self.0 + } +} + +impl Drop for TempDir { + fn drop(&mut self) { + fs::remove_dir_all(self).unwrap(); + } +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/wallet_store.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/wallet_store.rs new file mode 100644 index 0000000..2750988 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/wallet_store.rs @@ -0,0 +1,57 @@ +use std::prelude::v1::ToString; + +use sgx_wallet_impl::schema::actions; +use sgx_wallet_impl::schema::actions::{ + CreateWalletResult, + LoadOnfidoCheck, + LoadOnfidoCheckResult, + OnfidoCheckResult, + SaveOnfidoCheck, + SaveOnfidoCheckResult, +}; +use sgx_wallet_impl::schema::entities::WalletDisplay; +use sgx_wallet_impl::wallet_operations::create_wallet::create_wallet; +use sgx_wallet_impl::wallet_operations::load_onfido_check::load_onfido_check; +use sgx_wallet_impl::wallet_operations::save_onfido_check::save_onfido_check; + +pub fn create_test_wallet() -> WalletDisplay { + type Result = CreateWalletResult; + + let request = &actions::CreateWallet { + owner_name: "New Owner".to_string(), + auth_pin: "123456".to_string(), + phone_number: None, + }; + match create_wallet(request) { + Result::Created(created) => created, + otherwise => panic!("{:?}", otherwise), + } +} + +pub fn create_test_check(existing: &WalletDisplay) -> OnfidoCheckResult { + let check = OnfidoCheckResult { + id: "stub id".to_string(), + href: "stub href".to_string(), + result: "stub result".to_string(), + sub_result: None, + }; + match save_onfido_check(&SaveOnfidoCheck { + wallet_id: existing.wallet_id.clone(), + auth_pin: "123456".to_string(), + check: check.clone(), + }) { + SaveOnfidoCheckResult::Saved => {} + otherwise => panic!("{:?}", otherwise), + }; + check +} + +pub fn load_test_check(existing: &WalletDisplay) -> OnfidoCheckResult { + match load_onfido_check(&LoadOnfidoCheck { + wallet_id: existing.wallet_id.clone(), + auth_pin: "123456".to_string(), + }) { + LoadOnfidoCheckResult::Loaded(check) => check, + otherwise => panic!("{:?}", otherwise), + } +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/lib.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/lib.rs new file mode 100644 index 0000000..7db477a --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/lib.rs @@ -0,0 +1,57 @@ +#![no_std] + +#[macro_use] +extern crate sgx_tstd as std; + +mod helpers; +mod ported; +mod schema; +mod wallet_operations; + +use std::backtrace; +use std::string::String; +use std::vec::Vec; + +use sgx_tunittest::*; + +#[no_mangle] +pub extern "C" fn run_tests_ecall() -> usize { + backtrace::enable_backtrace("enclave.signed.so", backtrace::PrintFormat::Short).unwrap(); + + rsgx_unit_tests!( + ported::proptest_crypto::prop_soda_box_roundtrips, + ported::test_attestation::create_report_impl_works, + ported::test_crypto::soda_box_decrypt_works, + ported::test_crypto::soda_box_encrypt_works, + ported::test_kv_store::test_alter, + ported::test_kv_store::test_load_save_delete, + ported::test_kv_store::test_mutate, + ported::test_kv_store::test_try_insert, + ported::test_kv_store_fs::prop_fs_safe_roundtrip, + schema::test_sealing::prop_seal_unseal_msgpack_roundtrips, + schema::test_sealing::prop_seal_unseal_roundtrips, + schema::test_types::test_xrpl_key_type_serde, + wallet_operations::test_create_wallet::create_wallet_works, + wallet_operations::test_dispatch::wallet_operation_sealing_works, + wallet_operations::test_load_onfido_check::load_onfido_check_bad_pin, + wallet_operations::test_load_onfido_check::load_onfido_check_malformed_wallet_id, + wallet_operations::test_load_onfido_check::load_onfido_check_not_found, + wallet_operations::test_load_onfido_check::load_onfido_check_works, + wallet_operations::test_open_wallet::open_wallet_bad_pin, + wallet_operations::test_open_wallet::open_wallet_malformed_wallet_id, + wallet_operations::test_open_wallet::open_wallet_works, + wallet_operations::test_save_onfido_check::save_onfido_check_bad_pin, + wallet_operations::test_save_onfido_check::save_onfido_check_malformed_wallet_id, + wallet_operations::test_save_onfido_check::save_onfido_check_works, + wallet_operations::test_sign_transaction::sign_transaction_empty, + wallet_operations::test_sign_transaction::sign_transaction_malformed_transaction, + wallet_operations::test_sign_transaction::sign_transaction_without_tag, + wallet_operations::test_sign_transaction::sign_transaction_works, + wallet_operations::test_sign_transaction_msgpack::prop_transaction_msgpack_roundtrips, + wallet_operations::test_sign_transaction_xrpl::sign_transaction_empty, + wallet_operations::test_store::unlock_wallet_bad_auth_pin, + wallet_operations::test_store::unlock_wallet_malformed_wallet_id, + wallet_operations::test_store::unlock_wallet_not_found, + wallet_operations::test_store::unlock_wallet_works, + ) +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/kv_store/tests.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/kv_store/tests.rs new file mode 100644 index 0000000..b58a255 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/kv_store/tests.rs @@ -0,0 +1,31 @@ +//! Tests for [`rtc_tenclave::kv_store`] + +use std::prelude::v1::*; + +use sgx_wallet_impl::ported::kv_store::in_memory::{InMemoryStore, Never}; +use sgx_wallet_impl::ported::kv_store::KvStore; + +pub(crate) fn test_mutate() -> Result<(), Never> { + let mut store = InMemoryStore::default(); + + assert_eq!(store.mutate("missing", |n| n + 1)?, None); + + store.save("existing", &2)?; + assert_eq!(store.mutate("existing", |n| n + 1)?, Some(3)); + assert_eq!(store.load("existing")?, Some(3)); + + Ok(()) +} + +pub(crate) fn test_try_insert() -> Result<(), Never> { + let mut store = InMemoryStore::default(); + + assert_eq!(store.try_insert("missing", &42)?, None); + assert_eq!(store.load("missing")?, Some(42)); + + store.save("existing", &5)?; + assert_eq!(store.try_insert("existing", &42)?, Some(5)); + assert_eq!(store.load("existing")?, Some(5)); + + Ok(()) +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/mod.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/mod.rs new file mode 100644 index 0000000..fe93157 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/mod.rs @@ -0,0 +1,5 @@ +pub(crate) mod proptest_crypto; +pub(crate) mod test_attestation; +pub(crate) mod test_crypto; +pub(crate) mod test_kv_store; +pub(crate) mod test_kv_store_fs; diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/proptest_crypto.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/proptest_crypto.rs new file mode 100644 index 0000000..382829e --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/proptest_crypto.rs @@ -0,0 +1,47 @@ +use std::boxed::Box; +use std::format; + +use proptest::prelude::*; +use secrecy::{ExposeSecret, Secret}; +use sgx_wallet_impl::ported::crypto::SodaBoxCrypto; + +/// Encrypt and decrypt a message using [`SodaBoxCrypto`]. +pub(crate) fn prop_soda_box_roundtrips() { + prop_soda_box_roundtrips_wrapper(); +} + +proptest! { + fn prop_soda_box_roundtrips_wrapper( + sender_seed: [u8; 32], + receiver_seed: [u8; 32], + plaintext: Box<[u8]>, + ) { + prop_assume!(sender_seed != receiver_seed); + prop_soda_box_roundtrips_impl(sender_seed, receiver_seed, plaintext)?; + } +} + +fn prop_soda_box_roundtrips_impl( + sender_seed: [u8; 32], + receiver_seed: [u8; 32], + plaintext: Box<[u8]>, +) -> Result<(), TestCaseError> { + let mut sender = SodaBoxCrypto::from_seed(sender_seed); + let receiver = SodaBoxCrypto::from_seed(receiver_seed); + prop_assert_ne!(sender.get_pubkey(), receiver.get_pubkey()); + + let encrypted = sender + .encrypt_message(&Secret::new(plaintext.clone()), &receiver.get_pubkey()) + .unwrap(); + let decrypted = receiver + .decrypt_message( + &encrypted.ciphertext, + &sender.get_pubkey(), + &encrypted.nonce, + ) + .unwrap(); + + prop_assert_eq!(decrypted.expose_secret(), &plaintext); + + Ok(()) +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_attestation.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_attestation.rs new file mode 100644 index 0000000..1dcf8a7 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_attestation.rs @@ -0,0 +1,17 @@ +use sgx_tcrypto::rsgx_sha256_slice; +use sgx_types::sgx_target_info_t; +use sgx_wallet_impl::ported::attestation::create_report_impl; +use sgx_wallet_impl::ported::crypto::SodaBoxCrypto; + +pub fn create_report_impl_works() { + let expected_public_key = SodaBoxCrypto::new().get_pubkey(); + let expected_report_data = rsgx_sha256_slice(&expected_public_key).unwrap(); + + let qe_target_info = &sgx_target_info_t::default(); + let (public_key, report) = create_report_impl(qe_target_info).unwrap(); + + assert_eq!(public_key, expected_public_key); + assert_eq!(report.body.report_data.d[..32], expected_report_data); + // The rest should be zero. + assert_eq!(report.body.report_data.d[32..], [0; 32]); +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_crypto.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_crypto.rs new file mode 100644 index 0000000..748bed7 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_crypto.rs @@ -0,0 +1,79 @@ +//! XXX see `rtc_tenclave::crypto` + +use std::ops::Deref; +use std::vec; + +use secrecy::{ExposeSecret, Secret}; +use sgx_wallet_impl::ported::crypto::{ + SodaBoxCrypto, + CRYPTO_BOX_BOXZEROBYTES, + CRYPTO_BOX_ZEROBYTES, +}; + +pub(crate) fn get_test_keypair( + seed: &[u8; 32], +) -> (sodalite::BoxPublicKey, sodalite::BoxSecretKey) { + let mut pub_key = sodalite::BoxPublicKey::default(); + let mut secret_key = sodalite::BoxSecretKey::default(); + sodalite::box_keypair_seed(&mut pub_key, &mut secret_key, seed); + (pub_key, secret_key) +} + +pub fn soda_box_decrypt_works() { + let message = vec![83_u8; 432]; + let plaintext = [vec![0_u8; CRYPTO_BOX_ZEROBYTES], message.clone()].concat(); + let (pub_key, secret_key) = get_test_keypair(&[32_u8; 32]); + let mut ciphertext = vec![0_u8; plaintext.len()]; + let nonce = [32_u8; sodalite::BOX_NONCE_LEN]; + + let sut = SodaBoxCrypto::new(); + + sodalite::box_( + &mut ciphertext, + &plaintext, + &nonce, + &sut.get_pubkey(), + &secret_key, + ) + .unwrap(); + + let result = sut.decrypt_message(&ciphertext[CRYPTO_BOX_BOXZEROBYTES..], &pub_key, &nonce); + assert!(result.is_ok()); + assert_eq!( + result.unwrap().expose_secret().deref(), + &message, + "decrypt_message result: got left, expected right" + ) +} + +pub fn soda_box_encrypt_works() { + let message = vec![83_u8; 432]; + let (pub_key, secret_key) = get_test_keypair(&[32_u8; 32]); + + let mut sut = SodaBoxCrypto::new(); + + let result = sut + .encrypt_message(&Secret::new(message.clone().into_boxed_slice()), &pub_key) + .unwrap(); + let ciphertext = [ + vec![0_u8; CRYPTO_BOX_BOXZEROBYTES], + result.ciphertext.into(), + ] + .concat(); + let mut plaintext = vec![0_u8; ciphertext.len()]; + + sodalite::box_open( + &mut plaintext, + &ciphertext, + &result.nonce, + &sut.get_pubkey(), + &secret_key, + ) + .unwrap(); + let result_decrypted = &plaintext[CRYPTO_BOX_ZEROBYTES..]; + + assert_eq!( + &result_decrypted, &message, + "encrypt_message result: decrypts to left, expected right" + ) +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_kv_store.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_kv_store.rs new file mode 100644 index 0000000..9f8ff83 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_kv_store.rs @@ -0,0 +1,63 @@ +use serde::de::DeserializeOwned; +use serde::Serialize; +use sgx_wallet_impl::ported::kv_store::fs::{FsStore, SgxFiler}; +use sgx_wallet_impl::ported::kv_store::KvStore; + +use crate::helpers::temp_dir::TempDir; + +// Helper: Run `f` with a non-existent file path inside a temporary directory. +fn with_temp_store(f: impl FnOnce(&mut FsStore)) +where + V: Serialize + DeserializeOwned, +{ + let root = &TempDir::create(); + let mut store = FsStore::new(root, SgxFiler); + f(&mut store); +} + +pub(crate) fn test_load_save_delete() { + with_temp_store(|store| { + assert_eq!(store.load(b"key").unwrap(), None); + store.save(b"key", &2).unwrap(); + assert_eq!(store.load(b"key").unwrap(), Some(2)); + store.save(b"key", &5).unwrap(); + assert_eq!(store.load(b"key").unwrap(), Some(5)); + store.delete(b"key").unwrap(); + assert_eq!(store.load(b"key").unwrap(), None); + }); +} + +/// Like [`test_load_save_delete`], but using [`KvStore::alter`]. +pub(crate) fn test_alter() { + with_temp_store(|store| { + assert_eq!(store.alter(b"key", |v| v).unwrap(), None); + store.alter(b"key", |_| Some(2)).unwrap(); + assert_eq!(store.alter(b"key", |v| v).unwrap(), Some(2)); + store.alter(b"key", |_| Some(5)).unwrap(); + assert_eq!(store.alter(b"key", |v| v).unwrap(), Some(5)); + store.alter(b"key", |_| None).unwrap(); + assert_eq!(store.alter(b"key", |v| v).unwrap(), None); + }); +} + +pub(crate) fn test_mutate() { + with_temp_store(|store| { + assert_eq!(store.mutate(b"missing", |n| n + 1).unwrap(), None); + assert_eq!(store.load(b"missing").unwrap(), None); + + store.save(b"existing", &2).unwrap(); + assert_eq!(store.mutate(b"existing", |n| n + 1).unwrap(), Some(3)); + assert_eq!(store.load(b"existing").unwrap(), Some(3)); + }); +} + +pub(crate) fn test_try_insert() { + with_temp_store(|store| { + assert_eq!(store.try_insert(b"missing", &42).unwrap(), None); + assert_eq!(store.load(b"missing").unwrap(), Some(42)); + + store.save(b"existing", &5).unwrap(); + assert_eq!(store.try_insert(b"existing", &42).unwrap(), Some(5)); + assert_eq!(store.load(b"existing").unwrap(), Some(5)); + }); +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_kv_store_fs.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_kv_store_fs.rs new file mode 100644 index 0000000..eb13e71 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_kv_store_fs.rs @@ -0,0 +1,33 @@ +use std::prelude::v1::*; + +use proptest::prelude::*; +use sgx_wallet_impl::ported::kv_store::fs::{decode_from_fs_safe, encode_to_fs_safe}; +use sgx_wallet_impl::ported::kv_store::Key; + +/// [`encode_to_fs_safe`] encodes to filesystem-safe, and [`decode_from_fs_safe`] round-trips. +pub(crate) fn prop_fs_safe_roundtrip() { + prop_fs_safe_roundtrip_wrapper() +} + +proptest! { + fn prop_fs_safe_roundtrip_wrapper(key: Box) { + prop_fs_safe_roundtrip_impl(&key)?; + } +} + +fn prop_fs_safe_roundtrip_impl(key: &Key) -> Result<(), TestCaseError> { + let encoded = &encode_to_fs_safe(key); + prop_assert!( + is_fs_safe(encoded), + "expected filesystem-safe, got encoded = {:?}", + encoded + ); + let decoded = &decode_from_fs_safe(encoded).unwrap(); + prop_assert_eq!(key, decoded); + Ok(()) +} + +/// Helper: Very conservative definition of filesystem-safe. +fn is_fs_safe(encoded: &str) -> bool { + !encoded.is_empty() && encoded.chars().all(|c| c.is_ascii_alphanumeric()) +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/schema/mod.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/schema/mod.rs new file mode 100644 index 0000000..16edc33 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/schema/mod.rs @@ -0,0 +1,2 @@ +pub(crate) mod test_sealing; +pub(crate) mod test_types; diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/schema/test_sealing.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/schema/test_sealing.rs new file mode 100644 index 0000000..10260bb --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/schema/test_sealing.rs @@ -0,0 +1,56 @@ +use std::boxed::Box; + +use proptest::prelude::*; +use secrecy::{ExposeSecret, Secret}; +use sgx_wallet_impl::ported::crypto::{SecretBytes, SodaBoxCrypto}; +use sgx_wallet_impl::schema::sealing::{seal, seal_msgpack, unseal, unseal_secret_msgpack}; + +/// Roundtrip with [`seal`] and then [`unseal`]. +pub(crate) fn prop_seal_unseal_roundtrips() { + proptest!(|(message: Box<[u8]>, sender_seed: [u8; 32], receiver_seed: [u8; 32])| { + prop_assume!(sender_seed != receiver_seed); + prop_seal_unseal_roundtrips_impl(message, sender_seed, receiver_seed); + }); +} + +fn prop_seal_unseal_roundtrips_impl( + message: Box<[u8]>, + sender_seed: [u8; 32], + receiver_seed: [u8; 32], +) { + let message = &SecretBytes::new(message); + let sender = &mut SodaBoxCrypto::from_seed(sender_seed); + let receiver = &SodaBoxCrypto::from_seed(receiver_seed); + assert_ne!(sender.get_pubkey(), receiver.get_pubkey()); + + let sealed = &seal(message, &receiver.get_pubkey(), sender).unwrap(); + let unsealed = &unseal(sealed, receiver).unwrap(); + + assert_eq!(unsealed.expose_secret(), message.expose_secret()); +} + +type TestMessage = Box<[i32]>; + +/// Roundtrip with [`seal_msgpack`] and then [`unseal_msgpack`]. +pub(crate) fn prop_seal_unseal_msgpack_roundtrips() { + proptest!(|(message: TestMessage, sender_seed: [u8; 32], receiver_seed: [u8; 32])| { + prop_assume!(sender_seed != receiver_seed); + prop_seal_unseal_msgpack_roundtrips_impl(message, sender_seed, receiver_seed); + }); +} + +fn prop_seal_unseal_msgpack_roundtrips_impl( + message: TestMessage, + sender_seed: [u8; 32], + receiver_seed: [u8; 32], +) { + let message = &Secret::new(message); + let sender = &mut SodaBoxCrypto::from_seed(sender_seed); + let receiver = &SodaBoxCrypto::from_seed(receiver_seed); + assert_ne!(sender.get_pubkey(), receiver.get_pubkey()); + + let sealed = &seal_msgpack(message.expose_secret(), &receiver.get_pubkey(), sender).unwrap(); + let unsealed = &unseal_secret_msgpack::(sealed, receiver).unwrap(); + + assert_eq!(unsealed.expose_secret(), message.expose_secret()); +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/schema/test_types.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/schema/test_types.rs new file mode 100644 index 0000000..60202cd --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/schema/test_types.rs @@ -0,0 +1,20 @@ +//! Test [`sgx_wallet_impl::schema::types`] + +use serde_json::Value; +use sgx_wallet_impl::schema::types::XrplKeyType; + +/// [`XrplKeyType`] serializes to the same lowercase string constants used throughout the XRP Ledger. +pub(crate) fn test_xrpl_key_type_serde() { + let pairs = [ + (XrplKeyType::Secp256k1, "secp256k1"), + (XrplKeyType::Ed25519, "ed25519"), + ]; + for (key_type, expected) in pairs { + let expected_json = Value::from(expected); + assert_eq!(serde_json::to_value(&key_type).unwrap(), expected_json); + assert_eq!( + serde_json::from_value::(expected_json).unwrap(), + key_type + ); + } +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/mod.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/mod.rs new file mode 100644 index 0000000..7bde76c --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/mod.rs @@ -0,0 +1,9 @@ +pub(crate) mod test_create_wallet; +pub(crate) mod test_dispatch; +pub(crate) mod test_load_onfido_check; +pub(crate) mod test_open_wallet; +pub(crate) mod test_save_onfido_check; +pub(crate) mod test_sign_transaction; +pub(crate) mod test_sign_transaction_msgpack; +pub(crate) mod test_sign_transaction_xrpl; +pub(crate) mod test_store; diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_create_wallet.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_create_wallet.rs new file mode 100644 index 0000000..4f60da1 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_create_wallet.rs @@ -0,0 +1,37 @@ +use std::prelude::v1::ToString; + +use sgx_wallet_impl::schema::actions; +use sgx_wallet_impl::schema::actions::CreateWalletResult as Result; +use sgx_wallet_impl::schema::entities::XrplAccountDisplay; +use sgx_wallet_impl::wallet_operations::create_wallet::create_wallet; +use sgx_wallet_impl::wallet_operations::store::load_wallet; + +pub(crate) fn create_wallet_works() { + let request = &actions::CreateWallet { + owner_name: "New Owner".to_string(), + auth_pin: "123456".to_string(), + phone_number: None, + }; + let display = &match create_wallet(request) { + Result::Created(created) => created, + Result::Failed(failed) => panic!("{}", failed), + }; + + assert_eq!(display.owner_name, request.owner_name); + + let stored = load_wallet(&display.wallet_id).unwrap().unwrap(); + assert_eq!(display.wallet_id, stored.wallet_id); + assert_eq!(display.owner_name, stored.owner_name); + assert_eq!( + display.algorand_address_base32, + stored.algorand_account.address_base32() + ); + assert_eq!( + display.xrpl_account, + XrplAccountDisplay { + key_type: stored.xrpl_account.key_type, + public_key_hex: stored.xrpl_account.to_public_key_hex(), + address_base58: stored.xrpl_account.to_address_base58() + } + ); +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_dispatch.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_dispatch.rs new file mode 100644 index 0000000..f887f9f --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_dispatch.rs @@ -0,0 +1,40 @@ +use std::prelude::v1::ToString; + +use sgx_wallet_impl::ported::crypto::SodaBoxCrypto; +use sgx_wallet_impl::schema::actions::{ + OpenWallet, + OpenWalletResult, + WalletRequest, + WalletResponse, +}; +use sgx_wallet_impl::schema::sealing::{seal_msgpack, unseal_non_secret_msgpack}; +use sgx_wallet_impl::wallet_operations::dispatch::wallet_operation_impl; + +pub(crate) fn wallet_operation_sealing_works() { + let client_crypto = &mut SodaBoxCrypto::from_seed([0; 32]); + let enclave_crypto = SodaBoxCrypto::new(); + + // Seal + let wallet_request = &WalletRequest::OpenWallet(OpenWallet { + wallet_id: "123456".to_string(), + auth_pin: "1234".to_string(), + }); + let sealed_request_bytes = + &seal_msgpack(wallet_request, &enclave_crypto.get_pubkey(), client_crypto).unwrap(); + + // Call + let sealed_response_bytes = &wallet_operation_impl(sealed_request_bytes); + + // Unseal + let unsealed_message: WalletResponse = + unseal_non_secret_msgpack(sealed_response_bytes, client_crypto).unwrap(); + + // Check + assert_eq!( + unsealed_message, + OpenWalletResult::Failed( + "key_from_id failed for wallet_id = \"123456\": decode error".to_string() + ) + .into() + ); +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_load_onfido_check.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_load_onfido_check.rs new file mode 100644 index 0000000..fbeaf0a --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_load_onfido_check.rs @@ -0,0 +1,63 @@ +use std::prelude::v1::ToString; + +use sgx_wallet_impl::schema::actions; +use sgx_wallet_impl::schema::actions::LoadOnfidoCheckResult; +use sgx_wallet_impl::wallet_operations::load_onfido_check::load_onfido_check; + +use crate::helpers::wallet_store; +use crate::helpers::wallet_store::create_test_wallet; + +pub(crate) fn load_onfido_check_works() { + let existing = create_test_wallet(); + let existing_check = wallet_store::create_test_check(&existing); + + let request = actions::LoadOnfidoCheck { + wallet_id: existing.wallet_id, + auth_pin: "123456".to_string(), + }; + let loaded_check = match load_onfido_check(&request) { + LoadOnfidoCheckResult::Loaded(loaded) => loaded, + otherwise => panic!("{:?}", otherwise), + }; + + assert_eq!(existing_check, loaded_check); +} + +pub(crate) fn load_onfido_check_not_found() { + let existing = create_test_wallet(); + + let request = actions::LoadOnfidoCheck { + wallet_id: existing.wallet_id.clone(), + auth_pin: "123456".to_string(), + }; + match load_onfido_check(&request) { + LoadOnfidoCheckResult::NotFound => (), + otherwise => panic!("{:?}", otherwise), + }; +} + +pub(crate) fn load_onfido_check_malformed_wallet_id() { + let request = actions::LoadOnfidoCheck { + wallet_id: "malformed".to_string(), + auth_pin: "123456".to_string(), + }; + + match load_onfido_check(&request) { + LoadOnfidoCheckResult::Failed(_) => (), + otherwise => panic!("{:?}", otherwise), + } +} + +pub(crate) fn load_onfido_check_bad_pin() { + let existing = create_test_wallet(); + + let request = actions::LoadOnfidoCheck { + wallet_id: existing.wallet_id.clone(), + auth_pin: "000000".to_string(), + }; + + match load_onfido_check(&request) { + LoadOnfidoCheckResult::InvalidAuth => (), + otherwise => panic!("{:?}", otherwise), + } +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_open_wallet.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_open_wallet.rs new file mode 100644 index 0000000..d876dd0 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_open_wallet.rs @@ -0,0 +1,50 @@ +use std::prelude::v1::ToString; + +use sgx_wallet_impl::schema::actions; +use sgx_wallet_impl::schema::actions::OpenWalletResult; +use sgx_wallet_impl::wallet_operations::open_wallet::open_wallet; + +use crate::helpers::wallet_store; + +type Result = OpenWalletResult; + +pub(crate) fn open_wallet_works() { + let existing = &wallet_store::create_test_wallet(); + + let request = &actions::OpenWallet { + wallet_id: existing.wallet_id.clone(), + auth_pin: "123456".to_string(), + }; + let display = &match open_wallet(request) { + Result::Opened(opened) => opened, + otherwise => panic!("{:?}", otherwise), + }; + + assert_eq!(display, existing); +} + +pub(crate) fn open_wallet_malformed_wallet_id() { + let request = &actions::OpenWallet { + wallet_id: "malformed".to_string(), + auth_pin: "123456".to_string(), + }; + + match open_wallet(request) { + Result::Failed(_) => (), + otherwise => panic!("{:?}", otherwise), + } +} + +pub(crate) fn open_wallet_bad_pin() { + let existing = &wallet_store::create_test_wallet(); + + let request = &actions::OpenWallet { + wallet_id: existing.wallet_id.clone(), + auth_pin: "000000".to_string(), + }; + + match open_wallet(request) { + Result::InvalidAuth => (), + otherwise => panic!("{:?}", otherwise), + } +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_save_onfido_check.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_save_onfido_check.rs new file mode 100644 index 0000000..538fd4d --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_save_onfido_check.rs @@ -0,0 +1,63 @@ +use std::prelude::v1::ToString; + +use sgx_wallet_impl::schema::actions; +use sgx_wallet_impl::schema::actions::{OnfidoCheckResult, SaveOnfidoCheckResult}; +use sgx_wallet_impl::schema::types::WalletPin; +use sgx_wallet_impl::wallet_operations::save_onfido_check::save_onfido_check; + +use crate::helpers::wallet_store::{create_test_wallet, load_test_check}; + +fn get_check() -> OnfidoCheckResult { + OnfidoCheckResult { + id: "stub id".to_string(), + href: "stub href".to_string(), + result: "stub result".to_string(), + sub_result: None, + } +} + +pub(crate) fn save_onfido_check_works() { + let existing = create_test_wallet(); + let check = get_check(); + + let request = actions::SaveOnfidoCheck { + wallet_id: existing.wallet_id.clone(), + auth_pin: WalletPin::from("123456"), + check: check.clone(), + }; + match save_onfido_check(&request) { + SaveOnfidoCheckResult::Saved => {} + otherwise => panic!("{:?}", otherwise), + }; + + let saved = load_test_check(&existing); + assert_eq!(saved, check) +} + +pub(crate) fn save_onfido_check_malformed_wallet_id() { + let request = actions::SaveOnfidoCheck { + wallet_id: "malformed".into(), + auth_pin: "123456".into(), + check: get_check(), + }; + + match save_onfido_check(&request) { + SaveOnfidoCheckResult::Failed(_) => (), + otherwise => panic!("{:?}", otherwise), + } +} + +pub(crate) fn save_onfido_check_bad_pin() { + let existing = create_test_wallet(); + + let request = actions::SaveOnfidoCheck { + wallet_id: existing.wallet_id, + auth_pin: "000000".to_string(), + check: get_check(), + }; + + match save_onfido_check(&request) { + SaveOnfidoCheckResult::InvalidAuth => (), + otherwise => panic!("{:?}", otherwise), + } +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_sign_transaction.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_sign_transaction.rs new file mode 100644 index 0000000..746d495 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_sign_transaction.rs @@ -0,0 +1,116 @@ +use std::prelude::v1::ToString; + +use algonaut::core::ToMsgPack; +use algonaut::transaction::SignedTransaction as AlgonautSignedTransaction; +use sgx_wallet_impl::schema::actions; +use sgx_wallet_impl::schema::actions::{SignTransactionResult, TransactionToSign}; +use sgx_wallet_impl::schema::msgpack::FromMessagePack; +use sgx_wallet_impl::wallet_operations::sign_transaction::sign_transaction; + +use crate::helpers::algonaut::create_test_transaction; +use crate::helpers::wallet_store::create_test_wallet; + +type Result = SignTransactionResult; + +pub(crate) fn sign_transaction_works() { + let existing = &create_test_wallet(); + + let algonaut_transaction = create_test_transaction(); + let transaction_bytes = algonaut_transaction + .bytes_to_sign() + .unwrap() + .into_boxed_slice(); + let transaction_to_sign = TransactionToSign::AlgorandTransaction { transaction_bytes }; + + let request = &actions::SignTransaction { + wallet_id: existing.wallet_id.clone(), + auth_pin: "123456".to_string(), + transaction_to_sign, + }; + let signed = sign_transaction(request).unwrap_signed(); + + let algonaut_signed_transaction = + AlgonautSignedTransaction::from_msgpack(&signed.unwrap_algorand_bytes()).unwrap(); + assert_eq!( + algonaut_signed_transaction.transaction, + algonaut_transaction + ); +} + +pub(crate) fn sign_transaction_without_tag() { + let existing = &create_test_wallet(); + + let algonaut_transaction = create_test_transaction(); + let transaction_bytes = algonaut_transaction + .to_msg_pack() + .unwrap() + .into_boxed_slice(); + let transaction_to_sign = TransactionToSign::AlgorandTransaction { transaction_bytes }; + + let request = &actions::SignTransaction { + wallet_id: existing.wallet_id.clone(), + auth_pin: "123456".to_string(), + transaction_to_sign, + }; + match sign_transaction(request) { + Result::Failed(err) => assert!( + // Only check the start: the transaction body contains randomness. + err.starts_with( + "ERROR(sign_transaction): transaction prefix tag not recognised\n\ + ( error = expected TX, got [137, 163] )\n\ + [ unsigned transaction msgpack = " + ), + "{}", + err + ), + otherwise => panic!("{:?}", otherwise), + }; +} + +pub(crate) fn sign_transaction_empty() { + let existing = &create_test_wallet(); + + let transaction_bytes = Default::default(); + let transaction_to_sign = TransactionToSign::AlgorandTransaction { transaction_bytes }; + + let request = &actions::SignTransaction { + wallet_id: existing.wallet_id.clone(), + auth_pin: "123456".to_string(), + transaction_to_sign, + }; + match sign_transaction(request) { + Result::Failed(err) => { + assert_eq!( + err, + "ERROR(sign_transaction): transaction too short\n\ + ( error = len = 0 )\n\ + [ unsigned transaction msgpack = ]" + ) + } + otherwise => panic!("{:?}", otherwise), + }; +} + +pub(crate) fn sign_transaction_malformed_transaction() { + let existing = &create_test_wallet(); + + let transaction_bytes = "malformed".as_bytes().into(); + let transaction_to_sign = TransactionToSign::AlgorandTransaction { transaction_bytes }; + + let request = &actions::SignTransaction { + wallet_id: existing.wallet_id.clone(), + auth_pin: "123456".to_string(), + transaction_to_sign, + }; + match sign_transaction(request) { + Result::Failed(err) => { + assert_eq!( + err, + "ERROR(sign_transaction): transaction prefix tag not recognised\n\ + ( error = expected TX, got [109, 97] )\n\ + [ unsigned transaction msgpack = bWFsZm9ybWVk ]" + ) + } + otherwise => panic!("{:?}", otherwise), + }; +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_sign_transaction_msgpack.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_sign_transaction_msgpack.rs new file mode 100644 index 0000000..a985791 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_sign_transaction_msgpack.rs @@ -0,0 +1,78 @@ +use std::prelude::v1::{String, ToString, Vec}; + +use algonaut::core::{Address, MicroAlgos, Round}; +use algonaut::crypto::HashDigest; +use algonaut::transaction::transaction::Payment; +use algonaut::transaction::{Transaction, TransactionType}; +use proptest::{prop_assume, proptest}; +use sgx_wallet_impl::wallet_operations::sign_transaction_algorand::algorand_network_compatible; + +pub(crate) fn prop_transaction_msgpack_roundtrips() { + proptest!( + |( + fee: u64, + first_valid: u64, + genesis_hash: [u8; 32], + last_valid: u64, + txn_type: ([u8; 32], [u8; 32], u64, Option<[u8; 32]>), + genesis_id: Option>, + group: Option<[u8; 32]>, + lease: Option<[u8; 32]>, + note: Option>, + rekey_to: Option<[u8; 32]>, + )| { + let genesis_id: Result, _> = genesis_id.map(String::from_utf8).transpose(); + prop_assume!(genesis_id.is_ok()); + let genesis_id = genesis_id.unwrap(); + + let txn_type = TransactionType::Payment( + Payment { + sender: Address(txn_type.0), + receiver: Address(txn_type.1), + amount: MicroAlgos(txn_type.2), + close_remainder_to: txn_type.3.map(Address), + } + ); + + prop_transaction_msgpack_roundtrips_impl(Transaction { + fee: MicroAlgos(fee), + first_valid: Round(first_valid), + genesis_hash: HashDigest(genesis_hash), + last_valid: Round(last_valid), + txn_type, + genesis_id, + group: group.map(HashDigest), + lease: lease.map(HashDigest), + note, + rekey_to: rekey_to.map(Address), + }); + }); +} + +fn prop_transaction_msgpack_roundtrips_impl(transaction: Transaction) { + let bytes = algorand_network_compatible::to_msgpack(&transaction).unwrap(); + let transaction2 = algorand_network_compatible::from_msgpack(&bytes).unwrap(); + + // XXX: See the serialization documentation comments for [`ApiTransaction`]. + // The transaction serialization will discard certain default / "empty" values, + // treating them as absent. The test expects the same here. + let expected = Transaction { + genesis_id: collapse("".to_string(), transaction.genesis_id), + note: collapse(vec![], transaction.note), + ..transaction + }; + + assert_eq!(expected, transaction2); +} + +/// Helper: Collapse `Some(empty)` to `None`. +fn collapse(empty: T, value: Option) -> Option +where + T: PartialEq, +{ + if value == Some(empty) { + None + } else { + value + } +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_sign_transaction_xrpl.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_sign_transaction_xrpl.rs new file mode 100644 index 0000000..6adf56d --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_sign_transaction_xrpl.rs @@ -0,0 +1,32 @@ +use std::prelude::v1::ToString; + +use sgx_wallet_impl::schema::actions; +use sgx_wallet_impl::schema::actions::{TransactionSigned, TransactionToSign}; +use sgx_wallet_impl::wallet_operations::sign_transaction::sign_transaction; + +use crate::helpers::wallet_store::create_test_wallet; + +pub(crate) fn sign_transaction_empty() { + let existing = &create_test_wallet(); + + let transaction_bytes = Default::default(); + + let request = &actions::SignTransaction { + wallet_id: existing.wallet_id.clone(), + auth_pin: "123456".to_string(), + transaction_to_sign: TransactionToSign::XrplTransaction { transaction_bytes }, + }; + let signed = sign_transaction(request).unwrap_signed(); + + match signed { + TransactionSigned::XrplTransactionSigned { + signed_transaction_bytes: _, + signature_bytes, + } => { + assert_eq!(signature_bytes[0], 0x30); // DER tag for SEQUENCE + } + otherwise => panic!("unexpected: {:?}", otherwise), + } + + // TODO(Pi): Test more substantially. +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_store.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_store.rs new file mode 100644 index 0000000..05345e5 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_store.rs @@ -0,0 +1,37 @@ +//! Test [`sgx_wallet_impl::wallet_operations::store`] + +use std::prelude::v1::ToString; + +use sgx_wallet_impl::ported::kv_store::KvStore; +use sgx_wallet_impl::schema::entities::WalletDisplay; +use sgx_wallet_impl::wallet_operations::store::{key_from_id, unlock_wallet, wallet_store}; + +use crate::helpers::wallet_store::create_test_wallet; + +pub(crate) fn unlock_wallet_works() { + let existing = create_test_wallet(); + let stored = unlock_wallet(&existing.wallet_id, "123456").unwrap(); + assert_eq!(existing, WalletDisplay::from(stored)); +} + +pub(crate) fn unlock_wallet_not_found() { + let existing = create_test_wallet(); + let mut store = wallet_store(); + let key = &key_from_id(&existing.wallet_id).unwrap(); + store.delete(key).unwrap(); + + let err = unlock_wallet(&existing.wallet_id, "123456").unwrap_err(); + assert_eq!(err.to_string(), "invalid wallet ID provided"); +} + +pub(crate) fn unlock_wallet_malformed_wallet_id() { + create_test_wallet(); + let err = unlock_wallet("malformed", "123456").unwrap_err(); + assert_eq!(err.to_string(), "I/O error while opening wallet"); +} + +pub(crate) fn unlock_wallet_bad_auth_pin() { + let existing = create_test_wallet(); + let err = unlock_wallet(&existing.wallet_id, "000000").unwrap_err(); + assert_eq!(err.to_string(), "invalid authentication PIN provided"); +} diff --git a/rust-sgx-workspace/projects/sgx-wallet/.gitignore b/rust-sgx-workspace/projects/sgx-wallet/.gitignore new file mode 100644 index 0000000..438fbf5 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/.gitignore @@ -0,0 +1,2 @@ +/build +/keys diff --git a/rust-sgx-workspace/projects/sgx-wallet/Makefile b/rust-sgx-workspace/projects/sgx-wallet/Makefile new file mode 100644 index 0000000..3004958 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/Makefile @@ -0,0 +1,50 @@ +# Dummy makefile, will call the host and enclave makefile when requested. + +SRC_U = app/ +SRC_T = enclave/ + +# Compilation process, will call the appropriate makefiles. + +all: host enclave + +host: + @echo "\033[32mRequest to compile the host part...\033[0m" + @make -C $(SRC_U) + +enclave: + @echo "\033[32mRequest to compile the enclave part...\033[0m" + @make -C $(SRC_T) + +clean: + @make -C $(SRC_U) clean + @make -C $(SRC_T) clean + +fclean: + @make -C $(SRC_U) fclean + @make -C $(SRC_T) fclean + +clean_host: + @make -C $(SRC_U) clean + +clean_enclave: + @make -C $(SRC_T) clean + +fclean_host: + @make -C $(SRC_U) fclean + +fclean_enclave: + @make -C $(SRC_T) fclean + +re_host: fclean_host host + +re_enclave: fclean_enclave enclave + +re: fclean all + +# Dummy rules to let make know that those rules are not files. + +.PHONY: host enclave clean clean_host clean_enclave fclean_host fclean_enclave fclean re re_host re_enclave + +.PHONY: run +run: all + @(cd build/bin && ./sgx-wallet-app) diff --git a/rust-sgx-workspace/projects/sgx-wallet/Makefile.toml b/rust-sgx-workspace/projects/sgx-wallet/Makefile.toml new file mode 100644 index 0000000..6d7ad18 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/Makefile.toml @@ -0,0 +1,5 @@ +[env] + +# https://github.com/sagiegurari/cargo-make#workspace-emulation +CARGO_MAKE_WORKSPACE_EMULATION = true +CARGO_MAKE_CRATE_WORKSPACE_MEMBERS = ["app", "enclave"] diff --git a/rust-sgx-workspace/projects/sgx-wallet/app/.gitignore b/rust-sgx-workspace/projects/sgx-wallet/app/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/app/.gitignore @@ -0,0 +1 @@ +/target diff --git a/rust-sgx-workspace/projects/sgx-wallet/app/Cargo.lock b/rust-sgx-workspace/projects/sgx-wallet/app/Cargo.lock new file mode 100644 index 0000000..6ed2ef2 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/app/Cargo.lock @@ -0,0 +1,1560 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "actix" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3720d0064a0ce5c0de7bd93bdb0a6caebab2a9b5668746145d7b3b0c5da02914" +dependencies = [ + "actix-rt", + "actix_derive", + "bitflags", + "bytes", + "crossbeam-channel", + "futures-core", + "futures-sink", + "futures-task", + "futures-util", + "log", + "once_cell", + "parking_lot", + "pin-project-lite", + "smallvec", + "tokio", + "tokio-util", +] + +[[package]] +name = "actix-codec" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d5dbeb2d9e51344cb83ca7cc170f1217f9fe25bfc50160e6e200b5c31c1019a" +dependencies = [ + "bitflags", + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", + "tokio-util", +] + +[[package]] +name = "actix-cors" +version = "0.6.0-beta.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01552b8facccd5d7a4cc5d8e2b07d306160c97a4968181c2db965533389c8725" +dependencies = [ + "actix-service", + "actix-web", + "derive_more", + "futures-util", + "log", + "once_cell", + "smallvec", +] + +[[package]] +name = "actix-http" +version = "3.0.0-beta.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01260589f1aafad11224002741eb37bc603b4ce55b4e3556d2b2122f9aac7c51" +dependencies = [ + "actix-codec", + "actix-rt", + "actix-service", + "actix-tls", + "actix-utils", + "ahash", + "base64", + "bitflags", + "brotli2", + "bytes", + "bytestring", + "derive_more", + "encoding_rs", + "flate2", + "futures-core", + "futures-util", + "h2", + "http", + "httparse", + "itoa", + "language-tags", + "local-channel", + "log", + "mime", + "once_cell", + "percent-encoding", + "pin-project", + "pin-project-lite", + "rand", + "regex", + "serde", + "sha-1", + "smallvec", + "time", + "tokio", + "zstd", +] + +[[package]] +name = "actix-macros" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2f86cd6857c135e6e9fe57b1619a88d1f94a7df34c00e11fe13e64fd3438837" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "actix-router" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ad299af73649e1fc893e333ccf86f377751eb95ff875d095131574c6f43452c" +dependencies = [ + "bytestring", + "http", + "log", + "regex", + "serde", +] + +[[package]] +name = "actix-rt" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc7d7cd957c9ed92288a7c3c96af81fa5291f65247a76a34dac7b6af74e52ba0" +dependencies = [ + "actix-macros", + "futures-core", + "tokio", +] + +[[package]] +name = "actix-server" +version = "2.0.0-beta.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26369215fcc3b0176018b3b68756a8bcc275bb000e6212e454944913a1f9bf87" +dependencies = [ + "actix-rt", + "actix-service", + "actix-utils", + "futures-core", + "log", + "mio", + "num_cpus", + "slab", + "tokio", +] + +[[package]] +name = "actix-service" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77f5f9d66a8730d0fae62c26f3424f5751e5518086628a40b7ab6fca4a705034" +dependencies = [ + "futures-core", + "paste", + "pin-project-lite", +] + +[[package]] +name = "actix-tls" +version = "3.0.0-beta.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65b7bb60840962ef0332f7ea01a57d73a24d2cb663708511ff800250bbfef569" +dependencies = [ + "actix-codec", + "actix-rt", + "actix-service", + "actix-utils", + "derive_more", + "futures-core", + "http", + "log", + "tokio-util", +] + +[[package]] +name = "actix-utils" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e491cbaac2e7fc788dfff99ff48ef317e23b3cf63dbaf7aaab6418f40f92aa94" +dependencies = [ + "local-waker", + "pin-project-lite", +] + +[[package]] +name = "actix-web" +version = "4.0.0-beta.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c503f726f895e55dac39adeafd14b5ee00cc956796314e9227fc7ae2e176f443" +dependencies = [ + "actix-codec", + "actix-http", + "actix-macros", + "actix-router", + "actix-rt", + "actix-server", + "actix-service", + "actix-utils", + "actix-web-codegen", + "ahash", + "bytes", + "cfg-if", + "cookie", + "derive_more", + "either", + "encoding_rs", + "futures-core", + "futures-util", + "itoa", + "language-tags", + "log", + "mime", + "once_cell", + "paste", + "pin-project", + "regex", + "serde", + "serde_json", + "serde_urlencoded", + "smallvec", + "socket2", + "time", + "url", +] + +[[package]] +name = "actix-web-codegen" +version = "0.5.0-beta.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d048c6986743105c1e8e9729fbc8d5d1667f2f62393a58be8d85a7d9a5a6c8d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "actix_derive" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d44b8fee1ced9671ba043476deddef739dd0959bf77030b26b738cc591737a7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "ahash" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43bb833f0bf979d8475d38fbf09ed3b8a55e1885fe93ad3f93239fc6a4f17b98" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +dependencies = [ + "memchr", +] + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "base-x" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" + +[[package]] +name = "base64" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" + +[[package]] +name = "bitflags" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2da1976d75adbe5fbc88130ecd119529cf1cc6a93ae1546d8696ee66f0d21af1" + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "brotli-sys" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4445dea95f4c2b41cde57cc9fee236ae4dbae88d8fcbdb4750fc1bb5d86aaecd" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "brotli2" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cb036c3eade309815c15ddbacec5b22c4d1f3983a774ab2eac2e3e9ea85568e" +dependencies = [ + "brotli-sys", + "libc", +] + +[[package]] +name = "bumpalo" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" + +[[package]] +name = "bytestring" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90706ba19e97b90786e19dc0d5e2abd80008d99d4c0c5d1ad0b5e72cec7c494d" +dependencies = [ + "bytes", +] + +[[package]] +name = "cc" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2" +dependencies = [ + "jobserver", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "const_fn" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f92cfa0fd5690b3cf8c1ef2cabbd9b7ef22fa53cf5e1f92b05103f6d5d1cf6e7" + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "cookie" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f1c7727e460397e56abc4bddc1d49e07a1ad78fc98eb2e1c8f032a58a2f80d" +dependencies = [ + "percent-encoding", + "time", + "version_check", +] + +[[package]] +name = "cpufeatures" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" +dependencies = [ + "cfg-if", + "lazy_static", +] + +[[package]] +name = "derive_more" +version = "0.99.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40eebddd2156ce1bb37b20bbe5151340a31828b1f2d22ba4141f3531710e38df" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version 0.3.3", + "syn", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "discard" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "encoding_rs" +version = "0.8.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80df024fbc5ac80f87dfef0d9f5209a252f2a497f7f42944cff24d8253cac065" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "env-var-helpers" +version = "0.1.0" +source = "git+https://github.com/PiDelport/rust-env-var-helpers#8aed1f58daf2e68b880e2dc0defa3650987e69c6" +dependencies = [ + "thiserror", +] + +[[package]] +name = "flate2" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd3aec53de10fe96d7d8c565eb17f2c687bb5518a2ec453b5b1252964526abe0" +dependencies = [ + "cfg-if", + "crc32fast", + "libc", + "miniz_oxide", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +dependencies = [ + "matches", + "percent-encoding", +] + +[[package]] +name = "futures-core" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af51b1b4a7fdff033703db39de8802c673eb91855f2e0d47dcf3bf2c0ef01f99" + +[[package]] +name = "futures-sink" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0f30aaa67363d119812743aa5f33c201a7a66329f97d1a887022971feea4b53" + +[[package]] +name = "futures-task" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbe54a98670017f3be909561f6ad13e810d9a51f3f061b902062ca3da80799f2" + +[[package]] +name = "futures-util" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67eb846bfd58e44a8481a00049e82c43e0ccb5d61f8dc071057cb19249dd4d78" +dependencies = [ + "autocfg", + "futures-core", + "futures-sink", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "generic-array" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "h2" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "825343c4eef0b63f541f8903f395dc5beb362a979b5799a84062527ef1e37726" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "http" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "527e8c9ac747e28542699a951517aa9a6945af506cd1f2e1b53a576c17b6cc11" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-service-impl" +version = "0.1.0" +dependencies = [ + "actix", + "actix-cors", + "actix-web", + "rmp-serde", + "serde", + "sgx_types", +] + +[[package]] +name = "httparse" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a87b616e37e93c22fb19bcd386f02f3af5ea98a25670ad0fce773de23c5e68" + +[[package]] +name = "idna" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "instant" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "itoa" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" + +[[package]] +name = "jobserver" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5ca711fd837261e14ec9e674f092cbb931d3fa1482b017ae59328ddc6f3212b" +dependencies = [ + "libc", +] + +[[package]] +name = "language-tags" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790" + +[[package]] +name = "local-channel" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6246c68cf195087205a0512559c97e15eaf95198bf0e206d662092cdcb03fe9f" +dependencies = [ + "futures-core", + "futures-sink", + "futures-util", + "local-waker", +] + +[[package]] +name = "local-waker" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84f9a2d3e27ce99ce2c3aad0b09b1a7b916293ea9b2bf624c13fe646fadd8da4" + +[[package]] +name = "lock_api" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "matches" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" + +[[package]] +name = "memchr" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" + +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + +[[package]] +name = "miniz_oxide" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" +dependencies = [ + "adler", + "autocfg", +] + +[[package]] +name = "mio" +version = "0.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c2bdb6314ec10835cd3293dd268473a835c02b7b352e788be788b3c6ca6bb16" +dependencies = [ + "libc", + "log", + "miow", + "ntapi", + "winapi", +] + +[[package]] +name = "miow" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" +dependencies = [ + "winapi", +] + +[[package]] +name = "ntapi" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" +dependencies = [ + "winapi", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "parking_lot" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + +[[package]] +name = "paste" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "pest" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +dependencies = [ + "ucd-trie", +] + +[[package]] +name = "pin-project" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "576bc800220cc65dac09e99e97b08b358cfab6e17078de8dc5fee223bd2d0c08" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e8fe8163d14ce7f0cdac2e040116f22eac817edabff0be91e8aff7e9accf389" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "ppv-lite86" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" + +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro2" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", + "rand_hc", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_hc" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" +dependencies = [ + "rand_core", +] + +[[package]] +name = "redox_syscall" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" + +[[package]] +name = "rmp" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f55e5fa1446c4d5dd1f5daeed2a4fe193071771a2636274d0d7a3b082aa7ad6" +dependencies = [ + "byteorder", + "num-traits", +] + +[[package]] +name = "rmp-serde" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "723ecff9ad04f4ad92fe1c8ca6c20d2196d9286e9c60727c4cb5511629260e9d" +dependencies = [ + "byteorder", + "rmp", + "serde", +] + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver 0.9.0", +] + +[[package]] +name = "rustc_version" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver 0.11.0", +] + +[[package]] +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser 0.7.0", +] + +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser 0.10.2", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + +[[package]] +name = "serde" +version = "1.0.127" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f03b9878abf6d14e6779d3f24f07b2cfa90352cfec4acc5aab8f1ac7f146fae8" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.127" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a024926d3432516606328597e0f224a51355a493b49fdd67e9209187cbe55ecc" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "336b10da19a12ad094b59d870ebde26a45402e5b470add4b5fd03c5048a32127" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sgx-helpers" +version = "0.1.0" +dependencies = [ + "sgx_types", +] + +[[package]] +name = "sgx-wallet-app" +version = "0.1.0" +dependencies = [ + "actix-web", + "env-var-helpers", + "http-service-impl", + "sgx-helpers", + "sgx_types", + "sgx_urts", +] + +[[package]] +name = "sgx_types" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" + +[[package]] +name = "sgx_urts" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "libc", + "sgx_types", +] + +[[package]] +name = "sha-1" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a0c8611594e2ab4ebbf06ec7cbbf0a99450b8570e96cbf5188b5d5f6ef18d81" +dependencies = [ + "block-buffer", + "cfg-if", + "cpufeatures", + "digest", + "opaque-debug", +] + +[[package]] +name = "sha1" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" + +[[package]] +name = "signal-hook-registry" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c307a32c1c5c437f38c7fd45d753050587732ba8628319fbdf12a7e289ccc590" + +[[package]] +name = "smallvec" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" + +[[package]] +name = "socket2" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "765f090f0e423d2b55843402a07915add955e7d60657db13707a159727326cad" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "standback" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff" +dependencies = [ + "version_check", +] + +[[package]] +name = "stdweb" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" +dependencies = [ + "discard", + "rustc_version 0.2.3", + "stdweb-derive", + "stdweb-internal-macros", + "stdweb-internal-runtime", + "wasm-bindgen", +] + +[[package]] +name = "stdweb-derive" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "serde_derive", + "syn", +] + +[[package]] +name = "stdweb-internal-macros" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" +dependencies = [ + "base-x", + "proc-macro2", + "quote", + "serde", + "serde_derive", + "serde_json", + "sha1", + "syn", +] + +[[package]] +name = "stdweb-internal-runtime" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" + +[[package]] +name = "syn" +version = "1.0.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1873d832550d4588c3dbc20f01361ab00bfe741048f71e3fecf145a7cc18b29c" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "thiserror" +version = "1.0.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "602eca064b2d83369e2b2f34b09c70b605402801927c65c11071ac911d299b88" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bad553cc2c78e8de258400763a647e80e6d1b31ee237275d756f6836d204494c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "time" +version = "0.2.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4752a97f8eebd6854ff91f1c1824cd6160626ac4bd44287f7f4ea2035a02a242" +dependencies = [ + "const_fn", + "libc", + "standback", + "stdweb", + "time-macros", + "version_check", + "winapi", +] + +[[package]] +name = "time-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1" +dependencies = [ + "proc-macro-hack", + "time-macros-impl", +] + +[[package]] +name = "time-macros-impl" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3c141a1b43194f3f56a1411225df8646c55781d5f26db825b3d98507eb482f" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "standback", + "syn", +] + +[[package]] +name = "tinyvec" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "848a1e1181b9f6753b5e96a092749e29b11d19ede67dfbbd6c7dc7e0f49b5338" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "tokio" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01cf844b23c6131f624accf65ce0e4e9956a8bb329400ea5bcc26ae3a5c20b0b" +dependencies = [ + "autocfg", + "bytes", + "libc", + "memchr", + "mio", + "once_cell", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "winapi", +] + +[[package]] +name = "tokio-util" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1caa0b0c8d94a049db56b5acf8cba99dc0623aab1b26d5b5f5e2d945846b3592" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tracing" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9ff14f98b1a4b289c6248a023c1c2fa1491062964e9fed67ab29c4e4da4a052" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "typenum" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" + +[[package]] +name = "ucd-trie" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" + +[[package]] +name = "unicode-bidi" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "246f4c42e67e7a4e3c6106ff716a5d067d4132a642840b242e357e468a2a0085" + +[[package]] +name = "unicode-normalization" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "url" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" +dependencies = [ + "form_urlencoded", + "idna", + "matches", + "percent-encoding", +] + +[[package]] +name = "version_check" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" + +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + +[[package]] +name = "wasm-bindgen" +version = "0.2.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b608ecc8f4198fe8680e2ed18eccab5f0cd4caaf3d83516fa5fb2e927fda2586" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "580aa3a91a63d23aac5b6b267e2d13cb4f363e31dce6c352fca4752ae12e479f" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "171ebf0ed9e1458810dfcb31f2e766ad6b3a89dbda42d8901f2b268277e5f09c" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c2657dd393f03aa2a659c25c6ae18a13a4048cebd220e147933ea837efc589f" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e0c4a743a309662d45f4ede961d7afa4ba4131a59a639f29b0069c3798bbcc2" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "zstd" +version = "0.7.0+zstd.1.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9428752481d8372e15b1bf779ea518a179ad6c771cca2d2c60e4fbff3cc2cd52" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "3.1.0+zstd.1.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa1926623ad7fe406e090555387daf73db555b948134b4d73eac5eb08fb666d" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "1.5.0+zstd.1.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e6c094340240369025fc6b731b054ee2a834328fa584310ac96aa4baebdc465" +dependencies = [ + "cc", + "libc", +] diff --git a/rust-sgx-workspace/projects/sgx-wallet/app/Cargo.toml b/rust-sgx-workspace/projects/sgx-wallet/app/Cargo.toml new file mode 100644 index 0000000..96777e6 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/app/Cargo.toml @@ -0,0 +1,20 @@ +[package] +# name matches APP_U in Makefile +name = "sgx-wallet-app" +version = "0.1.0" +edition = "2021" +build = "build.rs" + +[dependencies] +actix-web = "4.0.0-beta.8" + +env-var-helpers = { git = "https://github.com/PiDelport/rust-env-var-helpers", default-features = false } + +# SGX SDK +sgx_types = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } +sgx_urts = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } + +http-service-impl = { path = "../../../crates/http-service-impl" } +sgx-helpers = { path = "../../../crates/sgx-helpers" } + +[patch.'https://github.com/apache/teaclave-sgx-sdk.git'] diff --git a/rust-sgx-workspace/projects/sgx-wallet/app/Makefile b/rust-sgx-workspace/projects/sgx-wallet/app/Makefile new file mode 100644 index 0000000..935599d --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/app/Makefile @@ -0,0 +1,100 @@ +# Makefile settings - Host part + +LIB = ../build/lib/ +BIN = ../build/bin/ +# APP_U matches name in Cargo.toml +APP_U = sgx-wallet-app +APP_T = enclave.so +NAME_U = libEnclave_u.a +SRC_U = ./ +CODEGEN_U = $(SRC_U)/codegen/ +SRC_T = ../enclave/ +OBJ_U = ../build/obj/ +FLAGS = -Wall -Wextra +GCC_STEP1_U = -I $(CODEGEN_U) -I./include -I$(SGX_SDK)/include -I$(CUSTOM_EDL_PATH) -fPIC -Wno-attributes $(SGX_COMMON_CFLAGS) +FILES_U = Enclave_u.c +FILES_U_H = Enclave_u.h +SGX_ARCH = x64 +TRTS_LIB = sgx_trts +SERVICE_LIB = sgx_tservice +# Addprefix dependant variables, no need to change those +OUTPUT_U = $(FILES_U:.c=.o) +BIN_U = $(addprefix $(BIN), $(APP_U)) +NAME_U_D = $(addprefix $(LIB), $(NAME_U)) +FILES_U_F=$(addprefix $(CODEGEN_U), $(FILES_U)) +FILES_U_H_F=$(addprefix $(CODEGEN_U), $(FILES_U_H)) +OUTPUT_W_FU=$(addprefix $(OBJ_U), $(OUTPUT_U)) + +# All Rust and other source files that the Cargo build depends on. +FILES_RUST_F = Cargo.toml Cargo.lock build.rs $(shell find src ../../../crates/http-service-impl/src -name '*.rs') $(CODEGEN_U)Enclave_u.rs + +# Contains compilation rules for the enclave part + +include ../buildenv.mk +include ../buildenv_sgx.mk + +# Custom libraries, EDL paths. Needs to be specified with make (CUSTOM_EDL_PATH) (CUSTOM_COMMON_PATH) + +# Compilation process, we set up all the dependencies needed to have the correct order of build, and avoid relink + +all: $(BIN_U) + +$(FILES_U_F): $(SGX_EDGER8R) $(SRC_T)/Enclave.edl + @echo "\033[32mGenerating untrusted SGX C edl files...\033[0m" + @$(SGX_EDGER8R) --untrusted $(SRC_T)/Enclave.edl --search-path $(SGX_SDK)/include --search-path $(CUSTOM_EDL_PATH) --untrusted-dir $(CODEGEN_U) + +$(NAME_U_D): $(FILES_U_F) $(OUTPUT_W_FU) + @echo "\033[32mBuilding untrusted C edl static library...\033[0m" + @mkdir -p $(LIB) + @$(AR) rcsD $@ $(OUTPUT_W_FU) + +$(OBJ_U)%.o:$(CODEGEN_U)%.c + @mkdir -p $(OBJ_U) + @echo "\033[32m$?: Build in progress...\033[0m" + @$(CC) $(FLAGS) $(GCC_STEP1_U) -o $@ -c $? + +# We print the compilation mode we're in (hardware/software mode), just as a reminder. + +$(BIN_U): $(NAME_U_D) $(FILES_RUST_F) $(FILES_U_H_F) +ifeq ($(SGX_MODE), SW) + @echo "\033[32mSoftware / Simulation mode\033[0m" +else + @echo "\033[32mHardware mode\033[0m" +endif + @echo "\033[32mStarting cargo to build the host...\033[0m" + @cd $(SRC_U) && SGX_SDK=$(SGX_SDK) cargo build --release + @echo "\033[32mCopying the host to the correct location... ($(BIN_U))\033[0m" + @mkdir -p $(BIN) + @cp $(SRC_U)/target/release/$(APP_U) $(BIN) + +$(CODEGEN_U)Enclave_u.rs: $(CODEGEN_U)Enclave_u.h + @echo "\033[32mGenerating Rust bindings: $@\033[0m" + @bindgen \ + --no-recursive-allowlist \ + --raw-line 'use sgx_types::*;' \ + --allowlist-function 'enclave_create_report|wallet_operation' \ + --use-array-pointers-in-arguments \ + --output $@ \ + $? \ + -- -I$(SGX_SDK)/include -I$(CUSTOM_EDL_PATH) + +clean: c_clean + @rm -rf $(OBJ_U) + @echo "\033[32mObject files deleted\033[0m" + +fclean: clean fclean_host + +fclean_host: + @echo "\033[32mBinary file $(BIN_U) deleted\033[0m" + @rm -f $(BIN_U) + @rm -f $(NAME_U_D) + @cargo clean + +c_clean: + @echo "\033[32mC edl generated files deleted\033[0m" + @rm -rf $(FILES_U_F) + @rm -rf $(FILES_U_H_F) + +re: fclean all + +.PHONY: all clean c_clean fclean re fclean_host diff --git a/rust-sgx-workspace/projects/sgx-wallet/app/build.rs b/rust-sgx-workspace/projects/sgx-wallet/app/build.rs new file mode 100644 index 0000000..8cb97aa --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/app/build.rs @@ -0,0 +1,21 @@ +use std::env; + +fn main() { + println!("cargo:rerun-if-env-changed=SGX_SDK"); + println!("cargo:rerun-if-env-changed=SGX_MODE"); + + let sdk_dir = env::var("SGX_SDK").unwrap_or_else(|_| "/opt/sgxsdk".to_string()); + let is_sim = env::var("SGX_MODE").unwrap_or_else(|_| "HW".to_string()); + + println!("cargo:rustc-link-search=native=../build/lib"); + println!("cargo:rustc-link-lib=static=Enclave_u"); + + println!("cargo:rustc-link-search=native={}/lib64", sdk_dir); + match is_sim.as_ref() { + "SW" => println!("cargo:rustc-link-lib=dylib=sgx_urts_sim"), + "HW" => println!("cargo:rustc-link-lib=dylib=sgx_urts"), + _ => println!("cargo:rustc-link-lib=dylib=sgx_urts"), // Treat undefined as HW + } + + println!("cargo:rustc-link-lib=dylib=sgx_uprotected_fs"); +} diff --git a/rust-sgx-workspace/projects/sgx-wallet/app/codegen/Enclave_u.c b/rust-sgx-workspace/projects/sgx-wallet/app/codegen/Enclave_u.c new file mode 100644 index 0000000..4d5b70d --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/app/codegen/Enclave_u.c @@ -0,0 +1,1336 @@ +#include "Enclave_u.h" +#include + +typedef struct ms_enclave_create_report_t { + sgx_status_t ms_retval; + const sgx_target_info_t* ms_p_qe3_target; + sgx_report_t* ms_p_report; + uint8_t* ms_enclave_data; +} ms_enclave_create_report_t; + +typedef struct ms_wallet_operation_t { + sgx_status_t ms_retval; + const uint8_t* ms_sealed_request_buffer; + size_t ms_sealed_request_size; + uint8_t* ms_sealed_response_buffer; + size_t ms_sealed_response_capacity; + size_t* ms_sealed_response_used; +} ms_wallet_operation_t; + +typedef struct ms_t_global_init_ecall_t { + uint64_t ms_id; + const uint8_t* ms_path; + size_t ms_len; +} ms_t_global_init_ecall_t; + +typedef struct ms_sgx_oc_cpuidex_t { + int* ms_cpuinfo; + int ms_leaf; + int ms_subleaf; +} ms_sgx_oc_cpuidex_t; + +typedef struct ms_sgx_thread_wait_untrusted_event_ocall_t { + int ms_retval; + const void* ms_self; +} ms_sgx_thread_wait_untrusted_event_ocall_t; + +typedef struct ms_sgx_thread_set_untrusted_event_ocall_t { + int ms_retval; + const void* ms_waiter; +} ms_sgx_thread_set_untrusted_event_ocall_t; + +typedef struct ms_sgx_thread_setwait_untrusted_events_ocall_t { + int ms_retval; + const void* ms_waiter; + const void* ms_self; +} ms_sgx_thread_setwait_untrusted_events_ocall_t; + +typedef struct ms_sgx_thread_set_multiple_untrusted_events_ocall_t { + int ms_retval; + const void** ms_waiters; + size_t ms_total; +} ms_sgx_thread_set_multiple_untrusted_events_ocall_t; + +typedef struct ms_u_thread_set_event_ocall_t { + int ms_retval; + int* ms_error; + const void* ms_tcs; +} ms_u_thread_set_event_ocall_t; + +typedef struct ms_u_thread_wait_event_ocall_t { + int ms_retval; + int* ms_error; + const void* ms_tcs; + const struct timespec* ms_timeout; +} ms_u_thread_wait_event_ocall_t; + +typedef struct ms_u_thread_set_multiple_events_ocall_t { + int ms_retval; + int* ms_error; + const void** ms_tcss; + int ms_total; +} ms_u_thread_set_multiple_events_ocall_t; + +typedef struct ms_u_thread_setwait_events_ocall_t { + int ms_retval; + int* ms_error; + const void* ms_waiter_tcs; + const void* ms_self_tcs; + const struct timespec* ms_timeout; +} ms_u_thread_setwait_events_ocall_t; + +typedef struct ms_u_clock_gettime_ocall_t { + int ms_retval; + int* ms_error; + int ms_clk_id; + struct timespec* ms_tp; +} ms_u_clock_gettime_ocall_t; + +typedef struct ms_u_read_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + void* ms_buf; + size_t ms_count; +} ms_u_read_ocall_t; + +typedef struct ms_u_pread64_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + void* ms_buf; + size_t ms_count; + int64_t ms_offset; +} ms_u_pread64_ocall_t; + +typedef struct ms_u_readv_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const struct iovec* ms_iov; + int ms_iovcnt; +} ms_u_readv_ocall_t; + +typedef struct ms_u_preadv64_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const struct iovec* ms_iov; + int ms_iovcnt; + int64_t ms_offset; +} ms_u_preadv64_ocall_t; + +typedef struct ms_u_write_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const void* ms_buf; + size_t ms_count; +} ms_u_write_ocall_t; + +typedef struct ms_u_pwrite64_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const void* ms_buf; + size_t ms_count; + int64_t ms_offset; +} ms_u_pwrite64_ocall_t; + +typedef struct ms_u_writev_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const struct iovec* ms_iov; + int ms_iovcnt; +} ms_u_writev_ocall_t; + +typedef struct ms_u_pwritev64_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const struct iovec* ms_iov; + int ms_iovcnt; + int64_t ms_offset; +} ms_u_pwritev64_ocall_t; + +typedef struct ms_u_fcntl_arg0_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int ms_cmd; +} ms_u_fcntl_arg0_ocall_t; + +typedef struct ms_u_fcntl_arg1_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int ms_cmd; + int ms_arg; +} ms_u_fcntl_arg1_ocall_t; + +typedef struct ms_u_ioctl_arg0_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int ms_request; +} ms_u_ioctl_arg0_ocall_t; + +typedef struct ms_u_ioctl_arg1_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int ms_request; + int* ms_arg; +} ms_u_ioctl_arg1_ocall_t; + +typedef struct ms_u_close_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; +} ms_u_close_ocall_t; + +typedef struct ms_u_malloc_ocall_t { + void* ms_retval; + int* ms_error; + size_t ms_size; +} ms_u_malloc_ocall_t; + +typedef struct ms_u_free_ocall_t { + void* ms_p; +} ms_u_free_ocall_t; + +typedef struct ms_u_mmap_ocall_t { + void* ms_retval; + int* ms_error; + void* ms_start; + size_t ms_length; + int ms_prot; + int ms_flags; + int ms_fd; + int64_t ms_offset; +} ms_u_mmap_ocall_t; + +typedef struct ms_u_munmap_ocall_t { + int ms_retval; + int* ms_error; + void* ms_start; + size_t ms_length; +} ms_u_munmap_ocall_t; + +typedef struct ms_u_msync_ocall_t { + int ms_retval; + int* ms_error; + void* ms_addr; + size_t ms_length; + int ms_flags; +} ms_u_msync_ocall_t; + +typedef struct ms_u_mprotect_ocall_t { + int ms_retval; + int* ms_error; + void* ms_addr; + size_t ms_length; + int ms_prot; +} ms_u_mprotect_ocall_t; + +typedef struct ms_u_open_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_pathname; + int ms_flags; +} ms_u_open_ocall_t; + +typedef struct ms_u_open64_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + int ms_oflag; + int ms_mode; +} ms_u_open64_ocall_t; + +typedef struct ms_u_fstat_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + struct stat_t* ms_buf; +} ms_u_fstat_ocall_t; + +typedef struct ms_u_fstat64_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + struct stat64_t* ms_buf; +} ms_u_fstat64_ocall_t; + +typedef struct ms_u_stat_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + struct stat_t* ms_buf; +} ms_u_stat_ocall_t; + +typedef struct ms_u_stat64_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + struct stat64_t* ms_buf; +} ms_u_stat64_ocall_t; + +typedef struct ms_u_lstat_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + struct stat_t* ms_buf; +} ms_u_lstat_ocall_t; + +typedef struct ms_u_lstat64_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + struct stat64_t* ms_buf; +} ms_u_lstat64_ocall_t; + +typedef struct ms_u_lseek_ocall_t { + uint64_t ms_retval; + int* ms_error; + int ms_fd; + int64_t ms_offset; + int ms_whence; +} ms_u_lseek_ocall_t; + +typedef struct ms_u_lseek64_ocall_t { + int64_t ms_retval; + int* ms_error; + int ms_fd; + int64_t ms_offset; + int ms_whence; +} ms_u_lseek64_ocall_t; + +typedef struct ms_u_ftruncate_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int64_t ms_length; +} ms_u_ftruncate_ocall_t; + +typedef struct ms_u_ftruncate64_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int64_t ms_length; +} ms_u_ftruncate64_ocall_t; + +typedef struct ms_u_truncate_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + int64_t ms_length; +} ms_u_truncate_ocall_t; + +typedef struct ms_u_truncate64_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + int64_t ms_length; +} ms_u_truncate64_ocall_t; + +typedef struct ms_u_fsync_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; +} ms_u_fsync_ocall_t; + +typedef struct ms_u_fdatasync_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; +} ms_u_fdatasync_ocall_t; + +typedef struct ms_u_fchmod_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + uint32_t ms_mode; +} ms_u_fchmod_ocall_t; + +typedef struct ms_u_unlink_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_pathname; +} ms_u_unlink_ocall_t; + +typedef struct ms_u_link_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_oldpath; + const char* ms_newpath; +} ms_u_link_ocall_t; + +typedef struct ms_u_linkat_ocall_t { + int ms_retval; + int* ms_error; + int ms_olddirfd; + const char* ms_oldpath; + int ms_newdirfd; + const char* ms_newpath; + int ms_flags; +} ms_u_linkat_ocall_t; + +typedef struct ms_u_rename_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_oldpath; + const char* ms_newpath; +} ms_u_rename_ocall_t; + +typedef struct ms_u_chmod_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + uint32_t ms_mode; +} ms_u_chmod_ocall_t; + +typedef struct ms_u_readlink_ocall_t { + size_t ms_retval; + int* ms_error; + const char* ms_path; + char* ms_buf; + size_t ms_bufsz; +} ms_u_readlink_ocall_t; + +typedef struct ms_u_symlink_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path1; + const char* ms_path2; +} ms_u_symlink_ocall_t; + +typedef struct ms_u_realpath_ocall_t { + char* ms_retval; + int* ms_error; + const char* ms_pathname; +} ms_u_realpath_ocall_t; + +typedef struct ms_u_mkdir_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_pathname; + uint32_t ms_mode; +} ms_u_mkdir_ocall_t; + +typedef struct ms_u_rmdir_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_pathname; +} ms_u_rmdir_ocall_t; + +typedef struct ms_u_opendir_ocall_t { + void* ms_retval; + int* ms_error; + const char* ms_pathname; +} ms_u_opendir_ocall_t; + +typedef struct ms_u_readdir64_r_ocall_t { + int ms_retval; + void* ms_dirp; + struct dirent64_t* ms_entry; + struct dirent64_t** ms_result; +} ms_u_readdir64_r_ocall_t; + +typedef struct ms_u_closedir_ocall_t { + int ms_retval; + int* ms_error; + void* ms_dirp; +} ms_u_closedir_ocall_t; + +typedef struct ms_u_dirfd_ocall_t { + int ms_retval; + int* ms_error; + void* ms_dirp; +} ms_u_dirfd_ocall_t; + +typedef struct ms_u_fstatat64_ocall_t { + int ms_retval; + int* ms_error; + int ms_dirfd; + const char* ms_pathname; + struct stat64_t* ms_buf; + int ms_flags; +} ms_u_fstatat64_ocall_t; + +typedef struct ms_u_environ_ocall_t { + char** ms_retval; +} ms_u_environ_ocall_t; + +typedef struct ms_u_getenv_ocall_t { + char* ms_retval; + const char* ms_name; +} ms_u_getenv_ocall_t; + +typedef struct ms_u_setenv_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_name; + const char* ms_value; + int ms_overwrite; +} ms_u_setenv_ocall_t; + +typedef struct ms_u_unsetenv_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_name; +} ms_u_unsetenv_ocall_t; + +typedef struct ms_u_chdir_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_dir; +} ms_u_chdir_ocall_t; + +typedef struct ms_u_getcwd_ocall_t { + char* ms_retval; + int* ms_error; + char* ms_buf; + size_t ms_buflen; +} ms_u_getcwd_ocall_t; + +typedef struct ms_u_getpwuid_r_ocall_t { + int ms_retval; + unsigned int ms_uid; + struct passwd* ms_pwd; + char* ms_buf; + size_t ms_buflen; + struct passwd** ms_passwd_result; +} ms_u_getpwuid_r_ocall_t; + +typedef struct ms_u_getuid_ocall_t { + unsigned int ms_retval; +} ms_u_getuid_ocall_t; + +typedef struct ms_u_sgxprotectedfs_exclusive_file_open_t { + void* ms_retval; + const char* ms_filename; + uint8_t ms_read_only; + int64_t* ms_file_size; + int32_t* ms_error_code; +} ms_u_sgxprotectedfs_exclusive_file_open_t; + +typedef struct ms_u_sgxprotectedfs_check_if_file_exists_t { + uint8_t ms_retval; + const char* ms_filename; +} ms_u_sgxprotectedfs_check_if_file_exists_t; + +typedef struct ms_u_sgxprotectedfs_fread_node_t { + int32_t ms_retval; + void* ms_f; + uint64_t ms_node_number; + uint8_t* ms_buffer; + uint32_t ms_node_size; +} ms_u_sgxprotectedfs_fread_node_t; + +typedef struct ms_u_sgxprotectedfs_fwrite_node_t { + int32_t ms_retval; + void* ms_f; + uint64_t ms_node_number; + uint8_t* ms_buffer; + uint32_t ms_node_size; +} ms_u_sgxprotectedfs_fwrite_node_t; + +typedef struct ms_u_sgxprotectedfs_fclose_t { + int32_t ms_retval; + void* ms_f; +} ms_u_sgxprotectedfs_fclose_t; + +typedef struct ms_u_sgxprotectedfs_fflush_t { + uint8_t ms_retval; + void* ms_f; +} ms_u_sgxprotectedfs_fflush_t; + +typedef struct ms_u_sgxprotectedfs_remove_t { + int32_t ms_retval; + const char* ms_filename; +} ms_u_sgxprotectedfs_remove_t; + +typedef struct ms_u_sgxprotectedfs_recovery_file_open_t { + void* ms_retval; + const char* ms_filename; +} ms_u_sgxprotectedfs_recovery_file_open_t; + +typedef struct ms_u_sgxprotectedfs_fwrite_recovery_node_t { + uint8_t ms_retval; + void* ms_f; + uint8_t* ms_data; + uint32_t ms_data_length; +} ms_u_sgxprotectedfs_fwrite_recovery_node_t; + +typedef struct ms_u_sgxprotectedfs_do_file_recovery_t { + int32_t ms_retval; + const char* ms_filename; + const char* ms_recovery_filename; + uint32_t ms_node_size; +} ms_u_sgxprotectedfs_do_file_recovery_t; + +static sgx_status_t SGX_CDECL Enclave_sgx_oc_cpuidex(void* pms) +{ + ms_sgx_oc_cpuidex_t* ms = SGX_CAST(ms_sgx_oc_cpuidex_t*, pms); + sgx_oc_cpuidex(ms->ms_cpuinfo, ms->ms_leaf, ms->ms_subleaf); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_sgx_thread_wait_untrusted_event_ocall(void* pms) +{ + ms_sgx_thread_wait_untrusted_event_ocall_t* ms = SGX_CAST(ms_sgx_thread_wait_untrusted_event_ocall_t*, pms); + ms->ms_retval = sgx_thread_wait_untrusted_event_ocall(ms->ms_self); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_sgx_thread_set_untrusted_event_ocall(void* pms) +{ + ms_sgx_thread_set_untrusted_event_ocall_t* ms = SGX_CAST(ms_sgx_thread_set_untrusted_event_ocall_t*, pms); + ms->ms_retval = sgx_thread_set_untrusted_event_ocall(ms->ms_waiter); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_sgx_thread_setwait_untrusted_events_ocall(void* pms) +{ + ms_sgx_thread_setwait_untrusted_events_ocall_t* ms = SGX_CAST(ms_sgx_thread_setwait_untrusted_events_ocall_t*, pms); + ms->ms_retval = sgx_thread_setwait_untrusted_events_ocall(ms->ms_waiter, ms->ms_self); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_sgx_thread_set_multiple_untrusted_events_ocall(void* pms) +{ + ms_sgx_thread_set_multiple_untrusted_events_ocall_t* ms = SGX_CAST(ms_sgx_thread_set_multiple_untrusted_events_ocall_t*, pms); + ms->ms_retval = sgx_thread_set_multiple_untrusted_events_ocall(ms->ms_waiters, ms->ms_total); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_thread_set_event_ocall(void* pms) +{ + ms_u_thread_set_event_ocall_t* ms = SGX_CAST(ms_u_thread_set_event_ocall_t*, pms); + ms->ms_retval = u_thread_set_event_ocall(ms->ms_error, ms->ms_tcs); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_thread_wait_event_ocall(void* pms) +{ + ms_u_thread_wait_event_ocall_t* ms = SGX_CAST(ms_u_thread_wait_event_ocall_t*, pms); + ms->ms_retval = u_thread_wait_event_ocall(ms->ms_error, ms->ms_tcs, ms->ms_timeout); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_thread_set_multiple_events_ocall(void* pms) +{ + ms_u_thread_set_multiple_events_ocall_t* ms = SGX_CAST(ms_u_thread_set_multiple_events_ocall_t*, pms); + ms->ms_retval = u_thread_set_multiple_events_ocall(ms->ms_error, ms->ms_tcss, ms->ms_total); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_thread_setwait_events_ocall(void* pms) +{ + ms_u_thread_setwait_events_ocall_t* ms = SGX_CAST(ms_u_thread_setwait_events_ocall_t*, pms); + ms->ms_retval = u_thread_setwait_events_ocall(ms->ms_error, ms->ms_waiter_tcs, ms->ms_self_tcs, ms->ms_timeout); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_clock_gettime_ocall(void* pms) +{ + ms_u_clock_gettime_ocall_t* ms = SGX_CAST(ms_u_clock_gettime_ocall_t*, pms); + ms->ms_retval = u_clock_gettime_ocall(ms->ms_error, ms->ms_clk_id, ms->ms_tp); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_read_ocall(void* pms) +{ + ms_u_read_ocall_t* ms = SGX_CAST(ms_u_read_ocall_t*, pms); + ms->ms_retval = u_read_ocall(ms->ms_error, ms->ms_fd, ms->ms_buf, ms->ms_count); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_pread64_ocall(void* pms) +{ + ms_u_pread64_ocall_t* ms = SGX_CAST(ms_u_pread64_ocall_t*, pms); + ms->ms_retval = u_pread64_ocall(ms->ms_error, ms->ms_fd, ms->ms_buf, ms->ms_count, ms->ms_offset); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_readv_ocall(void* pms) +{ + ms_u_readv_ocall_t* ms = SGX_CAST(ms_u_readv_ocall_t*, pms); + ms->ms_retval = u_readv_ocall(ms->ms_error, ms->ms_fd, ms->ms_iov, ms->ms_iovcnt); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_preadv64_ocall(void* pms) +{ + ms_u_preadv64_ocall_t* ms = SGX_CAST(ms_u_preadv64_ocall_t*, pms); + ms->ms_retval = u_preadv64_ocall(ms->ms_error, ms->ms_fd, ms->ms_iov, ms->ms_iovcnt, ms->ms_offset); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_write_ocall(void* pms) +{ + ms_u_write_ocall_t* ms = SGX_CAST(ms_u_write_ocall_t*, pms); + ms->ms_retval = u_write_ocall(ms->ms_error, ms->ms_fd, ms->ms_buf, ms->ms_count); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_pwrite64_ocall(void* pms) +{ + ms_u_pwrite64_ocall_t* ms = SGX_CAST(ms_u_pwrite64_ocall_t*, pms); + ms->ms_retval = u_pwrite64_ocall(ms->ms_error, ms->ms_fd, ms->ms_buf, ms->ms_count, ms->ms_offset); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_writev_ocall(void* pms) +{ + ms_u_writev_ocall_t* ms = SGX_CAST(ms_u_writev_ocall_t*, pms); + ms->ms_retval = u_writev_ocall(ms->ms_error, ms->ms_fd, ms->ms_iov, ms->ms_iovcnt); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_pwritev64_ocall(void* pms) +{ + ms_u_pwritev64_ocall_t* ms = SGX_CAST(ms_u_pwritev64_ocall_t*, pms); + ms->ms_retval = u_pwritev64_ocall(ms->ms_error, ms->ms_fd, ms->ms_iov, ms->ms_iovcnt, ms->ms_offset); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_fcntl_arg0_ocall(void* pms) +{ + ms_u_fcntl_arg0_ocall_t* ms = SGX_CAST(ms_u_fcntl_arg0_ocall_t*, pms); + ms->ms_retval = u_fcntl_arg0_ocall(ms->ms_error, ms->ms_fd, ms->ms_cmd); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_fcntl_arg1_ocall(void* pms) +{ + ms_u_fcntl_arg1_ocall_t* ms = SGX_CAST(ms_u_fcntl_arg1_ocall_t*, pms); + ms->ms_retval = u_fcntl_arg1_ocall(ms->ms_error, ms->ms_fd, ms->ms_cmd, ms->ms_arg); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_ioctl_arg0_ocall(void* pms) +{ + ms_u_ioctl_arg0_ocall_t* ms = SGX_CAST(ms_u_ioctl_arg0_ocall_t*, pms); + ms->ms_retval = u_ioctl_arg0_ocall(ms->ms_error, ms->ms_fd, ms->ms_request); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_ioctl_arg1_ocall(void* pms) +{ + ms_u_ioctl_arg1_ocall_t* ms = SGX_CAST(ms_u_ioctl_arg1_ocall_t*, pms); + ms->ms_retval = u_ioctl_arg1_ocall(ms->ms_error, ms->ms_fd, ms->ms_request, ms->ms_arg); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_close_ocall(void* pms) +{ + ms_u_close_ocall_t* ms = SGX_CAST(ms_u_close_ocall_t*, pms); + ms->ms_retval = u_close_ocall(ms->ms_error, ms->ms_fd); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_malloc_ocall(void* pms) +{ + ms_u_malloc_ocall_t* ms = SGX_CAST(ms_u_malloc_ocall_t*, pms); + ms->ms_retval = u_malloc_ocall(ms->ms_error, ms->ms_size); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_free_ocall(void* pms) +{ + ms_u_free_ocall_t* ms = SGX_CAST(ms_u_free_ocall_t*, pms); + u_free_ocall(ms->ms_p); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_mmap_ocall(void* pms) +{ + ms_u_mmap_ocall_t* ms = SGX_CAST(ms_u_mmap_ocall_t*, pms); + ms->ms_retval = u_mmap_ocall(ms->ms_error, ms->ms_start, ms->ms_length, ms->ms_prot, ms->ms_flags, ms->ms_fd, ms->ms_offset); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_munmap_ocall(void* pms) +{ + ms_u_munmap_ocall_t* ms = SGX_CAST(ms_u_munmap_ocall_t*, pms); + ms->ms_retval = u_munmap_ocall(ms->ms_error, ms->ms_start, ms->ms_length); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_msync_ocall(void* pms) +{ + ms_u_msync_ocall_t* ms = SGX_CAST(ms_u_msync_ocall_t*, pms); + ms->ms_retval = u_msync_ocall(ms->ms_error, ms->ms_addr, ms->ms_length, ms->ms_flags); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_mprotect_ocall(void* pms) +{ + ms_u_mprotect_ocall_t* ms = SGX_CAST(ms_u_mprotect_ocall_t*, pms); + ms->ms_retval = u_mprotect_ocall(ms->ms_error, ms->ms_addr, ms->ms_length, ms->ms_prot); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_open_ocall(void* pms) +{ + ms_u_open_ocall_t* ms = SGX_CAST(ms_u_open_ocall_t*, pms); + ms->ms_retval = u_open_ocall(ms->ms_error, ms->ms_pathname, ms->ms_flags); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_open64_ocall(void* pms) +{ + ms_u_open64_ocall_t* ms = SGX_CAST(ms_u_open64_ocall_t*, pms); + ms->ms_retval = u_open64_ocall(ms->ms_error, ms->ms_path, ms->ms_oflag, ms->ms_mode); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_fstat_ocall(void* pms) +{ + ms_u_fstat_ocall_t* ms = SGX_CAST(ms_u_fstat_ocall_t*, pms); + ms->ms_retval = u_fstat_ocall(ms->ms_error, ms->ms_fd, ms->ms_buf); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_fstat64_ocall(void* pms) +{ + ms_u_fstat64_ocall_t* ms = SGX_CAST(ms_u_fstat64_ocall_t*, pms); + ms->ms_retval = u_fstat64_ocall(ms->ms_error, ms->ms_fd, ms->ms_buf); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_stat_ocall(void* pms) +{ + ms_u_stat_ocall_t* ms = SGX_CAST(ms_u_stat_ocall_t*, pms); + ms->ms_retval = u_stat_ocall(ms->ms_error, ms->ms_path, ms->ms_buf); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_stat64_ocall(void* pms) +{ + ms_u_stat64_ocall_t* ms = SGX_CAST(ms_u_stat64_ocall_t*, pms); + ms->ms_retval = u_stat64_ocall(ms->ms_error, ms->ms_path, ms->ms_buf); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_lstat_ocall(void* pms) +{ + ms_u_lstat_ocall_t* ms = SGX_CAST(ms_u_lstat_ocall_t*, pms); + ms->ms_retval = u_lstat_ocall(ms->ms_error, ms->ms_path, ms->ms_buf); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_lstat64_ocall(void* pms) +{ + ms_u_lstat64_ocall_t* ms = SGX_CAST(ms_u_lstat64_ocall_t*, pms); + ms->ms_retval = u_lstat64_ocall(ms->ms_error, ms->ms_path, ms->ms_buf); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_lseek_ocall(void* pms) +{ + ms_u_lseek_ocall_t* ms = SGX_CAST(ms_u_lseek_ocall_t*, pms); + ms->ms_retval = u_lseek_ocall(ms->ms_error, ms->ms_fd, ms->ms_offset, ms->ms_whence); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_lseek64_ocall(void* pms) +{ + ms_u_lseek64_ocall_t* ms = SGX_CAST(ms_u_lseek64_ocall_t*, pms); + ms->ms_retval = u_lseek64_ocall(ms->ms_error, ms->ms_fd, ms->ms_offset, ms->ms_whence); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_ftruncate_ocall(void* pms) +{ + ms_u_ftruncate_ocall_t* ms = SGX_CAST(ms_u_ftruncate_ocall_t*, pms); + ms->ms_retval = u_ftruncate_ocall(ms->ms_error, ms->ms_fd, ms->ms_length); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_ftruncate64_ocall(void* pms) +{ + ms_u_ftruncate64_ocall_t* ms = SGX_CAST(ms_u_ftruncate64_ocall_t*, pms); + ms->ms_retval = u_ftruncate64_ocall(ms->ms_error, ms->ms_fd, ms->ms_length); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_truncate_ocall(void* pms) +{ + ms_u_truncate_ocall_t* ms = SGX_CAST(ms_u_truncate_ocall_t*, pms); + ms->ms_retval = u_truncate_ocall(ms->ms_error, ms->ms_path, ms->ms_length); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_truncate64_ocall(void* pms) +{ + ms_u_truncate64_ocall_t* ms = SGX_CAST(ms_u_truncate64_ocall_t*, pms); + ms->ms_retval = u_truncate64_ocall(ms->ms_error, ms->ms_path, ms->ms_length); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_fsync_ocall(void* pms) +{ + ms_u_fsync_ocall_t* ms = SGX_CAST(ms_u_fsync_ocall_t*, pms); + ms->ms_retval = u_fsync_ocall(ms->ms_error, ms->ms_fd); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_fdatasync_ocall(void* pms) +{ + ms_u_fdatasync_ocall_t* ms = SGX_CAST(ms_u_fdatasync_ocall_t*, pms); + ms->ms_retval = u_fdatasync_ocall(ms->ms_error, ms->ms_fd); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_fchmod_ocall(void* pms) +{ + ms_u_fchmod_ocall_t* ms = SGX_CAST(ms_u_fchmod_ocall_t*, pms); + ms->ms_retval = u_fchmod_ocall(ms->ms_error, ms->ms_fd, ms->ms_mode); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_unlink_ocall(void* pms) +{ + ms_u_unlink_ocall_t* ms = SGX_CAST(ms_u_unlink_ocall_t*, pms); + ms->ms_retval = u_unlink_ocall(ms->ms_error, ms->ms_pathname); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_link_ocall(void* pms) +{ + ms_u_link_ocall_t* ms = SGX_CAST(ms_u_link_ocall_t*, pms); + ms->ms_retval = u_link_ocall(ms->ms_error, ms->ms_oldpath, ms->ms_newpath); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_linkat_ocall(void* pms) +{ + ms_u_linkat_ocall_t* ms = SGX_CAST(ms_u_linkat_ocall_t*, pms); + ms->ms_retval = u_linkat_ocall(ms->ms_error, ms->ms_olddirfd, ms->ms_oldpath, ms->ms_newdirfd, ms->ms_newpath, ms->ms_flags); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_rename_ocall(void* pms) +{ + ms_u_rename_ocall_t* ms = SGX_CAST(ms_u_rename_ocall_t*, pms); + ms->ms_retval = u_rename_ocall(ms->ms_error, ms->ms_oldpath, ms->ms_newpath); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_chmod_ocall(void* pms) +{ + ms_u_chmod_ocall_t* ms = SGX_CAST(ms_u_chmod_ocall_t*, pms); + ms->ms_retval = u_chmod_ocall(ms->ms_error, ms->ms_path, ms->ms_mode); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_readlink_ocall(void* pms) +{ + ms_u_readlink_ocall_t* ms = SGX_CAST(ms_u_readlink_ocall_t*, pms); + ms->ms_retval = u_readlink_ocall(ms->ms_error, ms->ms_path, ms->ms_buf, ms->ms_bufsz); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_symlink_ocall(void* pms) +{ + ms_u_symlink_ocall_t* ms = SGX_CAST(ms_u_symlink_ocall_t*, pms); + ms->ms_retval = u_symlink_ocall(ms->ms_error, ms->ms_path1, ms->ms_path2); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_realpath_ocall(void* pms) +{ + ms_u_realpath_ocall_t* ms = SGX_CAST(ms_u_realpath_ocall_t*, pms); + ms->ms_retval = u_realpath_ocall(ms->ms_error, ms->ms_pathname); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_mkdir_ocall(void* pms) +{ + ms_u_mkdir_ocall_t* ms = SGX_CAST(ms_u_mkdir_ocall_t*, pms); + ms->ms_retval = u_mkdir_ocall(ms->ms_error, ms->ms_pathname, ms->ms_mode); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_rmdir_ocall(void* pms) +{ + ms_u_rmdir_ocall_t* ms = SGX_CAST(ms_u_rmdir_ocall_t*, pms); + ms->ms_retval = u_rmdir_ocall(ms->ms_error, ms->ms_pathname); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_opendir_ocall(void* pms) +{ + ms_u_opendir_ocall_t* ms = SGX_CAST(ms_u_opendir_ocall_t*, pms); + ms->ms_retval = u_opendir_ocall(ms->ms_error, ms->ms_pathname); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_readdir64_r_ocall(void* pms) +{ + ms_u_readdir64_r_ocall_t* ms = SGX_CAST(ms_u_readdir64_r_ocall_t*, pms); + ms->ms_retval = u_readdir64_r_ocall(ms->ms_dirp, ms->ms_entry, ms->ms_result); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_closedir_ocall(void* pms) +{ + ms_u_closedir_ocall_t* ms = SGX_CAST(ms_u_closedir_ocall_t*, pms); + ms->ms_retval = u_closedir_ocall(ms->ms_error, ms->ms_dirp); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_dirfd_ocall(void* pms) +{ + ms_u_dirfd_ocall_t* ms = SGX_CAST(ms_u_dirfd_ocall_t*, pms); + ms->ms_retval = u_dirfd_ocall(ms->ms_error, ms->ms_dirp); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_fstatat64_ocall(void* pms) +{ + ms_u_fstatat64_ocall_t* ms = SGX_CAST(ms_u_fstatat64_ocall_t*, pms); + ms->ms_retval = u_fstatat64_ocall(ms->ms_error, ms->ms_dirfd, ms->ms_pathname, ms->ms_buf, ms->ms_flags); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_environ_ocall(void* pms) +{ + ms_u_environ_ocall_t* ms = SGX_CAST(ms_u_environ_ocall_t*, pms); + ms->ms_retval = u_environ_ocall(); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_getenv_ocall(void* pms) +{ + ms_u_getenv_ocall_t* ms = SGX_CAST(ms_u_getenv_ocall_t*, pms); + ms->ms_retval = u_getenv_ocall(ms->ms_name); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_setenv_ocall(void* pms) +{ + ms_u_setenv_ocall_t* ms = SGX_CAST(ms_u_setenv_ocall_t*, pms); + ms->ms_retval = u_setenv_ocall(ms->ms_error, ms->ms_name, ms->ms_value, ms->ms_overwrite); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_unsetenv_ocall(void* pms) +{ + ms_u_unsetenv_ocall_t* ms = SGX_CAST(ms_u_unsetenv_ocall_t*, pms); + ms->ms_retval = u_unsetenv_ocall(ms->ms_error, ms->ms_name); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_chdir_ocall(void* pms) +{ + ms_u_chdir_ocall_t* ms = SGX_CAST(ms_u_chdir_ocall_t*, pms); + ms->ms_retval = u_chdir_ocall(ms->ms_error, ms->ms_dir); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_getcwd_ocall(void* pms) +{ + ms_u_getcwd_ocall_t* ms = SGX_CAST(ms_u_getcwd_ocall_t*, pms); + ms->ms_retval = u_getcwd_ocall(ms->ms_error, ms->ms_buf, ms->ms_buflen); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_getpwuid_r_ocall(void* pms) +{ + ms_u_getpwuid_r_ocall_t* ms = SGX_CAST(ms_u_getpwuid_r_ocall_t*, pms); + ms->ms_retval = u_getpwuid_r_ocall(ms->ms_uid, ms->ms_pwd, ms->ms_buf, ms->ms_buflen, ms->ms_passwd_result); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_getuid_ocall(void* pms) +{ + ms_u_getuid_ocall_t* ms = SGX_CAST(ms_u_getuid_ocall_t*, pms); + ms->ms_retval = u_getuid_ocall(); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_sgxprotectedfs_exclusive_file_open(void* pms) +{ + ms_u_sgxprotectedfs_exclusive_file_open_t* ms = SGX_CAST(ms_u_sgxprotectedfs_exclusive_file_open_t*, pms); + ms->ms_retval = u_sgxprotectedfs_exclusive_file_open(ms->ms_filename, ms->ms_read_only, ms->ms_file_size, ms->ms_error_code); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_sgxprotectedfs_check_if_file_exists(void* pms) +{ + ms_u_sgxprotectedfs_check_if_file_exists_t* ms = SGX_CAST(ms_u_sgxprotectedfs_check_if_file_exists_t*, pms); + ms->ms_retval = u_sgxprotectedfs_check_if_file_exists(ms->ms_filename); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_sgxprotectedfs_fread_node(void* pms) +{ + ms_u_sgxprotectedfs_fread_node_t* ms = SGX_CAST(ms_u_sgxprotectedfs_fread_node_t*, pms); + ms->ms_retval = u_sgxprotectedfs_fread_node(ms->ms_f, ms->ms_node_number, ms->ms_buffer, ms->ms_node_size); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_sgxprotectedfs_fwrite_node(void* pms) +{ + ms_u_sgxprotectedfs_fwrite_node_t* ms = SGX_CAST(ms_u_sgxprotectedfs_fwrite_node_t*, pms); + ms->ms_retval = u_sgxprotectedfs_fwrite_node(ms->ms_f, ms->ms_node_number, ms->ms_buffer, ms->ms_node_size); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_sgxprotectedfs_fclose(void* pms) +{ + ms_u_sgxprotectedfs_fclose_t* ms = SGX_CAST(ms_u_sgxprotectedfs_fclose_t*, pms); + ms->ms_retval = u_sgxprotectedfs_fclose(ms->ms_f); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_sgxprotectedfs_fflush(void* pms) +{ + ms_u_sgxprotectedfs_fflush_t* ms = SGX_CAST(ms_u_sgxprotectedfs_fflush_t*, pms); + ms->ms_retval = u_sgxprotectedfs_fflush(ms->ms_f); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_sgxprotectedfs_remove(void* pms) +{ + ms_u_sgxprotectedfs_remove_t* ms = SGX_CAST(ms_u_sgxprotectedfs_remove_t*, pms); + ms->ms_retval = u_sgxprotectedfs_remove(ms->ms_filename); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_sgxprotectedfs_recovery_file_open(void* pms) +{ + ms_u_sgxprotectedfs_recovery_file_open_t* ms = SGX_CAST(ms_u_sgxprotectedfs_recovery_file_open_t*, pms); + ms->ms_retval = u_sgxprotectedfs_recovery_file_open(ms->ms_filename); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_sgxprotectedfs_fwrite_recovery_node(void* pms) +{ + ms_u_sgxprotectedfs_fwrite_recovery_node_t* ms = SGX_CAST(ms_u_sgxprotectedfs_fwrite_recovery_node_t*, pms); + ms->ms_retval = u_sgxprotectedfs_fwrite_recovery_node(ms->ms_f, ms->ms_data, ms->ms_data_length); + + return SGX_SUCCESS; +} + +static sgx_status_t SGX_CDECL Enclave_u_sgxprotectedfs_do_file_recovery(void* pms) +{ + ms_u_sgxprotectedfs_do_file_recovery_t* ms = SGX_CAST(ms_u_sgxprotectedfs_do_file_recovery_t*, pms); + ms->ms_retval = u_sgxprotectedfs_do_file_recovery(ms->ms_filename, ms->ms_recovery_filename, ms->ms_node_size); + + return SGX_SUCCESS; +} + +static const struct { + size_t nr_ocall; + void * table[79]; +} ocall_table_Enclave = { + 79, + { + (void*)Enclave_sgx_oc_cpuidex, + (void*)Enclave_sgx_thread_wait_untrusted_event_ocall, + (void*)Enclave_sgx_thread_set_untrusted_event_ocall, + (void*)Enclave_sgx_thread_setwait_untrusted_events_ocall, + (void*)Enclave_sgx_thread_set_multiple_untrusted_events_ocall, + (void*)Enclave_u_thread_set_event_ocall, + (void*)Enclave_u_thread_wait_event_ocall, + (void*)Enclave_u_thread_set_multiple_events_ocall, + (void*)Enclave_u_thread_setwait_events_ocall, + (void*)Enclave_u_clock_gettime_ocall, + (void*)Enclave_u_read_ocall, + (void*)Enclave_u_pread64_ocall, + (void*)Enclave_u_readv_ocall, + (void*)Enclave_u_preadv64_ocall, + (void*)Enclave_u_write_ocall, + (void*)Enclave_u_pwrite64_ocall, + (void*)Enclave_u_writev_ocall, + (void*)Enclave_u_pwritev64_ocall, + (void*)Enclave_u_fcntl_arg0_ocall, + (void*)Enclave_u_fcntl_arg1_ocall, + (void*)Enclave_u_ioctl_arg0_ocall, + (void*)Enclave_u_ioctl_arg1_ocall, + (void*)Enclave_u_close_ocall, + (void*)Enclave_u_malloc_ocall, + (void*)Enclave_u_free_ocall, + (void*)Enclave_u_mmap_ocall, + (void*)Enclave_u_munmap_ocall, + (void*)Enclave_u_msync_ocall, + (void*)Enclave_u_mprotect_ocall, + (void*)Enclave_u_open_ocall, + (void*)Enclave_u_open64_ocall, + (void*)Enclave_u_fstat_ocall, + (void*)Enclave_u_fstat64_ocall, + (void*)Enclave_u_stat_ocall, + (void*)Enclave_u_stat64_ocall, + (void*)Enclave_u_lstat_ocall, + (void*)Enclave_u_lstat64_ocall, + (void*)Enclave_u_lseek_ocall, + (void*)Enclave_u_lseek64_ocall, + (void*)Enclave_u_ftruncate_ocall, + (void*)Enclave_u_ftruncate64_ocall, + (void*)Enclave_u_truncate_ocall, + (void*)Enclave_u_truncate64_ocall, + (void*)Enclave_u_fsync_ocall, + (void*)Enclave_u_fdatasync_ocall, + (void*)Enclave_u_fchmod_ocall, + (void*)Enclave_u_unlink_ocall, + (void*)Enclave_u_link_ocall, + (void*)Enclave_u_linkat_ocall, + (void*)Enclave_u_rename_ocall, + (void*)Enclave_u_chmod_ocall, + (void*)Enclave_u_readlink_ocall, + (void*)Enclave_u_symlink_ocall, + (void*)Enclave_u_realpath_ocall, + (void*)Enclave_u_mkdir_ocall, + (void*)Enclave_u_rmdir_ocall, + (void*)Enclave_u_opendir_ocall, + (void*)Enclave_u_readdir64_r_ocall, + (void*)Enclave_u_closedir_ocall, + (void*)Enclave_u_dirfd_ocall, + (void*)Enclave_u_fstatat64_ocall, + (void*)Enclave_u_environ_ocall, + (void*)Enclave_u_getenv_ocall, + (void*)Enclave_u_setenv_ocall, + (void*)Enclave_u_unsetenv_ocall, + (void*)Enclave_u_chdir_ocall, + (void*)Enclave_u_getcwd_ocall, + (void*)Enclave_u_getpwuid_r_ocall, + (void*)Enclave_u_getuid_ocall, + (void*)Enclave_u_sgxprotectedfs_exclusive_file_open, + (void*)Enclave_u_sgxprotectedfs_check_if_file_exists, + (void*)Enclave_u_sgxprotectedfs_fread_node, + (void*)Enclave_u_sgxprotectedfs_fwrite_node, + (void*)Enclave_u_sgxprotectedfs_fclose, + (void*)Enclave_u_sgxprotectedfs_fflush, + (void*)Enclave_u_sgxprotectedfs_remove, + (void*)Enclave_u_sgxprotectedfs_recovery_file_open, + (void*)Enclave_u_sgxprotectedfs_fwrite_recovery_node, + (void*)Enclave_u_sgxprotectedfs_do_file_recovery, + } +}; +sgx_status_t enclave_create_report(sgx_enclave_id_t eid, sgx_status_t* retval, const sgx_target_info_t* p_qe3_target, sgx_report_t* p_report, uint8_t enclave_data[32]) +{ + sgx_status_t status; + ms_enclave_create_report_t ms; + ms.ms_p_qe3_target = p_qe3_target; + ms.ms_p_report = p_report; + ms.ms_enclave_data = (uint8_t*)enclave_data; + status = sgx_ecall(eid, 0, &ocall_table_Enclave, &ms); + if (status == SGX_SUCCESS && retval) *retval = ms.ms_retval; + return status; +} + +sgx_status_t wallet_operation(sgx_enclave_id_t eid, sgx_status_t* retval, const uint8_t* sealed_request_buffer, size_t sealed_request_size, uint8_t* sealed_response_buffer, size_t sealed_response_capacity, size_t* sealed_response_used) +{ + sgx_status_t status; + ms_wallet_operation_t ms; + ms.ms_sealed_request_buffer = sealed_request_buffer; + ms.ms_sealed_request_size = sealed_request_size; + ms.ms_sealed_response_buffer = sealed_response_buffer; + ms.ms_sealed_response_capacity = sealed_response_capacity; + ms.ms_sealed_response_used = sealed_response_used; + status = sgx_ecall(eid, 1, &ocall_table_Enclave, &ms); + if (status == SGX_SUCCESS && retval) *retval = ms.ms_retval; + return status; +} + +sgx_status_t t_global_init_ecall(sgx_enclave_id_t eid, uint64_t id, const uint8_t* path, size_t len) +{ + sgx_status_t status; + ms_t_global_init_ecall_t ms; + ms.ms_id = id; + ms.ms_path = path; + ms.ms_len = len; + status = sgx_ecall(eid, 2, &ocall_table_Enclave, &ms); + return status; +} + +sgx_status_t t_global_exit_ecall(sgx_enclave_id_t eid) +{ + sgx_status_t status; + status = sgx_ecall(eid, 3, &ocall_table_Enclave, NULL); + return status; +} + diff --git a/rust-sgx-workspace/projects/sgx-wallet/app/codegen/Enclave_u.h b/rust-sgx-workspace/projects/sgx-wallet/app/codegen/Enclave_u.h new file mode 100644 index 0000000..255e58a --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/app/codegen/Enclave_u.h @@ -0,0 +1,352 @@ +#ifndef ENCLAVE_U_H__ +#define ENCLAVE_U_H__ + +#include +#include +#include +#include +#include "sgx_edger8r.h" /* for sgx_status_t etc. */ + +#include "sgx_report.h" +#include "time.h" +#include "inc/stat.h" +#include "sys/uio.h" +#include "inc/stat.h" +#include "inc/dirent.h" +#include "pwd.h" + +#include /* for size_t */ + +#define SGX_CAST(type, item) ((type)(item)) + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef SGX_OC_CPUIDEX_DEFINED__ +#define SGX_OC_CPUIDEX_DEFINED__ +void SGX_UBRIDGE(SGX_CDECL, sgx_oc_cpuidex, (int cpuinfo[4], int leaf, int subleaf)); +#endif +#ifndef SGX_THREAD_WAIT_UNTRUSTED_EVENT_OCALL_DEFINED__ +#define SGX_THREAD_WAIT_UNTRUSTED_EVENT_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_CDECL, sgx_thread_wait_untrusted_event_ocall, (const void* self)); +#endif +#ifndef SGX_THREAD_SET_UNTRUSTED_EVENT_OCALL_DEFINED__ +#define SGX_THREAD_SET_UNTRUSTED_EVENT_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_CDECL, sgx_thread_set_untrusted_event_ocall, (const void* waiter)); +#endif +#ifndef SGX_THREAD_SETWAIT_UNTRUSTED_EVENTS_OCALL_DEFINED__ +#define SGX_THREAD_SETWAIT_UNTRUSTED_EVENTS_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_CDECL, sgx_thread_setwait_untrusted_events_ocall, (const void* waiter, const void* self)); +#endif +#ifndef SGX_THREAD_SET_MULTIPLE_UNTRUSTED_EVENTS_OCALL_DEFINED__ +#define SGX_THREAD_SET_MULTIPLE_UNTRUSTED_EVENTS_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_CDECL, sgx_thread_set_multiple_untrusted_events_ocall, (const void** waiters, size_t total)); +#endif +#ifndef U_THREAD_SET_EVENT_OCALL_DEFINED__ +#define U_THREAD_SET_EVENT_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_thread_set_event_ocall, (int* error, const void* tcs)); +#endif +#ifndef U_THREAD_WAIT_EVENT_OCALL_DEFINED__ +#define U_THREAD_WAIT_EVENT_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_thread_wait_event_ocall, (int* error, const void* tcs, const struct timespec* timeout)); +#endif +#ifndef U_THREAD_SET_MULTIPLE_EVENTS_OCALL_DEFINED__ +#define U_THREAD_SET_MULTIPLE_EVENTS_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_thread_set_multiple_events_ocall, (int* error, const void** tcss, int total)); +#endif +#ifndef U_THREAD_SETWAIT_EVENTS_OCALL_DEFINED__ +#define U_THREAD_SETWAIT_EVENTS_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_thread_setwait_events_ocall, (int* error, const void* waiter_tcs, const void* self_tcs, const struct timespec* timeout)); +#endif +#ifndef U_CLOCK_GETTIME_OCALL_DEFINED__ +#define U_CLOCK_GETTIME_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_clock_gettime_ocall, (int* error, int clk_id, struct timespec* tp)); +#endif +#ifndef U_READ_OCALL_DEFINED__ +#define U_READ_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_read_ocall, (int* error, int fd, void* buf, size_t count)); +#endif +#ifndef U_PREAD64_OCALL_DEFINED__ +#define U_PREAD64_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_pread64_ocall, (int* error, int fd, void* buf, size_t count, int64_t offset)); +#endif +#ifndef U_READV_OCALL_DEFINED__ +#define U_READV_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_readv_ocall, (int* error, int fd, const struct iovec* iov, int iovcnt)); +#endif +#ifndef U_PREADV64_OCALL_DEFINED__ +#define U_PREADV64_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_preadv64_ocall, (int* error, int fd, const struct iovec* iov, int iovcnt, int64_t offset)); +#endif +#ifndef U_WRITE_OCALL_DEFINED__ +#define U_WRITE_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_write_ocall, (int* error, int fd, const void* buf, size_t count)); +#endif +#ifndef U_PWRITE64_OCALL_DEFINED__ +#define U_PWRITE64_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_pwrite64_ocall, (int* error, int fd, const void* buf, size_t count, int64_t offset)); +#endif +#ifndef U_WRITEV_OCALL_DEFINED__ +#define U_WRITEV_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_writev_ocall, (int* error, int fd, const struct iovec* iov, int iovcnt)); +#endif +#ifndef U_PWRITEV64_OCALL_DEFINED__ +#define U_PWRITEV64_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_pwritev64_ocall, (int* error, int fd, const struct iovec* iov, int iovcnt, int64_t offset)); +#endif +#ifndef U_FCNTL_ARG0_OCALL_DEFINED__ +#define U_FCNTL_ARG0_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_fcntl_arg0_ocall, (int* error, int fd, int cmd)); +#endif +#ifndef U_FCNTL_ARG1_OCALL_DEFINED__ +#define U_FCNTL_ARG1_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_fcntl_arg1_ocall, (int* error, int fd, int cmd, int arg)); +#endif +#ifndef U_IOCTL_ARG0_OCALL_DEFINED__ +#define U_IOCTL_ARG0_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_ioctl_arg0_ocall, (int* error, int fd, int request)); +#endif +#ifndef U_IOCTL_ARG1_OCALL_DEFINED__ +#define U_IOCTL_ARG1_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_ioctl_arg1_ocall, (int* error, int fd, int request, int* arg)); +#endif +#ifndef U_CLOSE_OCALL_DEFINED__ +#define U_CLOSE_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_close_ocall, (int* error, int fd)); +#endif +#ifndef U_MALLOC_OCALL_DEFINED__ +#define U_MALLOC_OCALL_DEFINED__ +void* SGX_UBRIDGE(SGX_NOCONVENTION, u_malloc_ocall, (int* error, size_t size)); +#endif +#ifndef U_FREE_OCALL_DEFINED__ +#define U_FREE_OCALL_DEFINED__ +void SGX_UBRIDGE(SGX_NOCONVENTION, u_free_ocall, (void* p)); +#endif +#ifndef U_MMAP_OCALL_DEFINED__ +#define U_MMAP_OCALL_DEFINED__ +void* SGX_UBRIDGE(SGX_NOCONVENTION, u_mmap_ocall, (int* error, void* start, size_t length, int prot, int flags, int fd, int64_t offset)); +#endif +#ifndef U_MUNMAP_OCALL_DEFINED__ +#define U_MUNMAP_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_munmap_ocall, (int* error, void* start, size_t length)); +#endif +#ifndef U_MSYNC_OCALL_DEFINED__ +#define U_MSYNC_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_msync_ocall, (int* error, void* addr, size_t length, int flags)); +#endif +#ifndef U_MPROTECT_OCALL_DEFINED__ +#define U_MPROTECT_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_mprotect_ocall, (int* error, void* addr, size_t length, int prot)); +#endif +#ifndef U_OPEN_OCALL_DEFINED__ +#define U_OPEN_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_open_ocall, (int* error, const char* pathname, int flags)); +#endif +#ifndef U_OPEN64_OCALL_DEFINED__ +#define U_OPEN64_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_open64_ocall, (int* error, const char* path, int oflag, int mode)); +#endif +#ifndef U_FSTAT_OCALL_DEFINED__ +#define U_FSTAT_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_fstat_ocall, (int* error, int fd, struct stat_t* buf)); +#endif +#ifndef U_FSTAT64_OCALL_DEFINED__ +#define U_FSTAT64_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_fstat64_ocall, (int* error, int fd, struct stat64_t* buf)); +#endif +#ifndef U_STAT_OCALL_DEFINED__ +#define U_STAT_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_stat_ocall, (int* error, const char* path, struct stat_t* buf)); +#endif +#ifndef U_STAT64_OCALL_DEFINED__ +#define U_STAT64_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_stat64_ocall, (int* error, const char* path, struct stat64_t* buf)); +#endif +#ifndef U_LSTAT_OCALL_DEFINED__ +#define U_LSTAT_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_lstat_ocall, (int* error, const char* path, struct stat_t* buf)); +#endif +#ifndef U_LSTAT64_OCALL_DEFINED__ +#define U_LSTAT64_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_lstat64_ocall, (int* error, const char* path, struct stat64_t* buf)); +#endif +#ifndef U_LSEEK_OCALL_DEFINED__ +#define U_LSEEK_OCALL_DEFINED__ +uint64_t SGX_UBRIDGE(SGX_NOCONVENTION, u_lseek_ocall, (int* error, int fd, int64_t offset, int whence)); +#endif +#ifndef U_LSEEK64_OCALL_DEFINED__ +#define U_LSEEK64_OCALL_DEFINED__ +int64_t SGX_UBRIDGE(SGX_NOCONVENTION, u_lseek64_ocall, (int* error, int fd, int64_t offset, int whence)); +#endif +#ifndef U_FTRUNCATE_OCALL_DEFINED__ +#define U_FTRUNCATE_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_ftruncate_ocall, (int* error, int fd, int64_t length)); +#endif +#ifndef U_FTRUNCATE64_OCALL_DEFINED__ +#define U_FTRUNCATE64_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_ftruncate64_ocall, (int* error, int fd, int64_t length)); +#endif +#ifndef U_TRUNCATE_OCALL_DEFINED__ +#define U_TRUNCATE_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_truncate_ocall, (int* error, const char* path, int64_t length)); +#endif +#ifndef U_TRUNCATE64_OCALL_DEFINED__ +#define U_TRUNCATE64_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_truncate64_ocall, (int* error, const char* path, int64_t length)); +#endif +#ifndef U_FSYNC_OCALL_DEFINED__ +#define U_FSYNC_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_fsync_ocall, (int* error, int fd)); +#endif +#ifndef U_FDATASYNC_OCALL_DEFINED__ +#define U_FDATASYNC_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_fdatasync_ocall, (int* error, int fd)); +#endif +#ifndef U_FCHMOD_OCALL_DEFINED__ +#define U_FCHMOD_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_fchmod_ocall, (int* error, int fd, uint32_t mode)); +#endif +#ifndef U_UNLINK_OCALL_DEFINED__ +#define U_UNLINK_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_unlink_ocall, (int* error, const char* pathname)); +#endif +#ifndef U_LINK_OCALL_DEFINED__ +#define U_LINK_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_link_ocall, (int* error, const char* oldpath, const char* newpath)); +#endif +#ifndef U_LINKAT_OCALL_DEFINED__ +#define U_LINKAT_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_linkat_ocall, (int* error, int olddirfd, const char* oldpath, int newdirfd, const char* newpath, int flags)); +#endif +#ifndef U_RENAME_OCALL_DEFINED__ +#define U_RENAME_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_rename_ocall, (int* error, const char* oldpath, const char* newpath)); +#endif +#ifndef U_CHMOD_OCALL_DEFINED__ +#define U_CHMOD_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_chmod_ocall, (int* error, const char* path, uint32_t mode)); +#endif +#ifndef U_READLINK_OCALL_DEFINED__ +#define U_READLINK_OCALL_DEFINED__ +size_t SGX_UBRIDGE(SGX_NOCONVENTION, u_readlink_ocall, (int* error, const char* path, char* buf, size_t bufsz)); +#endif +#ifndef U_SYMLINK_OCALL_DEFINED__ +#define U_SYMLINK_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_symlink_ocall, (int* error, const char* path1, const char* path2)); +#endif +#ifndef U_REALPATH_OCALL_DEFINED__ +#define U_REALPATH_OCALL_DEFINED__ +char* SGX_UBRIDGE(SGX_NOCONVENTION, u_realpath_ocall, (int* error, const char* pathname)); +#endif +#ifndef U_MKDIR_OCALL_DEFINED__ +#define U_MKDIR_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_mkdir_ocall, (int* error, const char* pathname, uint32_t mode)); +#endif +#ifndef U_RMDIR_OCALL_DEFINED__ +#define U_RMDIR_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_rmdir_ocall, (int* error, const char* pathname)); +#endif +#ifndef U_OPENDIR_OCALL_DEFINED__ +#define U_OPENDIR_OCALL_DEFINED__ +void* SGX_UBRIDGE(SGX_NOCONVENTION, u_opendir_ocall, (int* error, const char* pathname)); +#endif +#ifndef U_READDIR64_R_OCALL_DEFINED__ +#define U_READDIR64_R_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_readdir64_r_ocall, (void* dirp, struct dirent64_t* entry, struct dirent64_t** result)); +#endif +#ifndef U_CLOSEDIR_OCALL_DEFINED__ +#define U_CLOSEDIR_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_closedir_ocall, (int* error, void* dirp)); +#endif +#ifndef U_DIRFD_OCALL_DEFINED__ +#define U_DIRFD_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_dirfd_ocall, (int* error, void* dirp)); +#endif +#ifndef U_FSTATAT64_OCALL_DEFINED__ +#define U_FSTATAT64_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_fstatat64_ocall, (int* error, int dirfd, const char* pathname, struct stat64_t* buf, int flags)); +#endif +#ifndef U_ENVIRON_OCALL_DEFINED__ +#define U_ENVIRON_OCALL_DEFINED__ +char** SGX_UBRIDGE(SGX_NOCONVENTION, u_environ_ocall, (void)); +#endif +#ifndef U_GETENV_OCALL_DEFINED__ +#define U_GETENV_OCALL_DEFINED__ +char* SGX_UBRIDGE(SGX_NOCONVENTION, u_getenv_ocall, (const char* name)); +#endif +#ifndef U_SETENV_OCALL_DEFINED__ +#define U_SETENV_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_setenv_ocall, (int* error, const char* name, const char* value, int overwrite)); +#endif +#ifndef U_UNSETENV_OCALL_DEFINED__ +#define U_UNSETENV_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_unsetenv_ocall, (int* error, const char* name)); +#endif +#ifndef U_CHDIR_OCALL_DEFINED__ +#define U_CHDIR_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_chdir_ocall, (int* error, const char* dir)); +#endif +#ifndef U_GETCWD_OCALL_DEFINED__ +#define U_GETCWD_OCALL_DEFINED__ +char* SGX_UBRIDGE(SGX_NOCONVENTION, u_getcwd_ocall, (int* error, char* buf, size_t buflen)); +#endif +#ifndef U_GETPWUID_R_OCALL_DEFINED__ +#define U_GETPWUID_R_OCALL_DEFINED__ +int SGX_UBRIDGE(SGX_NOCONVENTION, u_getpwuid_r_ocall, (unsigned int uid, struct passwd* pwd, char* buf, size_t buflen, struct passwd** passwd_result)); +#endif +#ifndef U_GETUID_OCALL_DEFINED__ +#define U_GETUID_OCALL_DEFINED__ +unsigned int SGX_UBRIDGE(SGX_NOCONVENTION, u_getuid_ocall, (void)); +#endif +#ifndef U_SGXPROTECTEDFS_EXCLUSIVE_FILE_OPEN_DEFINED__ +#define U_SGXPROTECTEDFS_EXCLUSIVE_FILE_OPEN_DEFINED__ +void* SGX_UBRIDGE(SGX_NOCONVENTION, u_sgxprotectedfs_exclusive_file_open, (const char* filename, uint8_t read_only, int64_t* file_size, int32_t* error_code)); +#endif +#ifndef U_SGXPROTECTEDFS_CHECK_IF_FILE_EXISTS_DEFINED__ +#define U_SGXPROTECTEDFS_CHECK_IF_FILE_EXISTS_DEFINED__ +uint8_t SGX_UBRIDGE(SGX_NOCONVENTION, u_sgxprotectedfs_check_if_file_exists, (const char* filename)); +#endif +#ifndef U_SGXPROTECTEDFS_FREAD_NODE_DEFINED__ +#define U_SGXPROTECTEDFS_FREAD_NODE_DEFINED__ +int32_t SGX_UBRIDGE(SGX_NOCONVENTION, u_sgxprotectedfs_fread_node, (void* f, uint64_t node_number, uint8_t* buffer, uint32_t node_size)); +#endif +#ifndef U_SGXPROTECTEDFS_FWRITE_NODE_DEFINED__ +#define U_SGXPROTECTEDFS_FWRITE_NODE_DEFINED__ +int32_t SGX_UBRIDGE(SGX_NOCONVENTION, u_sgxprotectedfs_fwrite_node, (void* f, uint64_t node_number, uint8_t* buffer, uint32_t node_size)); +#endif +#ifndef U_SGXPROTECTEDFS_FCLOSE_DEFINED__ +#define U_SGXPROTECTEDFS_FCLOSE_DEFINED__ +int32_t SGX_UBRIDGE(SGX_NOCONVENTION, u_sgxprotectedfs_fclose, (void* f)); +#endif +#ifndef U_SGXPROTECTEDFS_FFLUSH_DEFINED__ +#define U_SGXPROTECTEDFS_FFLUSH_DEFINED__ +uint8_t SGX_UBRIDGE(SGX_NOCONVENTION, u_sgxprotectedfs_fflush, (void* f)); +#endif +#ifndef U_SGXPROTECTEDFS_REMOVE_DEFINED__ +#define U_SGXPROTECTEDFS_REMOVE_DEFINED__ +int32_t SGX_UBRIDGE(SGX_NOCONVENTION, u_sgxprotectedfs_remove, (const char* filename)); +#endif +#ifndef U_SGXPROTECTEDFS_RECOVERY_FILE_OPEN_DEFINED__ +#define U_SGXPROTECTEDFS_RECOVERY_FILE_OPEN_DEFINED__ +void* SGX_UBRIDGE(SGX_NOCONVENTION, u_sgxprotectedfs_recovery_file_open, (const char* filename)); +#endif +#ifndef U_SGXPROTECTEDFS_FWRITE_RECOVERY_NODE_DEFINED__ +#define U_SGXPROTECTEDFS_FWRITE_RECOVERY_NODE_DEFINED__ +uint8_t SGX_UBRIDGE(SGX_NOCONVENTION, u_sgxprotectedfs_fwrite_recovery_node, (void* f, uint8_t* data, uint32_t data_length)); +#endif +#ifndef U_SGXPROTECTEDFS_DO_FILE_RECOVERY_DEFINED__ +#define U_SGXPROTECTEDFS_DO_FILE_RECOVERY_DEFINED__ +int32_t SGX_UBRIDGE(SGX_NOCONVENTION, u_sgxprotectedfs_do_file_recovery, (const char* filename, const char* recovery_filename, uint32_t node_size)); +#endif + +sgx_status_t enclave_create_report(sgx_enclave_id_t eid, sgx_status_t* retval, const sgx_target_info_t* p_qe3_target, sgx_report_t* p_report, uint8_t enclave_data[32]); +sgx_status_t wallet_operation(sgx_enclave_id_t eid, sgx_status_t* retval, const uint8_t* sealed_request_buffer, size_t sealed_request_size, uint8_t* sealed_response_buffer, size_t sealed_response_capacity, size_t* sealed_response_used); +sgx_status_t t_global_init_ecall(sgx_enclave_id_t eid, uint64_t id, const uint8_t* path, size_t len); +sgx_status_t t_global_exit_ecall(sgx_enclave_id_t eid); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/rust-sgx-workspace/projects/sgx-wallet/app/codegen/Enclave_u.rs b/rust-sgx-workspace/projects/sgx-wallet/app/codegen/Enclave_u.rs new file mode 100644 index 0000000..655c45d --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/app/codegen/Enclave_u.rs @@ -0,0 +1,24 @@ +/* automatically generated by rust-bindgen 0.59.2 */ + +use sgx_types::*; + +extern "C" { + pub fn enclave_create_report( + eid: sgx_enclave_id_t, + retval: *mut sgx_status_t, + p_qe3_target: *const sgx_target_info_t, + p_report: *mut sgx_report_t, + enclave_data: *mut [u8; 32usize], + ) -> sgx_status_t; +} +extern "C" { + pub fn wallet_operation( + eid: sgx_enclave_id_t, + retval: *mut sgx_status_t, + sealed_request_buffer: *const u8, + sealed_request_size: size_t, + sealed_response_buffer: *mut u8, + sealed_response_capacity: size_t, + sealed_response_used: *mut size_t, + ) -> sgx_status_t; +} diff --git a/rust-sgx-workspace/projects/sgx-wallet/app/src/main.rs b/rust-sgx-workspace/projects/sgx-wallet/app/src/main.rs new file mode 100644 index 0000000..adcf0c1 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/app/src/main.rs @@ -0,0 +1,60 @@ +use std::fs::create_dir_all; +use std::io; +use std::net::ToSocketAddrs; + +use env_var_helpers::env_vars; +use http_service_impl::server::run_server; +use sgx_types::{sgx_attributes_t, sgx_launch_token_t, sgx_misc_attribute_t, SgxResult}; +use sgx_urts::SgxEnclave; + +use crate::trait_impls::WalletEnclaveImpl; + +#[path = "../codegen/Enclave_u.rs"] +mod enclave_u; +mod safe_ecalls; +mod trait_impls; + +static ENCLAVE_FILE: &str = "enclave.signed.so"; + +fn init_enclave() -> SgxResult { + let mut launch_token: sgx_launch_token_t = [0; 1024]; + let mut launch_token_updated: i32 = 0; + // call sgx_create_enclave to initialize an enclave instance + // Debug Support: set 2nd parameter to 1 + let debug = 1; + let mut misc_attr = sgx_misc_attribute_t { + secs_attr: sgx_attributes_t { flags: 0, xfrm: 0 }, + misc_select: 0, + }; + SgxEnclave::create( + ENCLAVE_FILE, + debug, + &mut launch_token, + &mut launch_token_updated, + &mut misc_attr, + ) +} + +#[actix_web::main] +async fn main() -> io::Result<()> { + let enclave = init_enclave() + .map_err(|sgx_error| { + io::Error::new( + io::ErrorKind::Other, + format!("init_enclave failed: {:?}", sgx_error), + ) + }) + .unwrap(); + let wallet_enclave = Box::new(WalletEnclaveImpl { enclave }); + + // FIXME: See WALLET_STORE_DIR + create_dir_all("wallet_store")?; + + let bind_addr = env_vars::var_default("BIND_ADDR", "127.0.0.1:8080")?; + + for socket_addr in bind_addr.to_socket_addrs()? { + println!("run_server: binding to http://{}/", socket_addr); + } + + run_server(wallet_enclave, bind_addr).await +} diff --git a/rust-sgx-workspace/projects/sgx-wallet/app/src/safe_ecalls.rs b/rust-sgx-workspace/projects/sgx-wallet/app/src/safe_ecalls.rs new file mode 100644 index 0000000..35031d0 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/app/src/safe_ecalls.rs @@ -0,0 +1,58 @@ +//! Safe Rust wrappers around [`enclave_u`]. + +use sgx_helpers::status::sgx_success_and_then; +use sgx_types::{sgx_enclave_id_t, sgx_report_t, sgx_status_t, sgx_target_info_t, SgxResult}; + +use crate::enclave_u; + +pub fn safe_enclave_create_report( + eid: sgx_enclave_id_t, + qe3_target: sgx_target_info_t, +) -> SgxResult> { + let mut retval = sgx_status_t::SGX_ERROR_UNEXPECTED; + let mut ret_report: sgx_report_t = sgx_report_t::default(); + let mut ret_enclave_data = [0; 32]; + + let result = unsafe { + enclave_u::enclave_create_report( + eid, + &mut retval, + &qe3_target, + &mut ret_report, + &mut ret_enclave_data, + ) + }; + + sgx_success_and_then(result, || { + sgx_success_and_then(retval, || (ret_report, ret_enclave_data)) + }) +} + +pub fn safe_wallet_operation( + eid: sgx_enclave_id_t, + sealed_request: &[u8], + sealed_response_capacity: usize, +) -> SgxResult>> { + let mut retval = sgx_status_t::SGX_ERROR_UNEXPECTED; + let mut sealed_response = vec![0; sealed_response_capacity]; + let mut sealed_response_used = 0; + + let result = unsafe { + enclave_u::wallet_operation( + eid, + &mut retval, + sealed_request.as_ptr(), + sealed_request.len(), + sealed_response.as_mut_ptr(), + sealed_response.len(), + &mut sealed_response_used, + ) + }; + sgx_success_and_then(result, || { + sgx_success_and_then(retval, || { + assert!(sealed_response_used <= sealed_response_capacity); + sealed_response.truncate(sealed_response_used); + sealed_response.into_boxed_slice() + }) + }) +} diff --git a/rust-sgx-workspace/projects/sgx-wallet/app/src/trait_impls.rs b/rust-sgx-workspace/projects/sgx-wallet/app/src/trait_impls.rs new file mode 100644 index 0000000..164accb --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/app/src/trait_impls.rs @@ -0,0 +1,32 @@ +//! Implement [`WalletEnclave`] using [`safe_ecalls`]. + +use http_service_impl::traits::WalletEnclave; +use sgx_types::{sgx_report_t, sgx_target_info_t, SgxResult}; +use sgx_urts::SgxEnclave; + +use crate::safe_ecalls; + +pub(crate) struct WalletEnclaveImpl { + pub(crate) enclave: SgxEnclave, +} + +impl WalletEnclave for WalletEnclaveImpl { + fn create_report( + &self, + target_info: sgx_target_info_t, + ) -> SgxResult> { + safe_ecalls::safe_enclave_create_report(self.enclave.geteid(), target_info) + } + + fn wallet_operation( + &self, + sealed_request: &[u8], + sealed_response_capacity: usize, + ) -> SgxResult>> { + safe_ecalls::safe_wallet_operation( + self.enclave.geteid(), + sealed_request, + sealed_response_capacity, + ) + } +} diff --git a/rust-sgx-workspace/projects/sgx-wallet/buildenv.mk b/rust-sgx-workspace/projects/sgx-wallet/buildenv.mk new file mode 100644 index 0000000..a86675e --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/buildenv.mk @@ -0,0 +1,167 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License.. +# +# + +CP := /bin/cp -f +MKDIR := mkdir -p +STRIP := strip +OBJCOPY := objcopy + +# clean the content of 'INCLUDE' - this variable will be set by vcvars32.bat +# thus it will cause build error when this variable is used by our Makefile, +# when compiling the code under Cygwin tainted by MSVC environment settings. +INCLUDE := + +# turn on stack protector for SDK +COMMON_FLAGS += -fstack-protector + +ifdef DEBUG + COMMON_FLAGS += -O0 -g -DDEBUG -UNDEBUG +else + COMMON_FLAGS += -O2 -D_FORTIFY_SOURCE=2 -UDEBUG -DNDEBUG +endif + +# turn on compiler warnings as much as possible +COMMON_FLAGS += -Wall -Wextra -Winit-self -Wpointer-arith -Wreturn-type \ + -Waddress -Wsequence-point -Wformat-security \ + -Wmissing-include-dirs -Wfloat-equal -Wundef -Wshadow \ + -Wcast-align -Wconversion -Wredundant-decls + +# additional warnings flags for C +CFLAGS += -Wjump-misses-init -Wstrict-prototypes -Wunsuffixed-float-constants + +# additional warnings flags for C++ +CXXFLAGS += -Wnon-virtual-dtor + +# for static_assert() +CXXFLAGS += -std=c++0x + +.DEFAULT_GOAL := all +# this turns off the RCS / SCCS implicit rules of GNU Make +% : RCS/%,v +% : RCS/% +% : %,v +% : s.% +% : SCCS/s.% + +# If a rule fails, delete $@. +.DELETE_ON_ERROR: + +HOST_FILE_PROGRAM := file + +UNAME := $(shell uname -m) +ifneq (,$(findstring 86,$(UNAME))) + HOST_ARCH := x86 + ifneq (,$(shell $(HOST_FILE_PROGRAM) -L $(SHELL) | grep 'x86[_-]64')) + HOST_ARCH := x86_64 + endif +else + $(info Unknown host CPU arhitecture $(UNAME)) + $(error Aborting) +endif + + +ifeq "$(findstring __INTEL_COMPILER, $(shell $(CC) -E -dM -xc /dev/null))" "__INTEL_COMPILER" + ifeq ($(shell test -f /usr/bin/dpkg; echo $$?), 0) + ADDED_INC := -I /usr/include/$(shell dpkg-architecture -qDEB_BUILD_MULTIARCH) + endif +endif + +ARCH := $(HOST_ARCH) +ifeq "$(findstring -m32, $(CXXFLAGS))" "-m32" + ARCH := x86 +endif + +ifeq ($(ARCH), x86) +COMMON_FLAGS += -DITT_ARCH_IA32 +else +COMMON_FLAGS += -DITT_ARCH_IA64 +endif + +CFLAGS += $(COMMON_FLAGS) +CXXFLAGS += $(COMMON_FLAGS) + +# Enable the security flags +COMMON_LDFLAGS := -Wl,-z,relro,-z,now,-z,noexecstack + +# mitigation options +MITIGATION_INDIRECT ?= 0 +MITIGATION_RET ?= 0 +MITIGATION_C ?= 0 +MITIGATION_ASM ?= 0 +MITIGATION_AFTERLOAD ?= 0 +MITIGATION_LIB_PATH := + +ifeq ($(MITIGATION-CVE-2020-0551), LOAD) + MITIGATION_C := 1 + MITIGATION_ASM := 1 + MITIGATION_INDIRECT := 1 + MITIGATION_RET := 1 + MITIGATION_AFTERLOAD := 1 + MITIGATION_LIB_PATH := cve_2020_0551_load +else ifeq ($(MITIGATION-CVE-2020-0551), CF) + MITIGATION_C := 1 + MITIGATION_ASM := 1 + MITIGATION_INDIRECT := 1 + MITIGATION_RET := 1 + MITIGATION_AFTERLOAD := 0 + MITIGATION_LIB_PATH := cve_2020_0551_cf +endif + +MITIGATION_CFLAGS := +MITIGATION_ASFLAGS := +ifeq ($(MITIGATION_C), 1) +ifeq ($(MITIGATION_INDIRECT), 1) + MITIGATION_CFLAGS += -mindirect-branch-register +endif +ifeq ($(MITIGATION_RET), 1) + MITIGATION_CFLAGS += -mfunction-return=thunk-extern +endif +endif + +ifeq ($(MITIGATION_ASM), 1) + MITIGATION_ASFLAGS += -fno-plt +ifeq ($(MITIGATION_AFTERLOAD), 1) + MITIGATION_ASFLAGS += -Wa,-mlfence-after-load=yes +else + MITIGATION_ASFLAGS += -Wa,-mlfence-before-indirect-branch=register +endif +ifeq ($(MITIGATION_RET), 1) + MITIGATION_ASFLAGS += -Wa,-mlfence-before-ret=not +endif +endif + +MITIGATION_CFLAGS += $(MITIGATION_ASFLAGS) + +# Compiler and linker options for an Enclave +# +# We are using '--export-dynamic' so that `g_global_data_sim' etc. +# will be exported to dynamic symbol table. +# +# When `pie' is enabled, the linker (both BFD and Gold) under Ubuntu 14.04 +# will hide all symbols from dynamic symbol table even if they are marked +# as `global' in the LD version script. +ENCLAVE_CFLAGS = -ffreestanding -nostdinc -fvisibility=hidden -fpie -fno-strict-overflow -fno-delete-null-pointer-checks +ENCLAVE_CXXFLAGS = $(ENCLAVE_CFLAGS) -nostdinc++ +ENCLAVE_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined \ + -Wl,-pie,-eenclave_entry -Wl,--export-dynamic \ + -Wl,--gc-sections \ + -Wl,--defsym,__ImageBase=0 + +ENCLAVE_CFLAGS += $(MITIGATION_CFLAGS) +ENCLAVE_ASFLAGS = $(MITIGATION_ASFLAGS) \ No newline at end of file diff --git a/rust-sgx-workspace/projects/sgx-wallet/buildenv_sgx.mk b/rust-sgx-workspace/projects/sgx-wallet/buildenv_sgx.mk new file mode 100644 index 0000000..4ec0119 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/buildenv_sgx.mk @@ -0,0 +1,49 @@ +SGX_SDK ?= /opt/sgxsdk + +# Directly imported from the original Intel SGX samples, helpful to detect the system architecture + +ifeq ($(shell getconf LONG_BIT), 32) + SGX_ARCH := x86 +else ifeq ($(findstring -m32, $(CXXFLAGS)), -m32) + SGX_ARCH := x86 +endif + +ifeq ($(SGX_ARCH), x86) + SGX_COMMON_CFLAGS := -m32 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x86/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x86/sgx_edger8r +else + SGX_COMMON_CFLAGS := -m64 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib64 + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x64/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x64/sgx_edger8r +endif + +# If specified, software / simulation mode. Otherwise, hardware mode no matter what. + +ifeq ($(SGX_MODE), SW) + TRTS_LIB := sgx_trts_sim + SERVICE_LIB := sgx_tservice_sim +endif + +# If debug mode, we can set up extra options such as the debug flags + +ifeq ($(SGX_DEBUG), 1) + SGX_COMMON_CFLAGS += -O0 -g +else + SGX_COMMON_CFLAGS += -O2 +endif + +# Show helpful error messages if main environment variables are not set. + +$(SGX_EDGER8R): + $(error "$@" does not exist. (Is SGX_SDK set correctly?)) + +ifndef CUSTOM_EDL_PATH +$(error CUSTOM_EDL_PATH not set) +endif + +ifndef CUSTOM_COMMON_PATH +$(error CUSTOM_COMMON_PATH not set) +endif diff --git a/rust-sgx-workspace/projects/sgx-wallet/enclave/.gitignore b/rust-sgx-workspace/projects/sgx-wallet/enclave/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/enclave/.gitignore @@ -0,0 +1 @@ +/target diff --git a/rust-sgx-workspace/projects/sgx-wallet/enclave/Cargo.lock b/rust-sgx-workspace/projects/sgx-wallet/enclave/Cargo.lock new file mode 100644 index 0000000..8a33a8d --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/enclave/Cargo.lock @@ -0,0 +1,1048 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "algonaut" +version = "0.3.0" +source = "git+https://github.com/registreerocks/algonaut-sgx?branch=main-sgx#4c2a24f5ba08e6623f0103853396f417b10d097b" +dependencies = [ + "algonaut_core", + "algonaut_crypto", + "algonaut_encoding", + "algonaut_transaction", +] + +[[package]] +name = "algonaut_core" +version = "0.3.0" +source = "git+https://github.com/registreerocks/algonaut-sgx?branch=main-sgx#4c2a24f5ba08e6623f0103853396f417b10d097b" +dependencies = [ + "algonaut_crypto", + "algonaut_encoding", + "data-encoding", + "derive_more", + "rmp-serde", + "serde", + "sgx_tstd", + "sha2 0.9.5", + "static_assertions", + "thiserror", +] + +[[package]] +name = "algonaut_crypto" +version = "0.3.0" +source = "git+https://github.com/registreerocks/algonaut-sgx?branch=main-sgx#4c2a24f5ba08e6623f0103853396f417b10d097b" +dependencies = [ + "algonaut_encoding", + "data-encoding", + "derive_more", + "indexmap", + "lazy_static", + "ring", + "serde", + "sgx_tstd", + "sha2 0.9.5", + "static_assertions", + "thiserror", +] + +[[package]] +name = "algonaut_encoding" +version = "0.3.0" +source = "git+https://github.com/registreerocks/algonaut-sgx?branch=main-sgx#4c2a24f5ba08e6623f0103853396f417b10d097b" +dependencies = [ + "data-encoding", + "serde", + "sgx_tstd", +] + +[[package]] +name = "algonaut_transaction" +version = "0.3.0" +source = "git+https://github.com/registreerocks/algonaut-sgx?branch=main-sgx#4c2a24f5ba08e6623f0103853396f417b10d097b" +dependencies = [ + "algonaut_core", + "algonaut_crypto", + "algonaut_encoding", + "data-encoding", + "derive_more", + "getrandom 0.2.3", + "num-traits", + "rand", + "ring", + "rmp-serde", + "serde", + "serde_bytes", + "sgx_tstd", + "sha2 0.9.5", + "thiserror", + "url", +] + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "autocfg" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "base-x" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" + +[[package]] +name = "base64" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" + +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "git+https://github.com/mesalock-linux/rustcrypto-utils-sgx#07ebf780554e018037f750186d61ea9bdc031148" +dependencies = [ + "block-padding", + "byte-tools", + "byteorder", + "generic-array 0.12.4", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array 0.14.4", +] + +[[package]] +name = "block-padding" +version = "0.1.4" +source = "git+https://github.com/mesalock-linux/rustcrypto-utils-sgx#07ebf780554e018037f750186d61ea9bdc031148" +dependencies = [ + "byte-tools", +] + +[[package]] +name = "bumpalo" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631" + +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "git+https://github.com/mesalock-linux/rustcrypto-utils-sgx#07ebf780554e018037f750186d61ea9bdc031148" + +[[package]] +name = "byteorder" +version = "1.3.4" +source = "git+https://github.com/mesalock-linux/byteorder-sgx#325f392dcd294109eb05f0a3c45e4141514c7784" +dependencies = [ + "sgx_tstd", +] + +[[package]] +name = "cc" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "cpufeatures" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef" +dependencies = [ + "libc", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "git+https://github.com/mesalock-linux/rustcrypto-traits-sgx#7a5cb154f438c2401b3d8e37de96dd0acf8f493e" +dependencies = [ + "generic-array 0.12.4", + "subtle", +] + +[[package]] +name = "data-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" + +[[package]] +name = "derive_more" +version = "0.99.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40eebddd2156ce1bb37b20bbe5151340a31828b1f2d22ba4141f3531710e38df" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn", +] + +[[package]] +name = "digest" +version = "0.8.1" +source = "git+https://github.com/mesalock-linux/rustcrypto-traits-sgx#7a5cb154f438c2401b3d8e37de96dd0acf8f493e" +dependencies = [ + "generic-array 0.12.4", + "sgx_tstd", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array 0.14.4", +] + +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.14" +source = "git+https://github.com/mesalock-linux/getrandom-sgx#0aa9cc20c7dea713ccaac2c44430d625a395ebae" +dependencies = [ + "cfg-if 0.1.10", + "sgx_libc", + "sgx_trts", + "sgx_tstd", +] + +[[package]] +name = "getrandom" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +dependencies = [ + "cfg-if 1.0.0", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "hashbrown" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" + +[[package]] +name = "hashbrown_tstd" +version = "0.11.2" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.7.1" +source = "git+https://github.com/mesalock-linux/rustcrypto-MACs-sgx#e8e1410b9c82d2e59da42fa8b0d8ed38e80a203c" +dependencies = [ + "crypto-mac", + "digest 0.8.1", +] + +[[package]] +name = "hmac-drbg" +version = "0.1.2" +source = "git+https://github.com/mesalock-linux/hmac-drbg-rs-sgx#89d6b0113157599417af867a8d2b4afd5c6f1946" +dependencies = [ + "generic-array 0.12.4", + "hmac", +] + +[[package]] +name = "idna" +version = "0.2.0" +source = "git+https://github.com/mesalock-linux/rust-url-sgx#23832f3191456c2d4a0faab10952e1747be58ca8" +dependencies = [ + "matches", + "sgx_tstd", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "index-fixed" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161ceaf2f41b6cd3f6502f5da085d4ad4393a51e0c70ed2fce1d5698d798fae" + +[[package]] +name = "indexmap" +version = "1.6.1" +source = "git+https://github.com/mesalock-linux/indexmap-sgx#19f52458ba64dd7349a5d3a62227619a17e4db85" +dependencies = [ + "autocfg 1.0.1", + "hashbrown", + "sgx_tstd", +] + +[[package]] +name = "itoa" +version = "0.4.5" +source = "git+https://github.com/mesalock-linux/itoa-sgx#295ee451f5ec74f25c299552b481beb445ea3eb7" +dependencies = [ + "sgx_tstd", +] + +[[package]] +name = "js-sys" +version = "0.3.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce791b7ca6638aae45be056e068fc756d871eb3b3b10b8efa62d1c9cec616752" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin", +] + +[[package]] +name = "libc" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7f823d141fe0a24df1e23b4af4e3c7ba9e5966ec514ea068c93024aa7deb765" + +[[package]] +name = "libsecp256k1" +version = "0.3.5" +source = "git+https://github.com/ntls-io/libsecp256k1-rs-sgx#2a6c35a1876b3553486d34142155b89eaae77965" +dependencies = [ + "arrayref", + "crunchy", + "digest 0.8.1", + "hmac-drbg", + "rand", + "sgx_tstd", + "sha2 0.8.0", + "subtle", + "typenum", +] + +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "matches" +version = "0.1.8" +source = "git+https://github.com/mesalock-linux/rust-std-candidates-sgx#5747bcf37f3e18687758838da0339ff0f2c83924" + +[[package]] +name = "num-bigint" +version = "0.2.5" +source = "git+https://github.com/mesalock-linux/num-bigint-sgx#76a5bed94dc31c32bd1670dbf72877abcf9bbc09" +dependencies = [ + "autocfg 1.0.1", + "num-integer", + "num-traits", + "sgx_tstd", +] + +[[package]] +name = "num-integer" +version = "0.1.41" +source = "git+https://github.com/mesalock-linux/num-integer-sgx#404c50e5378ca635261688b080dee328ff42b6bd" +dependencies = [ + "autocfg 0.1.7", + "num-traits", + "sgx_tstd", +] + +[[package]] +name = "num-traits" +version = "0.2.10" +source = "git+https://github.com/mesalock-linux/num-traits-sgx#af046e0b15c594c960007418097dd4ff37ec3f7a" +dependencies = [ + "autocfg 0.1.7", + "sgx_tstd", +] + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "git+https://github.com/mesalock-linux/rust-url-sgx#23832f3191456c2d4a0faab10952e1747be58ca8" + +[[package]] +name = "pest" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +dependencies = [ + "ucd-trie", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.6" +source = "git+https://github.com/mesalock-linux/cryptocorrosion-sgx#32d7de50b5f03a10fe5a42167410be2dd3c2e389" + +[[package]] +name = "proc-macro2" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "git+https://github.com/mesalock-linux/rand-sgx#83583f073de3b4f75c3c3ef5e174d484ed941f85" +dependencies = [ + "getrandom 0.1.14", + "rand_chacha", + "rand_core", + "sgx_tstd", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "git+https://github.com/mesalock-linux/rand-sgx#83583f073de3b4f75c3c3ef5e174d484ed941f85" +dependencies = [ + "ppv-lite86", + "rand_core", + "sgx_tstd", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "git+https://github.com/mesalock-linux/rand-sgx#83583f073de3b4f75c3c3ef5e174d484ed941f85" +dependencies = [ + "getrandom 0.1.14", + "sgx_tstd", +] + +[[package]] +name = "ring" +version = "0.16.19" +source = "git+https://github.com/mesalock-linux/ring-sgx#844efe271ed78a399d803b2579f5f2424d543c9f" +dependencies = [ + "cc", + "sgx_tstd", + "spin", + "untrusted", +] + +[[package]] +name = "ripemd160" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eca4ecc81b7f313189bf73ce724400a07da2a6dac19588b03c8bd76a2dcc251" +dependencies = [ + "block-buffer 0.9.0", + "digest 0.9.0", + "opaque-debug 0.3.0", +] + +[[package]] +name = "ripple-address-codec" +version = "0.1.1" +source = "git+https://github.com/ntls-io/ripple-address-codec-rust-sgx?branch=v0.1.1-sgx#e2b03486a9e0627bbc922681863b4661be8a4e3b" +dependencies = [ + "base-x", + "ring", + "sgx_tstd", +] + +[[package]] +name = "ripple-keypairs" +version = "0.1.0" +source = "git+https://github.com/ntls-io/ripple-keypairs-rust-sgx?branch=v0.1.0-sgx#ef55261e2f0aa6b5c54cac43abc4c57b4f97b286" +dependencies = [ + "base-x", + "hex", + "libsecp256k1", + "num-bigint", + "ring", + "ripemd160", + "ripple-address-codec", + "sgx_tstd", +] + +[[package]] +name = "rmp" +version = "0.8.9" +source = "git+https://github.com/mesalock-linux/msgpack-rust-sgx#55273d79a63a08bdfe06d744e635296875307b22" +dependencies = [ + "byteorder", + "num-traits", + "sgx_tstd", +] + +[[package]] +name = "rmp-serde" +version = "0.15.0" +source = "git+https://github.com/mesalock-linux/msgpack-rust-sgx#55273d79a63a08bdfe06d744e635296875307b22" +dependencies = [ + "byteorder", + "rmp", + "serde", + "sgx_tstd", +] + +[[package]] +name = "rustc_version" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver", +] + +[[package]] +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + +[[package]] +name = "secrecy" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bd1c54ea06cfd2f6b63219704de0b9b4f72dcc2b8fdef820be6cd799780e91e" +dependencies = [ + "zeroize", +] + +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + +[[package]] +name = "serde" +version = "1.0.118" +source = "git+https://github.com/mesalock-linux/serde-sgx#db0226f1d5d70fca6b96af2c285851502204e21c" +dependencies = [ + "serde_derive", + "sgx_tstd", +] + +[[package]] +name = "serde_bytes" +version = "0.11.5" +source = "git+https://github.com/registreerocks/serde-bytes-sgx#0bdf5e0596258f8895ce60527d82b6b5961a2eae" +dependencies = [ + "serde", + "sgx_tstd", +] + +[[package]] +name = "serde_derive" +version = "1.0.118" +source = "git+https://github.com/mesalock-linux/serde-sgx#db0226f1d5d70fca6b96af2c285851502204e21c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.60" +source = "git+https://github.com/mesalock-linux/serde-json-sgx#380893814ad2a057758d825bab798aa117f7362a" +dependencies = [ + "itoa", + "ryu", + "serde", + "sgx_tstd", +] + +[[package]] +name = "sgx-wallet-enclave" +version = "0.1.0" +dependencies = [ + "sgx-wallet-impl", + "sgx_tstd", + "sgx_types", +] + +[[package]] +name = "sgx-wallet-impl" +version = "0.1.0" +dependencies = [ + "algonaut", + "base64", + "hex", + "rand", + "ripple-address-codec", + "ripple-keypairs", + "rmp-serde", + "secrecy", + "serde", + "serde_bytes", + "serde_json", + "sgx_tcrypto", + "sgx_trts", + "sgx_tse", + "sgx_tstd", + "sgx_types", + "sodalite", + "thiserror", + "zeroize", +] + +[[package]] +name = "sgx_alloc" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" + +[[package]] +name = "sgx_backtrace_sys" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "cc", + "sgx_build_helper", + "sgx_libc", +] + +[[package]] +name = "sgx_build_helper" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" + +[[package]] +name = "sgx_demangle" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" + +[[package]] +name = "sgx_libc" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "sgx_types", +] + +[[package]] +name = "sgx_tcrypto" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "sgx_types", +] + +[[package]] +name = "sgx_tprotected_fs" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "sgx_trts", + "sgx_types", +] + +[[package]] +name = "sgx_trts" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "sgx_libc", + "sgx_types", +] + +[[package]] +name = "sgx_tse" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "sgx_types", +] + +[[package]] +name = "sgx_tstd" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "hashbrown_tstd", + "sgx_alloc", + "sgx_backtrace_sys", + "sgx_demangle", + "sgx_libc", + "sgx_tprotected_fs", + "sgx_trts", + "sgx_types", + "sgx_unwind", +] + +[[package]] +name = "sgx_types" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" + +[[package]] +name = "sgx_unwind" +version = "1.1.4" +source = "git+https://github.com/apache/incubator-teaclave-sgx-sdk?rev=e8a9fc22939befa27ff67f5509b2c2dfe8499945#e8a9fc22939befa27ff67f5509b2c2dfe8499945" +dependencies = [ + "sgx_build_helper", +] + +[[package]] +name = "sha2" +version = "0.8.0" +source = "git+https://github.com/mesalock-linux/rustcrypto-hashes-sgx#54ac4af765ec6b424add4e7559e82328bd052060" +dependencies = [ + "block-buffer 0.7.3", + "digest 0.8.1", + "fake-simd", + "opaque-debug 0.2.3", + "sgx_tstd", +] + +[[package]] +name = "sha2" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.9.0", + "opaque-debug 0.3.0", +] + +[[package]] +name = "smallvec" +version = "1.6.1" +source = "git+https://github.com/mesalock-linux/rust-smallvec-sgx#b5925f10aa5bc3370a0fb339140ee063f5a888dd" +dependencies = [ + "sgx_tstd", +] + +[[package]] +name = "sodalite" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41784a359d15c58bba298cccb7f30a847a1a42d0620c9bdaa0aa42fdb3c280e0" +dependencies = [ + "index-fixed", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "subtle" +version = "2.2.2" +source = "git+https://github.com/mesalock-linux/subtle-sgx#8ee32fc0902a4594bd12e272357e2d76cde9dad1" +dependencies = [ + "sgx_tstd", +] + +[[package]] +name = "syn" +version = "1.0.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1873d832550d4588c3dbc20f01361ab00bfe741048f71e3fecf145a7cc18b29c" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "synstructure" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "474aaa926faa1603c40b7885a9eaea29b444d1cb2850cb7c0e37bb1a4182f4fa" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "thiserror" +version = "1.0.9" +source = "git+https://github.com/mesalock-linux/thiserror-sgx#c2f806b88616e06aab0af770366a76885d974fdc" +dependencies = [ + "sgx_tstd", + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.9" +source = "git+https://github.com/mesalock-linux/thiserror-sgx#c2f806b88616e06aab0af770366a76885d974fdc" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "typenum" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" + +[[package]] +name = "ucd-trie" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" + +[[package]] +name = "unicode-bidi" +version = "0.3.4" +source = "git+https://github.com/mesalock-linux/unicode-bidi-sgx#eb10728a635a046e75747849fbc680cbbb7832c7" +dependencies = [ + "matches", + "sgx_tstd", +] + +[[package]] +name = "unicode-normalization" +version = "0.1.12" +source = "git+https://github.com/mesalock-linux/unicode-normalization-sgx#c1b030611969f87d75782c1df77975167cbbd509" +dependencies = [ + "smallvec", +] + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "url" +version = "2.1.1" +source = "git+https://github.com/mesalock-linux/rust-url-sgx#23832f3191456c2d4a0faab10952e1747be58ca8" +dependencies = [ + "idna", + "matches", + "percent-encoding", + "sgx_tstd", +] + +[[package]] +name = "version_check" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" + +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + +[[package]] +name = "wasm-bindgen" +version = "0.2.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b608ecc8f4198fe8680e2ed18eccab5f0cd4caaf3d83516fa5fb2e927fda2586" +dependencies = [ + "cfg-if 1.0.0", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "580aa3a91a63d23aac5b6b267e2d13cb4f363e31dce6c352fca4752ae12e479f" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "171ebf0ed9e1458810dfcb31f2e766ad6b3a89dbda42d8901f2b268277e5f09c" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c2657dd393f03aa2a659c25c6ae18a13a4048cebd220e147933ea837efc589f" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e0c4a743a309662d45f4ede961d7afa4ba4131a59a639f29b0069c3798bbcc2" + +[[package]] +name = "zeroize" +version = "1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eb5728b8afd3f280a869ce1d4c554ffaed35f45c231fc41bfbd0381bef50317" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f8f187641dad4f680d25c4bfc4225b418165984179f26ca76ec4fb6441d3a17" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] diff --git a/rust-sgx-workspace/projects/sgx-wallet/enclave/Cargo.toml b/rust-sgx-workspace/projects/sgx-wallet/enclave/Cargo.toml new file mode 100644 index 0000000..e64fa35 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/enclave/Cargo.toml @@ -0,0 +1,25 @@ +[package] +# name matches ENCLAVE_CARGO_LIB in Makefile +name = "sgx-wallet-enclave" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["staticlib"] +bench = false +test = false + +[features] +default = [] + +[dependencies] +# SGX SDK +sgx_types = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } +sgx_tstd = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", features = ["backtrace"], rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } + +sgx-wallet-impl = { path = "../../../crates/sgx-wallet-impl" } + +[patch.'https://github.com/apache/teaclave-sgx-sdk.git'] +sgx_libc = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } +sgx_trts = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } +sgx_tstd = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } diff --git a/rust-sgx-workspace/projects/sgx-wallet/enclave/Enclave.config.xml b/rust-sgx-workspace/projects/sgx-wallet/enclave/Enclave.config.xml new file mode 100644 index 0000000..ee4c3f7 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/enclave/Enclave.config.xml @@ -0,0 +1,12 @@ + + + 0 + 0 + 0x40000 + 0x100000 + 1 + 1 + 0 + 0 + 0xFFFFFFFF + diff --git a/rust-sgx-workspace/projects/sgx-wallet/enclave/Enclave.edl b/rust-sgx-workspace/projects/sgx-wallet/enclave/Enclave.edl new file mode 100644 index 0000000..8d5c89c --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/enclave/Enclave.edl @@ -0,0 +1,26 @@ +enclave { + from "sgx_tstdc.edl" import *; + from "sgx_tstd.edl" import *; + from "sgx_backtrace.edl" import *; + + from "sgx_env.edl" import *; + from "sgx_tprotected_fs.edl" import *; + + include "sgx_report.h" + + trusted { + public sgx_status_t enclave_create_report( + [in] const sgx_target_info_t* p_qe3_target, + [out] sgx_report_t* p_report, + [out] uint8_t enclave_data[32] + ); + + public sgx_status_t wallet_operation( + [in, count=sealed_request_size] const uint8_t* sealed_request_buffer, + size_t sealed_request_size, + [out, count=sealed_response_capacity] uint8_t* sealed_response_buffer, + size_t sealed_response_capacity, + [out] size_t* sealed_response_used + ); + }; +}; diff --git a/rust-sgx-workspace/projects/sgx-wallet/enclave/Enclave.lds b/rust-sgx-workspace/projects/sgx-wallet/enclave/Enclave.lds new file mode 100644 index 0000000..e3d9d0e --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/enclave/Enclave.lds @@ -0,0 +1,9 @@ +enclave.so +{ + global: + g_global_data_sim; + g_global_data; + enclave_entry; + local: + *; +}; diff --git a/rust-sgx-workspace/projects/sgx-wallet/enclave/Makefile b/rust-sgx-workspace/projects/sgx-wallet/enclave/Makefile new file mode 100644 index 0000000..1fdc694 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/enclave/Makefile @@ -0,0 +1,117 @@ +# Makefile settings + +APP_T_SIGNED = enclave.signed.so +KEYS = ../keys +LIB = ../build/lib/ +BIN = ../build/bin/ +APP_T = enclave.so +NAME_T = libenclave.a +SRC_U = ../app/ +SRC_T = ./ +CODEGEN_T = $(SRC_T)/codegen/ +OBJ_T = ../build/obj/ +FLAGS = -Wall -Wextra +GCC_STEP1_T = -fstack-protector -I$(CUSTOM_COMMON_PATH)/inc -I$(CUSTOM_EDL_PATH) -I$(SGX_SDK)/include \ + -I$(SGX_SDK)/include/tlibc -I$(SGX_SDK)/include/stlport -I$(SGX_SDK)/include/epid -I $(CODEGEN_T) \ + -L$(LIB) $(ENCLAVE_CFLAGS) $(SGX_COMMON_CFLAGS) +GCC_STEP2_T = -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L$(SGX_LIBRARY_PATH) \ + -Wl,--whole-archive -l$(TRTS_LIB) -Wl,--no-whole-archive \ + -Wl,--start-group -lsgx_tstdc -l$(SERVICE_LIB) -lsgx_tcrypto -lsgx_tcxx -lsgx_tprotected_fs -L$(LIB) -lenclave -Wl,--end-group \ + -Wl,--version-script=$(SRC_T)Enclave.lds $(ENCLAVE_LDFLAGS) +FILES_T = Enclave_t.c +FILES_T_H = Enclave_t.h +EDL_FILE = Enclave.edl +ENCLAVE_CONFIG = Enclave.config.xml +SGX_ARCH = x64 +TRTS_LIB = sgx_trts +SERVICE_LIB = sgx_tservice +# ENCLAVE_CARGO_LIB matches name in Cargo.toml +ENCLAVE_CARGO_LIB=libsgx_wallet_enclave.a +# Addprefix dependant variables, no need to change those +OUTPUT_T = $(FILES_T:.c=.o) +NAME = $(addprefix $(BIN), $(APP_T_SIGNED)) +BIN_T = $(addprefix $(BIN), $(APP_T)) +NAME_T_D = $(addprefix $(LIB), $(NAME_T)) +OUTPUT_W_FU=$(addprefix $(OBJ_U), $(OUTPUT_U)) +FILES_T_F=$(addprefix $(CODEGEN_T), $(FILES_T)) +FILES_T_H_F=$(addprefix $(CODEGEN_T), $(FILES_T_H)) +FILES_T_F_RUST=$(addprefix $(SRC_T), $(FILES_T_RUST)) +OUTPUT_W_FT=$(addprefix $(OBJ_T), $(OUTPUT_T)) + +# All Rust and other source files that the Cargo build depends on. +FILES_RUST_F = Cargo.toml Cargo.lock $(shell find src ../../../crates/sgx-wallet-impl/src -name '*.rs') + +# Contains compilation rules for the enclave part + +include ../buildenv.mk +include ../buildenv_sgx.mk + +# Custom header files and EDL paths needs to be specified with make (CUSTOM_EDL_PATH) (CUSTOM_COMMON_PATH) + +ifeq ($(MITIGATION-CVE-2020-0551), LOAD) +export MITIGATION_CVE_2020_0551=LOAD +else ifeq ($(MITIGATION-CVE-2020-0551), CF) +export MITIGATION_CVE_2020_0551=CF +endif + +# Compilation process, we set up all the dependencies needed to have the correct order of build, and avoid relink + +all: $(NAME) + +# We print the compilation mode we're in (hardware/software mode), just as a reminder. + +$(NAME): $(BIN_T) $(KEYS)/Enclave_private.pem +ifeq ($(SGX_MODE), SW) + @echo "\033[32mSoftware / Simulation mode\033[0m" +else + @echo "\033[32mHardware mode\033[0m" +endif + @echo "\033[32mSigning the enclave...\033[0m" + @mkdir -p $(BIN) + @$(SGX_ENCLAVE_SIGNER) sign -key $(KEYS)/Enclave_private.pem -enclave $(BIN_T) -out $@ -config $(SRC_T)Enclave.config.xml + +$(KEYS)/Enclave_private.pem $(KEYS)/Enclave_public.pem: + @echo "\033[32mGenerating keys...\033[0m" + @mkdir -p $(KEYS) + @openssl genrsa -out $(KEYS)/Enclave_private.pem -3 3072 + @openssl rsa -in $(KEYS)/Enclave_private.pem -pubout -out $(KEYS)/Enclave_public.pem + +$(BIN_T): $(NAME_T_D) + @echo "\033[32mBuilding the enclave...\033[0m" + @$(CXX) $(OUTPUT_W_FT) -o $@ $(GCC_STEP2_T) + +$(NAME_T_D): $(FILES_T_F) $(OUTPUT_W_FT) $(FILES_RUST_F) $(EDL_FILE) $(ENCLAVE_CONFIG) # We added as a reference the rust files, along with the EDL, the XML config file and the cargo.toml file, so Make can detect if any change was made + @echo "\033[32mBuilding enclave static library with Cargo...\033[0m" + @cargo build --release + @cp ./target/release/$(ENCLAVE_CARGO_LIB) $(LIB)libenclave.a + +$(FILES_T_F): $(SGX_EDGER8R) $(SRC_T)/Enclave.edl + @echo "\033[32mGenerating trusted SGX C edl files...\033[0m" + @$(SGX_EDGER8R) --trusted $(SRC_T)/Enclave.edl --search-path $(SGX_SDK)/include --search-path $(CUSTOM_EDL_PATH) --trusted-dir $(CODEGEN_T) + +$(OBJ_T)%.o:$(CODEGEN_T)%.c + @mkdir -p $(OBJ_T) + @echo "\033[32m$?: Build in progress...\033[0m" + @$(CC) $(FLAGS) $(GCC_STEP1_T) -o $@ -c $? + +clean: c_clean + @rm -rf $(OBJ_T) + @echo "\033[32mObject files deleted\033[0m" + +fclean: clean fclean_enclave + +fclean_enclave: + @echo "\033[32mBinary file $(NAME) deleted\033[0m" + @rm -f $(NAME) + @rm -f $(BIN_T) + @rm -f $(LIB)libenclave.a + @cargo clean + +c_clean: + @echo "\033[32mC edl generated files deleted\033[0m" + @rm -rf $(FILES_T_F) + @rm -f $(FILES_T_H_F) + +re: fclean all + +.PHONY: all clean c_clean fclean re fclean_enclave diff --git a/rust-sgx-workspace/projects/sgx-wallet/enclave/codegen/Enclave_t.c b/rust-sgx-workspace/projects/sgx-wallet/enclave/codegen/Enclave_t.c new file mode 100644 index 0000000..1d5ec92 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/enclave/codegen/Enclave_t.c @@ -0,0 +1,6122 @@ +#include "Enclave_t.h" + +#include "sgx_trts.h" /* for sgx_ocalloc, sgx_is_outside_enclave */ +#include "sgx_lfence.h" /* for sgx_lfence */ + +#include +#include /* for memcpy_s etc */ +#include /* for malloc/free etc */ + +#define CHECK_REF_POINTER(ptr, siz) do { \ + if (!(ptr) || ! sgx_is_outside_enclave((ptr), (siz))) \ + return SGX_ERROR_INVALID_PARAMETER;\ +} while (0) + +#define CHECK_UNIQUE_POINTER(ptr, siz) do { \ + if ((ptr) && ! sgx_is_outside_enclave((ptr), (siz))) \ + return SGX_ERROR_INVALID_PARAMETER;\ +} while (0) + +#define CHECK_ENCLAVE_POINTER(ptr, siz) do { \ + if ((ptr) && ! sgx_is_within_enclave((ptr), (siz))) \ + return SGX_ERROR_INVALID_PARAMETER;\ +} while (0) + +#define ADD_ASSIGN_OVERFLOW(a, b) ( \ + ((a) += (b)) < (b) \ +) + + +typedef struct ms_enclave_create_report_t { + sgx_status_t ms_retval; + const sgx_target_info_t* ms_p_qe3_target; + sgx_report_t* ms_p_report; + uint8_t* ms_enclave_data; +} ms_enclave_create_report_t; + +typedef struct ms_wallet_operation_t { + sgx_status_t ms_retval; + const uint8_t* ms_sealed_request_buffer; + size_t ms_sealed_request_size; + uint8_t* ms_sealed_response_buffer; + size_t ms_sealed_response_capacity; + size_t* ms_sealed_response_used; +} ms_wallet_operation_t; + +typedef struct ms_t_global_init_ecall_t { + uint64_t ms_id; + const uint8_t* ms_path; + size_t ms_len; +} ms_t_global_init_ecall_t; + +typedef struct ms_sgx_oc_cpuidex_t { + int* ms_cpuinfo; + int ms_leaf; + int ms_subleaf; +} ms_sgx_oc_cpuidex_t; + +typedef struct ms_sgx_thread_wait_untrusted_event_ocall_t { + int ms_retval; + const void* ms_self; +} ms_sgx_thread_wait_untrusted_event_ocall_t; + +typedef struct ms_sgx_thread_set_untrusted_event_ocall_t { + int ms_retval; + const void* ms_waiter; +} ms_sgx_thread_set_untrusted_event_ocall_t; + +typedef struct ms_sgx_thread_setwait_untrusted_events_ocall_t { + int ms_retval; + const void* ms_waiter; + const void* ms_self; +} ms_sgx_thread_setwait_untrusted_events_ocall_t; + +typedef struct ms_sgx_thread_set_multiple_untrusted_events_ocall_t { + int ms_retval; + const void** ms_waiters; + size_t ms_total; +} ms_sgx_thread_set_multiple_untrusted_events_ocall_t; + +typedef struct ms_u_thread_set_event_ocall_t { + int ms_retval; + int* ms_error; + const void* ms_tcs; +} ms_u_thread_set_event_ocall_t; + +typedef struct ms_u_thread_wait_event_ocall_t { + int ms_retval; + int* ms_error; + const void* ms_tcs; + const struct timespec* ms_timeout; +} ms_u_thread_wait_event_ocall_t; + +typedef struct ms_u_thread_set_multiple_events_ocall_t { + int ms_retval; + int* ms_error; + const void** ms_tcss; + int ms_total; +} ms_u_thread_set_multiple_events_ocall_t; + +typedef struct ms_u_thread_setwait_events_ocall_t { + int ms_retval; + int* ms_error; + const void* ms_waiter_tcs; + const void* ms_self_tcs; + const struct timespec* ms_timeout; +} ms_u_thread_setwait_events_ocall_t; + +typedef struct ms_u_clock_gettime_ocall_t { + int ms_retval; + int* ms_error; + int ms_clk_id; + struct timespec* ms_tp; +} ms_u_clock_gettime_ocall_t; + +typedef struct ms_u_read_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + void* ms_buf; + size_t ms_count; +} ms_u_read_ocall_t; + +typedef struct ms_u_pread64_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + void* ms_buf; + size_t ms_count; + int64_t ms_offset; +} ms_u_pread64_ocall_t; + +typedef struct ms_u_readv_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const struct iovec* ms_iov; + int ms_iovcnt; +} ms_u_readv_ocall_t; + +typedef struct ms_u_preadv64_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const struct iovec* ms_iov; + int ms_iovcnt; + int64_t ms_offset; +} ms_u_preadv64_ocall_t; + +typedef struct ms_u_write_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const void* ms_buf; + size_t ms_count; +} ms_u_write_ocall_t; + +typedef struct ms_u_pwrite64_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const void* ms_buf; + size_t ms_count; + int64_t ms_offset; +} ms_u_pwrite64_ocall_t; + +typedef struct ms_u_writev_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const struct iovec* ms_iov; + int ms_iovcnt; +} ms_u_writev_ocall_t; + +typedef struct ms_u_pwritev64_ocall_t { + size_t ms_retval; + int* ms_error; + int ms_fd; + const struct iovec* ms_iov; + int ms_iovcnt; + int64_t ms_offset; +} ms_u_pwritev64_ocall_t; + +typedef struct ms_u_fcntl_arg0_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int ms_cmd; +} ms_u_fcntl_arg0_ocall_t; + +typedef struct ms_u_fcntl_arg1_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int ms_cmd; + int ms_arg; +} ms_u_fcntl_arg1_ocall_t; + +typedef struct ms_u_ioctl_arg0_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int ms_request; +} ms_u_ioctl_arg0_ocall_t; + +typedef struct ms_u_ioctl_arg1_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int ms_request; + int* ms_arg; +} ms_u_ioctl_arg1_ocall_t; + +typedef struct ms_u_close_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; +} ms_u_close_ocall_t; + +typedef struct ms_u_malloc_ocall_t { + void* ms_retval; + int* ms_error; + size_t ms_size; +} ms_u_malloc_ocall_t; + +typedef struct ms_u_free_ocall_t { + void* ms_p; +} ms_u_free_ocall_t; + +typedef struct ms_u_mmap_ocall_t { + void* ms_retval; + int* ms_error; + void* ms_start; + size_t ms_length; + int ms_prot; + int ms_flags; + int ms_fd; + int64_t ms_offset; +} ms_u_mmap_ocall_t; + +typedef struct ms_u_munmap_ocall_t { + int ms_retval; + int* ms_error; + void* ms_start; + size_t ms_length; +} ms_u_munmap_ocall_t; + +typedef struct ms_u_msync_ocall_t { + int ms_retval; + int* ms_error; + void* ms_addr; + size_t ms_length; + int ms_flags; +} ms_u_msync_ocall_t; + +typedef struct ms_u_mprotect_ocall_t { + int ms_retval; + int* ms_error; + void* ms_addr; + size_t ms_length; + int ms_prot; +} ms_u_mprotect_ocall_t; + +typedef struct ms_u_open_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_pathname; + int ms_flags; +} ms_u_open_ocall_t; + +typedef struct ms_u_open64_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + int ms_oflag; + int ms_mode; +} ms_u_open64_ocall_t; + +typedef struct ms_u_fstat_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + struct stat_t* ms_buf; +} ms_u_fstat_ocall_t; + +typedef struct ms_u_fstat64_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + struct stat64_t* ms_buf; +} ms_u_fstat64_ocall_t; + +typedef struct ms_u_stat_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + struct stat_t* ms_buf; +} ms_u_stat_ocall_t; + +typedef struct ms_u_stat64_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + struct stat64_t* ms_buf; +} ms_u_stat64_ocall_t; + +typedef struct ms_u_lstat_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + struct stat_t* ms_buf; +} ms_u_lstat_ocall_t; + +typedef struct ms_u_lstat64_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + struct stat64_t* ms_buf; +} ms_u_lstat64_ocall_t; + +typedef struct ms_u_lseek_ocall_t { + uint64_t ms_retval; + int* ms_error; + int ms_fd; + int64_t ms_offset; + int ms_whence; +} ms_u_lseek_ocall_t; + +typedef struct ms_u_lseek64_ocall_t { + int64_t ms_retval; + int* ms_error; + int ms_fd; + int64_t ms_offset; + int ms_whence; +} ms_u_lseek64_ocall_t; + +typedef struct ms_u_ftruncate_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int64_t ms_length; +} ms_u_ftruncate_ocall_t; + +typedef struct ms_u_ftruncate64_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + int64_t ms_length; +} ms_u_ftruncate64_ocall_t; + +typedef struct ms_u_truncate_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + int64_t ms_length; +} ms_u_truncate_ocall_t; + +typedef struct ms_u_truncate64_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + int64_t ms_length; +} ms_u_truncate64_ocall_t; + +typedef struct ms_u_fsync_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; +} ms_u_fsync_ocall_t; + +typedef struct ms_u_fdatasync_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; +} ms_u_fdatasync_ocall_t; + +typedef struct ms_u_fchmod_ocall_t { + int ms_retval; + int* ms_error; + int ms_fd; + uint32_t ms_mode; +} ms_u_fchmod_ocall_t; + +typedef struct ms_u_unlink_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_pathname; +} ms_u_unlink_ocall_t; + +typedef struct ms_u_link_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_oldpath; + const char* ms_newpath; +} ms_u_link_ocall_t; + +typedef struct ms_u_linkat_ocall_t { + int ms_retval; + int* ms_error; + int ms_olddirfd; + const char* ms_oldpath; + int ms_newdirfd; + const char* ms_newpath; + int ms_flags; +} ms_u_linkat_ocall_t; + +typedef struct ms_u_rename_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_oldpath; + const char* ms_newpath; +} ms_u_rename_ocall_t; + +typedef struct ms_u_chmod_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path; + uint32_t ms_mode; +} ms_u_chmod_ocall_t; + +typedef struct ms_u_readlink_ocall_t { + size_t ms_retval; + int* ms_error; + const char* ms_path; + char* ms_buf; + size_t ms_bufsz; +} ms_u_readlink_ocall_t; + +typedef struct ms_u_symlink_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_path1; + const char* ms_path2; +} ms_u_symlink_ocall_t; + +typedef struct ms_u_realpath_ocall_t { + char* ms_retval; + int* ms_error; + const char* ms_pathname; +} ms_u_realpath_ocall_t; + +typedef struct ms_u_mkdir_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_pathname; + uint32_t ms_mode; +} ms_u_mkdir_ocall_t; + +typedef struct ms_u_rmdir_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_pathname; +} ms_u_rmdir_ocall_t; + +typedef struct ms_u_opendir_ocall_t { + void* ms_retval; + int* ms_error; + const char* ms_pathname; +} ms_u_opendir_ocall_t; + +typedef struct ms_u_readdir64_r_ocall_t { + int ms_retval; + void* ms_dirp; + struct dirent64_t* ms_entry; + struct dirent64_t** ms_result; +} ms_u_readdir64_r_ocall_t; + +typedef struct ms_u_closedir_ocall_t { + int ms_retval; + int* ms_error; + void* ms_dirp; +} ms_u_closedir_ocall_t; + +typedef struct ms_u_dirfd_ocall_t { + int ms_retval; + int* ms_error; + void* ms_dirp; +} ms_u_dirfd_ocall_t; + +typedef struct ms_u_fstatat64_ocall_t { + int ms_retval; + int* ms_error; + int ms_dirfd; + const char* ms_pathname; + struct stat64_t* ms_buf; + int ms_flags; +} ms_u_fstatat64_ocall_t; + +typedef struct ms_u_environ_ocall_t { + char** ms_retval; +} ms_u_environ_ocall_t; + +typedef struct ms_u_getenv_ocall_t { + char* ms_retval; + const char* ms_name; +} ms_u_getenv_ocall_t; + +typedef struct ms_u_setenv_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_name; + const char* ms_value; + int ms_overwrite; +} ms_u_setenv_ocall_t; + +typedef struct ms_u_unsetenv_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_name; +} ms_u_unsetenv_ocall_t; + +typedef struct ms_u_chdir_ocall_t { + int ms_retval; + int* ms_error; + const char* ms_dir; +} ms_u_chdir_ocall_t; + +typedef struct ms_u_getcwd_ocall_t { + char* ms_retval; + int* ms_error; + char* ms_buf; + size_t ms_buflen; +} ms_u_getcwd_ocall_t; + +typedef struct ms_u_getpwuid_r_ocall_t { + int ms_retval; + unsigned int ms_uid; + struct passwd* ms_pwd; + char* ms_buf; + size_t ms_buflen; + struct passwd** ms_passwd_result; +} ms_u_getpwuid_r_ocall_t; + +typedef struct ms_u_getuid_ocall_t { + unsigned int ms_retval; +} ms_u_getuid_ocall_t; + +typedef struct ms_u_sgxprotectedfs_exclusive_file_open_t { + void* ms_retval; + const char* ms_filename; + uint8_t ms_read_only; + int64_t* ms_file_size; + int32_t* ms_error_code; +} ms_u_sgxprotectedfs_exclusive_file_open_t; + +typedef struct ms_u_sgxprotectedfs_check_if_file_exists_t { + uint8_t ms_retval; + const char* ms_filename; +} ms_u_sgxprotectedfs_check_if_file_exists_t; + +typedef struct ms_u_sgxprotectedfs_fread_node_t { + int32_t ms_retval; + void* ms_f; + uint64_t ms_node_number; + uint8_t* ms_buffer; + uint32_t ms_node_size; +} ms_u_sgxprotectedfs_fread_node_t; + +typedef struct ms_u_sgxprotectedfs_fwrite_node_t { + int32_t ms_retval; + void* ms_f; + uint64_t ms_node_number; + uint8_t* ms_buffer; + uint32_t ms_node_size; +} ms_u_sgxprotectedfs_fwrite_node_t; + +typedef struct ms_u_sgxprotectedfs_fclose_t { + int32_t ms_retval; + void* ms_f; +} ms_u_sgxprotectedfs_fclose_t; + +typedef struct ms_u_sgxprotectedfs_fflush_t { + uint8_t ms_retval; + void* ms_f; +} ms_u_sgxprotectedfs_fflush_t; + +typedef struct ms_u_sgxprotectedfs_remove_t { + int32_t ms_retval; + const char* ms_filename; +} ms_u_sgxprotectedfs_remove_t; + +typedef struct ms_u_sgxprotectedfs_recovery_file_open_t { + void* ms_retval; + const char* ms_filename; +} ms_u_sgxprotectedfs_recovery_file_open_t; + +typedef struct ms_u_sgxprotectedfs_fwrite_recovery_node_t { + uint8_t ms_retval; + void* ms_f; + uint8_t* ms_data; + uint32_t ms_data_length; +} ms_u_sgxprotectedfs_fwrite_recovery_node_t; + +typedef struct ms_u_sgxprotectedfs_do_file_recovery_t { + int32_t ms_retval; + const char* ms_filename; + const char* ms_recovery_filename; + uint32_t ms_node_size; +} ms_u_sgxprotectedfs_do_file_recovery_t; + +static sgx_status_t SGX_CDECL sgx_enclave_create_report(void* pms) +{ + CHECK_REF_POINTER(pms, sizeof(ms_enclave_create_report_t)); + // + // fence after pointer checks + // + sgx_lfence(); + ms_enclave_create_report_t* ms = SGX_CAST(ms_enclave_create_report_t*, pms); + sgx_status_t status = SGX_SUCCESS; + const sgx_target_info_t* _tmp_p_qe3_target = ms->ms_p_qe3_target; + size_t _len_p_qe3_target = sizeof(sgx_target_info_t); + sgx_target_info_t* _in_p_qe3_target = NULL; + sgx_report_t* _tmp_p_report = ms->ms_p_report; + size_t _len_p_report = sizeof(sgx_report_t); + sgx_report_t* _in_p_report = NULL; + uint8_t* _tmp_enclave_data = ms->ms_enclave_data; + size_t _len_enclave_data = 32 * sizeof(uint8_t); + uint8_t* _in_enclave_data = NULL; + + CHECK_UNIQUE_POINTER(_tmp_p_qe3_target, _len_p_qe3_target); + CHECK_UNIQUE_POINTER(_tmp_p_report, _len_p_report); + CHECK_UNIQUE_POINTER(_tmp_enclave_data, _len_enclave_data); + + // + // fence after pointer checks + // + sgx_lfence(); + + if (_tmp_p_qe3_target != NULL && _len_p_qe3_target != 0) { + _in_p_qe3_target = (sgx_target_info_t*)malloc(_len_p_qe3_target); + if (_in_p_qe3_target == NULL) { + status = SGX_ERROR_OUT_OF_MEMORY; + goto err; + } + + if (memcpy_s(_in_p_qe3_target, _len_p_qe3_target, _tmp_p_qe3_target, _len_p_qe3_target)) { + status = SGX_ERROR_UNEXPECTED; + goto err; + } + + } + if (_tmp_p_report != NULL && _len_p_report != 0) { + if ((_in_p_report = (sgx_report_t*)malloc(_len_p_report)) == NULL) { + status = SGX_ERROR_OUT_OF_MEMORY; + goto err; + } + + memset((void*)_in_p_report, 0, _len_p_report); + } + if (_tmp_enclave_data != NULL && _len_enclave_data != 0) { + if ( _len_enclave_data % sizeof(*_tmp_enclave_data) != 0) + { + status = SGX_ERROR_INVALID_PARAMETER; + goto err; + } + if ((_in_enclave_data = (uint8_t*)malloc(_len_enclave_data)) == NULL) { + status = SGX_ERROR_OUT_OF_MEMORY; + goto err; + } + + memset((void*)_in_enclave_data, 0, _len_enclave_data); + } + + ms->ms_retval = enclave_create_report((const sgx_target_info_t*)_in_p_qe3_target, _in_p_report, _in_enclave_data); + if (_in_p_report) { + if (memcpy_s(_tmp_p_report, _len_p_report, _in_p_report, _len_p_report)) { + status = SGX_ERROR_UNEXPECTED; + goto err; + } + } + if (_in_enclave_data) { + if (memcpy_s(_tmp_enclave_data, _len_enclave_data, _in_enclave_data, _len_enclave_data)) { + status = SGX_ERROR_UNEXPECTED; + goto err; + } + } + +err: + if (_in_p_qe3_target) free(_in_p_qe3_target); + if (_in_p_report) free(_in_p_report); + if (_in_enclave_data) free(_in_enclave_data); + return status; +} + +static sgx_status_t SGX_CDECL sgx_wallet_operation(void* pms) +{ + CHECK_REF_POINTER(pms, sizeof(ms_wallet_operation_t)); + // + // fence after pointer checks + // + sgx_lfence(); + ms_wallet_operation_t* ms = SGX_CAST(ms_wallet_operation_t*, pms); + sgx_status_t status = SGX_SUCCESS; + const uint8_t* _tmp_sealed_request_buffer = ms->ms_sealed_request_buffer; + size_t _tmp_sealed_request_size = ms->ms_sealed_request_size; + size_t _len_sealed_request_buffer = _tmp_sealed_request_size * sizeof(uint8_t); + uint8_t* _in_sealed_request_buffer = NULL; + uint8_t* _tmp_sealed_response_buffer = ms->ms_sealed_response_buffer; + size_t _tmp_sealed_response_capacity = ms->ms_sealed_response_capacity; + size_t _len_sealed_response_buffer = _tmp_sealed_response_capacity * sizeof(uint8_t); + uint8_t* _in_sealed_response_buffer = NULL; + size_t* _tmp_sealed_response_used = ms->ms_sealed_response_used; + size_t _len_sealed_response_used = sizeof(size_t); + size_t* _in_sealed_response_used = NULL; + + if (sizeof(*_tmp_sealed_request_buffer) != 0 && + (size_t)_tmp_sealed_request_size > (SIZE_MAX / sizeof(*_tmp_sealed_request_buffer))) { + return SGX_ERROR_INVALID_PARAMETER; + } + + if (sizeof(*_tmp_sealed_response_buffer) != 0 && + (size_t)_tmp_sealed_response_capacity > (SIZE_MAX / sizeof(*_tmp_sealed_response_buffer))) { + return SGX_ERROR_INVALID_PARAMETER; + } + + CHECK_UNIQUE_POINTER(_tmp_sealed_request_buffer, _len_sealed_request_buffer); + CHECK_UNIQUE_POINTER(_tmp_sealed_response_buffer, _len_sealed_response_buffer); + CHECK_UNIQUE_POINTER(_tmp_sealed_response_used, _len_sealed_response_used); + + // + // fence after pointer checks + // + sgx_lfence(); + + if (_tmp_sealed_request_buffer != NULL && _len_sealed_request_buffer != 0) { + if ( _len_sealed_request_buffer % sizeof(*_tmp_sealed_request_buffer) != 0) + { + status = SGX_ERROR_INVALID_PARAMETER; + goto err; + } + _in_sealed_request_buffer = (uint8_t*)malloc(_len_sealed_request_buffer); + if (_in_sealed_request_buffer == NULL) { + status = SGX_ERROR_OUT_OF_MEMORY; + goto err; + } + + if (memcpy_s(_in_sealed_request_buffer, _len_sealed_request_buffer, _tmp_sealed_request_buffer, _len_sealed_request_buffer)) { + status = SGX_ERROR_UNEXPECTED; + goto err; + } + + } + if (_tmp_sealed_response_buffer != NULL && _len_sealed_response_buffer != 0) { + if ( _len_sealed_response_buffer % sizeof(*_tmp_sealed_response_buffer) != 0) + { + status = SGX_ERROR_INVALID_PARAMETER; + goto err; + } + if ((_in_sealed_response_buffer = (uint8_t*)malloc(_len_sealed_response_buffer)) == NULL) { + status = SGX_ERROR_OUT_OF_MEMORY; + goto err; + } + + memset((void*)_in_sealed_response_buffer, 0, _len_sealed_response_buffer); + } + if (_tmp_sealed_response_used != NULL && _len_sealed_response_used != 0) { + if ( _len_sealed_response_used % sizeof(*_tmp_sealed_response_used) != 0) + { + status = SGX_ERROR_INVALID_PARAMETER; + goto err; + } + if ((_in_sealed_response_used = (size_t*)malloc(_len_sealed_response_used)) == NULL) { + status = SGX_ERROR_OUT_OF_MEMORY; + goto err; + } + + memset((void*)_in_sealed_response_used, 0, _len_sealed_response_used); + } + + ms->ms_retval = wallet_operation((const uint8_t*)_in_sealed_request_buffer, _tmp_sealed_request_size, _in_sealed_response_buffer, _tmp_sealed_response_capacity, _in_sealed_response_used); + if (_in_sealed_response_buffer) { + if (memcpy_s(_tmp_sealed_response_buffer, _len_sealed_response_buffer, _in_sealed_response_buffer, _len_sealed_response_buffer)) { + status = SGX_ERROR_UNEXPECTED; + goto err; + } + } + if (_in_sealed_response_used) { + if (memcpy_s(_tmp_sealed_response_used, _len_sealed_response_used, _in_sealed_response_used, _len_sealed_response_used)) { + status = SGX_ERROR_UNEXPECTED; + goto err; + } + } + +err: + if (_in_sealed_request_buffer) free(_in_sealed_request_buffer); + if (_in_sealed_response_buffer) free(_in_sealed_response_buffer); + if (_in_sealed_response_used) free(_in_sealed_response_used); + return status; +} + +static sgx_status_t SGX_CDECL sgx_t_global_init_ecall(void* pms) +{ + CHECK_REF_POINTER(pms, sizeof(ms_t_global_init_ecall_t)); + // + // fence after pointer checks + // + sgx_lfence(); + ms_t_global_init_ecall_t* ms = SGX_CAST(ms_t_global_init_ecall_t*, pms); + sgx_status_t status = SGX_SUCCESS; + const uint8_t* _tmp_path = ms->ms_path; + size_t _tmp_len = ms->ms_len; + size_t _len_path = _tmp_len; + uint8_t* _in_path = NULL; + + CHECK_UNIQUE_POINTER(_tmp_path, _len_path); + + // + // fence after pointer checks + // + sgx_lfence(); + + if (_tmp_path != NULL && _len_path != 0) { + if ( _len_path % sizeof(*_tmp_path) != 0) + { + status = SGX_ERROR_INVALID_PARAMETER; + goto err; + } + _in_path = (uint8_t*)malloc(_len_path); + if (_in_path == NULL) { + status = SGX_ERROR_OUT_OF_MEMORY; + goto err; + } + + if (memcpy_s(_in_path, _len_path, _tmp_path, _len_path)) { + status = SGX_ERROR_UNEXPECTED; + goto err; + } + + } + + t_global_init_ecall(ms->ms_id, (const uint8_t*)_in_path, _tmp_len); + +err: + if (_in_path) free(_in_path); + return status; +} + +static sgx_status_t SGX_CDECL sgx_t_global_exit_ecall(void* pms) +{ + sgx_status_t status = SGX_SUCCESS; + if (pms != NULL) return SGX_ERROR_INVALID_PARAMETER; + t_global_exit_ecall(); + return status; +} + +SGX_EXTERNC const struct { + size_t nr_ecall; + struct {void* ecall_addr; uint8_t is_priv; uint8_t is_switchless;} ecall_table[4]; +} g_ecall_table = { + 4, + { + {(void*)(uintptr_t)sgx_enclave_create_report, 0, 0}, + {(void*)(uintptr_t)sgx_wallet_operation, 0, 0}, + {(void*)(uintptr_t)sgx_t_global_init_ecall, 0, 0}, + {(void*)(uintptr_t)sgx_t_global_exit_ecall, 0, 0}, + } +}; + +SGX_EXTERNC const struct { + size_t nr_ocall; + uint8_t entry_table[79][4]; +} g_dyn_entry_table = { + 79, + { + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + {0, 0, 0, 0, }, + } +}; + + +sgx_status_t SGX_CDECL sgx_oc_cpuidex(int cpuinfo[4], int leaf, int subleaf) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_cpuinfo = 4 * sizeof(int); + + ms_sgx_oc_cpuidex_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_sgx_oc_cpuidex_t); + void *__tmp = NULL; + + void *__tmp_cpuinfo = NULL; + + CHECK_ENCLAVE_POINTER(cpuinfo, _len_cpuinfo); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (cpuinfo != NULL) ? _len_cpuinfo : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_sgx_oc_cpuidex_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_sgx_oc_cpuidex_t)); + ocalloc_size -= sizeof(ms_sgx_oc_cpuidex_t); + + if (cpuinfo != NULL) { + ms->ms_cpuinfo = (int*)__tmp; + __tmp_cpuinfo = __tmp; + if (_len_cpuinfo % sizeof(*cpuinfo) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_cpuinfo, 0, _len_cpuinfo); + __tmp = (void *)((size_t)__tmp + _len_cpuinfo); + ocalloc_size -= _len_cpuinfo; + } else { + ms->ms_cpuinfo = NULL; + } + + ms->ms_leaf = leaf; + ms->ms_subleaf = subleaf; + status = sgx_ocall(0, ms); + + if (status == SGX_SUCCESS) { + if (cpuinfo) { + if (memcpy_s((void*)cpuinfo, _len_cpuinfo, __tmp_cpuinfo, _len_cpuinfo)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL sgx_thread_wait_untrusted_event_ocall(int* retval, const void* self) +{ + sgx_status_t status = SGX_SUCCESS; + + ms_sgx_thread_wait_untrusted_event_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_sgx_thread_wait_untrusted_event_ocall_t); + void *__tmp = NULL; + + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_sgx_thread_wait_untrusted_event_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_sgx_thread_wait_untrusted_event_ocall_t)); + ocalloc_size -= sizeof(ms_sgx_thread_wait_untrusted_event_ocall_t); + + ms->ms_self = self; + status = sgx_ocall(1, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL sgx_thread_set_untrusted_event_ocall(int* retval, const void* waiter) +{ + sgx_status_t status = SGX_SUCCESS; + + ms_sgx_thread_set_untrusted_event_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_sgx_thread_set_untrusted_event_ocall_t); + void *__tmp = NULL; + + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_sgx_thread_set_untrusted_event_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_sgx_thread_set_untrusted_event_ocall_t)); + ocalloc_size -= sizeof(ms_sgx_thread_set_untrusted_event_ocall_t); + + ms->ms_waiter = waiter; + status = sgx_ocall(2, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL sgx_thread_setwait_untrusted_events_ocall(int* retval, const void* waiter, const void* self) +{ + sgx_status_t status = SGX_SUCCESS; + + ms_sgx_thread_setwait_untrusted_events_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_sgx_thread_setwait_untrusted_events_ocall_t); + void *__tmp = NULL; + + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_sgx_thread_setwait_untrusted_events_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_sgx_thread_setwait_untrusted_events_ocall_t)); + ocalloc_size -= sizeof(ms_sgx_thread_setwait_untrusted_events_ocall_t); + + ms->ms_waiter = waiter; + ms->ms_self = self; + status = sgx_ocall(3, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL sgx_thread_set_multiple_untrusted_events_ocall(int* retval, const void** waiters, size_t total) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_waiters = total * sizeof(void*); + + ms_sgx_thread_set_multiple_untrusted_events_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_sgx_thread_set_multiple_untrusted_events_ocall_t); + void *__tmp = NULL; + + + CHECK_ENCLAVE_POINTER(waiters, _len_waiters); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (waiters != NULL) ? _len_waiters : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_sgx_thread_set_multiple_untrusted_events_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_sgx_thread_set_multiple_untrusted_events_ocall_t)); + ocalloc_size -= sizeof(ms_sgx_thread_set_multiple_untrusted_events_ocall_t); + + if (waiters != NULL) { + ms->ms_waiters = (const void**)__tmp; + if (_len_waiters % sizeof(*waiters) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, waiters, _len_waiters)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_waiters); + ocalloc_size -= _len_waiters; + } else { + ms->ms_waiters = NULL; + } + + ms->ms_total = total; + status = sgx_ocall(4, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_thread_set_event_ocall(int* retval, int* error, const void* tcs) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_thread_set_event_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_thread_set_event_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_thread_set_event_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_thread_set_event_ocall_t)); + ocalloc_size -= sizeof(ms_u_thread_set_event_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_tcs = tcs; + status = sgx_ocall(5, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_thread_wait_event_ocall(int* retval, int* error, const void* tcs, const struct timespec* timeout) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_timeout = sizeof(struct timespec); + + ms_u_thread_wait_event_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_thread_wait_event_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(timeout, _len_timeout); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (timeout != NULL) ? _len_timeout : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_thread_wait_event_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_thread_wait_event_ocall_t)); + ocalloc_size -= sizeof(ms_u_thread_wait_event_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_tcs = tcs; + if (timeout != NULL) { + ms->ms_timeout = (const struct timespec*)__tmp; + if (memcpy_s(__tmp, ocalloc_size, timeout, _len_timeout)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_timeout); + ocalloc_size -= _len_timeout; + } else { + ms->ms_timeout = NULL; + } + + status = sgx_ocall(6, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_thread_set_multiple_events_ocall(int* retval, int* error, const void** tcss, int total) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_tcss = total * sizeof(void*); + + ms_u_thread_set_multiple_events_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_thread_set_multiple_events_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(tcss, _len_tcss); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (tcss != NULL) ? _len_tcss : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_thread_set_multiple_events_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_thread_set_multiple_events_ocall_t)); + ocalloc_size -= sizeof(ms_u_thread_set_multiple_events_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (tcss != NULL) { + ms->ms_tcss = (const void**)__tmp; + if (_len_tcss % sizeof(*tcss) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, tcss, _len_tcss)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_tcss); + ocalloc_size -= _len_tcss; + } else { + ms->ms_tcss = NULL; + } + + ms->ms_total = total; + status = sgx_ocall(7, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_thread_setwait_events_ocall(int* retval, int* error, const void* waiter_tcs, const void* self_tcs, const struct timespec* timeout) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_timeout = sizeof(struct timespec); + + ms_u_thread_setwait_events_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_thread_setwait_events_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(timeout, _len_timeout); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (timeout != NULL) ? _len_timeout : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_thread_setwait_events_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_thread_setwait_events_ocall_t)); + ocalloc_size -= sizeof(ms_u_thread_setwait_events_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_waiter_tcs = waiter_tcs; + ms->ms_self_tcs = self_tcs; + if (timeout != NULL) { + ms->ms_timeout = (const struct timespec*)__tmp; + if (memcpy_s(__tmp, ocalloc_size, timeout, _len_timeout)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_timeout); + ocalloc_size -= _len_timeout; + } else { + ms->ms_timeout = NULL; + } + + status = sgx_ocall(8, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_clock_gettime_ocall(int* retval, int* error, int clk_id, struct timespec* tp) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_tp = sizeof(struct timespec); + + ms_u_clock_gettime_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_clock_gettime_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_tp = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(tp, _len_tp); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (tp != NULL) ? _len_tp : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_clock_gettime_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_clock_gettime_ocall_t)); + ocalloc_size -= sizeof(ms_u_clock_gettime_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_clk_id = clk_id; + if (tp != NULL) { + ms->ms_tp = (struct timespec*)__tmp; + __tmp_tp = __tmp; + memset(__tmp_tp, 0, _len_tp); + __tmp = (void *)((size_t)__tmp + _len_tp); + ocalloc_size -= _len_tp; + } else { + ms->ms_tp = NULL; + } + + status = sgx_ocall(9, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (tp) { + if (memcpy_s((void*)tp, _len_tp, __tmp_tp, _len_tp)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_read_ocall(size_t* retval, int* error, int fd, void* buf, size_t count) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_read_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_read_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_read_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_read_ocall_t)); + ocalloc_size -= sizeof(ms_u_read_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_buf = buf; + ms->ms_count = count; + status = sgx_ocall(10, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_pread64_ocall(size_t* retval, int* error, int fd, void* buf, size_t count, int64_t offset) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_pread64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_pread64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_pread64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_pread64_ocall_t)); + ocalloc_size -= sizeof(ms_u_pread64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_buf = buf; + ms->ms_count = count; + ms->ms_offset = offset; + status = sgx_ocall(11, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_readv_ocall(size_t* retval, int* error, int fd, const struct iovec* iov, int iovcnt) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_iov = iovcnt * sizeof(struct iovec); + + ms_u_readv_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_readv_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(iov, _len_iov); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (iov != NULL) ? _len_iov : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_readv_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_readv_ocall_t)); + ocalloc_size -= sizeof(ms_u_readv_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + if (iov != NULL) { + ms->ms_iov = (const struct iovec*)__tmp; + if (memcpy_s(__tmp, ocalloc_size, iov, _len_iov)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_iov); + ocalloc_size -= _len_iov; + } else { + ms->ms_iov = NULL; + } + + ms->ms_iovcnt = iovcnt; + status = sgx_ocall(12, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_preadv64_ocall(size_t* retval, int* error, int fd, const struct iovec* iov, int iovcnt, int64_t offset) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_iov = iovcnt * sizeof(struct iovec); + + ms_u_preadv64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_preadv64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(iov, _len_iov); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (iov != NULL) ? _len_iov : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_preadv64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_preadv64_ocall_t)); + ocalloc_size -= sizeof(ms_u_preadv64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + if (iov != NULL) { + ms->ms_iov = (const struct iovec*)__tmp; + if (memcpy_s(__tmp, ocalloc_size, iov, _len_iov)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_iov); + ocalloc_size -= _len_iov; + } else { + ms->ms_iov = NULL; + } + + ms->ms_iovcnt = iovcnt; + ms->ms_offset = offset; + status = sgx_ocall(13, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_write_ocall(size_t* retval, int* error, int fd, const void* buf, size_t count) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_write_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_write_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_write_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_write_ocall_t)); + ocalloc_size -= sizeof(ms_u_write_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_buf = buf; + ms->ms_count = count; + status = sgx_ocall(14, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_pwrite64_ocall(size_t* retval, int* error, int fd, const void* buf, size_t count, int64_t offset) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_pwrite64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_pwrite64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_pwrite64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_pwrite64_ocall_t)); + ocalloc_size -= sizeof(ms_u_pwrite64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_buf = buf; + ms->ms_count = count; + ms->ms_offset = offset; + status = sgx_ocall(15, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_writev_ocall(size_t* retval, int* error, int fd, const struct iovec* iov, int iovcnt) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_iov = iovcnt * sizeof(struct iovec); + + ms_u_writev_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_writev_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(iov, _len_iov); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (iov != NULL) ? _len_iov : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_writev_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_writev_ocall_t)); + ocalloc_size -= sizeof(ms_u_writev_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + if (iov != NULL) { + ms->ms_iov = (const struct iovec*)__tmp; + if (memcpy_s(__tmp, ocalloc_size, iov, _len_iov)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_iov); + ocalloc_size -= _len_iov; + } else { + ms->ms_iov = NULL; + } + + ms->ms_iovcnt = iovcnt; + status = sgx_ocall(16, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_pwritev64_ocall(size_t* retval, int* error, int fd, const struct iovec* iov, int iovcnt, int64_t offset) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_iov = iovcnt * sizeof(struct iovec); + + ms_u_pwritev64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_pwritev64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(iov, _len_iov); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (iov != NULL) ? _len_iov : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_pwritev64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_pwritev64_ocall_t)); + ocalloc_size -= sizeof(ms_u_pwritev64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + if (iov != NULL) { + ms->ms_iov = (const struct iovec*)__tmp; + if (memcpy_s(__tmp, ocalloc_size, iov, _len_iov)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_iov); + ocalloc_size -= _len_iov; + } else { + ms->ms_iov = NULL; + } + + ms->ms_iovcnt = iovcnt; + ms->ms_offset = offset; + status = sgx_ocall(17, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_fcntl_arg0_ocall(int* retval, int* error, int fd, int cmd) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_fcntl_arg0_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_fcntl_arg0_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_fcntl_arg0_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_fcntl_arg0_ocall_t)); + ocalloc_size -= sizeof(ms_u_fcntl_arg0_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_cmd = cmd; + status = sgx_ocall(18, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_fcntl_arg1_ocall(int* retval, int* error, int fd, int cmd, int arg) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_fcntl_arg1_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_fcntl_arg1_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_fcntl_arg1_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_fcntl_arg1_ocall_t)); + ocalloc_size -= sizeof(ms_u_fcntl_arg1_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_cmd = cmd; + ms->ms_arg = arg; + status = sgx_ocall(19, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_ioctl_arg0_ocall(int* retval, int* error, int fd, int request) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_ioctl_arg0_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_ioctl_arg0_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_ioctl_arg0_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_ioctl_arg0_ocall_t)); + ocalloc_size -= sizeof(ms_u_ioctl_arg0_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_request = request; + status = sgx_ocall(20, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_ioctl_arg1_ocall(int* retval, int* error, int fd, int request, int* arg) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_arg = sizeof(int); + + ms_u_ioctl_arg1_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_ioctl_arg1_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_arg = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(arg, _len_arg); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (arg != NULL) ? _len_arg : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_ioctl_arg1_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_ioctl_arg1_ocall_t)); + ocalloc_size -= sizeof(ms_u_ioctl_arg1_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_request = request; + if (arg != NULL) { + ms->ms_arg = (int*)__tmp; + __tmp_arg = __tmp; + if (_len_arg % sizeof(*arg) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, arg, _len_arg)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_arg); + ocalloc_size -= _len_arg; + } else { + ms->ms_arg = NULL; + } + + status = sgx_ocall(21, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (arg) { + if (memcpy_s((void*)arg, _len_arg, __tmp_arg, _len_arg)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_close_ocall(int* retval, int* error, int fd) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_close_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_close_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_close_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_close_ocall_t)); + ocalloc_size -= sizeof(ms_u_close_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + status = sgx_ocall(22, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_malloc_ocall(void** retval, int* error, size_t size) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_malloc_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_malloc_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_malloc_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_malloc_ocall_t)); + ocalloc_size -= sizeof(ms_u_malloc_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_size = size; + status = sgx_ocall(23, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_free_ocall(void* p) +{ + sgx_status_t status = SGX_SUCCESS; + + ms_u_free_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_free_ocall_t); + void *__tmp = NULL; + + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_free_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_free_ocall_t)); + ocalloc_size -= sizeof(ms_u_free_ocall_t); + + ms->ms_p = p; + status = sgx_ocall(24, ms); + + if (status == SGX_SUCCESS) { + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_mmap_ocall(void** retval, int* error, void* start, size_t length, int prot, int flags, int fd, int64_t offset) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_mmap_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_mmap_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_mmap_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_mmap_ocall_t)); + ocalloc_size -= sizeof(ms_u_mmap_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_start = start; + ms->ms_length = length; + ms->ms_prot = prot; + ms->ms_flags = flags; + ms->ms_fd = fd; + ms->ms_offset = offset; + status = sgx_ocall(25, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_munmap_ocall(int* retval, int* error, void* start, size_t length) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_munmap_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_munmap_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_munmap_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_munmap_ocall_t)); + ocalloc_size -= sizeof(ms_u_munmap_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_start = start; + ms->ms_length = length; + status = sgx_ocall(26, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_msync_ocall(int* retval, int* error, void* addr, size_t length, int flags) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_msync_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_msync_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_msync_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_msync_ocall_t)); + ocalloc_size -= sizeof(ms_u_msync_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_addr = addr; + ms->ms_length = length; + ms->ms_flags = flags; + status = sgx_ocall(27, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_mprotect_ocall(int* retval, int* error, void* addr, size_t length, int prot) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_mprotect_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_mprotect_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_mprotect_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_mprotect_ocall_t)); + ocalloc_size -= sizeof(ms_u_mprotect_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_addr = addr; + ms->ms_length = length; + ms->ms_prot = prot; + status = sgx_ocall(28, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_open_ocall(int* retval, int* error, const char* pathname, int flags) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_pathname = pathname ? strlen(pathname) + 1 : 0; + + ms_u_open_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_open_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(pathname, _len_pathname); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (pathname != NULL) ? _len_pathname : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_open_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_open_ocall_t)); + ocalloc_size -= sizeof(ms_u_open_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (pathname != NULL) { + ms->ms_pathname = (const char*)__tmp; + if (_len_pathname % sizeof(*pathname) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, pathname, _len_pathname)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_pathname); + ocalloc_size -= _len_pathname; + } else { + ms->ms_pathname = NULL; + } + + ms->ms_flags = flags; + status = sgx_ocall(29, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_open64_ocall(int* retval, int* error, const char* path, int oflag, int mode) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + + ms_u_open64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_open64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_open64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_open64_ocall_t)); + ocalloc_size -= sizeof(ms_u_open64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + ms->ms_oflag = oflag; + ms->ms_mode = mode; + status = sgx_ocall(30, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_fstat_ocall(int* retval, int* error, int fd, struct stat_t* buf) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_buf = sizeof(struct stat_t); + + ms_u_fstat_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_fstat_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_fstat_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_fstat_ocall_t)); + ocalloc_size -= sizeof(ms_u_fstat_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + if (buf != NULL) { + ms->ms_buf = (struct stat_t*)__tmp; + __tmp_buf = __tmp; + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + status = sgx_ocall(31, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_fstat64_ocall(int* retval, int* error, int fd, struct stat64_t* buf) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_buf = sizeof(struct stat64_t); + + ms_u_fstat64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_fstat64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_fstat64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_fstat64_ocall_t)); + ocalloc_size -= sizeof(ms_u_fstat64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + if (buf != NULL) { + ms->ms_buf = (struct stat64_t*)__tmp; + __tmp_buf = __tmp; + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + status = sgx_ocall(32, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_stat_ocall(int* retval, int* error, const char* path, struct stat_t* buf) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + size_t _len_buf = sizeof(struct stat_t); + + ms_u_stat_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_stat_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_stat_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_stat_ocall_t)); + ocalloc_size -= sizeof(ms_u_stat_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + if (buf != NULL) { + ms->ms_buf = (struct stat_t*)__tmp; + __tmp_buf = __tmp; + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + status = sgx_ocall(33, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_stat64_ocall(int* retval, int* error, const char* path, struct stat64_t* buf) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + size_t _len_buf = sizeof(struct stat64_t); + + ms_u_stat64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_stat64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_stat64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_stat64_ocall_t)); + ocalloc_size -= sizeof(ms_u_stat64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + if (buf != NULL) { + ms->ms_buf = (struct stat64_t*)__tmp; + __tmp_buf = __tmp; + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + status = sgx_ocall(34, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_lstat_ocall(int* retval, int* error, const char* path, struct stat_t* buf) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + size_t _len_buf = sizeof(struct stat_t); + + ms_u_lstat_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_lstat_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_lstat_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_lstat_ocall_t)); + ocalloc_size -= sizeof(ms_u_lstat_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + if (buf != NULL) { + ms->ms_buf = (struct stat_t*)__tmp; + __tmp_buf = __tmp; + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + status = sgx_ocall(35, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_lstat64_ocall(int* retval, int* error, const char* path, struct stat64_t* buf) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + size_t _len_buf = sizeof(struct stat64_t); + + ms_u_lstat64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_lstat64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_lstat64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_lstat64_ocall_t)); + ocalloc_size -= sizeof(ms_u_lstat64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + if (buf != NULL) { + ms->ms_buf = (struct stat64_t*)__tmp; + __tmp_buf = __tmp; + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + status = sgx_ocall(36, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_lseek_ocall(uint64_t* retval, int* error, int fd, int64_t offset, int whence) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_lseek_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_lseek_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_lseek_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_lseek_ocall_t)); + ocalloc_size -= sizeof(ms_u_lseek_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_offset = offset; + ms->ms_whence = whence; + status = sgx_ocall(37, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_lseek64_ocall(int64_t* retval, int* error, int fd, int64_t offset, int whence) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_lseek64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_lseek64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_lseek64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_lseek64_ocall_t)); + ocalloc_size -= sizeof(ms_u_lseek64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_offset = offset; + ms->ms_whence = whence; + status = sgx_ocall(38, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_ftruncate_ocall(int* retval, int* error, int fd, int64_t length) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_ftruncate_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_ftruncate_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_ftruncate_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_ftruncate_ocall_t)); + ocalloc_size -= sizeof(ms_u_ftruncate_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_length = length; + status = sgx_ocall(39, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_ftruncate64_ocall(int* retval, int* error, int fd, int64_t length) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_ftruncate64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_ftruncate64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_ftruncate64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_ftruncate64_ocall_t)); + ocalloc_size -= sizeof(ms_u_ftruncate64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_length = length; + status = sgx_ocall(40, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_truncate_ocall(int* retval, int* error, const char* path, int64_t length) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + + ms_u_truncate_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_truncate_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_truncate_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_truncate_ocall_t)); + ocalloc_size -= sizeof(ms_u_truncate_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + ms->ms_length = length; + status = sgx_ocall(41, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_truncate64_ocall(int* retval, int* error, const char* path, int64_t length) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + + ms_u_truncate64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_truncate64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_truncate64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_truncate64_ocall_t)); + ocalloc_size -= sizeof(ms_u_truncate64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + ms->ms_length = length; + status = sgx_ocall(42, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_fsync_ocall(int* retval, int* error, int fd) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_fsync_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_fsync_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_fsync_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_fsync_ocall_t)); + ocalloc_size -= sizeof(ms_u_fsync_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + status = sgx_ocall(43, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_fdatasync_ocall(int* retval, int* error, int fd) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_fdatasync_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_fdatasync_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_fdatasync_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_fdatasync_ocall_t)); + ocalloc_size -= sizeof(ms_u_fdatasync_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + status = sgx_ocall(44, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_fchmod_ocall(int* retval, int* error, int fd, uint32_t mode) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_fchmod_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_fchmod_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_fchmod_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_fchmod_ocall_t)); + ocalloc_size -= sizeof(ms_u_fchmod_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_fd = fd; + ms->ms_mode = mode; + status = sgx_ocall(45, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_unlink_ocall(int* retval, int* error, const char* pathname) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_pathname = pathname ? strlen(pathname) + 1 : 0; + + ms_u_unlink_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_unlink_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(pathname, _len_pathname); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (pathname != NULL) ? _len_pathname : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_unlink_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_unlink_ocall_t)); + ocalloc_size -= sizeof(ms_u_unlink_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (pathname != NULL) { + ms->ms_pathname = (const char*)__tmp; + if (_len_pathname % sizeof(*pathname) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, pathname, _len_pathname)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_pathname); + ocalloc_size -= _len_pathname; + } else { + ms->ms_pathname = NULL; + } + + status = sgx_ocall(46, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_link_ocall(int* retval, int* error, const char* oldpath, const char* newpath) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_oldpath = oldpath ? strlen(oldpath) + 1 : 0; + size_t _len_newpath = newpath ? strlen(newpath) + 1 : 0; + + ms_u_link_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_link_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(oldpath, _len_oldpath); + CHECK_ENCLAVE_POINTER(newpath, _len_newpath); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (oldpath != NULL) ? _len_oldpath : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (newpath != NULL) ? _len_newpath : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_link_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_link_ocall_t)); + ocalloc_size -= sizeof(ms_u_link_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (oldpath != NULL) { + ms->ms_oldpath = (const char*)__tmp; + if (_len_oldpath % sizeof(*oldpath) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, oldpath, _len_oldpath)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_oldpath); + ocalloc_size -= _len_oldpath; + } else { + ms->ms_oldpath = NULL; + } + + if (newpath != NULL) { + ms->ms_newpath = (const char*)__tmp; + if (_len_newpath % sizeof(*newpath) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, newpath, _len_newpath)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_newpath); + ocalloc_size -= _len_newpath; + } else { + ms->ms_newpath = NULL; + } + + status = sgx_ocall(47, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_linkat_ocall(int* retval, int* error, int olddirfd, const char* oldpath, int newdirfd, const char* newpath, int flags) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_oldpath = oldpath ? strlen(oldpath) + 1 : 0; + size_t _len_newpath = newpath ? strlen(newpath) + 1 : 0; + + ms_u_linkat_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_linkat_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(oldpath, _len_oldpath); + CHECK_ENCLAVE_POINTER(newpath, _len_newpath); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (oldpath != NULL) ? _len_oldpath : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (newpath != NULL) ? _len_newpath : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_linkat_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_linkat_ocall_t)); + ocalloc_size -= sizeof(ms_u_linkat_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_olddirfd = olddirfd; + if (oldpath != NULL) { + ms->ms_oldpath = (const char*)__tmp; + if (_len_oldpath % sizeof(*oldpath) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, oldpath, _len_oldpath)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_oldpath); + ocalloc_size -= _len_oldpath; + } else { + ms->ms_oldpath = NULL; + } + + ms->ms_newdirfd = newdirfd; + if (newpath != NULL) { + ms->ms_newpath = (const char*)__tmp; + if (_len_newpath % sizeof(*newpath) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, newpath, _len_newpath)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_newpath); + ocalloc_size -= _len_newpath; + } else { + ms->ms_newpath = NULL; + } + + ms->ms_flags = flags; + status = sgx_ocall(48, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_rename_ocall(int* retval, int* error, const char* oldpath, const char* newpath) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_oldpath = oldpath ? strlen(oldpath) + 1 : 0; + size_t _len_newpath = newpath ? strlen(newpath) + 1 : 0; + + ms_u_rename_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_rename_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(oldpath, _len_oldpath); + CHECK_ENCLAVE_POINTER(newpath, _len_newpath); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (oldpath != NULL) ? _len_oldpath : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (newpath != NULL) ? _len_newpath : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_rename_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_rename_ocall_t)); + ocalloc_size -= sizeof(ms_u_rename_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (oldpath != NULL) { + ms->ms_oldpath = (const char*)__tmp; + if (_len_oldpath % sizeof(*oldpath) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, oldpath, _len_oldpath)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_oldpath); + ocalloc_size -= _len_oldpath; + } else { + ms->ms_oldpath = NULL; + } + + if (newpath != NULL) { + ms->ms_newpath = (const char*)__tmp; + if (_len_newpath % sizeof(*newpath) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, newpath, _len_newpath)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_newpath); + ocalloc_size -= _len_newpath; + } else { + ms->ms_newpath = NULL; + } + + status = sgx_ocall(49, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_chmod_ocall(int* retval, int* error, const char* path, uint32_t mode) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + + ms_u_chmod_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_chmod_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_chmod_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_chmod_ocall_t)); + ocalloc_size -= sizeof(ms_u_chmod_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + ms->ms_mode = mode; + status = sgx_ocall(50, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_readlink_ocall(size_t* retval, int* error, const char* path, char* buf, size_t bufsz) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path = path ? strlen(path) + 1 : 0; + size_t _len_buf = bufsz; + + ms_u_readlink_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_readlink_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path, _len_path); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path != NULL) ? _len_path : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_readlink_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_readlink_ocall_t)); + ocalloc_size -= sizeof(ms_u_readlink_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path != NULL) { + ms->ms_path = (const char*)__tmp; + if (_len_path % sizeof(*path) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path, _len_path)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path); + ocalloc_size -= _len_path; + } else { + ms->ms_path = NULL; + } + + if (buf != NULL) { + ms->ms_buf = (char*)__tmp; + __tmp_buf = __tmp; + if (_len_buf % sizeof(*buf) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + ms->ms_bufsz = bufsz; + status = sgx_ocall(51, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_symlink_ocall(int* retval, int* error, const char* path1, const char* path2) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_path1 = path1 ? strlen(path1) + 1 : 0; + size_t _len_path2 = path2 ? strlen(path2) + 1 : 0; + + ms_u_symlink_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_symlink_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(path1, _len_path1); + CHECK_ENCLAVE_POINTER(path2, _len_path2); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path1 != NULL) ? _len_path1 : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (path2 != NULL) ? _len_path2 : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_symlink_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_symlink_ocall_t)); + ocalloc_size -= sizeof(ms_u_symlink_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (path1 != NULL) { + ms->ms_path1 = (const char*)__tmp; + if (_len_path1 % sizeof(*path1) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path1, _len_path1)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path1); + ocalloc_size -= _len_path1; + } else { + ms->ms_path1 = NULL; + } + + if (path2 != NULL) { + ms->ms_path2 = (const char*)__tmp; + if (_len_path2 % sizeof(*path2) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, path2, _len_path2)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_path2); + ocalloc_size -= _len_path2; + } else { + ms->ms_path2 = NULL; + } + + status = sgx_ocall(52, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_realpath_ocall(char** retval, int* error, const char* pathname) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_pathname = pathname ? strlen(pathname) + 1 : 0; + + ms_u_realpath_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_realpath_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(pathname, _len_pathname); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (pathname != NULL) ? _len_pathname : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_realpath_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_realpath_ocall_t)); + ocalloc_size -= sizeof(ms_u_realpath_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (pathname != NULL) { + ms->ms_pathname = (const char*)__tmp; + if (_len_pathname % sizeof(*pathname) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, pathname, _len_pathname)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_pathname); + ocalloc_size -= _len_pathname; + } else { + ms->ms_pathname = NULL; + } + + status = sgx_ocall(53, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_mkdir_ocall(int* retval, int* error, const char* pathname, uint32_t mode) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_pathname = pathname ? strlen(pathname) + 1 : 0; + + ms_u_mkdir_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_mkdir_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(pathname, _len_pathname); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (pathname != NULL) ? _len_pathname : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_mkdir_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_mkdir_ocall_t)); + ocalloc_size -= sizeof(ms_u_mkdir_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (pathname != NULL) { + ms->ms_pathname = (const char*)__tmp; + if (_len_pathname % sizeof(*pathname) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, pathname, _len_pathname)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_pathname); + ocalloc_size -= _len_pathname; + } else { + ms->ms_pathname = NULL; + } + + ms->ms_mode = mode; + status = sgx_ocall(54, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_rmdir_ocall(int* retval, int* error, const char* pathname) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_pathname = pathname ? strlen(pathname) + 1 : 0; + + ms_u_rmdir_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_rmdir_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(pathname, _len_pathname); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (pathname != NULL) ? _len_pathname : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_rmdir_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_rmdir_ocall_t)); + ocalloc_size -= sizeof(ms_u_rmdir_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (pathname != NULL) { + ms->ms_pathname = (const char*)__tmp; + if (_len_pathname % sizeof(*pathname) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, pathname, _len_pathname)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_pathname); + ocalloc_size -= _len_pathname; + } else { + ms->ms_pathname = NULL; + } + + status = sgx_ocall(55, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_opendir_ocall(void** retval, int* error, const char* pathname) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_pathname = pathname ? strlen(pathname) + 1 : 0; + + ms_u_opendir_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_opendir_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(pathname, _len_pathname); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (pathname != NULL) ? _len_pathname : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_opendir_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_opendir_ocall_t)); + ocalloc_size -= sizeof(ms_u_opendir_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (pathname != NULL) { + ms->ms_pathname = (const char*)__tmp; + if (_len_pathname % sizeof(*pathname) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, pathname, _len_pathname)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_pathname); + ocalloc_size -= _len_pathname; + } else { + ms->ms_pathname = NULL; + } + + status = sgx_ocall(56, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_readdir64_r_ocall(int* retval, void* dirp, struct dirent64_t* entry, struct dirent64_t** result) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_entry = sizeof(struct dirent64_t); + size_t _len_result = sizeof(struct dirent64_t*); + + ms_u_readdir64_r_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_readdir64_r_ocall_t); + void *__tmp = NULL; + + void *__tmp_entry = NULL; + void *__tmp_result = NULL; + + CHECK_ENCLAVE_POINTER(entry, _len_entry); + CHECK_ENCLAVE_POINTER(result, _len_result); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (entry != NULL) ? _len_entry : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (result != NULL) ? _len_result : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_readdir64_r_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_readdir64_r_ocall_t)); + ocalloc_size -= sizeof(ms_u_readdir64_r_ocall_t); + + ms->ms_dirp = dirp; + if (entry != NULL) { + ms->ms_entry = (struct dirent64_t*)__tmp; + __tmp_entry = __tmp; + if (memcpy_s(__tmp, ocalloc_size, entry, _len_entry)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_entry); + ocalloc_size -= _len_entry; + } else { + ms->ms_entry = NULL; + } + + if (result != NULL) { + ms->ms_result = (struct dirent64_t**)__tmp; + __tmp_result = __tmp; + if (_len_result % sizeof(*result) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_result, 0, _len_result); + __tmp = (void *)((size_t)__tmp + _len_result); + ocalloc_size -= _len_result; + } else { + ms->ms_result = NULL; + } + + status = sgx_ocall(57, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (entry) { + if (memcpy_s((void*)entry, _len_entry, __tmp_entry, _len_entry)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (result) { + if (memcpy_s((void*)result, _len_result, __tmp_result, _len_result)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_closedir_ocall(int* retval, int* error, void* dirp) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_closedir_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_closedir_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_closedir_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_closedir_ocall_t)); + ocalloc_size -= sizeof(ms_u_closedir_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_dirp = dirp; + status = sgx_ocall(58, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_dirfd_ocall(int* retval, int* error, void* dirp) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + + ms_u_dirfd_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_dirfd_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_dirfd_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_dirfd_ocall_t)); + ocalloc_size -= sizeof(ms_u_dirfd_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_dirp = dirp; + status = sgx_ocall(59, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_fstatat64_ocall(int* retval, int* error, int dirfd, const char* pathname, struct stat64_t* buf, int flags) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_pathname = pathname ? strlen(pathname) + 1 : 0; + size_t _len_buf = sizeof(struct stat64_t); + + ms_u_fstatat64_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_fstatat64_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(pathname, _len_pathname); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (pathname != NULL) ? _len_pathname : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_fstatat64_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_fstatat64_ocall_t)); + ocalloc_size -= sizeof(ms_u_fstatat64_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + ms->ms_dirfd = dirfd; + if (pathname != NULL) { + ms->ms_pathname = (const char*)__tmp; + if (_len_pathname % sizeof(*pathname) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, pathname, _len_pathname)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_pathname); + ocalloc_size -= _len_pathname; + } else { + ms->ms_pathname = NULL; + } + + if (buf != NULL) { + ms->ms_buf = (struct stat64_t*)__tmp; + __tmp_buf = __tmp; + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + ms->ms_flags = flags; + status = sgx_ocall(60, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_environ_ocall(char*** retval) +{ + sgx_status_t status = SGX_SUCCESS; + + ms_u_environ_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_environ_ocall_t); + void *__tmp = NULL; + + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_environ_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_environ_ocall_t)); + ocalloc_size -= sizeof(ms_u_environ_ocall_t); + + status = sgx_ocall(61, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_getenv_ocall(char** retval, const char* name) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_name = name ? strlen(name) + 1 : 0; + + ms_u_getenv_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_getenv_ocall_t); + void *__tmp = NULL; + + + CHECK_ENCLAVE_POINTER(name, _len_name); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (name != NULL) ? _len_name : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_getenv_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_getenv_ocall_t)); + ocalloc_size -= sizeof(ms_u_getenv_ocall_t); + + if (name != NULL) { + ms->ms_name = (const char*)__tmp; + if (_len_name % sizeof(*name) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, name, _len_name)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_name); + ocalloc_size -= _len_name; + } else { + ms->ms_name = NULL; + } + + status = sgx_ocall(62, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_setenv_ocall(int* retval, int* error, const char* name, const char* value, int overwrite) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_name = name ? strlen(name) + 1 : 0; + size_t _len_value = value ? strlen(value) + 1 : 0; + + ms_u_setenv_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_setenv_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(name, _len_name); + CHECK_ENCLAVE_POINTER(value, _len_value); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (name != NULL) ? _len_name : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (value != NULL) ? _len_value : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_setenv_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_setenv_ocall_t)); + ocalloc_size -= sizeof(ms_u_setenv_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (name != NULL) { + ms->ms_name = (const char*)__tmp; + if (_len_name % sizeof(*name) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, name, _len_name)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_name); + ocalloc_size -= _len_name; + } else { + ms->ms_name = NULL; + } + + if (value != NULL) { + ms->ms_value = (const char*)__tmp; + if (_len_value % sizeof(*value) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, value, _len_value)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_value); + ocalloc_size -= _len_value; + } else { + ms->ms_value = NULL; + } + + ms->ms_overwrite = overwrite; + status = sgx_ocall(63, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_unsetenv_ocall(int* retval, int* error, const char* name) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_name = name ? strlen(name) + 1 : 0; + + ms_u_unsetenv_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_unsetenv_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(name, _len_name); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (name != NULL) ? _len_name : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_unsetenv_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_unsetenv_ocall_t)); + ocalloc_size -= sizeof(ms_u_unsetenv_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (name != NULL) { + ms->ms_name = (const char*)__tmp; + if (_len_name % sizeof(*name) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, name, _len_name)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_name); + ocalloc_size -= _len_name; + } else { + ms->ms_name = NULL; + } + + status = sgx_ocall(64, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_chdir_ocall(int* retval, int* error, const char* dir) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_dir = dir ? strlen(dir) + 1 : 0; + + ms_u_chdir_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_chdir_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(dir, _len_dir); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (dir != NULL) ? _len_dir : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_chdir_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_chdir_ocall_t)); + ocalloc_size -= sizeof(ms_u_chdir_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (dir != NULL) { + ms->ms_dir = (const char*)__tmp; + if (_len_dir % sizeof(*dir) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, dir, _len_dir)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_dir); + ocalloc_size -= _len_dir; + } else { + ms->ms_dir = NULL; + } + + status = sgx_ocall(65, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_getcwd_ocall(char** retval, int* error, char* buf, size_t buflen) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_error = sizeof(int); + size_t _len_buf = buflen; + + ms_u_getcwd_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_getcwd_ocall_t); + void *__tmp = NULL; + + void *__tmp_error = NULL; + void *__tmp_buf = NULL; + + CHECK_ENCLAVE_POINTER(error, _len_error); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error != NULL) ? _len_error : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_getcwd_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_getcwd_ocall_t)); + ocalloc_size -= sizeof(ms_u_getcwd_ocall_t); + + if (error != NULL) { + ms->ms_error = (int*)__tmp; + __tmp_error = __tmp; + if (_len_error % sizeof(*error) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error, 0, _len_error); + __tmp = (void *)((size_t)__tmp + _len_error); + ocalloc_size -= _len_error; + } else { + ms->ms_error = NULL; + } + + if (buf != NULL) { + ms->ms_buf = (char*)__tmp; + __tmp_buf = __tmp; + if (_len_buf % sizeof(*buf) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + ms->ms_buflen = buflen; + status = sgx_ocall(66, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (error) { + if (memcpy_s((void*)error, _len_error, __tmp_error, _len_error)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_getpwuid_r_ocall(int* retval, unsigned int uid, struct passwd* pwd, char* buf, size_t buflen, struct passwd** passwd_result) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_pwd = sizeof(struct passwd); + size_t _len_buf = buflen; + size_t _len_passwd_result = sizeof(struct passwd*); + + ms_u_getpwuid_r_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_getpwuid_r_ocall_t); + void *__tmp = NULL; + + void *__tmp_pwd = NULL; + void *__tmp_buf = NULL; + void *__tmp_passwd_result = NULL; + + CHECK_ENCLAVE_POINTER(pwd, _len_pwd); + CHECK_ENCLAVE_POINTER(buf, _len_buf); + CHECK_ENCLAVE_POINTER(passwd_result, _len_passwd_result); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (pwd != NULL) ? _len_pwd : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buf != NULL) ? _len_buf : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (passwd_result != NULL) ? _len_passwd_result : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_getpwuid_r_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_getpwuid_r_ocall_t)); + ocalloc_size -= sizeof(ms_u_getpwuid_r_ocall_t); + + ms->ms_uid = uid; + if (pwd != NULL) { + ms->ms_pwd = (struct passwd*)__tmp; + __tmp_pwd = __tmp; + memset(__tmp_pwd, 0, _len_pwd); + __tmp = (void *)((size_t)__tmp + _len_pwd); + ocalloc_size -= _len_pwd; + } else { + ms->ms_pwd = NULL; + } + + if (buf != NULL) { + ms->ms_buf = (char*)__tmp; + __tmp_buf = __tmp; + if (_len_buf % sizeof(*buf) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_buf, 0, _len_buf); + __tmp = (void *)((size_t)__tmp + _len_buf); + ocalloc_size -= _len_buf; + } else { + ms->ms_buf = NULL; + } + + ms->ms_buflen = buflen; + if (passwd_result != NULL) { + ms->ms_passwd_result = (struct passwd**)__tmp; + __tmp_passwd_result = __tmp; + if (_len_passwd_result % sizeof(*passwd_result) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_passwd_result, 0, _len_passwd_result); + __tmp = (void *)((size_t)__tmp + _len_passwd_result); + ocalloc_size -= _len_passwd_result; + } else { + ms->ms_passwd_result = NULL; + } + + status = sgx_ocall(67, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (pwd) { + if (memcpy_s((void*)pwd, _len_pwd, __tmp_pwd, _len_pwd)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (buf) { + if (memcpy_s((void*)buf, _len_buf, __tmp_buf, _len_buf)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (passwd_result) { + if (memcpy_s((void*)passwd_result, _len_passwd_result, __tmp_passwd_result, _len_passwd_result)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_getuid_ocall(unsigned int* retval) +{ + sgx_status_t status = SGX_SUCCESS; + + ms_u_getuid_ocall_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_getuid_ocall_t); + void *__tmp = NULL; + + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_getuid_ocall_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_getuid_ocall_t)); + ocalloc_size -= sizeof(ms_u_getuid_ocall_t); + + status = sgx_ocall(68, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_sgxprotectedfs_exclusive_file_open(void** retval, const char* filename, uint8_t read_only, int64_t* file_size, int32_t* error_code) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_filename = filename ? strlen(filename) + 1 : 0; + size_t _len_file_size = sizeof(int64_t); + size_t _len_error_code = sizeof(int32_t); + + ms_u_sgxprotectedfs_exclusive_file_open_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_sgxprotectedfs_exclusive_file_open_t); + void *__tmp = NULL; + + void *__tmp_file_size = NULL; + void *__tmp_error_code = NULL; + + CHECK_ENCLAVE_POINTER(filename, _len_filename); + CHECK_ENCLAVE_POINTER(file_size, _len_file_size); + CHECK_ENCLAVE_POINTER(error_code, _len_error_code); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (filename != NULL) ? _len_filename : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (file_size != NULL) ? _len_file_size : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (error_code != NULL) ? _len_error_code : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_sgxprotectedfs_exclusive_file_open_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_sgxprotectedfs_exclusive_file_open_t)); + ocalloc_size -= sizeof(ms_u_sgxprotectedfs_exclusive_file_open_t); + + if (filename != NULL) { + ms->ms_filename = (const char*)__tmp; + if (_len_filename % sizeof(*filename) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, filename, _len_filename)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_filename); + ocalloc_size -= _len_filename; + } else { + ms->ms_filename = NULL; + } + + ms->ms_read_only = read_only; + if (file_size != NULL) { + ms->ms_file_size = (int64_t*)__tmp; + __tmp_file_size = __tmp; + if (_len_file_size % sizeof(*file_size) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_file_size, 0, _len_file_size); + __tmp = (void *)((size_t)__tmp + _len_file_size); + ocalloc_size -= _len_file_size; + } else { + ms->ms_file_size = NULL; + } + + if (error_code != NULL) { + ms->ms_error_code = (int32_t*)__tmp; + __tmp_error_code = __tmp; + if (_len_error_code % sizeof(*error_code) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_error_code, 0, _len_error_code); + __tmp = (void *)((size_t)__tmp + _len_error_code); + ocalloc_size -= _len_error_code; + } else { + ms->ms_error_code = NULL; + } + + status = sgx_ocall(69, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (file_size) { + if (memcpy_s((void*)file_size, _len_file_size, __tmp_file_size, _len_file_size)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + if (error_code) { + if (memcpy_s((void*)error_code, _len_error_code, __tmp_error_code, _len_error_code)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_sgxprotectedfs_check_if_file_exists(uint8_t* retval, const char* filename) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_filename = filename ? strlen(filename) + 1 : 0; + + ms_u_sgxprotectedfs_check_if_file_exists_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_sgxprotectedfs_check_if_file_exists_t); + void *__tmp = NULL; + + + CHECK_ENCLAVE_POINTER(filename, _len_filename); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (filename != NULL) ? _len_filename : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_sgxprotectedfs_check_if_file_exists_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_sgxprotectedfs_check_if_file_exists_t)); + ocalloc_size -= sizeof(ms_u_sgxprotectedfs_check_if_file_exists_t); + + if (filename != NULL) { + ms->ms_filename = (const char*)__tmp; + if (_len_filename % sizeof(*filename) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, filename, _len_filename)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_filename); + ocalloc_size -= _len_filename; + } else { + ms->ms_filename = NULL; + } + + status = sgx_ocall(70, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_sgxprotectedfs_fread_node(int32_t* retval, void* f, uint64_t node_number, uint8_t* buffer, uint32_t node_size) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_buffer = node_size; + + ms_u_sgxprotectedfs_fread_node_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_sgxprotectedfs_fread_node_t); + void *__tmp = NULL; + + void *__tmp_buffer = NULL; + + CHECK_ENCLAVE_POINTER(buffer, _len_buffer); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buffer != NULL) ? _len_buffer : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_sgxprotectedfs_fread_node_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_sgxprotectedfs_fread_node_t)); + ocalloc_size -= sizeof(ms_u_sgxprotectedfs_fread_node_t); + + ms->ms_f = f; + ms->ms_node_number = node_number; + if (buffer != NULL) { + ms->ms_buffer = (uint8_t*)__tmp; + __tmp_buffer = __tmp; + if (_len_buffer % sizeof(*buffer) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + memset(__tmp_buffer, 0, _len_buffer); + __tmp = (void *)((size_t)__tmp + _len_buffer); + ocalloc_size -= _len_buffer; + } else { + ms->ms_buffer = NULL; + } + + ms->ms_node_size = node_size; + status = sgx_ocall(71, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + if (buffer) { + if (memcpy_s((void*)buffer, _len_buffer, __tmp_buffer, _len_buffer)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + } + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_sgxprotectedfs_fwrite_node(int32_t* retval, void* f, uint64_t node_number, uint8_t* buffer, uint32_t node_size) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_buffer = node_size; + + ms_u_sgxprotectedfs_fwrite_node_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_sgxprotectedfs_fwrite_node_t); + void *__tmp = NULL; + + + CHECK_ENCLAVE_POINTER(buffer, _len_buffer); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (buffer != NULL) ? _len_buffer : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_sgxprotectedfs_fwrite_node_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_sgxprotectedfs_fwrite_node_t)); + ocalloc_size -= sizeof(ms_u_sgxprotectedfs_fwrite_node_t); + + ms->ms_f = f; + ms->ms_node_number = node_number; + if (buffer != NULL) { + ms->ms_buffer = (uint8_t*)__tmp; + if (_len_buffer % sizeof(*buffer) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, buffer, _len_buffer)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_buffer); + ocalloc_size -= _len_buffer; + } else { + ms->ms_buffer = NULL; + } + + ms->ms_node_size = node_size; + status = sgx_ocall(72, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_sgxprotectedfs_fclose(int32_t* retval, void* f) +{ + sgx_status_t status = SGX_SUCCESS; + + ms_u_sgxprotectedfs_fclose_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_sgxprotectedfs_fclose_t); + void *__tmp = NULL; + + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_sgxprotectedfs_fclose_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_sgxprotectedfs_fclose_t)); + ocalloc_size -= sizeof(ms_u_sgxprotectedfs_fclose_t); + + ms->ms_f = f; + status = sgx_ocall(73, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_sgxprotectedfs_fflush(uint8_t* retval, void* f) +{ + sgx_status_t status = SGX_SUCCESS; + + ms_u_sgxprotectedfs_fflush_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_sgxprotectedfs_fflush_t); + void *__tmp = NULL; + + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_sgxprotectedfs_fflush_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_sgxprotectedfs_fflush_t)); + ocalloc_size -= sizeof(ms_u_sgxprotectedfs_fflush_t); + + ms->ms_f = f; + status = sgx_ocall(74, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_sgxprotectedfs_remove(int32_t* retval, const char* filename) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_filename = filename ? strlen(filename) + 1 : 0; + + ms_u_sgxprotectedfs_remove_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_sgxprotectedfs_remove_t); + void *__tmp = NULL; + + + CHECK_ENCLAVE_POINTER(filename, _len_filename); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (filename != NULL) ? _len_filename : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_sgxprotectedfs_remove_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_sgxprotectedfs_remove_t)); + ocalloc_size -= sizeof(ms_u_sgxprotectedfs_remove_t); + + if (filename != NULL) { + ms->ms_filename = (const char*)__tmp; + if (_len_filename % sizeof(*filename) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, filename, _len_filename)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_filename); + ocalloc_size -= _len_filename; + } else { + ms->ms_filename = NULL; + } + + status = sgx_ocall(75, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_sgxprotectedfs_recovery_file_open(void** retval, const char* filename) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_filename = filename ? strlen(filename) + 1 : 0; + + ms_u_sgxprotectedfs_recovery_file_open_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_sgxprotectedfs_recovery_file_open_t); + void *__tmp = NULL; + + + CHECK_ENCLAVE_POINTER(filename, _len_filename); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (filename != NULL) ? _len_filename : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_sgxprotectedfs_recovery_file_open_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_sgxprotectedfs_recovery_file_open_t)); + ocalloc_size -= sizeof(ms_u_sgxprotectedfs_recovery_file_open_t); + + if (filename != NULL) { + ms->ms_filename = (const char*)__tmp; + if (_len_filename % sizeof(*filename) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, filename, _len_filename)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_filename); + ocalloc_size -= _len_filename; + } else { + ms->ms_filename = NULL; + } + + status = sgx_ocall(76, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_sgxprotectedfs_fwrite_recovery_node(uint8_t* retval, void* f, uint8_t* data, uint32_t data_length) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_data = data_length * sizeof(uint8_t); + + ms_u_sgxprotectedfs_fwrite_recovery_node_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_sgxprotectedfs_fwrite_recovery_node_t); + void *__tmp = NULL; + + + CHECK_ENCLAVE_POINTER(data, _len_data); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (data != NULL) ? _len_data : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_sgxprotectedfs_fwrite_recovery_node_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_sgxprotectedfs_fwrite_recovery_node_t)); + ocalloc_size -= sizeof(ms_u_sgxprotectedfs_fwrite_recovery_node_t); + + ms->ms_f = f; + if (data != NULL) { + ms->ms_data = (uint8_t*)__tmp; + if (_len_data % sizeof(*data) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, data, _len_data)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_data); + ocalloc_size -= _len_data; + } else { + ms->ms_data = NULL; + } + + ms->ms_data_length = data_length; + status = sgx_ocall(77, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + +sgx_status_t SGX_CDECL u_sgxprotectedfs_do_file_recovery(int32_t* retval, const char* filename, const char* recovery_filename, uint32_t node_size) +{ + sgx_status_t status = SGX_SUCCESS; + size_t _len_filename = filename ? strlen(filename) + 1 : 0; + size_t _len_recovery_filename = recovery_filename ? strlen(recovery_filename) + 1 : 0; + + ms_u_sgxprotectedfs_do_file_recovery_t* ms = NULL; + size_t ocalloc_size = sizeof(ms_u_sgxprotectedfs_do_file_recovery_t); + void *__tmp = NULL; + + + CHECK_ENCLAVE_POINTER(filename, _len_filename); + CHECK_ENCLAVE_POINTER(recovery_filename, _len_recovery_filename); + + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (filename != NULL) ? _len_filename : 0)) + return SGX_ERROR_INVALID_PARAMETER; + if (ADD_ASSIGN_OVERFLOW(ocalloc_size, (recovery_filename != NULL) ? _len_recovery_filename : 0)) + return SGX_ERROR_INVALID_PARAMETER; + + __tmp = sgx_ocalloc(ocalloc_size); + if (__tmp == NULL) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + ms = (ms_u_sgxprotectedfs_do_file_recovery_t*)__tmp; + __tmp = (void *)((size_t)__tmp + sizeof(ms_u_sgxprotectedfs_do_file_recovery_t)); + ocalloc_size -= sizeof(ms_u_sgxprotectedfs_do_file_recovery_t); + + if (filename != NULL) { + ms->ms_filename = (const char*)__tmp; + if (_len_filename % sizeof(*filename) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, filename, _len_filename)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_filename); + ocalloc_size -= _len_filename; + } else { + ms->ms_filename = NULL; + } + + if (recovery_filename != NULL) { + ms->ms_recovery_filename = (const char*)__tmp; + if (_len_recovery_filename % sizeof(*recovery_filename) != 0) { + sgx_ocfree(); + return SGX_ERROR_INVALID_PARAMETER; + } + if (memcpy_s(__tmp, ocalloc_size, recovery_filename, _len_recovery_filename)) { + sgx_ocfree(); + return SGX_ERROR_UNEXPECTED; + } + __tmp = (void *)((size_t)__tmp + _len_recovery_filename); + ocalloc_size -= _len_recovery_filename; + } else { + ms->ms_recovery_filename = NULL; + } + + ms->ms_node_size = node_size; + status = sgx_ocall(78, ms); + + if (status == SGX_SUCCESS) { + if (retval) *retval = ms->ms_retval; + } + sgx_ocfree(); + return status; +} + diff --git a/rust-sgx-workspace/projects/sgx-wallet/enclave/codegen/Enclave_t.h b/rust-sgx-workspace/projects/sgx-wallet/enclave/codegen/Enclave_t.h new file mode 100644 index 0000000..6558f49 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/enclave/codegen/Enclave_t.h @@ -0,0 +1,114 @@ +#ifndef ENCLAVE_T_H__ +#define ENCLAVE_T_H__ + +#include +#include +#include +#include "sgx_edger8r.h" /* for sgx_ocall etc. */ + +#include "sgx_report.h" +#include "time.h" +#include "inc/stat.h" +#include "sys/uio.h" +#include "inc/stat.h" +#include "inc/dirent.h" +#include "pwd.h" + +#include /* for size_t */ + +#define SGX_CAST(type, item) ((type)(item)) + +#ifdef __cplusplus +extern "C" { +#endif + +sgx_status_t enclave_create_report(const sgx_target_info_t* p_qe3_target, sgx_report_t* p_report, uint8_t enclave_data[32]); +sgx_status_t wallet_operation(const uint8_t* sealed_request_buffer, size_t sealed_request_size, uint8_t* sealed_response_buffer, size_t sealed_response_capacity, size_t* sealed_response_used); +void t_global_init_ecall(uint64_t id, const uint8_t* path, size_t len); +void t_global_exit_ecall(void); + +sgx_status_t SGX_CDECL sgx_oc_cpuidex(int cpuinfo[4], int leaf, int subleaf); +sgx_status_t SGX_CDECL sgx_thread_wait_untrusted_event_ocall(int* retval, const void* self); +sgx_status_t SGX_CDECL sgx_thread_set_untrusted_event_ocall(int* retval, const void* waiter); +sgx_status_t SGX_CDECL sgx_thread_setwait_untrusted_events_ocall(int* retval, const void* waiter, const void* self); +sgx_status_t SGX_CDECL sgx_thread_set_multiple_untrusted_events_ocall(int* retval, const void** waiters, size_t total); +sgx_status_t SGX_CDECL u_thread_set_event_ocall(int* retval, int* error, const void* tcs); +sgx_status_t SGX_CDECL u_thread_wait_event_ocall(int* retval, int* error, const void* tcs, const struct timespec* timeout); +sgx_status_t SGX_CDECL u_thread_set_multiple_events_ocall(int* retval, int* error, const void** tcss, int total); +sgx_status_t SGX_CDECL u_thread_setwait_events_ocall(int* retval, int* error, const void* waiter_tcs, const void* self_tcs, const struct timespec* timeout); +sgx_status_t SGX_CDECL u_clock_gettime_ocall(int* retval, int* error, int clk_id, struct timespec* tp); +sgx_status_t SGX_CDECL u_read_ocall(size_t* retval, int* error, int fd, void* buf, size_t count); +sgx_status_t SGX_CDECL u_pread64_ocall(size_t* retval, int* error, int fd, void* buf, size_t count, int64_t offset); +sgx_status_t SGX_CDECL u_readv_ocall(size_t* retval, int* error, int fd, const struct iovec* iov, int iovcnt); +sgx_status_t SGX_CDECL u_preadv64_ocall(size_t* retval, int* error, int fd, const struct iovec* iov, int iovcnt, int64_t offset); +sgx_status_t SGX_CDECL u_write_ocall(size_t* retval, int* error, int fd, const void* buf, size_t count); +sgx_status_t SGX_CDECL u_pwrite64_ocall(size_t* retval, int* error, int fd, const void* buf, size_t count, int64_t offset); +sgx_status_t SGX_CDECL u_writev_ocall(size_t* retval, int* error, int fd, const struct iovec* iov, int iovcnt); +sgx_status_t SGX_CDECL u_pwritev64_ocall(size_t* retval, int* error, int fd, const struct iovec* iov, int iovcnt, int64_t offset); +sgx_status_t SGX_CDECL u_fcntl_arg0_ocall(int* retval, int* error, int fd, int cmd); +sgx_status_t SGX_CDECL u_fcntl_arg1_ocall(int* retval, int* error, int fd, int cmd, int arg); +sgx_status_t SGX_CDECL u_ioctl_arg0_ocall(int* retval, int* error, int fd, int request); +sgx_status_t SGX_CDECL u_ioctl_arg1_ocall(int* retval, int* error, int fd, int request, int* arg); +sgx_status_t SGX_CDECL u_close_ocall(int* retval, int* error, int fd); +sgx_status_t SGX_CDECL u_malloc_ocall(void** retval, int* error, size_t size); +sgx_status_t SGX_CDECL u_free_ocall(void* p); +sgx_status_t SGX_CDECL u_mmap_ocall(void** retval, int* error, void* start, size_t length, int prot, int flags, int fd, int64_t offset); +sgx_status_t SGX_CDECL u_munmap_ocall(int* retval, int* error, void* start, size_t length); +sgx_status_t SGX_CDECL u_msync_ocall(int* retval, int* error, void* addr, size_t length, int flags); +sgx_status_t SGX_CDECL u_mprotect_ocall(int* retval, int* error, void* addr, size_t length, int prot); +sgx_status_t SGX_CDECL u_open_ocall(int* retval, int* error, const char* pathname, int flags); +sgx_status_t SGX_CDECL u_open64_ocall(int* retval, int* error, const char* path, int oflag, int mode); +sgx_status_t SGX_CDECL u_fstat_ocall(int* retval, int* error, int fd, struct stat_t* buf); +sgx_status_t SGX_CDECL u_fstat64_ocall(int* retval, int* error, int fd, struct stat64_t* buf); +sgx_status_t SGX_CDECL u_stat_ocall(int* retval, int* error, const char* path, struct stat_t* buf); +sgx_status_t SGX_CDECL u_stat64_ocall(int* retval, int* error, const char* path, struct stat64_t* buf); +sgx_status_t SGX_CDECL u_lstat_ocall(int* retval, int* error, const char* path, struct stat_t* buf); +sgx_status_t SGX_CDECL u_lstat64_ocall(int* retval, int* error, const char* path, struct stat64_t* buf); +sgx_status_t SGX_CDECL u_lseek_ocall(uint64_t* retval, int* error, int fd, int64_t offset, int whence); +sgx_status_t SGX_CDECL u_lseek64_ocall(int64_t* retval, int* error, int fd, int64_t offset, int whence); +sgx_status_t SGX_CDECL u_ftruncate_ocall(int* retval, int* error, int fd, int64_t length); +sgx_status_t SGX_CDECL u_ftruncate64_ocall(int* retval, int* error, int fd, int64_t length); +sgx_status_t SGX_CDECL u_truncate_ocall(int* retval, int* error, const char* path, int64_t length); +sgx_status_t SGX_CDECL u_truncate64_ocall(int* retval, int* error, const char* path, int64_t length); +sgx_status_t SGX_CDECL u_fsync_ocall(int* retval, int* error, int fd); +sgx_status_t SGX_CDECL u_fdatasync_ocall(int* retval, int* error, int fd); +sgx_status_t SGX_CDECL u_fchmod_ocall(int* retval, int* error, int fd, uint32_t mode); +sgx_status_t SGX_CDECL u_unlink_ocall(int* retval, int* error, const char* pathname); +sgx_status_t SGX_CDECL u_link_ocall(int* retval, int* error, const char* oldpath, const char* newpath); +sgx_status_t SGX_CDECL u_linkat_ocall(int* retval, int* error, int olddirfd, const char* oldpath, int newdirfd, const char* newpath, int flags); +sgx_status_t SGX_CDECL u_rename_ocall(int* retval, int* error, const char* oldpath, const char* newpath); +sgx_status_t SGX_CDECL u_chmod_ocall(int* retval, int* error, const char* path, uint32_t mode); +sgx_status_t SGX_CDECL u_readlink_ocall(size_t* retval, int* error, const char* path, char* buf, size_t bufsz); +sgx_status_t SGX_CDECL u_symlink_ocall(int* retval, int* error, const char* path1, const char* path2); +sgx_status_t SGX_CDECL u_realpath_ocall(char** retval, int* error, const char* pathname); +sgx_status_t SGX_CDECL u_mkdir_ocall(int* retval, int* error, const char* pathname, uint32_t mode); +sgx_status_t SGX_CDECL u_rmdir_ocall(int* retval, int* error, const char* pathname); +sgx_status_t SGX_CDECL u_opendir_ocall(void** retval, int* error, const char* pathname); +sgx_status_t SGX_CDECL u_readdir64_r_ocall(int* retval, void* dirp, struct dirent64_t* entry, struct dirent64_t** result); +sgx_status_t SGX_CDECL u_closedir_ocall(int* retval, int* error, void* dirp); +sgx_status_t SGX_CDECL u_dirfd_ocall(int* retval, int* error, void* dirp); +sgx_status_t SGX_CDECL u_fstatat64_ocall(int* retval, int* error, int dirfd, const char* pathname, struct stat64_t* buf, int flags); +sgx_status_t SGX_CDECL u_environ_ocall(char*** retval); +sgx_status_t SGX_CDECL u_getenv_ocall(char** retval, const char* name); +sgx_status_t SGX_CDECL u_setenv_ocall(int* retval, int* error, const char* name, const char* value, int overwrite); +sgx_status_t SGX_CDECL u_unsetenv_ocall(int* retval, int* error, const char* name); +sgx_status_t SGX_CDECL u_chdir_ocall(int* retval, int* error, const char* dir); +sgx_status_t SGX_CDECL u_getcwd_ocall(char** retval, int* error, char* buf, size_t buflen); +sgx_status_t SGX_CDECL u_getpwuid_r_ocall(int* retval, unsigned int uid, struct passwd* pwd, char* buf, size_t buflen, struct passwd** passwd_result); +sgx_status_t SGX_CDECL u_getuid_ocall(unsigned int* retval); +sgx_status_t SGX_CDECL u_sgxprotectedfs_exclusive_file_open(void** retval, const char* filename, uint8_t read_only, int64_t* file_size, int32_t* error_code); +sgx_status_t SGX_CDECL u_sgxprotectedfs_check_if_file_exists(uint8_t* retval, const char* filename); +sgx_status_t SGX_CDECL u_sgxprotectedfs_fread_node(int32_t* retval, void* f, uint64_t node_number, uint8_t* buffer, uint32_t node_size); +sgx_status_t SGX_CDECL u_sgxprotectedfs_fwrite_node(int32_t* retval, void* f, uint64_t node_number, uint8_t* buffer, uint32_t node_size); +sgx_status_t SGX_CDECL u_sgxprotectedfs_fclose(int32_t* retval, void* f); +sgx_status_t SGX_CDECL u_sgxprotectedfs_fflush(uint8_t* retval, void* f); +sgx_status_t SGX_CDECL u_sgxprotectedfs_remove(int32_t* retval, const char* filename); +sgx_status_t SGX_CDECL u_sgxprotectedfs_recovery_file_open(void** retval, const char* filename); +sgx_status_t SGX_CDECL u_sgxprotectedfs_fwrite_recovery_node(uint8_t* retval, void* f, uint8_t* data, uint32_t data_length); +sgx_status_t SGX_CDECL u_sgxprotectedfs_do_file_recovery(int32_t* retval, const char* filename, const char* recovery_filename, uint32_t node_size); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/rust-sgx-workspace/projects/sgx-wallet/enclave/src/lib.rs b/rust-sgx-workspace/projects/sgx-wallet/enclave/src/lib.rs new file mode 100644 index 0000000..3db0bf4 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-wallet/enclave/src/lib.rs @@ -0,0 +1,7 @@ +#![no_std] + +extern crate sgx_tstd as std; + +// Re-export ECALL implementations: +pub use sgx_wallet_impl::ecalls::enclave_create_report::enclave_create_report; +pub use sgx_wallet_impl::ecalls::wallet_operation::wallet_operation; From d6c260dced754330ba399c4a76939edaa5d6c70d Mon Sep 17 00:00:00 2001 From: Bill Guo Date: Tue, 6 Sep 2022 10:50:27 +0200 Subject: [PATCH 07/22] refactor(rust-sgx-workspace): rename 'wallet' to 'vault' (#62) --- rust-sgx-workspace/Cargo.toml | 10 +- .../crates/http-service-impl/src/actors.rs | 30 ++--- .../src/resources/enclave_report.rs | 4 +- .../http-service-impl/src/resources/mod.rs | 2 +- ...wallet_operation.rs => vault_operation.rs} | 12 +- .../crates/http-service-impl/src/server.rs | 16 +-- .../crates/http-service-impl/src/traits.rs | 21 ++-- .../.gitignore | 0 .../Cargo.lock | 2 +- .../Cargo.toml | 4 +- .../src/ecall_helpers.rs | 0 .../src/ecalls/enclave_create_report.rs | 0 .../src/ecalls/mod.rs | 2 +- .../src/ecalls/vault_operation.rs} | 10 +- .../src/lib.rs | 2 +- .../src/ported/attestation.rs | 0 .../src/ported/crypto.rs | 0 .../src/ported/kv_store/fs/mod.rs | 0 .../src/ported/kv_store/fs/sgx_filer.rs | 0 .../src/ported/kv_store/mod.rs | 0 .../src/ported/mod.rs | 0 .../src/schema/actions.rs | 98 +++++++-------- .../src/schema/entities.rs | 28 ++--- .../src/schema/mod.rs | 2 +- .../src/schema/msgpack.rs | 0 .../src/schema/sealing.rs | 0 .../src/schema/serde_bytes_array.rs | 0 .../src/schema/types.rs | 8 +- .../src/vault_operations/create_vault.rs} | 18 +-- .../src/vault_operations/dispatch.rs | 115 ++++++++++++++++++ .../src/vault_operations}/errors.rs | 0 .../vault_operations}/load_onfido_check.rs | 4 +- .../src/vault_operations}/mod.rs | 6 +- .../src/vault_operations/open_vault.rs | 12 ++ .../vault_operations}/save_onfido_check.rs | 8 +- .../src/vault_operations}/sign_transaction.rs | 8 +- .../sign_transaction_algorand.rs | 2 +- .../sign_transaction_xrpl.rs | 0 .../src/vault_operations/store.rs | 86 +++++++++++++ .../src/wallet_operations/dispatch.rs | 115 ------------------ .../src/wallet_operations/open_wallet.rs | 12 -- .../src/wallet_operations/store.rs | 90 -------------- .../.gitignore | 0 .../Makefile | 2 +- .../Makefile.toml | 0 .../app/.gitignore | 0 .../app/Cargo.lock | 2 +- .../app/Cargo.toml | 2 +- .../app/Makefile | 2 +- .../app/build.rs | 0 .../app/codegen/Enclave_u.c | 0 .../app/codegen/Enclave_u.h | 0 .../app/codegen/Enclave_u.rs | 0 .../app/src/main.rs | 6 +- .../app/src/safe_ecalls.rs | 0 .../buildenv.mk | 0 .../buildenv_sgx.mk | 0 .../enclave/.gitignore | 0 .../enclave/Cargo.lock | 6 +- .../enclave/Cargo.toml | 4 +- .../enclave/Enclave.config.xml | 0 .../enclave/Enclave.edl | 0 .../enclave/Enclave.lds | 0 .../enclave/Makefile | 4 +- .../enclave/codegen/Enclave_t.c | 0 .../enclave/codegen/Enclave_t.h | 0 .../enclave/src/helpers/algonaut.rs | 0 .../enclave/src/helpers/mod.rs | 2 +- .../enclave/src/helpers/temp_dir.rs | 0 .../enclave/src/helpers/vault_store.rs} | 30 ++--- .../sgx-vault-test/enclave/src/lib.rs | 57 +++++++++ .../enclave/src/ported/kv_store/tests.rs | 4 +- .../enclave/src/ported/mod.rs | 0 .../enclave/src/ported/proptest_crypto.rs | 2 +- .../enclave/src/ported/test_attestation.rs | 4 +- .../enclave/src/ported/test_crypto.rs | 2 +- .../enclave/src/ported/test_kv_store.rs | 4 +- .../enclave/src/ported/test_kv_store_fs.rs | 4 +- .../enclave/src/schema/mod.rs | 0 .../enclave/src/schema/test_sealing.rs | 4 +- .../enclave/src/schema/test_types.rs | 4 +- .../enclave/src/vault_operations}/mod.rs | 4 +- .../vault_operations/test_create_vault.rs} | 20 +-- .../src/vault_operations/test_dispatch.rs | 35 ++++++ .../test_load_onfido_check.rs | 28 ++--- .../src/vault_operations/test_open_vault.rs | 50 ++++++++ .../test_save_onfido_check.rs | 24 ++-- .../test_sign_transaction.rs | 26 ++-- .../test_sign_transaction_msgpack.rs | 2 +- .../test_sign_transaction_xrpl.rs | 12 +- .../src/vault_operations/test_store.rs | 37 ++++++ .../{sgx-wallet => sgx-vault}/.gitignore | 0 .../{sgx-wallet => sgx-vault}/Makefile | 2 +- .../{sgx-wallet => sgx-vault}/Makefile.toml | 0 .../{sgx-wallet => sgx-vault}/app/.gitignore | 0 .../{sgx-wallet => sgx-vault}/app/Cargo.lock | 2 +- .../{sgx-wallet => sgx-vault}/app/Cargo.toml | 2 +- .../{sgx-wallet => sgx-vault}/app/Makefile | 4 +- .../{sgx-wallet => sgx-vault}/app/build.rs | 0 .../app/codegen/Enclave_u.c | 8 +- .../app/codegen/Enclave_u.h | 2 +- .../app/codegen/Enclave_u.rs | 2 +- .../{sgx-wallet => sgx-vault}/app/src/main.rs | 10 +- .../app/src/safe_ecalls.rs | 4 +- .../app/src/trait_impls.rs | 12 +- .../{sgx-wallet => sgx-vault}/buildenv.mk | 0 .../{sgx-wallet => sgx-vault}/buildenv_sgx.mk | 0 .../enclave/.gitignore | 0 .../enclave/Cargo.lock | 6 +- .../enclave/Cargo.toml | 4 +- .../enclave/Enclave.config.xml | 0 .../enclave/Enclave.edl | 2 +- .../enclave/Enclave.lds | 0 .../enclave/Makefile | 4 +- .../enclave/codegen/Enclave_t.c | 14 +-- .../enclave/codegen/Enclave_t.h | 2 +- .../projects/sgx-vault/enclave/src/lib.rs | 7 ++ .../sgx-wallet-test/enclave/src/lib.rs | 57 --------- .../src/wallet_operations/test_dispatch.rs | 40 ------ .../src/wallet_operations/test_open_wallet.rs | 50 -------- .../src/wallet_operations/test_store.rs | 37 ------ .../projects/sgx-wallet/enclave/src/lib.rs | 7 -- 122 files changed, 688 insertions(+), 700 deletions(-) rename rust-sgx-workspace/crates/http-service-impl/src/resources/{wallet_operation.rs => vault_operation.rs} (75%) rename rust-sgx-workspace/crates/{sgx-wallet-impl => sgx-vault-impl}/.gitignore (100%) rename rust-sgx-workspace/crates/{sgx-wallet-impl => sgx-vault-impl}/Cargo.lock (99%) rename rust-sgx-workspace/crates/{sgx-wallet-impl => sgx-vault-impl}/Cargo.toml (97%) rename rust-sgx-workspace/crates/{sgx-wallet-impl => sgx-vault-impl}/src/ecall_helpers.rs (100%) rename rust-sgx-workspace/crates/{sgx-wallet-impl => sgx-vault-impl}/src/ecalls/enclave_create_report.rs (100%) rename rust-sgx-workspace/crates/{sgx-wallet-impl => sgx-vault-impl}/src/ecalls/mod.rs (80%) rename rust-sgx-workspace/crates/{sgx-wallet-impl/src/ecalls/wallet_operation.rs => sgx-vault-impl/src/ecalls/vault_operation.rs} (84%) rename rust-sgx-workspace/crates/{sgx-wallet-impl => sgx-vault-impl}/src/lib.rs (85%) rename rust-sgx-workspace/crates/{sgx-wallet-impl => sgx-vault-impl}/src/ported/attestation.rs (100%) rename rust-sgx-workspace/crates/{sgx-wallet-impl => sgx-vault-impl}/src/ported/crypto.rs (100%) rename rust-sgx-workspace/crates/{sgx-wallet-impl => sgx-vault-impl}/src/ported/kv_store/fs/mod.rs (100%) rename rust-sgx-workspace/crates/{sgx-wallet-impl => sgx-vault-impl}/src/ported/kv_store/fs/sgx_filer.rs (100%) rename rust-sgx-workspace/crates/{sgx-wallet-impl => sgx-vault-impl}/src/ported/kv_store/mod.rs (100%) rename rust-sgx-workspace/crates/{sgx-wallet-impl => sgx-vault-impl}/src/ported/mod.rs (100%) rename rust-sgx-workspace/crates/{sgx-wallet-impl => sgx-vault-impl}/src/schema/actions.rs (76%) rename rust-sgx-workspace/crates/{sgx-wallet-impl => sgx-vault-impl}/src/schema/entities.rs (91%) rename rust-sgx-workspace/crates/{sgx-wallet-impl => sgx-vault-impl}/src/schema/mod.rs (91%) rename rust-sgx-workspace/crates/{sgx-wallet-impl => sgx-vault-impl}/src/schema/msgpack.rs (100%) rename rust-sgx-workspace/crates/{sgx-wallet-impl => sgx-vault-impl}/src/schema/sealing.rs (100%) rename rust-sgx-workspace/crates/{sgx-wallet-impl => sgx-vault-impl}/src/schema/serde_bytes_array.rs (100%) rename rust-sgx-workspace/crates/{sgx-wallet-impl => sgx-vault-impl}/src/schema/types.rs (94%) rename rust-sgx-workspace/crates/{sgx-wallet-impl/src/wallet_operations/create_wallet.rs => sgx-vault-impl/src/vault_operations/create_vault.rs} (56%) create mode 100644 rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/dispatch.rs rename rust-sgx-workspace/crates/{sgx-wallet-impl/src/wallet_operations => sgx-vault-impl/src/vault_operations}/errors.rs (100%) rename rust-sgx-workspace/crates/{sgx-wallet-impl/src/wallet_operations => sgx-vault-impl/src/vault_operations}/load_onfido_check.rs (73%) rename rust-sgx-workspace/crates/{sgx-wallet-impl/src/wallet_operations => sgx-vault-impl/src/vault_operations}/mod.rs (71%) create mode 100644 rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/open_vault.rs rename rust-sgx-workspace/crates/{sgx-wallet-impl/src/wallet_operations => sgx-vault-impl/src/vault_operations}/save_onfido_check.rs (62%) rename rust-sgx-workspace/crates/{sgx-wallet-impl/src/wallet_operations => sgx-vault-impl/src/vault_operations}/sign_transaction.rs (81%) rename rust-sgx-workspace/crates/{sgx-wallet-impl/src/wallet_operations => sgx-vault-impl/src/vault_operations}/sign_transaction_algorand.rs (98%) rename rust-sgx-workspace/crates/{sgx-wallet-impl/src/wallet_operations => sgx-vault-impl/src/vault_operations}/sign_transaction_xrpl.rs (100%) create mode 100644 rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/store.rs delete mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/dispatch.rs delete mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/open_wallet.rs delete mode 100644 rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/store.rs rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/.gitignore (100%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/Makefile (95%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/Makefile.toml (100%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/app/.gitignore (100%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/app/Cargo.lock (96%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/app/Cargo.toml (93%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/app/Makefile (99%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/app/build.rs (100%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/app/codegen/Enclave_u.c (100%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/app/codegen/Enclave_u.h (100%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/app/codegen/Enclave_u.rs (100%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/app/src/main.rs (88%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/app/src/safe_ecalls.rs (100%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/buildenv.mk (100%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/buildenv_sgx.mk (100%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/enclave/.gitignore (100%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/enclave/Cargo.lock (99%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/enclave/Cargo.toml (95%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/enclave/Enclave.config.xml (100%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/enclave/Enclave.edl (100%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/enclave/Enclave.lds (100%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/enclave/Makefile (97%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/enclave/codegen/Enclave_t.c (100%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/enclave/codegen/Enclave_t.h (100%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/enclave/src/helpers/algonaut.rs (100%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/enclave/src/helpers/mod.rs (63%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/enclave/src/helpers/temp_dir.rs (100%) rename rust-sgx-workspace/projects/{sgx-wallet-test/enclave/src/helpers/wallet_store.rs => sgx-vault-test/enclave/src/helpers/vault_store.rs} (56%) create mode 100644 rust-sgx-workspace/projects/sgx-vault-test/enclave/src/lib.rs rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/enclave/src/ported/kv_store/tests.rs (86%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/enclave/src/ported/mod.rs (100%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/enclave/src/ported/proptest_crypto.rs (96%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/enclave/src/ported/test_attestation.rs (84%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/enclave/src/ported/test_crypto.rs (98%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/enclave/src/ported/test_kv_store.rs (95%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/enclave/src/ported/test_kv_store_fs.rs (87%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/enclave/src/schema/mod.rs (100%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/enclave/src/schema/test_sealing.rs (92%) rename rust-sgx-workspace/projects/{sgx-wallet-test => sgx-vault-test}/enclave/src/schema/test_types.rs (86%) rename rust-sgx-workspace/projects/{sgx-wallet-test/enclave/src/wallet_operations => sgx-vault-test/enclave/src/vault_operations}/mod.rs (79%) rename rust-sgx-workspace/projects/{sgx-wallet-test/enclave/src/wallet_operations/test_create_wallet.rs => sgx-vault-test/enclave/src/vault_operations/test_create_vault.rs} (58%) create mode 100644 rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_dispatch.rs rename rust-sgx-workspace/projects/{sgx-wallet-test/enclave/src/wallet_operations => sgx-vault-test/enclave/src/vault_operations}/test_load_onfido_check.rs (63%) create mode 100644 rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_open_vault.rs rename rust-sgx-workspace/projects/{sgx-wallet-test/enclave/src/wallet_operations => sgx-vault-test/enclave/src/vault_operations}/test_save_onfido_check.rs (65%) rename rust-sgx-workspace/projects/{sgx-wallet-test/enclave/src/wallet_operations => sgx-vault-test/enclave/src/vault_operations}/test_sign_transaction.rs (83%) rename rust-sgx-workspace/projects/{sgx-wallet-test/enclave/src/wallet_operations => sgx-vault-test/enclave/src/vault_operations}/test_sign_transaction_msgpack.rs (96%) rename rust-sgx-workspace/projects/{sgx-wallet-test/enclave/src/wallet_operations => sgx-vault-test/enclave/src/vault_operations}/test_sign_transaction_xrpl.rs (68%) create mode 100644 rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_store.rs rename rust-sgx-workspace/projects/{sgx-wallet => sgx-vault}/.gitignore (100%) rename rust-sgx-workspace/projects/{sgx-wallet => sgx-vault}/Makefile (96%) rename rust-sgx-workspace/projects/{sgx-wallet => sgx-vault}/Makefile.toml (100%) rename rust-sgx-workspace/projects/{sgx-wallet => sgx-vault}/app/.gitignore (100%) rename rust-sgx-workspace/projects/{sgx-wallet => sgx-vault}/app/Cargo.lock (99%) rename rust-sgx-workspace/projects/{sgx-wallet => sgx-vault}/app/Cargo.toml (96%) rename rust-sgx-workspace/projects/{sgx-wallet => sgx-vault}/app/Makefile (97%) rename rust-sgx-workspace/projects/{sgx-wallet => sgx-vault}/app/build.rs (100%) rename rust-sgx-workspace/projects/{sgx-wallet => sgx-vault}/app/codegen/Enclave_u.c (99%) rename rust-sgx-workspace/projects/{sgx-wallet => sgx-vault}/app/codegen/Enclave_u.h (98%) rename rust-sgx-workspace/projects/{sgx-wallet => sgx-vault}/app/codegen/Enclave_u.rs (95%) rename rust-sgx-workspace/projects/{sgx-wallet => sgx-vault}/app/src/main.rs (86%) rename rust-sgx-workspace/projects/{sgx-wallet => sgx-vault}/app/src/safe_ecalls.rs (96%) rename rust-sgx-workspace/projects/{sgx-wallet => sgx-vault}/app/src/trait_impls.rs (71%) rename rust-sgx-workspace/projects/{sgx-wallet => sgx-vault}/buildenv.mk (100%) rename rust-sgx-workspace/projects/{sgx-wallet => sgx-vault}/buildenv_sgx.mk (100%) rename rust-sgx-workspace/projects/{sgx-wallet => sgx-vault}/enclave/.gitignore (100%) rename rust-sgx-workspace/projects/{sgx-wallet => sgx-vault}/enclave/Cargo.lock (99%) rename rust-sgx-workspace/projects/{sgx-wallet => sgx-vault}/enclave/Cargo.toml (90%) rename rust-sgx-workspace/projects/{sgx-wallet => sgx-vault}/enclave/Enclave.config.xml (100%) rename rust-sgx-workspace/projects/{sgx-wallet => sgx-vault}/enclave/Enclave.edl (94%) rename rust-sgx-workspace/projects/{sgx-wallet => sgx-vault}/enclave/Enclave.lds (100%) rename rust-sgx-workspace/projects/{sgx-wallet => sgx-vault}/enclave/Makefile (98%) rename rust-sgx-workspace/projects/{sgx-wallet => sgx-vault}/enclave/codegen/Enclave_t.c (99%) rename rust-sgx-workspace/projects/{sgx-wallet => sgx-vault}/enclave/codegen/Enclave_t.h (97%) create mode 100644 rust-sgx-workspace/projects/sgx-vault/enclave/src/lib.rs delete mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/lib.rs delete mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_dispatch.rs delete mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_open_wallet.rs delete mode 100644 rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_store.rs delete mode 100644 rust-sgx-workspace/projects/sgx-wallet/enclave/src/lib.rs diff --git a/rust-sgx-workspace/Cargo.toml b/rust-sgx-workspace/Cargo.toml index df34409..c128227 100644 --- a/rust-sgx-workspace/Cargo.toml +++ b/rust-sgx-workspace/Cargo.toml @@ -5,11 +5,11 @@ members = [ 'projects/*/enclave', ] exclude = [ - 'crates/sgx-wallet-impl', - 'projects/sgx-wallet/app', - 'projects/sgx-wallet/enclave', - 'projects/sgx-wallet-test/app', - 'projects/sgx-wallet-test/enclave', + 'crates/sgx-vault-impl', + 'projects/sgx-vault/app', + 'projects/sgx-vault/enclave', + 'projects/sgx-vault-test/app', + 'projects/sgx-vault-test/enclave', ] [patch.'https://github.com/apache/teaclave-sgx-sdk.git'] diff --git a/rust-sgx-workspace/crates/http-service-impl/src/actors.rs b/rust-sgx-workspace/crates/http-service-impl/src/actors.rs index 8b5d065..2464a05 100644 --- a/rust-sgx-workspace/crates/http-service-impl/src/actors.rs +++ b/rust-sgx-workspace/crates/http-service-impl/src/actors.rs @@ -1,14 +1,14 @@ use actix::{Actor, Context, Handler, Message}; use sgx_types::{sgx_report_t, sgx_target_info_t, SgxResult}; -use crate::traits::WalletEnclave; +use crate::traits::VaultEnclave; -/// This actor lets [`crate::resources`] interact with the wallet enclave. -pub(crate) struct WalletEnclaveActor { - pub(crate) wallet_enclave: Box, +/// This actor lets [`crate::resources`] interact with the vault enclave. +pub(crate) struct VaultEnclaveActor { + pub(crate) vault_enclave: Box, } -impl Actor for WalletEnclaveActor { +impl Actor for VaultEnclaveActor { type Context = Context; } @@ -22,29 +22,29 @@ impl Message for CreateReportMessage { type Result = SgxResult>; } -impl Handler for WalletEnclaveActor { +impl Handler for VaultEnclaveActor { type Result = ::Result; fn handle(&mut self, msg: CreateReportMessage, _ctx: &mut Self::Context) -> Self::Result { - self.wallet_enclave.create_report(msg.target_info) + self.vault_enclave.create_report(msg.target_info) } } -// WalletOperation message: +// VaultOperation message: -pub(crate) struct WalletOperationMessage { +pub(crate) struct VaultOperationMessage { pub(crate) sealed_request_bytes: Box<[u8]>, } -impl Message for WalletOperationMessage { +impl Message for VaultOperationMessage { type Result = SgxResult>>; } -impl Handler for WalletEnclaveActor { - type Result = ::Result; +impl Handler for VaultEnclaveActor { + type Result = ::Result; - fn handle(&mut self, msg: WalletOperationMessage, _ctx: &mut Self::Context) -> Self::Result { - self.wallet_enclave - .wallet_operation_with_retry(&msg.sealed_request_bytes) + fn handle(&mut self, msg: VaultOperationMessage, _ctx: &mut Self::Context) -> Self::Result { + self.vault_enclave + .vault_operation_with_retry(&msg.sealed_request_bytes) } } diff --git a/rust-sgx-workspace/crates/http-service-impl/src/resources/enclave_report.rs b/rust-sgx-workspace/crates/http-service-impl/src/resources/enclave_report.rs index 842b59e..385cadc 100644 --- a/rust-sgx-workspace/crates/http-service-impl/src/resources/enclave_report.rs +++ b/rust-sgx-workspace/crates/http-service-impl/src/resources/enclave_report.rs @@ -12,7 +12,7 @@ pub(crate) async fn get_enclave_report( target_info: Default::default(), }; let (report, enclave_data) = app_state - .wallet_enclave_addr + .vault_enclave_addr .send(message) .await .map_err(|mailbox_error| { @@ -49,7 +49,7 @@ mod attestation_report { use serde::{Deserialize, Serialize}; use sgx_types::*; - /// See [`../../crates/sgx_wallet_impl::schema::msgpack::ToMessagePack::to_msgpack`] + /// See [`../../crates/sgx_vault_impl::schema::msgpack::ToMessagePack::to_msgpack`] pub(crate) fn to_msgpack(message: &impl Serialize) -> Result, encode::Error> { // XXX: Like rmp_serde::to_vec_named, but we need string variants too. let mut wr = Vec::with_capacity(128); diff --git a/rust-sgx-workspace/crates/http-service-impl/src/resources/mod.rs b/rust-sgx-workspace/crates/http-service-impl/src/resources/mod.rs index 30c0f65..06720d2 100644 --- a/rust-sgx-workspace/crates/http-service-impl/src/resources/mod.rs +++ b/rust-sgx-workspace/crates/http-service-impl/src/resources/mod.rs @@ -1,2 +1,2 @@ pub(crate) mod enclave_report; -pub(crate) mod wallet_operation; +pub(crate) mod vault_operation; diff --git a/rust-sgx-workspace/crates/http-service-impl/src/resources/wallet_operation.rs b/rust-sgx-workspace/crates/http-service-impl/src/resources/vault_operation.rs similarity index 75% rename from rust-sgx-workspace/crates/http-service-impl/src/resources/wallet_operation.rs rename to rust-sgx-workspace/crates/http-service-impl/src/resources/vault_operation.rs index ba588f9..21955c4 100644 --- a/rust-sgx-workspace/crates/http-service-impl/src/resources/wallet_operation.rs +++ b/rust-sgx-workspace/crates/http-service-impl/src/resources/vault_operation.rs @@ -1,19 +1,19 @@ use actix_web::{error, post, web}; -use crate::actors::WalletOperationMessage; +use crate::actors::VaultOperationMessage; use crate::server::AppState; -#[post("/wallet-operation")] -pub(crate) async fn post_wallet_operation( +#[post("/vault-operation")] +pub(crate) async fn post_vault_operation( app_state: web::Data, request_body: web::Bytes, ) -> actix_web::Result { let sealed_request_bytes = request_body.to_vec().into_boxed_slice(); - let message = WalletOperationMessage { + let message = VaultOperationMessage { sealed_request_bytes, }; let sealed_response_bytes = app_state - .wallet_enclave_addr + .vault_enclave_addr .send(message) .await .map_err(|mailbox_error| { @@ -23,7 +23,7 @@ pub(crate) async fn post_wallet_operation( error::ErrorInternalServerError(format!("Failed to call enclave: {:?}", sgx_error)) })? .map_err(|sgx_error| { - error::ErrorInternalServerError(format!("wallet_operation failed: {}", sgx_error)) + error::ErrorInternalServerError(format!("vault_operation failed: {}", sgx_error)) })?; let response_body = sealed_response_bytes.into_vec(); Ok(actix_web::HttpResponse::Ok() diff --git a/rust-sgx-workspace/crates/http-service-impl/src/server.rs b/rust-sgx-workspace/crates/http-service-impl/src/server.rs index 1eed1c8..f644a37 100644 --- a/rust-sgx-workspace/crates/http-service-impl/src/server.rs +++ b/rust-sgx-workspace/crates/http-service-impl/src/server.rs @@ -4,39 +4,39 @@ use actix::{Actor, Addr, Arbiter}; use actix_cors::Cors; use actix_web::{web, App, HttpServer}; -use crate::actors::WalletEnclaveActor; +use crate::actors::VaultEnclaveActor; use crate::resources; -use crate::traits::WalletEnclave; +use crate::traits::VaultEnclave; #[derive(Clone)] pub(crate) struct AppState { - pub(crate) wallet_enclave_addr: Addr, + pub(crate) vault_enclave_addr: Addr, } /// Run the server on the given address. pub async fn run_server( - wallet_enclave: Box, + vault_enclave: Box, bind_addr: Addr, ) -> std::io::Result<()> where Addr: ToSocketAddrs, { let enclave_arbiter = Arbiter::new(); - let wallet_enclave_addr = Actor::start_in_arbiter(&enclave_arbiter.handle(), |_ctx| { - WalletEnclaveActor { wallet_enclave } + let vault_enclave_addr = Actor::start_in_arbiter(&enclave_arbiter.handle(), |_ctx| { + VaultEnclaveActor { vault_enclave } }); // TODO: Test coverage let server = HttpServer::new(move || { let app_state = AppState { - wallet_enclave_addr: wallet_enclave_addr.clone(), + vault_enclave_addr: vault_enclave_addr.clone(), }; let cors = Cors::permissive(); // TODO: Tighten this a bit more? App::new() .wrap(cors) .app_data(web::Data::new(app_state)) .service(resources::enclave_report::get_enclave_report) - .service(resources::wallet_operation::post_wallet_operation) + .service(resources::vault_operation::post_vault_operation) }); server.bind(bind_addr)?.run().await } diff --git a/rust-sgx-workspace/crates/http-service-impl/src/traits.rs b/rust-sgx-workspace/crates/http-service-impl/src/traits.rs index 35aa74d..33f9d18 100644 --- a/rust-sgx-workspace/crates/http-service-impl/src/traits.rs +++ b/rust-sgx-workspace/crates/http-service-impl/src/traits.rs @@ -1,37 +1,34 @@ use sgx_types::{sgx_report_t, sgx_status_t, sgx_target_info_t, SgxResult}; -/// Interface for working with wallet enclave. -pub trait WalletEnclave: Send + 'static { +/// Interface for working with vault enclave. +pub trait VaultEnclave: Send + 'static { fn create_report( &self, target_info: sgx_target_info_t, ) -> SgxResult>; - fn wallet_operation( + fn vault_operation( &self, sealed_request: &[u8], sealed_response_capacity: usize, ) -> SgxResult>>; - /// Wrapper: Retry [`Self::wallet_operation`] with increasing capacity. - fn wallet_operation_with_retry( - &self, - sealed_request: &[u8], - ) -> SgxResult>> { + /// Wrapper: Retry [`Self::vault_operation`] with increasing capacity. + fn vault_operation_with_retry(&self, sealed_request: &[u8]) -> SgxResult>> { // Attempt sizes: 1 KiB, 64 KiB, 1 MiB for &sealed_response_capacity in &[1 << 10, 1 << 16, 1 << 20] { - let result = self.wallet_operation(sealed_request, sealed_response_capacity); + let result = self.vault_operation(sealed_request, sealed_response_capacity); match result { Ok(Err(sgx_status_t::SGX_ERROR_FAAS_BUFFER_TOO_SHORT)) => { println!( - "DEBUG: wallet_operation_with_retry: capacity={} too short, retrying…", + "DEBUG: vault_operation_with_retry: capacity={} too short, retrying…", sealed_response_capacity ) } result => { if cfg!(feature = "verbose-debug-logging") { println!( - "DEBUG: wallet_operation_with_retry: capacity={} returning {:?}", + "DEBUG: vault_operation_with_retry: capacity={} returning {:?}", sealed_response_capacity, result ); } @@ -39,7 +36,7 @@ pub trait WalletEnclave: Send + 'static { } } } - println!("DEBUG: wallet_operation_with_retry: giving up!",); + println!("DEBUG: vault_operation_with_retry: giving up!",); Ok(Err(sgx_status_t::SGX_ERROR_FAAS_BUFFER_TOO_SHORT)) } } diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/.gitignore b/rust-sgx-workspace/crates/sgx-vault-impl/.gitignore similarity index 100% rename from rust-sgx-workspace/crates/sgx-wallet-impl/.gitignore rename to rust-sgx-workspace/crates/sgx-vault-impl/.gitignore diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/Cargo.lock b/rust-sgx-workspace/crates/sgx-vault-impl/Cargo.lock similarity index 99% rename from rust-sgx-workspace/crates/sgx-wallet-impl/Cargo.lock rename to rust-sgx-workspace/crates/sgx-vault-impl/Cargo.lock index dff1b07..f0b060b 100644 --- a/rust-sgx-workspace/crates/sgx-wallet-impl/Cargo.lock +++ b/rust-sgx-workspace/crates/sgx-vault-impl/Cargo.lock @@ -663,7 +663,7 @@ dependencies = [ ] [[package]] -name = "sgx-wallet-impl" +name = "sgx-vault-impl" version = "0.1.0" dependencies = [ "algonaut", diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/Cargo.toml b/rust-sgx-workspace/crates/sgx-vault-impl/Cargo.toml similarity index 97% rename from rust-sgx-workspace/crates/sgx-wallet-impl/Cargo.toml rename to rust-sgx-workspace/crates/sgx-vault-impl/Cargo.toml index 0ad38b5..1f370cd 100644 --- a/rust-sgx-workspace/crates/sgx-wallet-impl/Cargo.toml +++ b/rust-sgx-workspace/crates/sgx-vault-impl/Cargo.toml @@ -1,8 +1,8 @@ [package] -name = "sgx-wallet-impl" +name = "sgx-vault-impl" version = "0.1.0" edition = "2021" -description= "Wallet enclave implementation" +description= "Vault enclave implementation" [lib] bench = false diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/ecall_helpers.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/ecall_helpers.rs similarity index 100% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/ecall_helpers.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/ecall_helpers.rs diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/ecalls/enclave_create_report.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/ecalls/enclave_create_report.rs similarity index 100% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/ecalls/enclave_create_report.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/ecalls/enclave_create_report.rs diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/ecalls/mod.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/ecalls/mod.rs similarity index 80% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/ecalls/mod.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/ecalls/mod.rs index ff76c98..6061140 100644 --- a/rust-sgx-workspace/crates/sgx-wallet-impl/src/ecalls/mod.rs +++ b/rust-sgx-workspace/crates/sgx-vault-impl/src/ecalls/mod.rs @@ -1,4 +1,4 @@ //! ECALL wrappers: these bridge from SGX to our safe Rust implementations. pub mod enclave_create_report; -pub mod wallet_operation; +pub mod vault_operation; diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/ecalls/wallet_operation.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/ecalls/vault_operation.rs similarity index 84% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/ecalls/wallet_operation.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/ecalls/vault_operation.rs index 7bc90c3..99600f6 100644 --- a/rust-sgx-workspace/crates/sgx-wallet-impl/src/ecalls/wallet_operation.rs +++ b/rust-sgx-workspace/crates/sgx-vault-impl/src/ecalls/vault_operation.rs @@ -4,9 +4,9 @@ use std::{ptr, slice}; use sgx_types::{sgx_status_t, size_t, uint8_t}; use crate::ecall_helpers::catch_unwind_message; -use crate::wallet_operations::dispatch::wallet_operation_impl; +use crate::vault_operations::dispatch::vault_operation_impl; -/// ECALL wrapper for [`wallet_operation_impl`]. +/// ECALL wrapper for [`vault_operation_impl`]. /// /// # Errors /// @@ -19,7 +19,7 @@ use crate::wallet_operations::dispatch::wallet_operation_impl; /// # Safety /// Expects to be called from SGX bridge, with validated input. #[no_mangle] -pub unsafe extern "C" fn wallet_operation( +pub unsafe extern "C" fn vault_operation( sealed_request_buffer: *const uint8_t, sealed_request_size: size_t, sealed_response_buffer: *mut uint8_t, @@ -34,11 +34,11 @@ pub unsafe extern "C" fn wallet_operation( let sealed_request = unsafe { slice::from_raw_parts(sealed_request_buffer, sealed_request_size) }; - let sealed_response = match catch_unwind_message(|| wallet_operation_impl(sealed_request)) { + let sealed_response = match catch_unwind_message(|| vault_operation_impl(sealed_request)) { Ok(ok) => ok, Err(message) => { println!( - "PANIC in wallet_operation_impl ECALL: {}", + "PANIC in vault_operation_impl ECALL: {}", message.unwrap_or_else(|| ("XXX").to_string()) ); return sgx_status_t::SGX_ERROR_UNEXPECTED; diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/lib.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/lib.rs similarity index 85% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/lib.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/lib.rs index 5d67ebb..469c971 100644 --- a/rust-sgx-workspace/crates/sgx-wallet-impl/src/lib.rs +++ b/rust-sgx-workspace/crates/sgx-vault-impl/src/lib.rs @@ -8,4 +8,4 @@ mod ecall_helpers; pub mod ecalls; pub mod ported; pub mod schema; -pub mod wallet_operations; +pub mod vault_operations; diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/attestation.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/ported/attestation.rs similarity index 100% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/attestation.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/ported/attestation.rs diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/crypto.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/ported/crypto.rs similarity index 100% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/crypto.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/ported/crypto.rs diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/kv_store/fs/mod.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/ported/kv_store/fs/mod.rs similarity index 100% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/kv_store/fs/mod.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/ported/kv_store/fs/mod.rs diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/kv_store/fs/sgx_filer.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/ported/kv_store/fs/sgx_filer.rs similarity index 100% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/kv_store/fs/sgx_filer.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/ported/kv_store/fs/sgx_filer.rs diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/kv_store/mod.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/ported/kv_store/mod.rs similarity index 100% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/kv_store/mod.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/ported/kv_store/mod.rs diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/mod.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/ported/mod.rs similarity index 100% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/ported/mod.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/ported/mod.rs diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/actions.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/schema/actions.rs similarity index 76% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/actions.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/schema/actions.rs index 0989a4a..03e7f9f 100644 --- a/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/actions.rs +++ b/rust-sgx-workspace/crates/sgx-vault-impl/src/schema/actions.rs @@ -10,47 +10,47 @@ use std::prelude::v1::{String, ToString}; use serde::{Deserialize, Serialize}; use zeroize::{Zeroize, ZeroizeOnDrop}; -use crate::schema::entities::WalletDisplay; -use crate::schema::types::{Bytes, WalletId, WalletPin}; -use crate::wallet_operations::store::UnlockWalletError; +use crate::schema::entities::VaultDisplay; +use crate::schema::types::{Bytes, VaultId, VaultPin}; +use crate::vault_operations::store::UnlockVaultError; #[derive(Clone, Eq, PartialEq, Debug)] // core #[derive(Deserialize, Serialize)] // serde #[derive(Zeroize, ZeroizeOnDrop)] // zeroize -pub struct CreateWallet { +pub struct CreateVault { pub owner_name: String, - pub auth_pin: WalletPin, + pub auth_pin: VaultPin, pub phone_number: Option, } #[derive(Clone, Eq, PartialEq, Debug)] // core #[derive(Deserialize, Serialize)] // serde -pub enum CreateWalletResult { - Created(WalletDisplay), +pub enum CreateVaultResult { + Created(VaultDisplay), Failed(String), } #[derive(Clone, Eq, PartialEq, Debug)] // core #[derive(Deserialize, Serialize)] // serde #[derive(Zeroize, ZeroizeOnDrop)] // zeroize -pub struct OpenWallet { - pub wallet_id: WalletId, - pub auth_pin: WalletPin, +pub struct OpenVault { + pub vault_id: VaultId, + pub auth_pin: VaultPin, } #[derive(Clone, Eq, PartialEq, Debug)] // core #[derive(Deserialize, Serialize)] // serde -pub enum OpenWalletResult { - Opened(WalletDisplay), +pub enum OpenVaultResult { + Opened(VaultDisplay), InvalidAuth, Failed(String), } -impl From for OpenWalletResult { - fn from(err: UnlockWalletError) -> Self { - use UnlockWalletError::*; +impl From for OpenVaultResult { + fn from(err: UnlockVaultError) -> Self { + use UnlockVaultError::*; match err { - InvalidWalletId => Self::InvalidAuth, + InvalidVaultId => Self::InvalidAuth, InvalidAuthPin => Self::InvalidAuth, IoError(err) => Self::Failed(err.to_string()), } @@ -61,18 +61,18 @@ impl From for OpenWalletResult { #[derive(Deserialize, Serialize)] // serde #[derive(Zeroize, ZeroizeOnDrop)] // zeroize pub struct SignTransaction { - pub wallet_id: WalletId, - pub auth_pin: WalletPin, + pub vault_id: VaultId, + pub auth_pin: VaultPin, #[zeroize(skip)] pub transaction_to_sign: TransactionToSign, } -impl From for SignTransactionResult { - fn from(err: UnlockWalletError) -> Self { - use UnlockWalletError::*; +impl From for SignTransactionResult { + fn from(err: UnlockVaultError) -> Self { + use UnlockVaultError::*; match err { - InvalidWalletId => Self::InvalidAuth, + InvalidVaultId => Self::InvalidAuth, InvalidAuthPin => Self::InvalidAuth, IoError(err) => Self::Failed(err.to_string()), } @@ -162,8 +162,8 @@ impl TransactionSigned { #[derive(Clone, Eq, PartialEq, Debug)] // core #[derive(Deserialize, Serialize)] // serde pub struct SaveOnfidoCheck { - pub wallet_id: WalletId, - pub auth_pin: WalletPin, + pub vault_id: VaultId, + pub auth_pin: VaultPin, pub check: OnfidoCheckResult, } @@ -182,11 +182,11 @@ impl From for SaveOnfidoCheckResult { } } -impl From for SaveOnfidoCheckResult { - fn from(err: UnlockWalletError) -> Self { - use UnlockWalletError::*; +impl From for SaveOnfidoCheckResult { + fn from(err: UnlockVaultError) -> Self { + use UnlockVaultError::*; match err { - InvalidWalletId => Self::InvalidAuth, + InvalidVaultId => Self::InvalidAuth, InvalidAuthPin => Self::InvalidAuth, IoError(err) => Self::from(err), } @@ -196,8 +196,8 @@ impl From for SaveOnfidoCheckResult { #[derive(Clone, Eq, PartialEq, Debug)] // core #[derive(Deserialize, Serialize)] // serde pub struct LoadOnfidoCheck { - pub wallet_id: WalletId, - pub auth_pin: WalletPin, + pub vault_id: VaultId, + pub auth_pin: VaultPin, } #[derive(Clone, Eq, PartialEq, Debug)] // core @@ -215,11 +215,11 @@ impl From for LoadOnfidoCheckResult { } } -impl From for LoadOnfidoCheckResult { - fn from(err: UnlockWalletError) -> Self { - use UnlockWalletError::*; +impl From for LoadOnfidoCheckResult { + fn from(err: UnlockVaultError) -> Self { + use UnlockVaultError::*; match err { - InvalidWalletId => Self::InvalidAuth, + InvalidVaultId => Self::InvalidAuth, InvalidAuthPin => Self::InvalidAuth, IoError(err) => Self::from(err), } @@ -245,9 +245,9 @@ pub struct OnfidoCheckResult { #[derive(Clone, Eq, PartialEq, Debug)] // core #[derive(Deserialize, Serialize)] // serde #[derive(Zeroize, ZeroizeOnDrop)] // zeroize -pub enum WalletRequest { - CreateWallet(CreateWallet), - OpenWallet(OpenWallet), +pub enum VaultRequest { + CreateVault(CreateVault), + OpenVault(OpenVault), SignTransaction(SignTransaction), #[zeroize(skip)] @@ -260,9 +260,9 @@ pub enum WalletRequest { /// Dispatching enum for action results. #[derive(Clone, Eq, PartialEq, Debug)] // core #[derive(Deserialize, Serialize)] // serde -pub enum WalletResponse { - CreateWallet(CreateWalletResult), - OpenWallet(OpenWalletResult), +pub enum VaultResponse { + CreateVault(CreateVaultResult), + OpenVault(OpenVaultResult), SignTransaction(SignTransactionResult), SaveOnfidoCheck(SaveOnfidoCheckResult), LoadOnfidoCheck(LoadOnfidoCheckResult), @@ -270,31 +270,31 @@ pub enum WalletResponse { // Convenience conversions: -impl From for WalletResponse { - fn from(result: CreateWalletResult) -> Self { - Self::CreateWallet(result) +impl From for VaultResponse { + fn from(result: CreateVaultResult) -> Self { + Self::CreateVault(result) } } -impl From for WalletResponse { - fn from(result: OpenWalletResult) -> Self { - Self::OpenWallet(result) +impl From for VaultResponse { + fn from(result: OpenVaultResult) -> Self { + Self::OpenVault(result) } } -impl From for WalletResponse { +impl From for VaultResponse { fn from(result: SignTransactionResult) -> Self { Self::SignTransaction(result) } } -impl From for WalletResponse { +impl From for VaultResponse { fn from(result: SaveOnfidoCheckResult) -> Self { Self::SaveOnfidoCheck(result) } } -impl From for WalletResponse { +impl From for VaultResponse { fn from(result: LoadOnfidoCheckResult) -> Self { Self::LoadOnfidoCheck(result) } diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/entities.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/schema/entities.rs similarity index 91% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/entities.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/schema/entities.rs index f2cb29b..8101c8b 100644 --- a/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/entities.rs +++ b/rust-sgx-workspace/crates/sgx-vault-impl/src/schema/entities.rs @@ -12,33 +12,33 @@ use crate::schema::types::{ AlgorandAccountSeedBytes, AlgorandAddressBase32, AlgorandAddressBytes, - WalletId, - WalletPin, + VaultId, + VaultPin, XrplAddressBase58, XrplKeyType, XrplPublicKeyHex, }; -/// A Nautilus wallet's basic displayable details. +/// A Nautilus vault's basic displayable details. /// /// This is what gets sent to clients. #[derive(Clone, Eq, PartialEq, Debug)] // core #[derive(Deserialize, Serialize)] // serde -pub struct WalletDisplay { - pub wallet_id: WalletId, +pub struct VaultDisplay { + pub vault_id: VaultId, pub owner_name: String, pub phone_number: Option, - // TODO(Pi): Decouple for multiple accounts per wallet. + // TODO(Pi): Decouple for multiple accounts per vault. pub algorand_address_base32: AlgorandAddressBase32, pub xrpl_account: XrplAccountDisplay, } -impl From for WalletDisplay { - fn from(storable: WalletStorable) -> Self { +impl From for VaultDisplay { + fn from(storable: VaultStorable) -> Self { Self { - wallet_id: storable.wallet_id.clone(), + vault_id: storable.vault_id.clone(), owner_name: storable.owner_name.clone(), phone_number: storable.phone_number.clone(), @@ -48,15 +48,15 @@ impl From for WalletDisplay { } } -/// A Nautilus wallet's full details. +/// A Nautilus vault's full details. /// -/// This is everything that gets persisted in the wallet store. +/// This is everything that gets persisted in the vault store. #[derive(Clone, Eq, PartialEq, Debug)] // core #[derive(Deserialize, Serialize)] // serde #[derive(Zeroize, ZeroizeOnDrop)] // zeroize -pub struct WalletStorable { - pub wallet_id: WalletId, - pub auth_pin: WalletPin, +pub struct VaultStorable { + pub vault_id: VaultId, + pub auth_pin: VaultPin, pub owner_name: String, pub phone_number: Option, diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/mod.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/schema/mod.rs similarity index 91% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/mod.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/schema/mod.rs index e21070b..fcba298 100644 --- a/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/mod.rs +++ b/rust-sgx-workspace/crates/sgx-vault-impl/src/schema/mod.rs @@ -1,4 +1,4 @@ -//! Data types and schema for communicating with the wallet enclave. +//! Data types and schema for communicating with the vault enclave. //! //! Schema types should generally derive at least the following traits: //! diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/msgpack.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/schema/msgpack.rs similarity index 100% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/msgpack.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/schema/msgpack.rs diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/sealing.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/schema/sealing.rs similarity index 100% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/sealing.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/schema/sealing.rs diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/serde_bytes_array.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/schema/serde_bytes_array.rs similarity index 100% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/serde_bytes_array.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/schema/serde_bytes_array.rs diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/types.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/schema/types.rs similarity index 94% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/types.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/schema/types.rs index bd3a662..1b945ea 100644 --- a/rust-sgx-workspace/crates/sgx-wallet-impl/src/schema/types.rs +++ b/rust-sgx-workspace/crates/sgx-vault-impl/src/schema/types.rs @@ -8,11 +8,11 @@ use serde::{Deserialize, Serialize}; pub type Bytes = Box<[u8]>; -/// Nautilus Wallet ID. -pub type WalletId = String; +/// Nautilus Vault ID. +pub type VaultId = String; -/// A wallet owner's authenticating PIN. -pub type WalletPin = String; +/// A vault owner's authenticating PIN. +pub type VaultPin = String; /// Algorand account seed, as bytes. pub type AlgorandAccountSeedBytes = [u8; 32]; diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/create_wallet.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/create_vault.rs similarity index 56% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/create_wallet.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/create_vault.rs index 93a5f4d..7c9b43d 100644 --- a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/create_wallet.rs +++ b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/create_vault.rs @@ -1,19 +1,19 @@ use std::prelude::v1::ToString; -use crate::schema::actions::{CreateWallet, CreateWalletResult}; -use crate::schema::entities::{AlgorandAccount, WalletDisplay, WalletStorable, XrplAccount}; -use crate::wallet_operations::store::save_new_wallet; +use crate::schema::actions::{CreateVault, CreateVaultResult}; +use crate::schema::entities::{AlgorandAccount, VaultDisplay, VaultStorable, XrplAccount}; +use crate::vault_operations::store::save_new_vault; -type Result = CreateWalletResult; +type Result = CreateVaultResult; -pub fn create_wallet(request: &CreateWallet) -> Result { +pub fn create_vault(request: &CreateVault) -> Result { // TODO(Pi): Pull account / keypair creation into a separate operation. // For now, just generate both Algorand and XRP keypairs. let new_algorand_account = AlgorandAccount::generate(); let new_xrpl_account = XrplAccount::generate_default(); - let storable = WalletStorable { - wallet_id: new_xrpl_account.to_address_base58(), + let storable = VaultStorable { + vault_id: new_xrpl_account.to_address_base58(), owner_name: request.owner_name.clone(), auth_pin: request.auth_pin.clone(), phone_number: request.phone_number.clone(), @@ -23,8 +23,8 @@ pub fn create_wallet(request: &CreateWallet) -> Result { onfido_check_result: None, }; - match save_new_wallet(&storable) { - Ok(()) => Result::Created(WalletDisplay::from(storable)), + match save_new_vault(&storable) { + Ok(()) => Result::Created(VaultDisplay::from(storable)), Err(err) => Result::Failed(err.to_string()), } } diff --git a/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/dispatch.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/dispatch.rs new file mode 100644 index 0000000..696f3c9 --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/dispatch.rs @@ -0,0 +1,115 @@ +use std::error::Error; +use std::prelude::v1::Box; + +use secrecy::{ExposeSecret, Secret}; + +use crate::ported::crypto::SecretBytes; +use crate::schema::actions::{VaultRequest, VaultResponse}; +use crate::schema::msgpack::{FromMessagePack, ToMessagePack}; +use crate::schema::sealing::{seal_from_enclave, unseal_to_enclave, SealedMessage}; +use crate::vault_operations::create_vault::create_vault; +use crate::vault_operations::errors; +use crate::vault_operations::load_onfido_check::load_onfido_check; +use crate::vault_operations::open_vault::open_vault; +use crate::vault_operations::save_onfido_check::save_onfido_check; +use crate::vault_operations::sign_transaction::sign_transaction; + +/// Implementation for [`crate::ecalls::vault_operation::vault_operation`]. +/// +/// This processes an exchange of the following: +/// +/// Request: [`SealedMessage`] of [`VaultRequest`] +/// +/// Response: [`SealedMessage`] of [`VaultResponse`] +/// +pub fn vault_operation_impl(sealed_request_bytes: &[u8]) -> Box<[u8]> { + match vault_operation_impl_sealing(sealed_request_bytes) { + Ok(sealed_response_bytes) => sealed_response_bytes, + Err(error) => panic!("{}", error), // FIXME: better reporting + } +} + +/// Handle sealing and unsealing the exchange. +fn vault_operation_impl_sealing(sealed_request_bytes: &[u8]) -> Result, Box> { + // Unseal request + let sealed_request = &SealedMessage::from_msgpack(sealed_request_bytes).map_err(|err| { + errors::message_with_base64( + "vault_operation_impl_sealing", + "failed to unpack received sealed request", + err, + "sealed request msgpack", + sealed_request_bytes, + ) + })?; + let request_bytes = &unseal_to_enclave(sealed_request).map_err(|err| { + errors::message_with_debug_value( + "vault_operation_impl_sealing", + "failed to unseal request", + err, + "sealed request", + sealed_request, + ) + })?; + let vault_request = &Secret::new( + VaultRequest::from_msgpack(request_bytes.expose_secret()).map_err(|err| { + errors::message_with_base64( + "vault_operation_impl_sealing", + "invalid VaultReq", + err, + "unsealed VaultRequest msgpack", + request_bytes.expose_secret(), + ) + })?, + ); + + // Dispatch + let vault_response = vault_operation_impl_dispatch(vault_request.expose_secret()); + + // Seal response + let response_bytes = &SecretBytes::new(vault_response.to_msgpack().map_err(|err| { + errors::message_with_debug_value( + "vault_operation_impl_sealing", + "failed to msgpack VaultResponse-to-seal", + err, + "unsealed VaultResponse", + vault_response, + ) + })?); + let sealed_response = seal_from_enclave(response_bytes, &sealed_request.sender_public_key) + .map_err(|err| { + errors::message_with_base64( + "vault_operation_impl_sealing", + "failed to seal packed VaultResponse", + err, + "unsealed VaultResponse msgpack", + response_bytes.expose_secret(), + ) + })?; + let sealed_response_bytes = sealed_response.to_msgpack().map_err(|err| { + errors::message_with_debug_value( + "vault_operation_impl_sealing", + "failed to msgpack sealed VaultRequest", + err, + "sealed response", + sealed_response, + ) + })?; + Ok(sealed_response_bytes) +} + +/// Handle dispatching the exchange. +fn vault_operation_impl_dispatch(vault_request: &VaultRequest) -> VaultResponse { + if cfg!(feature = "verbose-debug-logging") { + println!( + "DEBUG: vault_operation_impl_dispatch: dispatching vault_request = \n{:#?}", + vault_request + ); + } + match vault_request { + VaultRequest::CreateVault(request) => create_vault(request).into(), + VaultRequest::OpenVault(request) => open_vault(request).into(), + VaultRequest::SignTransaction(request) => sign_transaction(request).into(), + VaultRequest::SaveOnfidoCheck(request) => save_onfido_check(request).into(), + VaultRequest::LoadOnfidoCheck(request) => load_onfido_check(request).into(), + } +} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/errors.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/errors.rs similarity index 100% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/errors.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/errors.rs diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/load_onfido_check.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/load_onfido_check.rs similarity index 73% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/load_onfido_check.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/load_onfido_check.rs index fb3dec5..943e75e 100644 --- a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/load_onfido_check.rs +++ b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/load_onfido_check.rs @@ -1,8 +1,8 @@ use crate::schema::actions::{LoadOnfidoCheck, LoadOnfidoCheckResult}; -use crate::wallet_operations::store::unlock_wallet; +use crate::vault_operations::store::unlock_vault; pub fn load_onfido_check(request: &LoadOnfidoCheck) -> LoadOnfidoCheckResult { - let stored = match unlock_wallet(&request.wallet_id, &request.auth_pin) { + let stored = match unlock_vault(&request.vault_id, &request.auth_pin) { Ok(stored) => stored, Err(err) => return err.into(), }; diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/mod.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/mod.rs similarity index 71% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/mod.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/mod.rs index d7b79c1..63d0fdb 100644 --- a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/mod.rs +++ b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/mod.rs @@ -1,10 +1,10 @@ -//! Wallet operation implementations. +//! Vault operation implementations. -pub mod create_wallet; +pub mod create_vault; pub mod dispatch; pub(crate) mod errors; pub mod load_onfido_check; -pub mod open_wallet; +pub mod open_vault; pub mod save_onfido_check; pub mod sign_transaction; pub mod sign_transaction_algorand; diff --git a/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/open_vault.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/open_vault.rs new file mode 100644 index 0000000..23815db --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/open_vault.rs @@ -0,0 +1,12 @@ +use crate::schema::actions::{OpenVault, OpenVaultResult}; +use crate::schema::entities::VaultDisplay; +use crate::vault_operations::store::unlock_vault; + +pub fn open_vault(request: &OpenVault) -> OpenVaultResult { + let stored = match unlock_vault(&request.vault_id, &request.auth_pin) { + Ok(stored) => stored, + Err(err) => return err.into(), + }; + + OpenVaultResult::Opened(VaultDisplay::from(stored)) +} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/save_onfido_check.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/save_onfido_check.rs similarity index 62% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/save_onfido_check.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/save_onfido_check.rs index 73d8eb8..9a3e6a5 100644 --- a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/save_onfido_check.rs +++ b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/save_onfido_check.rs @@ -1,13 +1,13 @@ use crate::schema::actions::{SaveOnfidoCheck, SaveOnfidoCheckResult}; -use crate::wallet_operations::store::{mutate_wallet, unlock_wallet}; +use crate::vault_operations::store::{mutate_vault, unlock_vault}; pub fn save_onfido_check(request: &SaveOnfidoCheck) -> SaveOnfidoCheckResult { - let stored = match unlock_wallet(&request.wallet_id, &request.auth_pin) { + let stored = match unlock_vault(&request.vault_id, &request.auth_pin) { Ok(ok) => ok, Err(err) => return err.into(), }; - match mutate_wallet(&stored.wallet_id, |mut stored| { + match mutate_vault(&stored.vault_id, |mut stored| { // FIXME: Avoid mut? stored.onfido_check_result = Some(request.check.clone()); stored @@ -15,7 +15,7 @@ pub fn save_onfido_check(request: &SaveOnfidoCheck) -> SaveOnfidoCheckResult { Ok(ok) => ok, Err(err) => return err.into(), } - .expect("save_onfido_check: wallet disappeared!"); + .expect("save_onfido_check: vault disappeared!"); SaveOnfidoCheckResult::Saved } diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/sign_transaction.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/sign_transaction.rs similarity index 81% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/sign_transaction.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/sign_transaction.rs index 1962acd..851e322 100644 --- a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/sign_transaction.rs +++ b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/sign_transaction.rs @@ -8,12 +8,12 @@ use crate::schema::actions::{ TransactionSigned, TransactionToSign, }; -use crate::wallet_operations::sign_transaction_algorand::sign_algorand; -use crate::wallet_operations::sign_transaction_xrpl::sign_xrpl; -use crate::wallet_operations::store::unlock_wallet; +use crate::vault_operations::sign_transaction_algorand::sign_algorand; +use crate::vault_operations::sign_transaction_xrpl::sign_xrpl; +use crate::vault_operations::store::unlock_vault; pub fn sign_transaction(request: &SignTransaction) -> SignTransactionResult { - let stored = match unlock_wallet(&request.wallet_id, &request.auth_pin) { + let stored = match unlock_vault(&request.vault_id, &request.auth_pin) { Ok(stored) => stored, Err(err) => return err.into(), }; diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/sign_transaction_algorand.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/sign_transaction_algorand.rs similarity index 98% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/sign_transaction_algorand.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/sign_transaction_algorand.rs index 01057df..e3a532f 100644 --- a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/sign_transaction_algorand.rs +++ b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/sign_transaction_algorand.rs @@ -4,7 +4,7 @@ use std::prelude::v1::String; use crate::schema::entities::AlgorandAccount; use crate::schema::types::Bytes; -use crate::wallet_operations::errors; +use crate::vault_operations::errors; pub(crate) fn sign_algorand( signing_account: &AlgorandAccount, diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/sign_transaction_xrpl.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/sign_transaction_xrpl.rs similarity index 100% rename from rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/sign_transaction_xrpl.rs rename to rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/sign_transaction_xrpl.rs diff --git a/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/store.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/store.rs new file mode 100644 index 0000000..7661b75 --- /dev/null +++ b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/store.rs @@ -0,0 +1,86 @@ +use std::io; +use std::prelude::v1::Box; + +use sgx_trts::memeq::ConsttimeMemEq; +use thiserror::Error; + +use crate::ported::kv_store::fs::{FsStore, SgxFiler}; +use crate::ported::kv_store::{Key, KvStore}; +use crate::schema::entities::VaultStorable; + +type VaultStore = FsStore; + +// FIXME: Hardcoded +pub const VAULT_STORE_DIR: &str = "vault_store"; + +pub fn vault_store() -> VaultStore { + FsStore::new(VAULT_STORE_DIR, SgxFiler) +} + +pub fn save_new_vault(new_vault: &VaultStorable) -> Result<(), io::Error> { + let mut store = vault_store(); + let key = &key_from_id(&new_vault.vault_id)?; + match store.try_insert(key, new_vault)? { + None => Ok(()), + Some(existing) => panic!( + "save_vault: key conflict! key = {:?}, existing owner = {:?}, new owner = {:?}", + key, existing.owner_name, new_vault.owner_name + ), + } +} + +/// Return `None` if `vault_id` not found. +pub fn load_vault(vault_id: &str) -> Result, io::Error> { + let store = vault_store(); + let key = &key_from_id(vault_id)?; + store.load(key) +} + +pub fn key_from_id(vault_id: &str) -> Result, io::Error> { + // XXX: Assume XRP address, for now. + let address = ripple_address_codec::decode_account_id(vault_id).map_err(|err| { + io::Error::new( + io::ErrorKind::InvalidInput, + format!("key_from_id failed for vault_id = {:?}: {}", vault_id, err), + ) + })?; + Ok(address.into()) +} + +/// Load and authenticate access to a vault. +pub fn unlock_vault(vault_id: &str, auth_pin: &str) -> Result { + let stored: VaultStorable = load_vault(vault_id)?.ok_or(UnlockVaultError::InvalidVaultId)?; + + match ConsttimeMemEq::consttime_memeq(stored.auth_pin.as_bytes(), auth_pin.as_bytes()) { + true => Ok(stored), + false => Err(UnlockVaultError::InvalidAuthPin), + } +} + +/// [`unlock_vault`] failed. +/// +/// # Security note +/// +/// This representation distinguishes `InvalidVaultId` and `InvalidAuthPin`, +/// but this distinction should be limited to internal interfaces: +/// public interfaces should combine invalid authentication cases to avoid information leakage. +#[derive(Debug, Error)] +pub enum UnlockVaultError { + #[error("invalid vault ID provided")] + InvalidVaultId, + + #[error("invalid authentication PIN provided")] + InvalidAuthPin, + + #[error("I/O error while opening vault")] + IoError(#[from] io::Error), +} + +pub fn mutate_vault( + vault_id: &str, + mutate_fn: impl FnOnce(VaultStorable) -> VaultStorable, +) -> Result, io::Error> { + let mut store = vault_store(); + let key = &key_from_id(vault_id)?; + store.mutate(key, mutate_fn) +} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/dispatch.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/dispatch.rs deleted file mode 100644 index 86f5eab..0000000 --- a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/dispatch.rs +++ /dev/null @@ -1,115 +0,0 @@ -use std::error::Error; -use std::prelude::v1::Box; - -use secrecy::{ExposeSecret, Secret}; - -use crate::ported::crypto::SecretBytes; -use crate::schema::actions::{WalletRequest, WalletResponse}; -use crate::schema::msgpack::{FromMessagePack, ToMessagePack}; -use crate::schema::sealing::{seal_from_enclave, unseal_to_enclave, SealedMessage}; -use crate::wallet_operations::create_wallet::create_wallet; -use crate::wallet_operations::errors; -use crate::wallet_operations::load_onfido_check::load_onfido_check; -use crate::wallet_operations::open_wallet::open_wallet; -use crate::wallet_operations::save_onfido_check::save_onfido_check; -use crate::wallet_operations::sign_transaction::sign_transaction; - -/// Implementation for [`crate::ecalls::wallet_operation::wallet_operation`]. -/// -/// This processes an exchange of the following: -/// -/// Request: [`SealedMessage`] of [`WalletRequest`] -/// -/// Response: [`SealedMessage`] of [`WalletResponse`] -/// -pub fn wallet_operation_impl(sealed_request_bytes: &[u8]) -> Box<[u8]> { - match wallet_operation_impl_sealing(sealed_request_bytes) { - Ok(sealed_response_bytes) => sealed_response_bytes, - Err(error) => panic!("{}", error), // FIXME: better reporting - } -} - -/// Handle sealing and unsealing the exchange. -fn wallet_operation_impl_sealing(sealed_request_bytes: &[u8]) -> Result, Box> { - // Unseal request - let sealed_request = &SealedMessage::from_msgpack(sealed_request_bytes).map_err(|err| { - errors::message_with_base64( - "wallet_operation_impl_sealing", - "failed to unpack received sealed request", - err, - "sealed request msgpack", - sealed_request_bytes, - ) - })?; - let request_bytes = &unseal_to_enclave(sealed_request).map_err(|err| { - errors::message_with_debug_value( - "wallet_operation_impl_sealing", - "failed to unseal request", - err, - "sealed request", - sealed_request, - ) - })?; - let wallet_request = &Secret::new( - WalletRequest::from_msgpack(request_bytes.expose_secret()).map_err(|err| { - errors::message_with_base64( - "wallet_operation_impl_sealing", - "invalid WalletReq", - err, - "unsealed WalletRequest msgpack", - request_bytes.expose_secret(), - ) - })?, - ); - - // Dispatch - let wallet_response = wallet_operation_impl_dispatch(wallet_request.expose_secret()); - - // Seal response - let response_bytes = &SecretBytes::new(wallet_response.to_msgpack().map_err(|err| { - errors::message_with_debug_value( - "wallet_operation_impl_sealing", - "failed to msgpack WalletResponse-to-seal", - err, - "unsealed WalletResponse", - wallet_response, - ) - })?); - let sealed_response = seal_from_enclave(response_bytes, &sealed_request.sender_public_key) - .map_err(|err| { - errors::message_with_base64( - "wallet_operation_impl_sealing", - "failed to seal packed WalletResponse", - err, - "unsealed WalletResponse msgpack", - response_bytes.expose_secret(), - ) - })?; - let sealed_response_bytes = sealed_response.to_msgpack().map_err(|err| { - errors::message_with_debug_value( - "wallet_operation_impl_sealing", - "failed to msgpack sealed WalletRequest", - err, - "sealed response", - sealed_response, - ) - })?; - Ok(sealed_response_bytes) -} - -/// Handle dispatching the exchange. -fn wallet_operation_impl_dispatch(wallet_request: &WalletRequest) -> WalletResponse { - if cfg!(feature = "verbose-debug-logging") { - println!( - "DEBUG: wallet_operation_impl_dispatch: dispatching wallet_request = \n{:#?}", - wallet_request - ); - } - match wallet_request { - WalletRequest::CreateWallet(request) => create_wallet(request).into(), - WalletRequest::OpenWallet(request) => open_wallet(request).into(), - WalletRequest::SignTransaction(request) => sign_transaction(request).into(), - WalletRequest::SaveOnfidoCheck(request) => save_onfido_check(request).into(), - WalletRequest::LoadOnfidoCheck(request) => load_onfido_check(request).into(), - } -} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/open_wallet.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/open_wallet.rs deleted file mode 100644 index 1990be7..0000000 --- a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/open_wallet.rs +++ /dev/null @@ -1,12 +0,0 @@ -use crate::schema::actions::{OpenWallet, OpenWalletResult}; -use crate::schema::entities::WalletDisplay; -use crate::wallet_operations::store::unlock_wallet; - -pub fn open_wallet(request: &OpenWallet) -> OpenWalletResult { - let stored = match unlock_wallet(&request.wallet_id, &request.auth_pin) { - Ok(stored) => stored, - Err(err) => return err.into(), - }; - - OpenWalletResult::Opened(WalletDisplay::from(stored)) -} diff --git a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/store.rs b/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/store.rs deleted file mode 100644 index 78c3c0b..0000000 --- a/rust-sgx-workspace/crates/sgx-wallet-impl/src/wallet_operations/store.rs +++ /dev/null @@ -1,90 +0,0 @@ -use std::io; -use std::prelude::v1::Box; - -use sgx_trts::memeq::ConsttimeMemEq; -use thiserror::Error; - -use crate::ported::kv_store::fs::{FsStore, SgxFiler}; -use crate::ported::kv_store::{Key, KvStore}; -use crate::schema::entities::WalletStorable; - -type WalletStore = FsStore; - -// FIXME: Hardcoded -pub const WALLET_STORE_DIR: &str = "wallet_store"; - -pub fn wallet_store() -> WalletStore { - FsStore::new(WALLET_STORE_DIR, SgxFiler) -} - -pub fn save_new_wallet(new_wallet: &WalletStorable) -> Result<(), io::Error> { - let mut store = wallet_store(); - let key = &key_from_id(&new_wallet.wallet_id)?; - match store.try_insert(key, new_wallet)? { - None => Ok(()), - Some(existing) => panic!( - "save_wallet: key conflict! key = {:?}, existing owner = {:?}, new owner = {:?}", - key, existing.owner_name, new_wallet.owner_name - ), - } -} - -/// Return `None` if `wallet_id` not found. -pub fn load_wallet(wallet_id: &str) -> Result, io::Error> { - let store = wallet_store(); - let key = &key_from_id(wallet_id)?; - store.load(key) -} - -pub fn key_from_id(wallet_id: &str) -> Result, io::Error> { - // XXX: Assume XRP address, for now. - let address = ripple_address_codec::decode_account_id(wallet_id).map_err(|err| { - io::Error::new( - io::ErrorKind::InvalidInput, - format!( - "key_from_id failed for wallet_id = {:?}: {}", - wallet_id, err - ), - ) - })?; - Ok(address.into()) -} - -/// Load and authenticate access to a wallet. -pub fn unlock_wallet(wallet_id: &str, auth_pin: &str) -> Result { - let stored: WalletStorable = - load_wallet(wallet_id)?.ok_or(UnlockWalletError::InvalidWalletId)?; - - match ConsttimeMemEq::consttime_memeq(stored.auth_pin.as_bytes(), auth_pin.as_bytes()) { - true => Ok(stored), - false => Err(UnlockWalletError::InvalidAuthPin), - } -} - -/// [`unlock_wallet`] failed. -/// -/// # Security note -/// -/// This representation distinguishes `InvalidWalletId` and `InvalidAuthPin`, -/// but this distinction should be limited to internal interfaces: -/// public interfaces should combine invalid authentication cases to avoid information leakage. -#[derive(Debug, Error)] -pub enum UnlockWalletError { - #[error("invalid wallet ID provided")] - InvalidWalletId, - - #[error("invalid authentication PIN provided")] - InvalidAuthPin, - - #[error("I/O error while opening wallet")] - IoError(#[from] io::Error), -} - -pub fn mutate_wallet( - wallet_id: &str, - mutate_fn: impl FnOnce(WalletStorable) -> WalletStorable, -) -> Result, io::Error> { - let mut store = wallet_store(); - let key = &key_from_id(wallet_id)?; - store.mutate(key, mutate_fn) -} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/.gitignore b/rust-sgx-workspace/projects/sgx-vault-test/.gitignore similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet-test/.gitignore rename to rust-sgx-workspace/projects/sgx-vault-test/.gitignore diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/Makefile b/rust-sgx-workspace/projects/sgx-vault-test/Makefile similarity index 95% rename from rust-sgx-workspace/projects/sgx-wallet-test/Makefile rename to rust-sgx-workspace/projects/sgx-vault-test/Makefile index 56fe048..8324b02 100644 --- a/rust-sgx-workspace/projects/sgx-wallet-test/Makefile +++ b/rust-sgx-workspace/projects/sgx-vault-test/Makefile @@ -47,4 +47,4 @@ re: fclean all .PHONY: run run: all - @(cd build/bin && ./sgx-wallet-test-app) + @(cd build/bin && ./sgx-vault-test-app) diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/Makefile.toml b/rust-sgx-workspace/projects/sgx-vault-test/Makefile.toml similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet-test/Makefile.toml rename to rust-sgx-workspace/projects/sgx-vault-test/Makefile.toml diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/app/.gitignore b/rust-sgx-workspace/projects/sgx-vault-test/app/.gitignore similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet-test/app/.gitignore rename to rust-sgx-workspace/projects/sgx-vault-test/app/.gitignore diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/app/Cargo.lock b/rust-sgx-workspace/projects/sgx-vault-test/app/Cargo.lock similarity index 96% rename from rust-sgx-workspace/projects/sgx-wallet-test/app/Cargo.lock rename to rust-sgx-workspace/projects/sgx-vault-test/app/Cargo.lock index 42f5325..41263e0 100644 --- a/rust-sgx-workspace/projects/sgx-wallet-test/app/Cargo.lock +++ b/rust-sgx-workspace/projects/sgx-vault-test/app/Cargo.lock @@ -9,7 +9,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790" [[package]] -name = "sgx-wallet-test-app" +name = "sgx-vault-test-app" version = "0.1.0" dependencies = [ "sgx_types", diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/app/Cargo.toml b/rust-sgx-workspace/projects/sgx-vault-test/app/Cargo.toml similarity index 93% rename from rust-sgx-workspace/projects/sgx-wallet-test/app/Cargo.toml rename to rust-sgx-workspace/projects/sgx-vault-test/app/Cargo.toml index 562563f..aa73bd0 100644 --- a/rust-sgx-workspace/projects/sgx-wallet-test/app/Cargo.toml +++ b/rust-sgx-workspace/projects/sgx-vault-test/app/Cargo.toml @@ -1,6 +1,6 @@ [package] # name matches APP_U in Makefile -name = "sgx-wallet-test-app" +name = "sgx-vault-test-app" version = "0.1.0" edition = "2021" build = "build.rs" diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/app/Makefile b/rust-sgx-workspace/projects/sgx-vault-test/app/Makefile similarity index 99% rename from rust-sgx-workspace/projects/sgx-wallet-test/app/Makefile rename to rust-sgx-workspace/projects/sgx-vault-test/app/Makefile index 926a771..c9e300d 100644 --- a/rust-sgx-workspace/projects/sgx-wallet-test/app/Makefile +++ b/rust-sgx-workspace/projects/sgx-vault-test/app/Makefile @@ -3,7 +3,7 @@ LIB = ../build/lib/ BIN = ../build/bin/ # APP_U matches name in Cargo.toml -APP_U = sgx-wallet-test-app +APP_U = sgx-vault-test-app APP_T = enclave.so NAME_U = libEnclave_u.a SRC_U = ./ diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/app/build.rs b/rust-sgx-workspace/projects/sgx-vault-test/app/build.rs similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet-test/app/build.rs rename to rust-sgx-workspace/projects/sgx-vault-test/app/build.rs diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/app/codegen/Enclave_u.c b/rust-sgx-workspace/projects/sgx-vault-test/app/codegen/Enclave_u.c similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet-test/app/codegen/Enclave_u.c rename to rust-sgx-workspace/projects/sgx-vault-test/app/codegen/Enclave_u.c diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/app/codegen/Enclave_u.h b/rust-sgx-workspace/projects/sgx-vault-test/app/codegen/Enclave_u.h similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet-test/app/codegen/Enclave_u.h rename to rust-sgx-workspace/projects/sgx-vault-test/app/codegen/Enclave_u.h diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/app/codegen/Enclave_u.rs b/rust-sgx-workspace/projects/sgx-vault-test/app/codegen/Enclave_u.rs similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet-test/app/codegen/Enclave_u.rs rename to rust-sgx-workspace/projects/sgx-vault-test/app/codegen/Enclave_u.rs diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/app/src/main.rs b/rust-sgx-workspace/projects/sgx-vault-test/app/src/main.rs similarity index 88% rename from rust-sgx-workspace/projects/sgx-wallet-test/app/src/main.rs rename to rust-sgx-workspace/projects/sgx-vault-test/app/src/main.rs index 45effdf..155611f 100644 --- a/rust-sgx-workspace/projects/sgx-wallet-test/app/src/main.rs +++ b/rust-sgx-workspace/projects/sgx-vault-test/app/src/main.rs @@ -33,9 +33,9 @@ fn init_enclave() -> SgxResult { fn main() -> Result<(), String> { let enclave = init_enclave().map_err(|err| format!("init_enclave failed: {:?}", err))?; - // FIXME: See WALLET_STORE_DIR - create_dir_all("wallet_store") - .map_err(|err| format!("failed to create test wallet_store directory: {:?}", err))?; + // FIXME: See VAULT_STORE_DIR + create_dir_all("vault_store") + .map_err(|err| format!("failed to create test vault_store directory: {:?}", err))?; let failed_tests = safe_run_tests_ecall(enclave.geteid()) .map_err(|err| format!("run_tests_ecall failed: {:?}", err))?; diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/app/src/safe_ecalls.rs b/rust-sgx-workspace/projects/sgx-vault-test/app/src/safe_ecalls.rs similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet-test/app/src/safe_ecalls.rs rename to rust-sgx-workspace/projects/sgx-vault-test/app/src/safe_ecalls.rs diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/buildenv.mk b/rust-sgx-workspace/projects/sgx-vault-test/buildenv.mk similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet-test/buildenv.mk rename to rust-sgx-workspace/projects/sgx-vault-test/buildenv.mk diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/buildenv_sgx.mk b/rust-sgx-workspace/projects/sgx-vault-test/buildenv_sgx.mk similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet-test/buildenv_sgx.mk rename to rust-sgx-workspace/projects/sgx-vault-test/buildenv_sgx.mk diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/.gitignore b/rust-sgx-workspace/projects/sgx-vault-test/enclave/.gitignore similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/.gitignore rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/.gitignore diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Cargo.lock b/rust-sgx-workspace/projects/sgx-vault-test/enclave/Cargo.lock similarity index 99% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/Cargo.lock rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/Cargo.lock index c5d0123..ea2a785 100644 --- a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Cargo.lock +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/Cargo.lock @@ -792,7 +792,7 @@ dependencies = [ ] [[package]] -name = "sgx-wallet-impl" +name = "sgx-vault-impl" version = "0.1.0" dependencies = [ "algonaut", @@ -817,7 +817,7 @@ dependencies = [ ] [[package]] -name = "sgx-wallet-test-enclave" +name = "sgx-vault-test-enclave" version = "0.1.0" dependencies = [ "algonaut", @@ -826,7 +826,7 @@ dependencies = [ "secrecy", "serde", "serde_json", - "sgx-wallet-impl", + "sgx-vault-impl", "sgx_rand", "sgx_tcrypto", "sgx_tstd", diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Cargo.toml b/rust-sgx-workspace/projects/sgx-vault-test/enclave/Cargo.toml similarity index 95% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/Cargo.toml rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/Cargo.toml index c389a1a..3a73749 100644 --- a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Cargo.toml +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/Cargo.toml @@ -1,6 +1,6 @@ [package] # name matches ENCLAVE_CARGO_LIB in Makefile -name = "sgx-wallet-test-enclave" +name = "sgx-vault-test-enclave" version = "0.1.0" edition = "2021" @@ -32,7 +32,7 @@ serde_json = { git = "https://github.com/mesalock-linux/serde-json-sgx" } # Our SGX forks algonaut = { git = "https://github.com/registreerocks/algonaut-sgx", branch = "main-sgx" } -sgx-wallet-impl = { path = "../../../crates/sgx-wallet-impl" } +sgx-vault-impl = { path = "../../../crates/sgx-vault-impl" } # Test-only # Docs: https://altsysrq.github.io/proptest-book/proptest/no-std.html diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Enclave.config.xml b/rust-sgx-workspace/projects/sgx-vault-test/enclave/Enclave.config.xml similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/Enclave.config.xml rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/Enclave.config.xml diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Enclave.edl b/rust-sgx-workspace/projects/sgx-vault-test/enclave/Enclave.edl similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/Enclave.edl rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/Enclave.edl diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Enclave.lds b/rust-sgx-workspace/projects/sgx-vault-test/enclave/Enclave.lds similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/Enclave.lds rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/Enclave.lds diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Makefile b/rust-sgx-workspace/projects/sgx-vault-test/enclave/Makefile similarity index 97% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/Makefile rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/Makefile index 2cafc8c..c25808e 100644 --- a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/Makefile +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/Makefile @@ -26,7 +26,7 @@ SGX_ARCH = x64 TRTS_LIB = sgx_trts SERVICE_LIB = sgx_tservice # ENCLAVE_CARGO_LIB matches name in Cargo.toml -ENCLAVE_CARGO_LIB=libsgx_wallet_test_enclave.a +ENCLAVE_CARGO_LIB=libsgx_vault_test_enclave.a # Addprefix dependant variables, no need to change those OUTPUT_T = $(FILES_T:.c=.o) NAME = $(addprefix $(BIN), $(APP_T_SIGNED)) @@ -39,7 +39,7 @@ FILES_T_F_RUST=$(addprefix $(SRC_T), $(FILES_T_RUST)) OUTPUT_W_FT=$(addprefix $(OBJ_T), $(OUTPUT_T)) # All Rust and other source files that the Cargo build depends on. -FILES_RUST_F = Cargo.toml Cargo.lock $(shell find src ../../../crates/sgx-wallet-impl/src -name '*.rs') +FILES_RUST_F = Cargo.toml Cargo.lock $(shell find src ../../../crates/sgx-vault-impl/src -name '*.rs') # Contains compilation rules for the enclave part diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/codegen/Enclave_t.c b/rust-sgx-workspace/projects/sgx-vault-test/enclave/codegen/Enclave_t.c similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/codegen/Enclave_t.c rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/codegen/Enclave_t.c diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/codegen/Enclave_t.h b/rust-sgx-workspace/projects/sgx-vault-test/enclave/codegen/Enclave_t.h similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/codegen/Enclave_t.h rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/codegen/Enclave_t.h diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/algonaut.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/helpers/algonaut.rs similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/algonaut.rs rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/src/helpers/algonaut.rs diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/mod.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/helpers/mod.rs similarity index 63% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/mod.rs rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/src/helpers/mod.rs index 90d64a1..1314664 100644 --- a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/mod.rs +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/helpers/mod.rs @@ -1,3 +1,3 @@ pub(crate) mod algonaut; pub(crate) mod temp_dir; -pub(crate) mod wallet_store; +pub(crate) mod vault_store; diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/temp_dir.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/helpers/temp_dir.rs similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/temp_dir.rs rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/src/helpers/temp_dir.rs diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/wallet_store.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/helpers/vault_store.rs similarity index 56% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/wallet_store.rs rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/src/helpers/vault_store.rs index 2750988..916e160 100644 --- a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/helpers/wallet_store.rs +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/helpers/vault_store.rs @@ -1,34 +1,34 @@ use std::prelude::v1::ToString; -use sgx_wallet_impl::schema::actions; -use sgx_wallet_impl::schema::actions::{ - CreateWalletResult, +use sgx_vault_impl::schema::actions; +use sgx_vault_impl::schema::actions::{ + CreateVaultResult, LoadOnfidoCheck, LoadOnfidoCheckResult, OnfidoCheckResult, SaveOnfidoCheck, SaveOnfidoCheckResult, }; -use sgx_wallet_impl::schema::entities::WalletDisplay; -use sgx_wallet_impl::wallet_operations::create_wallet::create_wallet; -use sgx_wallet_impl::wallet_operations::load_onfido_check::load_onfido_check; -use sgx_wallet_impl::wallet_operations::save_onfido_check::save_onfido_check; +use sgx_vault_impl::schema::entities::VaultDisplay; +use sgx_vault_impl::vault_operations::create_vault::create_vault; +use sgx_vault_impl::vault_operations::load_onfido_check::load_onfido_check; +use sgx_vault_impl::vault_operations::save_onfido_check::save_onfido_check; -pub fn create_test_wallet() -> WalletDisplay { - type Result = CreateWalletResult; +pub fn create_test_vault() -> VaultDisplay { + type Result = CreateVaultResult; - let request = &actions::CreateWallet { + let request = &actions::CreateVault { owner_name: "New Owner".to_string(), auth_pin: "123456".to_string(), phone_number: None, }; - match create_wallet(request) { + match create_vault(request) { Result::Created(created) => created, otherwise => panic!("{:?}", otherwise), } } -pub fn create_test_check(existing: &WalletDisplay) -> OnfidoCheckResult { +pub fn create_test_check(existing: &VaultDisplay) -> OnfidoCheckResult { let check = OnfidoCheckResult { id: "stub id".to_string(), href: "stub href".to_string(), @@ -36,7 +36,7 @@ pub fn create_test_check(existing: &WalletDisplay) -> OnfidoCheckResult { sub_result: None, }; match save_onfido_check(&SaveOnfidoCheck { - wallet_id: existing.wallet_id.clone(), + vault_id: existing.vault_id.clone(), auth_pin: "123456".to_string(), check: check.clone(), }) { @@ -46,9 +46,9 @@ pub fn create_test_check(existing: &WalletDisplay) -> OnfidoCheckResult { check } -pub fn load_test_check(existing: &WalletDisplay) -> OnfidoCheckResult { +pub fn load_test_check(existing: &VaultDisplay) -> OnfidoCheckResult { match load_onfido_check(&LoadOnfidoCheck { - wallet_id: existing.wallet_id.clone(), + vault_id: existing.vault_id.clone(), auth_pin: "123456".to_string(), }) { LoadOnfidoCheckResult::Loaded(check) => check, diff --git a/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/lib.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/lib.rs new file mode 100644 index 0000000..57c2342 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/lib.rs @@ -0,0 +1,57 @@ +#![no_std] + +#[macro_use] +extern crate sgx_tstd as std; + +mod helpers; +mod ported; +mod schema; +mod vault_operations; + +use std::backtrace; +use std::string::String; +use std::vec::Vec; + +use sgx_tunittest::*; + +#[no_mangle] +pub extern "C" fn run_tests_ecall() -> usize { + backtrace::enable_backtrace("enclave.signed.so", backtrace::PrintFormat::Short).unwrap(); + + rsgx_unit_tests!( + ported::proptest_crypto::prop_soda_box_roundtrips, + ported::test_attestation::create_report_impl_works, + ported::test_crypto::soda_box_decrypt_works, + ported::test_crypto::soda_box_encrypt_works, + ported::test_kv_store::test_alter, + ported::test_kv_store::test_load_save_delete, + ported::test_kv_store::test_mutate, + ported::test_kv_store::test_try_insert, + ported::test_kv_store_fs::prop_fs_safe_roundtrip, + schema::test_sealing::prop_seal_unseal_msgpack_roundtrips, + schema::test_sealing::prop_seal_unseal_roundtrips, + schema::test_types::test_xrpl_key_type_serde, + vault_operations::test_create_vault::create_vault_works, + vault_operations::test_dispatch::vault_operation_sealing_works, + vault_operations::test_load_onfido_check::load_onfido_check_bad_pin, + vault_operations::test_load_onfido_check::load_onfido_check_malformed_vault_id, + vault_operations::test_load_onfido_check::load_onfido_check_not_found, + vault_operations::test_load_onfido_check::load_onfido_check_works, + vault_operations::test_open_vault::open_vault_bad_pin, + vault_operations::test_open_vault::open_vault_malformed_vault_id, + vault_operations::test_open_vault::open_vault_works, + vault_operations::test_save_onfido_check::save_onfido_check_bad_pin, + vault_operations::test_save_onfido_check::save_onfido_check_malformed_vault_id, + vault_operations::test_save_onfido_check::save_onfido_check_works, + vault_operations::test_sign_transaction::sign_transaction_empty, + vault_operations::test_sign_transaction::sign_transaction_malformed_transaction, + vault_operations::test_sign_transaction::sign_transaction_without_tag, + vault_operations::test_sign_transaction::sign_transaction_works, + vault_operations::test_sign_transaction_msgpack::prop_transaction_msgpack_roundtrips, + vault_operations::test_sign_transaction_xrpl::sign_transaction_empty, + vault_operations::test_store::unlock_vault_bad_auth_pin, + vault_operations::test_store::unlock_vault_malformed_vault_id, + vault_operations::test_store::unlock_vault_not_found, + vault_operations::test_store::unlock_vault_works, + ) +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/kv_store/tests.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/ported/kv_store/tests.rs similarity index 86% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/kv_store/tests.rs rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/src/ported/kv_store/tests.rs index b58a255..8a61a8d 100644 --- a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/kv_store/tests.rs +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/ported/kv_store/tests.rs @@ -2,8 +2,8 @@ use std::prelude::v1::*; -use sgx_wallet_impl::ported::kv_store::in_memory::{InMemoryStore, Never}; -use sgx_wallet_impl::ported::kv_store::KvStore; +use sgx_vault_impl::ported::kv_store::in_memory::{InMemoryStore, Never}; +use sgx_vault_impl::ported::kv_store::KvStore; pub(crate) fn test_mutate() -> Result<(), Never> { let mut store = InMemoryStore::default(); diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/mod.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/ported/mod.rs similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/mod.rs rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/src/ported/mod.rs diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/proptest_crypto.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/ported/proptest_crypto.rs similarity index 96% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/proptest_crypto.rs rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/src/ported/proptest_crypto.rs index 382829e..edd53b7 100644 --- a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/proptest_crypto.rs +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/ported/proptest_crypto.rs @@ -3,7 +3,7 @@ use std::format; use proptest::prelude::*; use secrecy::{ExposeSecret, Secret}; -use sgx_wallet_impl::ported::crypto::SodaBoxCrypto; +use sgx_vault_impl::ported::crypto::SodaBoxCrypto; /// Encrypt and decrypt a message using [`SodaBoxCrypto`]. pub(crate) fn prop_soda_box_roundtrips() { diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_attestation.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/ported/test_attestation.rs similarity index 84% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_attestation.rs rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/src/ported/test_attestation.rs index 1dcf8a7..90a6c03 100644 --- a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_attestation.rs +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/ported/test_attestation.rs @@ -1,7 +1,7 @@ use sgx_tcrypto::rsgx_sha256_slice; use sgx_types::sgx_target_info_t; -use sgx_wallet_impl::ported::attestation::create_report_impl; -use sgx_wallet_impl::ported::crypto::SodaBoxCrypto; +use sgx_vault_impl::ported::attestation::create_report_impl; +use sgx_vault_impl::ported::crypto::SodaBoxCrypto; pub fn create_report_impl_works() { let expected_public_key = SodaBoxCrypto::new().get_pubkey(); diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_crypto.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/ported/test_crypto.rs similarity index 98% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_crypto.rs rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/src/ported/test_crypto.rs index 748bed7..beaad7c 100644 --- a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_crypto.rs +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/ported/test_crypto.rs @@ -4,7 +4,7 @@ use std::ops::Deref; use std::vec; use secrecy::{ExposeSecret, Secret}; -use sgx_wallet_impl::ported::crypto::{ +use sgx_vault_impl::ported::crypto::{ SodaBoxCrypto, CRYPTO_BOX_BOXZEROBYTES, CRYPTO_BOX_ZEROBYTES, diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_kv_store.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/ported/test_kv_store.rs similarity index 95% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_kv_store.rs rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/src/ported/test_kv_store.rs index 9f8ff83..95bf5e8 100644 --- a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_kv_store.rs +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/ported/test_kv_store.rs @@ -1,7 +1,7 @@ use serde::de::DeserializeOwned; use serde::Serialize; -use sgx_wallet_impl::ported::kv_store::fs::{FsStore, SgxFiler}; -use sgx_wallet_impl::ported::kv_store::KvStore; +use sgx_vault_impl::ported::kv_store::fs::{FsStore, SgxFiler}; +use sgx_vault_impl::ported::kv_store::KvStore; use crate::helpers::temp_dir::TempDir; diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_kv_store_fs.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/ported/test_kv_store_fs.rs similarity index 87% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_kv_store_fs.rs rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/src/ported/test_kv_store_fs.rs index eb13e71..3bfa1e0 100644 --- a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/ported/test_kv_store_fs.rs +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/ported/test_kv_store_fs.rs @@ -1,8 +1,8 @@ use std::prelude::v1::*; use proptest::prelude::*; -use sgx_wallet_impl::ported::kv_store::fs::{decode_from_fs_safe, encode_to_fs_safe}; -use sgx_wallet_impl::ported::kv_store::Key; +use sgx_vault_impl::ported::kv_store::fs::{decode_from_fs_safe, encode_to_fs_safe}; +use sgx_vault_impl::ported::kv_store::Key; /// [`encode_to_fs_safe`] encodes to filesystem-safe, and [`decode_from_fs_safe`] round-trips. pub(crate) fn prop_fs_safe_roundtrip() { diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/schema/mod.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/schema/mod.rs similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/schema/mod.rs rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/src/schema/mod.rs diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/schema/test_sealing.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/schema/test_sealing.rs similarity index 92% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/schema/test_sealing.rs rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/src/schema/test_sealing.rs index 10260bb..8c318c0 100644 --- a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/schema/test_sealing.rs +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/schema/test_sealing.rs @@ -2,8 +2,8 @@ use std::boxed::Box; use proptest::prelude::*; use secrecy::{ExposeSecret, Secret}; -use sgx_wallet_impl::ported::crypto::{SecretBytes, SodaBoxCrypto}; -use sgx_wallet_impl::schema::sealing::{seal, seal_msgpack, unseal, unseal_secret_msgpack}; +use sgx_vault_impl::ported::crypto::{SecretBytes, SodaBoxCrypto}; +use sgx_vault_impl::schema::sealing::{seal, seal_msgpack, unseal, unseal_secret_msgpack}; /// Roundtrip with [`seal`] and then [`unseal`]. pub(crate) fn prop_seal_unseal_roundtrips() { diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/schema/test_types.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/schema/test_types.rs similarity index 86% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/schema/test_types.rs rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/src/schema/test_types.rs index 60202cd..41dd896 100644 --- a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/schema/test_types.rs +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/schema/test_types.rs @@ -1,7 +1,7 @@ -//! Test [`sgx_wallet_impl::schema::types`] +//! Test [`sgx_vault_impl::schema::types`] use serde_json::Value; -use sgx_wallet_impl::schema::types::XrplKeyType; +use sgx_vault_impl::schema::types::XrplKeyType; /// [`XrplKeyType`] serializes to the same lowercase string constants used throughout the XRP Ledger. pub(crate) fn test_xrpl_key_type_serde() { diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/mod.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/mod.rs similarity index 79% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/mod.rs rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/mod.rs index 7bde76c..fc69779 100644 --- a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/mod.rs +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/mod.rs @@ -1,7 +1,7 @@ -pub(crate) mod test_create_wallet; +pub(crate) mod test_create_vault; pub(crate) mod test_dispatch; pub(crate) mod test_load_onfido_check; -pub(crate) mod test_open_wallet; +pub(crate) mod test_open_vault; pub(crate) mod test_save_onfido_check; pub(crate) mod test_sign_transaction; pub(crate) mod test_sign_transaction_msgpack; diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_create_wallet.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_create_vault.rs similarity index 58% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_create_wallet.rs rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_create_vault.rs index 4f60da1..bac2ef3 100644 --- a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_create_wallet.rs +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_create_vault.rs @@ -1,26 +1,26 @@ use std::prelude::v1::ToString; -use sgx_wallet_impl::schema::actions; -use sgx_wallet_impl::schema::actions::CreateWalletResult as Result; -use sgx_wallet_impl::schema::entities::XrplAccountDisplay; -use sgx_wallet_impl::wallet_operations::create_wallet::create_wallet; -use sgx_wallet_impl::wallet_operations::store::load_wallet; +use sgx_vault_impl::schema::actions; +use sgx_vault_impl::schema::actions::CreateVaultResult as Result; +use sgx_vault_impl::schema::entities::XrplAccountDisplay; +use sgx_vault_impl::vault_operations::create_vault::create_vault; +use sgx_vault_impl::vault_operations::store::load_vault; -pub(crate) fn create_wallet_works() { - let request = &actions::CreateWallet { +pub(crate) fn create_vault_works() { + let request = &actions::CreateVault { owner_name: "New Owner".to_string(), auth_pin: "123456".to_string(), phone_number: None, }; - let display = &match create_wallet(request) { + let display = &match create_vault(request) { Result::Created(created) => created, Result::Failed(failed) => panic!("{}", failed), }; assert_eq!(display.owner_name, request.owner_name); - let stored = load_wallet(&display.wallet_id).unwrap().unwrap(); - assert_eq!(display.wallet_id, stored.wallet_id); + let stored = load_vault(&display.vault_id).unwrap().unwrap(); + assert_eq!(display.vault_id, stored.vault_id); assert_eq!(display.owner_name, stored.owner_name); assert_eq!( display.algorand_address_base32, diff --git a/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_dispatch.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_dispatch.rs new file mode 100644 index 0000000..9593b10 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_dispatch.rs @@ -0,0 +1,35 @@ +use std::prelude::v1::ToString; + +use sgx_vault_impl::ported::crypto::SodaBoxCrypto; +use sgx_vault_impl::schema::actions::{OpenVault, OpenVaultResult, VaultRequest, VaultResponse}; +use sgx_vault_impl::schema::sealing::{seal_msgpack, unseal_non_secret_msgpack}; +use sgx_vault_impl::vault_operations::dispatch::vault_operation_impl; + +pub(crate) fn vault_operation_sealing_works() { + let client_crypto = &mut SodaBoxCrypto::from_seed([0; 32]); + let enclave_crypto = SodaBoxCrypto::new(); + + // Seal + let vault_request = &VaultRequest::OpenVault(OpenVault { + vault_id: "123456".to_string(), + auth_pin: "1234".to_string(), + }); + let sealed_request_bytes = + &seal_msgpack(vault_request, &enclave_crypto.get_pubkey(), client_crypto).unwrap(); + + // Call + let sealed_response_bytes = &vault_operation_impl(sealed_request_bytes); + + // Unseal + let unsealed_message: VaultResponse = + unseal_non_secret_msgpack(sealed_response_bytes, client_crypto).unwrap(); + + // Check + assert_eq!( + unsealed_message, + OpenVaultResult::Failed( + "key_from_id failed for vault_id = \"123456\": decode error".to_string() + ) + .into() + ); +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_load_onfido_check.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_load_onfido_check.rs similarity index 63% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_load_onfido_check.rs rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_load_onfido_check.rs index fbeaf0a..6a2080a 100644 --- a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_load_onfido_check.rs +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_load_onfido_check.rs @@ -1,18 +1,18 @@ use std::prelude::v1::ToString; -use sgx_wallet_impl::schema::actions; -use sgx_wallet_impl::schema::actions::LoadOnfidoCheckResult; -use sgx_wallet_impl::wallet_operations::load_onfido_check::load_onfido_check; +use sgx_vault_impl::schema::actions; +use sgx_vault_impl::schema::actions::LoadOnfidoCheckResult; +use sgx_vault_impl::vault_operations::load_onfido_check::load_onfido_check; -use crate::helpers::wallet_store; -use crate::helpers::wallet_store::create_test_wallet; +use crate::helpers::vault_store; +use crate::helpers::vault_store::create_test_vault; pub(crate) fn load_onfido_check_works() { - let existing = create_test_wallet(); - let existing_check = wallet_store::create_test_check(&existing); + let existing = create_test_vault(); + let existing_check = vault_store::create_test_check(&existing); let request = actions::LoadOnfidoCheck { - wallet_id: existing.wallet_id, + vault_id: existing.vault_id, auth_pin: "123456".to_string(), }; let loaded_check = match load_onfido_check(&request) { @@ -24,10 +24,10 @@ pub(crate) fn load_onfido_check_works() { } pub(crate) fn load_onfido_check_not_found() { - let existing = create_test_wallet(); + let existing = create_test_vault(); let request = actions::LoadOnfidoCheck { - wallet_id: existing.wallet_id.clone(), + vault_id: existing.vault_id.clone(), auth_pin: "123456".to_string(), }; match load_onfido_check(&request) { @@ -36,9 +36,9 @@ pub(crate) fn load_onfido_check_not_found() { }; } -pub(crate) fn load_onfido_check_malformed_wallet_id() { +pub(crate) fn load_onfido_check_malformed_vault_id() { let request = actions::LoadOnfidoCheck { - wallet_id: "malformed".to_string(), + vault_id: "malformed".to_string(), auth_pin: "123456".to_string(), }; @@ -49,10 +49,10 @@ pub(crate) fn load_onfido_check_malformed_wallet_id() { } pub(crate) fn load_onfido_check_bad_pin() { - let existing = create_test_wallet(); + let existing = create_test_vault(); let request = actions::LoadOnfidoCheck { - wallet_id: existing.wallet_id.clone(), + vault_id: existing.vault_id.clone(), auth_pin: "000000".to_string(), }; diff --git a/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_open_vault.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_open_vault.rs new file mode 100644 index 0000000..6e1065b --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_open_vault.rs @@ -0,0 +1,50 @@ +use std::prelude::v1::ToString; + +use sgx_vault_impl::schema::actions; +use sgx_vault_impl::schema::actions::OpenVaultResult; +use sgx_vault_impl::vault_operations::open_vault::open_vault; + +use crate::helpers::vault_store; + +type Result = OpenVaultResult; + +pub(crate) fn open_vault_works() { + let existing = &vault_store::create_test_vault(); + + let request = &actions::OpenVault { + vault_id: existing.vault_id.clone(), + auth_pin: "123456".to_string(), + }; + let display = &match open_vault(request) { + Result::Opened(opened) => opened, + otherwise => panic!("{:?}", otherwise), + }; + + assert_eq!(display, existing); +} + +pub(crate) fn open_vault_malformed_vault_id() { + let request = &actions::OpenVault { + vault_id: "malformed".to_string(), + auth_pin: "123456".to_string(), + }; + + match open_vault(request) { + Result::Failed(_) => (), + otherwise => panic!("{:?}", otherwise), + } +} + +pub(crate) fn open_vault_bad_pin() { + let existing = &vault_store::create_test_vault(); + + let request = &actions::OpenVault { + vault_id: existing.vault_id.clone(), + auth_pin: "000000".to_string(), + }; + + match open_vault(request) { + Result::InvalidAuth => (), + otherwise => panic!("{:?}", otherwise), + } +} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_save_onfido_check.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_save_onfido_check.rs similarity index 65% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_save_onfido_check.rs rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_save_onfido_check.rs index 538fd4d..45843a4 100644 --- a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_save_onfido_check.rs +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_save_onfido_check.rs @@ -1,11 +1,11 @@ use std::prelude::v1::ToString; -use sgx_wallet_impl::schema::actions; -use sgx_wallet_impl::schema::actions::{OnfidoCheckResult, SaveOnfidoCheckResult}; -use sgx_wallet_impl::schema::types::WalletPin; -use sgx_wallet_impl::wallet_operations::save_onfido_check::save_onfido_check; +use sgx_vault_impl::schema::actions; +use sgx_vault_impl::schema::actions::{OnfidoCheckResult, SaveOnfidoCheckResult}; +use sgx_vault_impl::schema::types::VaultPin; +use sgx_vault_impl::vault_operations::save_onfido_check::save_onfido_check; -use crate::helpers::wallet_store::{create_test_wallet, load_test_check}; +use crate::helpers::vault_store::{create_test_vault, load_test_check}; fn get_check() -> OnfidoCheckResult { OnfidoCheckResult { @@ -17,12 +17,12 @@ fn get_check() -> OnfidoCheckResult { } pub(crate) fn save_onfido_check_works() { - let existing = create_test_wallet(); + let existing = create_test_vault(); let check = get_check(); let request = actions::SaveOnfidoCheck { - wallet_id: existing.wallet_id.clone(), - auth_pin: WalletPin::from("123456"), + vault_id: existing.vault_id.clone(), + auth_pin: VaultPin::from("123456"), check: check.clone(), }; match save_onfido_check(&request) { @@ -34,9 +34,9 @@ pub(crate) fn save_onfido_check_works() { assert_eq!(saved, check) } -pub(crate) fn save_onfido_check_malformed_wallet_id() { +pub(crate) fn save_onfido_check_malformed_vault_id() { let request = actions::SaveOnfidoCheck { - wallet_id: "malformed".into(), + vault_id: "malformed".into(), auth_pin: "123456".into(), check: get_check(), }; @@ -48,10 +48,10 @@ pub(crate) fn save_onfido_check_malformed_wallet_id() { } pub(crate) fn save_onfido_check_bad_pin() { - let existing = create_test_wallet(); + let existing = create_test_vault(); let request = actions::SaveOnfidoCheck { - wallet_id: existing.wallet_id, + vault_id: existing.vault_id, auth_pin: "000000".to_string(), check: get_check(), }; diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_sign_transaction.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_sign_transaction.rs similarity index 83% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_sign_transaction.rs rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_sign_transaction.rs index 746d495..224570e 100644 --- a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_sign_transaction.rs +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_sign_transaction.rs @@ -2,18 +2,18 @@ use std::prelude::v1::ToString; use algonaut::core::ToMsgPack; use algonaut::transaction::SignedTransaction as AlgonautSignedTransaction; -use sgx_wallet_impl::schema::actions; -use sgx_wallet_impl::schema::actions::{SignTransactionResult, TransactionToSign}; -use sgx_wallet_impl::schema::msgpack::FromMessagePack; -use sgx_wallet_impl::wallet_operations::sign_transaction::sign_transaction; +use sgx_vault_impl::schema::actions; +use sgx_vault_impl::schema::actions::{SignTransactionResult, TransactionToSign}; +use sgx_vault_impl::schema::msgpack::FromMessagePack; +use sgx_vault_impl::vault_operations::sign_transaction::sign_transaction; use crate::helpers::algonaut::create_test_transaction; -use crate::helpers::wallet_store::create_test_wallet; +use crate::helpers::vault_store::create_test_vault; type Result = SignTransactionResult; pub(crate) fn sign_transaction_works() { - let existing = &create_test_wallet(); + let existing = &create_test_vault(); let algonaut_transaction = create_test_transaction(); let transaction_bytes = algonaut_transaction @@ -23,7 +23,7 @@ pub(crate) fn sign_transaction_works() { let transaction_to_sign = TransactionToSign::AlgorandTransaction { transaction_bytes }; let request = &actions::SignTransaction { - wallet_id: existing.wallet_id.clone(), + vault_id: existing.vault_id.clone(), auth_pin: "123456".to_string(), transaction_to_sign, }; @@ -38,7 +38,7 @@ pub(crate) fn sign_transaction_works() { } pub(crate) fn sign_transaction_without_tag() { - let existing = &create_test_wallet(); + let existing = &create_test_vault(); let algonaut_transaction = create_test_transaction(); let transaction_bytes = algonaut_transaction @@ -48,7 +48,7 @@ pub(crate) fn sign_transaction_without_tag() { let transaction_to_sign = TransactionToSign::AlgorandTransaction { transaction_bytes }; let request = &actions::SignTransaction { - wallet_id: existing.wallet_id.clone(), + vault_id: existing.vault_id.clone(), auth_pin: "123456".to_string(), transaction_to_sign, }; @@ -68,13 +68,13 @@ pub(crate) fn sign_transaction_without_tag() { } pub(crate) fn sign_transaction_empty() { - let existing = &create_test_wallet(); + let existing = &create_test_vault(); let transaction_bytes = Default::default(); let transaction_to_sign = TransactionToSign::AlgorandTransaction { transaction_bytes }; let request = &actions::SignTransaction { - wallet_id: existing.wallet_id.clone(), + vault_id: existing.vault_id.clone(), auth_pin: "123456".to_string(), transaction_to_sign, }; @@ -92,13 +92,13 @@ pub(crate) fn sign_transaction_empty() { } pub(crate) fn sign_transaction_malformed_transaction() { - let existing = &create_test_wallet(); + let existing = &create_test_vault(); let transaction_bytes = "malformed".as_bytes().into(); let transaction_to_sign = TransactionToSign::AlgorandTransaction { transaction_bytes }; let request = &actions::SignTransaction { - wallet_id: existing.wallet_id.clone(), + vault_id: existing.vault_id.clone(), auth_pin: "123456".to_string(), transaction_to_sign, }; diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_sign_transaction_msgpack.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_sign_transaction_msgpack.rs similarity index 96% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_sign_transaction_msgpack.rs rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_sign_transaction_msgpack.rs index a985791..2b6be0e 100644 --- a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_sign_transaction_msgpack.rs +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_sign_transaction_msgpack.rs @@ -5,7 +5,7 @@ use algonaut::crypto::HashDigest; use algonaut::transaction::transaction::Payment; use algonaut::transaction::{Transaction, TransactionType}; use proptest::{prop_assume, proptest}; -use sgx_wallet_impl::wallet_operations::sign_transaction_algorand::algorand_network_compatible; +use sgx_vault_impl::vault_operations::sign_transaction_algorand::algorand_network_compatible; pub(crate) fn prop_transaction_msgpack_roundtrips() { proptest!( diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_sign_transaction_xrpl.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_sign_transaction_xrpl.rs similarity index 68% rename from rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_sign_transaction_xrpl.rs rename to rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_sign_transaction_xrpl.rs index 6adf56d..1f55333 100644 --- a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_sign_transaction_xrpl.rs +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_sign_transaction_xrpl.rs @@ -1,18 +1,18 @@ use std::prelude::v1::ToString; -use sgx_wallet_impl::schema::actions; -use sgx_wallet_impl::schema::actions::{TransactionSigned, TransactionToSign}; -use sgx_wallet_impl::wallet_operations::sign_transaction::sign_transaction; +use sgx_vault_impl::schema::actions; +use sgx_vault_impl::schema::actions::{TransactionSigned, TransactionToSign}; +use sgx_vault_impl::vault_operations::sign_transaction::sign_transaction; -use crate::helpers::wallet_store::create_test_wallet; +use crate::helpers::vault_store::create_test_vault; pub(crate) fn sign_transaction_empty() { - let existing = &create_test_wallet(); + let existing = &create_test_vault(); let transaction_bytes = Default::default(); let request = &actions::SignTransaction { - wallet_id: existing.wallet_id.clone(), + vault_id: existing.vault_id.clone(), auth_pin: "123456".to_string(), transaction_to_sign: TransactionToSign::XrplTransaction { transaction_bytes }, }; diff --git a/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_store.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_store.rs new file mode 100644 index 0000000..e3b9173 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_store.rs @@ -0,0 +1,37 @@ +//! Test [`sgx_vault_impl::vault_operations::store`] + +use std::prelude::v1::ToString; + +use sgx_vault_impl::ported::kv_store::KvStore; +use sgx_vault_impl::schema::entities::VaultDisplay; +use sgx_vault_impl::vault_operations::store::{key_from_id, unlock_vault, vault_store}; + +use crate::helpers::vault_store::create_test_vault; + +pub(crate) fn unlock_vault_works() { + let existing = create_test_vault(); + let stored = unlock_vault(&existing.vault_id, "123456").unwrap(); + assert_eq!(existing, VaultDisplay::from(stored)); +} + +pub(crate) fn unlock_vault_not_found() { + let existing = create_test_vault(); + let mut store = vault_store(); + let key = &key_from_id(&existing.vault_id).unwrap(); + store.delete(key).unwrap(); + + let err = unlock_vault(&existing.vault_id, "123456").unwrap_err(); + assert_eq!(err.to_string(), "invalid vault ID provided"); +} + +pub(crate) fn unlock_vault_malformed_vault_id() { + create_test_vault(); + let err = unlock_vault("malformed", "123456").unwrap_err(); + assert_eq!(err.to_string(), "I/O error while opening vault"); +} + +pub(crate) fn unlock_vault_bad_auth_pin() { + let existing = create_test_vault(); + let err = unlock_vault(&existing.vault_id, "000000").unwrap_err(); + assert_eq!(err.to_string(), "invalid authentication PIN provided"); +} diff --git a/rust-sgx-workspace/projects/sgx-wallet/.gitignore b/rust-sgx-workspace/projects/sgx-vault/.gitignore similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet/.gitignore rename to rust-sgx-workspace/projects/sgx-vault/.gitignore diff --git a/rust-sgx-workspace/projects/sgx-wallet/Makefile b/rust-sgx-workspace/projects/sgx-vault/Makefile similarity index 96% rename from rust-sgx-workspace/projects/sgx-wallet/Makefile rename to rust-sgx-workspace/projects/sgx-vault/Makefile index 3004958..0ec6556 100644 --- a/rust-sgx-workspace/projects/sgx-wallet/Makefile +++ b/rust-sgx-workspace/projects/sgx-vault/Makefile @@ -47,4 +47,4 @@ re: fclean all .PHONY: run run: all - @(cd build/bin && ./sgx-wallet-app) + @(cd build/bin && ./sgx-vault-app) diff --git a/rust-sgx-workspace/projects/sgx-wallet/Makefile.toml b/rust-sgx-workspace/projects/sgx-vault/Makefile.toml similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet/Makefile.toml rename to rust-sgx-workspace/projects/sgx-vault/Makefile.toml diff --git a/rust-sgx-workspace/projects/sgx-wallet/app/.gitignore b/rust-sgx-workspace/projects/sgx-vault/app/.gitignore similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet/app/.gitignore rename to rust-sgx-workspace/projects/sgx-vault/app/.gitignore diff --git a/rust-sgx-workspace/projects/sgx-wallet/app/Cargo.lock b/rust-sgx-workspace/projects/sgx-vault/app/Cargo.lock similarity index 99% rename from rust-sgx-workspace/projects/sgx-wallet/app/Cargo.lock rename to rust-sgx-workspace/projects/sgx-vault/app/Cargo.lock index 6ed2ef2..0b142de 100644 --- a/rust-sgx-workspace/projects/sgx-wallet/app/Cargo.lock +++ b/rust-sgx-workspace/projects/sgx-vault/app/Cargo.lock @@ -1128,7 +1128,7 @@ dependencies = [ ] [[package]] -name = "sgx-wallet-app" +name = "sgx-vault-app" version = "0.1.0" dependencies = [ "actix-web", diff --git a/rust-sgx-workspace/projects/sgx-wallet/app/Cargo.toml b/rust-sgx-workspace/projects/sgx-vault/app/Cargo.toml similarity index 96% rename from rust-sgx-workspace/projects/sgx-wallet/app/Cargo.toml rename to rust-sgx-workspace/projects/sgx-vault/app/Cargo.toml index 96777e6..85466e8 100644 --- a/rust-sgx-workspace/projects/sgx-wallet/app/Cargo.toml +++ b/rust-sgx-workspace/projects/sgx-vault/app/Cargo.toml @@ -1,6 +1,6 @@ [package] # name matches APP_U in Makefile -name = "sgx-wallet-app" +name = "sgx-vault-app" version = "0.1.0" edition = "2021" build = "build.rs" diff --git a/rust-sgx-workspace/projects/sgx-wallet/app/Makefile b/rust-sgx-workspace/projects/sgx-vault/app/Makefile similarity index 97% rename from rust-sgx-workspace/projects/sgx-wallet/app/Makefile rename to rust-sgx-workspace/projects/sgx-vault/app/Makefile index 935599d..3313bc1 100644 --- a/rust-sgx-workspace/projects/sgx-wallet/app/Makefile +++ b/rust-sgx-workspace/projects/sgx-vault/app/Makefile @@ -3,7 +3,7 @@ LIB = ../build/lib/ BIN = ../build/bin/ # APP_U matches name in Cargo.toml -APP_U = sgx-wallet-app +APP_U = sgx-vault-app APP_T = enclave.so NAME_U = libEnclave_u.a SRC_U = ./ @@ -72,7 +72,7 @@ $(CODEGEN_U)Enclave_u.rs: $(CODEGEN_U)Enclave_u.h @bindgen \ --no-recursive-allowlist \ --raw-line 'use sgx_types::*;' \ - --allowlist-function 'enclave_create_report|wallet_operation' \ + --allowlist-function 'enclave_create_report|vault_operation' \ --use-array-pointers-in-arguments \ --output $@ \ $? \ diff --git a/rust-sgx-workspace/projects/sgx-wallet/app/build.rs b/rust-sgx-workspace/projects/sgx-vault/app/build.rs similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet/app/build.rs rename to rust-sgx-workspace/projects/sgx-vault/app/build.rs diff --git a/rust-sgx-workspace/projects/sgx-wallet/app/codegen/Enclave_u.c b/rust-sgx-workspace/projects/sgx-vault/app/codegen/Enclave_u.c similarity index 99% rename from rust-sgx-workspace/projects/sgx-wallet/app/codegen/Enclave_u.c rename to rust-sgx-workspace/projects/sgx-vault/app/codegen/Enclave_u.c index 4d5b70d..9e3f65c 100644 --- a/rust-sgx-workspace/projects/sgx-wallet/app/codegen/Enclave_u.c +++ b/rust-sgx-workspace/projects/sgx-vault/app/codegen/Enclave_u.c @@ -8,14 +8,14 @@ typedef struct ms_enclave_create_report_t { uint8_t* ms_enclave_data; } ms_enclave_create_report_t; -typedef struct ms_wallet_operation_t { +typedef struct ms_vault_operation_t { sgx_status_t ms_retval; const uint8_t* ms_sealed_request_buffer; size_t ms_sealed_request_size; uint8_t* ms_sealed_response_buffer; size_t ms_sealed_response_capacity; size_t* ms_sealed_response_used; -} ms_wallet_operation_t; +} ms_vault_operation_t; typedef struct ms_t_global_init_ecall_t { uint64_t ms_id; @@ -1302,10 +1302,10 @@ sgx_status_t enclave_create_report(sgx_enclave_id_t eid, sgx_status_t* retval, c return status; } -sgx_status_t wallet_operation(sgx_enclave_id_t eid, sgx_status_t* retval, const uint8_t* sealed_request_buffer, size_t sealed_request_size, uint8_t* sealed_response_buffer, size_t sealed_response_capacity, size_t* sealed_response_used) +sgx_status_t vault_operation(sgx_enclave_id_t eid, sgx_status_t* retval, const uint8_t* sealed_request_buffer, size_t sealed_request_size, uint8_t* sealed_response_buffer, size_t sealed_response_capacity, size_t* sealed_response_used) { sgx_status_t status; - ms_wallet_operation_t ms; + ms_vault_operation_t ms; ms.ms_sealed_request_buffer = sealed_request_buffer; ms.ms_sealed_request_size = sealed_request_size; ms.ms_sealed_response_buffer = sealed_response_buffer; diff --git a/rust-sgx-workspace/projects/sgx-wallet/app/codegen/Enclave_u.h b/rust-sgx-workspace/projects/sgx-vault/app/codegen/Enclave_u.h similarity index 98% rename from rust-sgx-workspace/projects/sgx-wallet/app/codegen/Enclave_u.h rename to rust-sgx-workspace/projects/sgx-vault/app/codegen/Enclave_u.h index 255e58a..f12297a 100644 --- a/rust-sgx-workspace/projects/sgx-wallet/app/codegen/Enclave_u.h +++ b/rust-sgx-workspace/projects/sgx-vault/app/codegen/Enclave_u.h @@ -341,7 +341,7 @@ int32_t SGX_UBRIDGE(SGX_NOCONVENTION, u_sgxprotectedfs_do_file_recovery, (const #endif sgx_status_t enclave_create_report(sgx_enclave_id_t eid, sgx_status_t* retval, const sgx_target_info_t* p_qe3_target, sgx_report_t* p_report, uint8_t enclave_data[32]); -sgx_status_t wallet_operation(sgx_enclave_id_t eid, sgx_status_t* retval, const uint8_t* sealed_request_buffer, size_t sealed_request_size, uint8_t* sealed_response_buffer, size_t sealed_response_capacity, size_t* sealed_response_used); +sgx_status_t vault_operation(sgx_enclave_id_t eid, sgx_status_t* retval, const uint8_t* sealed_request_buffer, size_t sealed_request_size, uint8_t* sealed_response_buffer, size_t sealed_response_capacity, size_t* sealed_response_used); sgx_status_t t_global_init_ecall(sgx_enclave_id_t eid, uint64_t id, const uint8_t* path, size_t len); sgx_status_t t_global_exit_ecall(sgx_enclave_id_t eid); diff --git a/rust-sgx-workspace/projects/sgx-wallet/app/codegen/Enclave_u.rs b/rust-sgx-workspace/projects/sgx-vault/app/codegen/Enclave_u.rs similarity index 95% rename from rust-sgx-workspace/projects/sgx-wallet/app/codegen/Enclave_u.rs rename to rust-sgx-workspace/projects/sgx-vault/app/codegen/Enclave_u.rs index 655c45d..3520fa5 100644 --- a/rust-sgx-workspace/projects/sgx-wallet/app/codegen/Enclave_u.rs +++ b/rust-sgx-workspace/projects/sgx-vault/app/codegen/Enclave_u.rs @@ -12,7 +12,7 @@ extern "C" { ) -> sgx_status_t; } extern "C" { - pub fn wallet_operation( + pub fn vault_operation( eid: sgx_enclave_id_t, retval: *mut sgx_status_t, sealed_request_buffer: *const u8, diff --git a/rust-sgx-workspace/projects/sgx-wallet/app/src/main.rs b/rust-sgx-workspace/projects/sgx-vault/app/src/main.rs similarity index 86% rename from rust-sgx-workspace/projects/sgx-wallet/app/src/main.rs rename to rust-sgx-workspace/projects/sgx-vault/app/src/main.rs index adcf0c1..50fa24b 100644 --- a/rust-sgx-workspace/projects/sgx-wallet/app/src/main.rs +++ b/rust-sgx-workspace/projects/sgx-vault/app/src/main.rs @@ -7,7 +7,7 @@ use http_service_impl::server::run_server; use sgx_types::{sgx_attributes_t, sgx_launch_token_t, sgx_misc_attribute_t, SgxResult}; use sgx_urts::SgxEnclave; -use crate::trait_impls::WalletEnclaveImpl; +use crate::trait_impls::VaultEnclaveImpl; #[path = "../codegen/Enclave_u.rs"] mod enclave_u; @@ -45,10 +45,10 @@ async fn main() -> io::Result<()> { ) }) .unwrap(); - let wallet_enclave = Box::new(WalletEnclaveImpl { enclave }); + let vault_enclave = Box::new(VaultEnclaveImpl { enclave }); - // FIXME: See WALLET_STORE_DIR - create_dir_all("wallet_store")?; + // FIXME: See VAULT_STORE_DIR + create_dir_all("vault_store")?; let bind_addr = env_vars::var_default("BIND_ADDR", "127.0.0.1:8080")?; @@ -56,5 +56,5 @@ async fn main() -> io::Result<()> { println!("run_server: binding to http://{}/", socket_addr); } - run_server(wallet_enclave, bind_addr).await + run_server(vault_enclave, bind_addr).await } diff --git a/rust-sgx-workspace/projects/sgx-wallet/app/src/safe_ecalls.rs b/rust-sgx-workspace/projects/sgx-vault/app/src/safe_ecalls.rs similarity index 96% rename from rust-sgx-workspace/projects/sgx-wallet/app/src/safe_ecalls.rs rename to rust-sgx-workspace/projects/sgx-vault/app/src/safe_ecalls.rs index 35031d0..26fefd4 100644 --- a/rust-sgx-workspace/projects/sgx-wallet/app/src/safe_ecalls.rs +++ b/rust-sgx-workspace/projects/sgx-vault/app/src/safe_ecalls.rs @@ -28,7 +28,7 @@ pub fn safe_enclave_create_report( }) } -pub fn safe_wallet_operation( +pub fn safe_vault_operation( eid: sgx_enclave_id_t, sealed_request: &[u8], sealed_response_capacity: usize, @@ -38,7 +38,7 @@ pub fn safe_wallet_operation( let mut sealed_response_used = 0; let result = unsafe { - enclave_u::wallet_operation( + enclave_u::vault_operation( eid, &mut retval, sealed_request.as_ptr(), diff --git a/rust-sgx-workspace/projects/sgx-wallet/app/src/trait_impls.rs b/rust-sgx-workspace/projects/sgx-vault/app/src/trait_impls.rs similarity index 71% rename from rust-sgx-workspace/projects/sgx-wallet/app/src/trait_impls.rs rename to rust-sgx-workspace/projects/sgx-vault/app/src/trait_impls.rs index 164accb..60ab438 100644 --- a/rust-sgx-workspace/projects/sgx-wallet/app/src/trait_impls.rs +++ b/rust-sgx-workspace/projects/sgx-vault/app/src/trait_impls.rs @@ -1,16 +1,16 @@ -//! Implement [`WalletEnclave`] using [`safe_ecalls`]. +//! Implement [`VaultEnclave`] using [`safe_ecalls`]. -use http_service_impl::traits::WalletEnclave; +use http_service_impl::traits::VaultEnclave; use sgx_types::{sgx_report_t, sgx_target_info_t, SgxResult}; use sgx_urts::SgxEnclave; use crate::safe_ecalls; -pub(crate) struct WalletEnclaveImpl { +pub(crate) struct VaultEnclaveImpl { pub(crate) enclave: SgxEnclave, } -impl WalletEnclave for WalletEnclaveImpl { +impl VaultEnclave for VaultEnclaveImpl { fn create_report( &self, target_info: sgx_target_info_t, @@ -18,12 +18,12 @@ impl WalletEnclave for WalletEnclaveImpl { safe_ecalls::safe_enclave_create_report(self.enclave.geteid(), target_info) } - fn wallet_operation( + fn vault_operation( &self, sealed_request: &[u8], sealed_response_capacity: usize, ) -> SgxResult>> { - safe_ecalls::safe_wallet_operation( + safe_ecalls::safe_vault_operation( self.enclave.geteid(), sealed_request, sealed_response_capacity, diff --git a/rust-sgx-workspace/projects/sgx-wallet/buildenv.mk b/rust-sgx-workspace/projects/sgx-vault/buildenv.mk similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet/buildenv.mk rename to rust-sgx-workspace/projects/sgx-vault/buildenv.mk diff --git a/rust-sgx-workspace/projects/sgx-wallet/buildenv_sgx.mk b/rust-sgx-workspace/projects/sgx-vault/buildenv_sgx.mk similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet/buildenv_sgx.mk rename to rust-sgx-workspace/projects/sgx-vault/buildenv_sgx.mk diff --git a/rust-sgx-workspace/projects/sgx-wallet/enclave/.gitignore b/rust-sgx-workspace/projects/sgx-vault/enclave/.gitignore similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet/enclave/.gitignore rename to rust-sgx-workspace/projects/sgx-vault/enclave/.gitignore diff --git a/rust-sgx-workspace/projects/sgx-wallet/enclave/Cargo.lock b/rust-sgx-workspace/projects/sgx-vault/enclave/Cargo.lock similarity index 99% rename from rust-sgx-workspace/projects/sgx-wallet/enclave/Cargo.lock rename to rust-sgx-workspace/projects/sgx-vault/enclave/Cargo.lock index 8a33a8d..2001896 100644 --- a/rust-sgx-workspace/projects/sgx-wallet/enclave/Cargo.lock +++ b/rust-sgx-workspace/projects/sgx-vault/enclave/Cargo.lock @@ -675,16 +675,16 @@ dependencies = [ ] [[package]] -name = "sgx-wallet-enclave" +name = "sgx-vault-enclave" version = "0.1.0" dependencies = [ - "sgx-wallet-impl", + "sgx-vault-impl", "sgx_tstd", "sgx_types", ] [[package]] -name = "sgx-wallet-impl" +name = "sgx-vault-impl" version = "0.1.0" dependencies = [ "algonaut", diff --git a/rust-sgx-workspace/projects/sgx-wallet/enclave/Cargo.toml b/rust-sgx-workspace/projects/sgx-vault/enclave/Cargo.toml similarity index 90% rename from rust-sgx-workspace/projects/sgx-wallet/enclave/Cargo.toml rename to rust-sgx-workspace/projects/sgx-vault/enclave/Cargo.toml index e64fa35..cd86a2e 100644 --- a/rust-sgx-workspace/projects/sgx-wallet/enclave/Cargo.toml +++ b/rust-sgx-workspace/projects/sgx-vault/enclave/Cargo.toml @@ -1,6 +1,6 @@ [package] # name matches ENCLAVE_CARGO_LIB in Makefile -name = "sgx-wallet-enclave" +name = "sgx-vault-enclave" version = "0.1.0" edition = "2021" @@ -17,7 +17,7 @@ default = [] sgx_types = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } sgx_tstd = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", features = ["backtrace"], rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } -sgx-wallet-impl = { path = "../../../crates/sgx-wallet-impl" } +sgx-vault-impl = { path = "../../../crates/sgx-vault-impl" } [patch.'https://github.com/apache/teaclave-sgx-sdk.git'] sgx_libc = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } diff --git a/rust-sgx-workspace/projects/sgx-wallet/enclave/Enclave.config.xml b/rust-sgx-workspace/projects/sgx-vault/enclave/Enclave.config.xml similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet/enclave/Enclave.config.xml rename to rust-sgx-workspace/projects/sgx-vault/enclave/Enclave.config.xml diff --git a/rust-sgx-workspace/projects/sgx-wallet/enclave/Enclave.edl b/rust-sgx-workspace/projects/sgx-vault/enclave/Enclave.edl similarity index 94% rename from rust-sgx-workspace/projects/sgx-wallet/enclave/Enclave.edl rename to rust-sgx-workspace/projects/sgx-vault/enclave/Enclave.edl index 8d5c89c..06fcf31 100644 --- a/rust-sgx-workspace/projects/sgx-wallet/enclave/Enclave.edl +++ b/rust-sgx-workspace/projects/sgx-vault/enclave/Enclave.edl @@ -15,7 +15,7 @@ enclave { [out] uint8_t enclave_data[32] ); - public sgx_status_t wallet_operation( + public sgx_status_t vault_operation( [in, count=sealed_request_size] const uint8_t* sealed_request_buffer, size_t sealed_request_size, [out, count=sealed_response_capacity] uint8_t* sealed_response_buffer, diff --git a/rust-sgx-workspace/projects/sgx-wallet/enclave/Enclave.lds b/rust-sgx-workspace/projects/sgx-vault/enclave/Enclave.lds similarity index 100% rename from rust-sgx-workspace/projects/sgx-wallet/enclave/Enclave.lds rename to rust-sgx-workspace/projects/sgx-vault/enclave/Enclave.lds diff --git a/rust-sgx-workspace/projects/sgx-wallet/enclave/Makefile b/rust-sgx-workspace/projects/sgx-vault/enclave/Makefile similarity index 98% rename from rust-sgx-workspace/projects/sgx-wallet/enclave/Makefile rename to rust-sgx-workspace/projects/sgx-vault/enclave/Makefile index 1fdc694..b141894 100644 --- a/rust-sgx-workspace/projects/sgx-wallet/enclave/Makefile +++ b/rust-sgx-workspace/projects/sgx-vault/enclave/Makefile @@ -26,7 +26,7 @@ SGX_ARCH = x64 TRTS_LIB = sgx_trts SERVICE_LIB = sgx_tservice # ENCLAVE_CARGO_LIB matches name in Cargo.toml -ENCLAVE_CARGO_LIB=libsgx_wallet_enclave.a +ENCLAVE_CARGO_LIB=libsgx_vault_enclave.a # Addprefix dependant variables, no need to change those OUTPUT_T = $(FILES_T:.c=.o) NAME = $(addprefix $(BIN), $(APP_T_SIGNED)) @@ -39,7 +39,7 @@ FILES_T_F_RUST=$(addprefix $(SRC_T), $(FILES_T_RUST)) OUTPUT_W_FT=$(addprefix $(OBJ_T), $(OUTPUT_T)) # All Rust and other source files that the Cargo build depends on. -FILES_RUST_F = Cargo.toml Cargo.lock $(shell find src ../../../crates/sgx-wallet-impl/src -name '*.rs') +FILES_RUST_F = Cargo.toml Cargo.lock $(shell find src ../../../crates/sgx-vault-impl/src -name '*.rs') # Contains compilation rules for the enclave part diff --git a/rust-sgx-workspace/projects/sgx-wallet/enclave/codegen/Enclave_t.c b/rust-sgx-workspace/projects/sgx-vault/enclave/codegen/Enclave_t.c similarity index 99% rename from rust-sgx-workspace/projects/sgx-wallet/enclave/codegen/Enclave_t.c rename to rust-sgx-workspace/projects/sgx-vault/enclave/codegen/Enclave_t.c index 1d5ec92..9ce28e3 100644 --- a/rust-sgx-workspace/projects/sgx-wallet/enclave/codegen/Enclave_t.c +++ b/rust-sgx-workspace/projects/sgx-vault/enclave/codegen/Enclave_t.c @@ -34,14 +34,14 @@ typedef struct ms_enclave_create_report_t { uint8_t* ms_enclave_data; } ms_enclave_create_report_t; -typedef struct ms_wallet_operation_t { +typedef struct ms_vault_operation_t { sgx_status_t ms_retval; const uint8_t* ms_sealed_request_buffer; size_t ms_sealed_request_size; uint8_t* ms_sealed_response_buffer; size_t ms_sealed_response_capacity; size_t* ms_sealed_response_used; -} ms_wallet_operation_t; +} ms_vault_operation_t; typedef struct ms_t_global_init_ecall_t { uint64_t ms_id; @@ -681,14 +681,14 @@ static sgx_status_t SGX_CDECL sgx_enclave_create_report(void* pms) return status; } -static sgx_status_t SGX_CDECL sgx_wallet_operation(void* pms) +static sgx_status_t SGX_CDECL sgx_vault_operation(void* pms) { - CHECK_REF_POINTER(pms, sizeof(ms_wallet_operation_t)); + CHECK_REF_POINTER(pms, sizeof(ms_vault_operation_t)); // // fence after pointer checks // sgx_lfence(); - ms_wallet_operation_t* ms = SGX_CAST(ms_wallet_operation_t*, pms); + ms_vault_operation_t* ms = SGX_CAST(ms_vault_operation_t*, pms); sgx_status_t status = SGX_SUCCESS; const uint8_t* _tmp_sealed_request_buffer = ms->ms_sealed_request_buffer; size_t _tmp_sealed_request_size = ms->ms_sealed_request_size; @@ -766,7 +766,7 @@ static sgx_status_t SGX_CDECL sgx_wallet_operation(void* pms) memset((void*)_in_sealed_response_used, 0, _len_sealed_response_used); } - ms->ms_retval = wallet_operation((const uint8_t*)_in_sealed_request_buffer, _tmp_sealed_request_size, _in_sealed_response_buffer, _tmp_sealed_response_capacity, _in_sealed_response_used); + ms->ms_retval = vault_operation((const uint8_t*)_in_sealed_request_buffer, _tmp_sealed_request_size, _in_sealed_response_buffer, _tmp_sealed_response_capacity, _in_sealed_response_used); if (_in_sealed_response_buffer) { if (memcpy_s(_tmp_sealed_response_buffer, _len_sealed_response_buffer, _in_sealed_response_buffer, _len_sealed_response_buffer)) { status = SGX_ERROR_UNEXPECTED; @@ -849,7 +849,7 @@ SGX_EXTERNC const struct { 4, { {(void*)(uintptr_t)sgx_enclave_create_report, 0, 0}, - {(void*)(uintptr_t)sgx_wallet_operation, 0, 0}, + {(void*)(uintptr_t)sgx_vault_operation, 0, 0}, {(void*)(uintptr_t)sgx_t_global_init_ecall, 0, 0}, {(void*)(uintptr_t)sgx_t_global_exit_ecall, 0, 0}, } diff --git a/rust-sgx-workspace/projects/sgx-wallet/enclave/codegen/Enclave_t.h b/rust-sgx-workspace/projects/sgx-vault/enclave/codegen/Enclave_t.h similarity index 97% rename from rust-sgx-workspace/projects/sgx-wallet/enclave/codegen/Enclave_t.h rename to rust-sgx-workspace/projects/sgx-vault/enclave/codegen/Enclave_t.h index 6558f49..7d4f6c1 100644 --- a/rust-sgx-workspace/projects/sgx-wallet/enclave/codegen/Enclave_t.h +++ b/rust-sgx-workspace/projects/sgx-vault/enclave/codegen/Enclave_t.h @@ -23,7 +23,7 @@ extern "C" { #endif sgx_status_t enclave_create_report(const sgx_target_info_t* p_qe3_target, sgx_report_t* p_report, uint8_t enclave_data[32]); -sgx_status_t wallet_operation(const uint8_t* sealed_request_buffer, size_t sealed_request_size, uint8_t* sealed_response_buffer, size_t sealed_response_capacity, size_t* sealed_response_used); +sgx_status_t vault_operation(const uint8_t* sealed_request_buffer, size_t sealed_request_size, uint8_t* sealed_response_buffer, size_t sealed_response_capacity, size_t* sealed_response_used); void t_global_init_ecall(uint64_t id, const uint8_t* path, size_t len); void t_global_exit_ecall(void); diff --git a/rust-sgx-workspace/projects/sgx-vault/enclave/src/lib.rs b/rust-sgx-workspace/projects/sgx-vault/enclave/src/lib.rs new file mode 100644 index 0000000..afc0d81 --- /dev/null +++ b/rust-sgx-workspace/projects/sgx-vault/enclave/src/lib.rs @@ -0,0 +1,7 @@ +#![no_std] + +extern crate sgx_tstd as std; + +// Re-export ECALL implementations: +pub use sgx_vault_impl::ecalls::enclave_create_report::enclave_create_report; +pub use sgx_vault_impl::ecalls::vault_operation::vault_operation; diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/lib.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/lib.rs deleted file mode 100644 index 7db477a..0000000 --- a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/lib.rs +++ /dev/null @@ -1,57 +0,0 @@ -#![no_std] - -#[macro_use] -extern crate sgx_tstd as std; - -mod helpers; -mod ported; -mod schema; -mod wallet_operations; - -use std::backtrace; -use std::string::String; -use std::vec::Vec; - -use sgx_tunittest::*; - -#[no_mangle] -pub extern "C" fn run_tests_ecall() -> usize { - backtrace::enable_backtrace("enclave.signed.so", backtrace::PrintFormat::Short).unwrap(); - - rsgx_unit_tests!( - ported::proptest_crypto::prop_soda_box_roundtrips, - ported::test_attestation::create_report_impl_works, - ported::test_crypto::soda_box_decrypt_works, - ported::test_crypto::soda_box_encrypt_works, - ported::test_kv_store::test_alter, - ported::test_kv_store::test_load_save_delete, - ported::test_kv_store::test_mutate, - ported::test_kv_store::test_try_insert, - ported::test_kv_store_fs::prop_fs_safe_roundtrip, - schema::test_sealing::prop_seal_unseal_msgpack_roundtrips, - schema::test_sealing::prop_seal_unseal_roundtrips, - schema::test_types::test_xrpl_key_type_serde, - wallet_operations::test_create_wallet::create_wallet_works, - wallet_operations::test_dispatch::wallet_operation_sealing_works, - wallet_operations::test_load_onfido_check::load_onfido_check_bad_pin, - wallet_operations::test_load_onfido_check::load_onfido_check_malformed_wallet_id, - wallet_operations::test_load_onfido_check::load_onfido_check_not_found, - wallet_operations::test_load_onfido_check::load_onfido_check_works, - wallet_operations::test_open_wallet::open_wallet_bad_pin, - wallet_operations::test_open_wallet::open_wallet_malformed_wallet_id, - wallet_operations::test_open_wallet::open_wallet_works, - wallet_operations::test_save_onfido_check::save_onfido_check_bad_pin, - wallet_operations::test_save_onfido_check::save_onfido_check_malformed_wallet_id, - wallet_operations::test_save_onfido_check::save_onfido_check_works, - wallet_operations::test_sign_transaction::sign_transaction_empty, - wallet_operations::test_sign_transaction::sign_transaction_malformed_transaction, - wallet_operations::test_sign_transaction::sign_transaction_without_tag, - wallet_operations::test_sign_transaction::sign_transaction_works, - wallet_operations::test_sign_transaction_msgpack::prop_transaction_msgpack_roundtrips, - wallet_operations::test_sign_transaction_xrpl::sign_transaction_empty, - wallet_operations::test_store::unlock_wallet_bad_auth_pin, - wallet_operations::test_store::unlock_wallet_malformed_wallet_id, - wallet_operations::test_store::unlock_wallet_not_found, - wallet_operations::test_store::unlock_wallet_works, - ) -} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_dispatch.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_dispatch.rs deleted file mode 100644 index f887f9f..0000000 --- a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_dispatch.rs +++ /dev/null @@ -1,40 +0,0 @@ -use std::prelude::v1::ToString; - -use sgx_wallet_impl::ported::crypto::SodaBoxCrypto; -use sgx_wallet_impl::schema::actions::{ - OpenWallet, - OpenWalletResult, - WalletRequest, - WalletResponse, -}; -use sgx_wallet_impl::schema::sealing::{seal_msgpack, unseal_non_secret_msgpack}; -use sgx_wallet_impl::wallet_operations::dispatch::wallet_operation_impl; - -pub(crate) fn wallet_operation_sealing_works() { - let client_crypto = &mut SodaBoxCrypto::from_seed([0; 32]); - let enclave_crypto = SodaBoxCrypto::new(); - - // Seal - let wallet_request = &WalletRequest::OpenWallet(OpenWallet { - wallet_id: "123456".to_string(), - auth_pin: "1234".to_string(), - }); - let sealed_request_bytes = - &seal_msgpack(wallet_request, &enclave_crypto.get_pubkey(), client_crypto).unwrap(); - - // Call - let sealed_response_bytes = &wallet_operation_impl(sealed_request_bytes); - - // Unseal - let unsealed_message: WalletResponse = - unseal_non_secret_msgpack(sealed_response_bytes, client_crypto).unwrap(); - - // Check - assert_eq!( - unsealed_message, - OpenWalletResult::Failed( - "key_from_id failed for wallet_id = \"123456\": decode error".to_string() - ) - .into() - ); -} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_open_wallet.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_open_wallet.rs deleted file mode 100644 index d876dd0..0000000 --- a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_open_wallet.rs +++ /dev/null @@ -1,50 +0,0 @@ -use std::prelude::v1::ToString; - -use sgx_wallet_impl::schema::actions; -use sgx_wallet_impl::schema::actions::OpenWalletResult; -use sgx_wallet_impl::wallet_operations::open_wallet::open_wallet; - -use crate::helpers::wallet_store; - -type Result = OpenWalletResult; - -pub(crate) fn open_wallet_works() { - let existing = &wallet_store::create_test_wallet(); - - let request = &actions::OpenWallet { - wallet_id: existing.wallet_id.clone(), - auth_pin: "123456".to_string(), - }; - let display = &match open_wallet(request) { - Result::Opened(opened) => opened, - otherwise => panic!("{:?}", otherwise), - }; - - assert_eq!(display, existing); -} - -pub(crate) fn open_wallet_malformed_wallet_id() { - let request = &actions::OpenWallet { - wallet_id: "malformed".to_string(), - auth_pin: "123456".to_string(), - }; - - match open_wallet(request) { - Result::Failed(_) => (), - otherwise => panic!("{:?}", otherwise), - } -} - -pub(crate) fn open_wallet_bad_pin() { - let existing = &wallet_store::create_test_wallet(); - - let request = &actions::OpenWallet { - wallet_id: existing.wallet_id.clone(), - auth_pin: "000000".to_string(), - }; - - match open_wallet(request) { - Result::InvalidAuth => (), - otherwise => panic!("{:?}", otherwise), - } -} diff --git a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_store.rs b/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_store.rs deleted file mode 100644 index 05345e5..0000000 --- a/rust-sgx-workspace/projects/sgx-wallet-test/enclave/src/wallet_operations/test_store.rs +++ /dev/null @@ -1,37 +0,0 @@ -//! Test [`sgx_wallet_impl::wallet_operations::store`] - -use std::prelude::v1::ToString; - -use sgx_wallet_impl::ported::kv_store::KvStore; -use sgx_wallet_impl::schema::entities::WalletDisplay; -use sgx_wallet_impl::wallet_operations::store::{key_from_id, unlock_wallet, wallet_store}; - -use crate::helpers::wallet_store::create_test_wallet; - -pub(crate) fn unlock_wallet_works() { - let existing = create_test_wallet(); - let stored = unlock_wallet(&existing.wallet_id, "123456").unwrap(); - assert_eq!(existing, WalletDisplay::from(stored)); -} - -pub(crate) fn unlock_wallet_not_found() { - let existing = create_test_wallet(); - let mut store = wallet_store(); - let key = &key_from_id(&existing.wallet_id).unwrap(); - store.delete(key).unwrap(); - - let err = unlock_wallet(&existing.wallet_id, "123456").unwrap_err(); - assert_eq!(err.to_string(), "invalid wallet ID provided"); -} - -pub(crate) fn unlock_wallet_malformed_wallet_id() { - create_test_wallet(); - let err = unlock_wallet("malformed", "123456").unwrap_err(); - assert_eq!(err.to_string(), "I/O error while opening wallet"); -} - -pub(crate) fn unlock_wallet_bad_auth_pin() { - let existing = create_test_wallet(); - let err = unlock_wallet(&existing.wallet_id, "000000").unwrap_err(); - assert_eq!(err.to_string(), "invalid authentication PIN provided"); -} diff --git a/rust-sgx-workspace/projects/sgx-wallet/enclave/src/lib.rs b/rust-sgx-workspace/projects/sgx-wallet/enclave/src/lib.rs deleted file mode 100644 index 3db0bf4..0000000 --- a/rust-sgx-workspace/projects/sgx-wallet/enclave/src/lib.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![no_std] - -extern crate sgx_tstd as std; - -// Re-export ECALL implementations: -pub use sgx_wallet_impl::ecalls::enclave_create_report::enclave_create_report; -pub use sgx_wallet_impl::ecalls::wallet_operation::wallet_operation; From fb262333ee30123c74be02829d23cfe49b68d558 Mon Sep 17 00:00:00 2001 From: Bill Guo Date: Tue, 6 Sep 2022 11:16:13 +0200 Subject: [PATCH 08/22] refactor(sgx-vault-impl): change vault id to algorand address (#65) --- .../sgx-vault-impl/src/vault_operations/create_vault.rs | 2 +- .../crates/sgx-vault-impl/src/vault_operations/store.rs | 6 ++++-- .../enclave/src/vault_operations/test_dispatch.rs | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/create_vault.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/create_vault.rs index 7c9b43d..1afb60c 100644 --- a/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/create_vault.rs +++ b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/create_vault.rs @@ -13,7 +13,7 @@ pub fn create_vault(request: &CreateVault) -> Result { let new_xrpl_account = XrplAccount::generate_default(); let storable = VaultStorable { - vault_id: new_xrpl_account.to_address_base58(), + vault_id: new_algorand_account.address_base32(), owner_name: request.owner_name.clone(), auth_pin: request.auth_pin.clone(), phone_number: request.phone_number.clone(), diff --git a/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/store.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/store.rs index 7661b75..dedb4ed 100644 --- a/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/store.rs +++ b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/store.rs @@ -1,6 +1,8 @@ use std::io; use std::prelude::v1::Box; +use std::str::FromStr; +use algonaut::core::Address; use sgx_trts::memeq::ConsttimeMemEq; use thiserror::Error; @@ -37,8 +39,8 @@ pub fn load_vault(vault_id: &str) -> Result, io::Error> { } pub fn key_from_id(vault_id: &str) -> Result, io::Error> { - // XXX: Assume XRP address, for now. - let address = ripple_address_codec::decode_account_id(vault_id).map_err(|err| { + // XXX: Assume ALGO address, for now. + let Address(address) = Address::from_str(vault_id).map_err(|err| { io::Error::new( io::ErrorKind::InvalidInput, format!("key_from_id failed for vault_id = {:?}: {}", vault_id, err), diff --git a/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_dispatch.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_dispatch.rs index 9593b10..f067c7d 100644 --- a/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_dispatch.rs +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_dispatch.rs @@ -28,7 +28,8 @@ pub(crate) fn vault_operation_sealing_works() { assert_eq!( unsealed_message, OpenVaultResult::Failed( - "key_from_id failed for vault_id = \"123456\": decode error".to_string() + "key_from_id failed for vault_id = \"123456\": Error decoding base32: DecodeError { position: 5, kind: Length }" + .to_string() ) .into() ); From 8e8d6d8aee454b57309a30d2dbd7957bb572d02d Mon Sep 17 00:00:00 2001 From: Bill Guo Date: Tue, 6 Sep 2022 11:21:56 +0200 Subject: [PATCH 09/22] refactor: remove Onfido operations and XRP related code (#66) --- .../crates/sgx-vault-impl/Cargo.lock | 210 +----------------- .../crates/sgx-vault-impl/Cargo.toml | 2 - .../sgx-vault-impl/src/schema/actions.rs | 122 ---------- .../sgx-vault-impl/src/schema/entities.rs | 113 +--------- .../crates/sgx-vault-impl/src/schema/types.rs | 56 ----- .../src/vault_operations/create_vault.rs | 8 +- .../src/vault_operations/dispatch.rs | 4 - .../src/vault_operations/load_onfido_check.rs | 14 -- .../src/vault_operations/mod.rs | 3 - .../src/vault_operations/save_onfido_check.rs | 21 -- .../src/vault_operations/sign_transaction.rs | 9 - .../vault_operations/sign_transaction_xrpl.rs | 8 - .../sgx-vault-test/enclave/Cargo.lock | 210 +----------------- .../enclave/src/helpers/vault_store.rs | 39 +--- .../sgx-vault-test/enclave/src/lib.rs | 9 - .../sgx-vault-test/enclave/src/schema/mod.rs | 1 - .../enclave/src/schema/test_types.rs | 20 -- .../enclave/src/vault_operations/mod.rs | 3 - .../src/vault_operations/test_create_vault.rs | 9 - .../test_load_onfido_check.rs | 63 ------ .../test_save_onfido_check.rs | 63 ------ .../test_sign_transaction_xrpl.rs | 32 --- .../projects/sgx-vault/enclave/Cargo.lock | 210 +----------------- 23 files changed, 28 insertions(+), 1201 deletions(-) delete mode 100644 rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/load_onfido_check.rs delete mode 100644 rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/save_onfido_check.rs delete mode 100644 rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/sign_transaction_xrpl.rs delete mode 100644 rust-sgx-workspace/projects/sgx-vault-test/enclave/src/schema/test_types.rs delete mode 100644 rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_load_onfido_check.rs delete mode 100644 rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_save_onfido_check.rs delete mode 100644 rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_sign_transaction_xrpl.rs diff --git a/rust-sgx-workspace/crates/sgx-vault-impl/Cargo.lock b/rust-sgx-workspace/crates/sgx-vault-impl/Cargo.lock index f0b060b..662613e 100644 --- a/rust-sgx-workspace/crates/sgx-vault-impl/Cargo.lock +++ b/rust-sgx-workspace/crates/sgx-vault-impl/Cargo.lock @@ -25,7 +25,7 @@ dependencies = [ "rmp-serde", "serde", "sgx_tstd", - "sha2 0.9.9", + "sha2", "static_assertions", "thiserror", ] @@ -43,7 +43,7 @@ dependencies = [ "ring", "serde", "sgx_tstd", - "sha2 0.9.9", + "sha2", "static_assertions", "thiserror", ] @@ -76,17 +76,11 @@ dependencies = [ "serde", "serde_bytes", "sgx_tstd", - "sha2 0.9.9", + "sha2", "thiserror", "url", ] -[[package]] -name = "arrayref" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" - [[package]] name = "autocfg" version = "0.1.8" @@ -102,44 +96,19 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "base-x" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" - [[package]] name = "base64" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "git+https://github.com/mesalock-linux/rustcrypto-utils-sgx#07ebf780554e018037f750186d61ea9bdc031148" -dependencies = [ - "block-padding", - "byte-tools", - "byteorder", - "generic-array 0.12.4", -] - [[package]] name = "block-buffer" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.6", -] - -[[package]] -name = "block-padding" -version = "0.1.4" -source = "git+https://github.com/mesalock-linux/rustcrypto-utils-sgx#07ebf780554e018037f750186d61ea9bdc031148" -dependencies = [ - "byte-tools", + "generic-array", ] [[package]] @@ -148,11 +117,6 @@ version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d" -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "git+https://github.com/mesalock-linux/rustcrypto-utils-sgx#07ebf780554e018037f750186d61ea9bdc031148" - [[package]] name = "byteorder" version = "1.3.4" @@ -194,21 +158,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - -[[package]] -name = "crypto-mac" -version = "0.8.0" -source = "git+https://github.com/mesalock-linux/rustcrypto-traits-sgx#7a5cb154f438c2401b3d8e37de96dd0acf8f493e" -dependencies = [ - "generic-array 0.12.4", - "subtle", -] - [[package]] name = "data-encoding" version = "2.3.2" @@ -228,37 +177,13 @@ dependencies = [ "syn", ] -[[package]] -name = "digest" -version = "0.8.1" -source = "git+https://github.com/mesalock-linux/rustcrypto-traits-sgx#7a5cb154f438c2401b3d8e37de96dd0acf8f493e" -dependencies = [ - "generic-array 0.12.4", - "sgx_tstd", -] - [[package]] name = "digest" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.6", -] - -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - -[[package]] -name = "generic-array" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" -dependencies = [ - "typenum", + "generic-array", ] [[package]] @@ -312,24 +237,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "hmac" -version = "0.7.1" -source = "git+https://github.com/mesalock-linux/rustcrypto-MACs-sgx#e8e1410b9c82d2e59da42fa8b0d8ed38e80a203c" -dependencies = [ - "crypto-mac", - "digest 0.8.1", -] - -[[package]] -name = "hmac-drbg" -version = "0.1.2" -source = "git+https://github.com/mesalock-linux/hmac-drbg-rs-sgx#89d6b0113157599417af867a8d2b4afd5c6f1946" -dependencies = [ - "generic-array 0.12.4", - "hmac", -] - [[package]] name = "idna" version = "0.2.0" @@ -389,22 +296,6 @@ version = "0.2.132" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" -[[package]] -name = "libsecp256k1" -version = "0.3.5" -source = "git+https://github.com/ntls-io/libsecp256k1-rs-sgx#2a6c35a1876b3553486d34142155b89eaae77965" -dependencies = [ - "arrayref", - "crunchy", - "digest 0.8.1", - "hmac-drbg", - "rand", - "sgx_tstd", - "sha2 0.8.0", - "subtle", - "typenum", -] - [[package]] name = "log" version = "0.4.17" @@ -419,27 +310,6 @@ name = "matches" version = "0.1.8" source = "git+https://github.com/mesalock-linux/rust-std-candidates-sgx#5747bcf37f3e18687758838da0339ff0f2c83924" -[[package]] -name = "num-bigint" -version = "0.2.5" -source = "git+https://github.com/mesalock-linux/num-bigint-sgx#76a5bed94dc31c32bd1670dbf72877abcf9bbc09" -dependencies = [ - "autocfg 1.1.0", - "num-integer", - "num-traits", - "sgx_tstd", -] - -[[package]] -name = "num-integer" -version = "0.1.41" -source = "git+https://github.com/mesalock-linux/num-integer-sgx#404c50e5378ca635261688b080dee328ff42b6bd" -dependencies = [ - "autocfg 0.1.8", - "num-traits", - "sgx_tstd", -] - [[package]] name = "num-traits" version = "0.2.10" @@ -455,12 +325,6 @@ version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "074864da206b4973b84eb91683020dbefd6a8c3f0f38e054d93954e891935e4e" -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - [[package]] name = "opaque-debug" version = "0.3.0" @@ -536,42 +400,6 @@ dependencies = [ "untrusted", ] -[[package]] -name = "ripemd160" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eca4ecc81b7f313189bf73ce724400a07da2a6dac19588b03c8bd76a2dcc251" -dependencies = [ - "block-buffer 0.9.0", - "digest 0.9.0", - "opaque-debug 0.3.0", -] - -[[package]] -name = "ripple-address-codec" -version = "0.1.1" -source = "git+https://github.com/ntls-io/ripple-address-codec-rust-sgx?branch=v0.1.1-sgx#e2b03486a9e0627bbc922681863b4661be8a4e3b" -dependencies = [ - "base-x", - "ring", - "sgx_tstd", -] - -[[package]] -name = "ripple-keypairs" -version = "0.1.0" -source = "git+https://github.com/ntls-io/ripple-keypairs-rust-sgx?branch=v0.1.0-sgx#ef55261e2f0aa6b5c54cac43abc4c57b4f97b286" -dependencies = [ - "base-x", - "hex", - "libsecp256k1", - "num-bigint", - "ring", - "ripemd160", - "ripple-address-codec", - "sgx_tstd", -] - [[package]] name = "rmp" version = "0.8.9" @@ -670,8 +498,6 @@ dependencies = [ "base64", "hex", "rand", - "ripple-address-codec", - "ripple-keypairs", "rmp-serde", "secrecy", "serde", @@ -783,29 +609,17 @@ dependencies = [ "sgx_build_helper", ] -[[package]] -name = "sha2" -version = "0.8.0" -source = "git+https://github.com/mesalock-linux/rustcrypto-hashes-sgx#54ac4af765ec6b424add4e7559e82328bd052060" -dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "fake-simd", - "opaque-debug 0.2.3", - "sgx_tstd", -] - [[package]] name = "sha2" version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ - "block-buffer 0.9.0", + "block-buffer", "cfg-if 1.0.0", "cpufeatures", - "digest 0.9.0", - "opaque-debug 0.3.0", + "digest", + "opaque-debug", ] [[package]] @@ -837,14 +651,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "subtle" -version = "2.2.2" -source = "git+https://github.com/mesalock-linux/subtle-sgx#8ee32fc0902a4594bd12e272357e2d76cde9dad1" -dependencies = [ - "sgx_tstd", -] - [[package]] name = "syn" version = "1.0.99" diff --git a/rust-sgx-workspace/crates/sgx-vault-impl/Cargo.toml b/rust-sgx-workspace/crates/sgx-vault-impl/Cargo.toml index 1f370cd..cc5ae04 100644 --- a/rust-sgx-workspace/crates/sgx-vault-impl/Cargo.toml +++ b/rust-sgx-workspace/crates/sgx-vault-impl/Cargo.toml @@ -33,8 +33,6 @@ thiserror = { git = "https://github.com/mesalock-linux/thiserror-sgx" } # Our SGX forks algonaut = { git = "https://github.com/registreerocks/algonaut-sgx", branch = "main-sgx" } serde_bytes = { version = "0.11.4", git = "https://github.com/registreerocks/serde-bytes-sgx" } # SGX: registreerocks fork for 0.11.4 -ripple-keypairs = { git = "https://github.com/ntls-io/ripple-keypairs-rust-sgx", branch = "v0.1.0-sgx" } -ripple-address-codec = { git = "https://github.com/ntls-io/ripple-address-codec-rust-sgx", branch = "v0.1.1-sgx" } [patch.'https://github.com/apache/teaclave-sgx-sdk.git'] sgx_libc = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", rev = "e8a9fc22939befa27ff67f5509b2c2dfe8499945" } diff --git a/rust-sgx-workspace/crates/sgx-vault-impl/src/schema/actions.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/schema/actions.rs index 03e7f9f..3f7c1c7 100644 --- a/rust-sgx-workspace/crates/sgx-vault-impl/src/schema/actions.rs +++ b/rust-sgx-workspace/crates/sgx-vault-impl/src/schema/actions.rs @@ -4,7 +4,6 @@ //! //! * -use std::io; use std::prelude::v1::{String, ToString}; use serde::{Deserialize, Serialize}; @@ -88,12 +87,6 @@ pub enum TransactionToSign { #[serde(with = "serde_bytes")] transaction_bytes: Bytes, }, - - /// An unsigned XRPL transaction. - XrplTransaction { - #[serde(with = "serde_bytes")] - transaction_bytes: Bytes, - }, } #[derive(Clone, Eq, PartialEq, Debug)] // core @@ -126,15 +119,6 @@ pub enum TransactionSigned { #[serde(with = "serde_bytes")] signed_transaction_bytes: Bytes, }, - - /// A signed XRPL transaction. - XrplTransactionSigned { - #[serde(with = "serde_bytes")] - signed_transaction_bytes: Bytes, - - #[serde(with = "serde_bytes")] - signature_bytes: Bytes, - }, } impl TransactionSigned { @@ -151,96 +135,10 @@ impl TransactionSigned { TransactionSigned::AlgorandTransactionSigned { signed_transaction_bytes, } => signed_transaction_bytes, - otherwise => panic!( - "called `TransactionSigned::unwrap_algorand_bytes` on: {:?}", - otherwise - ), - } - } -} - -#[derive(Clone, Eq, PartialEq, Debug)] // core -#[derive(Deserialize, Serialize)] // serde -pub struct SaveOnfidoCheck { - pub vault_id: VaultId, - pub auth_pin: VaultPin, - - pub check: OnfidoCheckResult, -} - -#[derive(Clone, Eq, PartialEq, Debug)] // core -#[derive(Deserialize, Serialize)] // serde -pub enum SaveOnfidoCheckResult { - Saved, - InvalidAuth, - Failed(String), -} - -impl From for SaveOnfidoCheckResult { - fn from(err: io::Error) -> Self { - Self::Failed(err.to_string()) - } -} - -impl From for SaveOnfidoCheckResult { - fn from(err: UnlockVaultError) -> Self { - use UnlockVaultError::*; - match err { - InvalidVaultId => Self::InvalidAuth, - InvalidAuthPin => Self::InvalidAuth, - IoError(err) => Self::from(err), } } } -#[derive(Clone, Eq, PartialEq, Debug)] // core -#[derive(Deserialize, Serialize)] // serde -pub struct LoadOnfidoCheck { - pub vault_id: VaultId, - pub auth_pin: VaultPin, -} - -#[derive(Clone, Eq, PartialEq, Debug)] // core -#[derive(Deserialize, Serialize)] // serde -pub enum LoadOnfidoCheckResult { - Loaded(OnfidoCheckResult), - NotFound, - InvalidAuth, - Failed(String), -} - -impl From for LoadOnfidoCheckResult { - fn from(err: io::Error) -> Self { - Self::Failed(err.to_string()) - } -} - -impl From for LoadOnfidoCheckResult { - fn from(err: UnlockVaultError) -> Self { - use UnlockVaultError::*; - match err { - InvalidVaultId => Self::InvalidAuth, - InvalidAuthPin => Self::InvalidAuth, - IoError(err) => Self::from(err), - } - } -} - -/// Docs: https://documentation.onfido.com/v2/#report-object -#[derive(Clone, Eq, PartialEq, Debug)] // core -#[derive(Deserialize, Serialize)] // serde -pub struct OnfidoCheckResult { - pub id: String, - - pub href: String, - - /// Docs: - pub result: String, - - /// Docs: - pub sub_result: Option, -} - /// Dispatching enum for action requests. #[derive(Clone, Eq, PartialEq, Debug)] // core #[derive(Deserialize, Serialize)] // serde @@ -249,12 +147,6 @@ pub enum VaultRequest { CreateVault(CreateVault), OpenVault(OpenVault), SignTransaction(SignTransaction), - - #[zeroize(skip)] - SaveOnfidoCheck(SaveOnfidoCheck), - - #[zeroize(skip)] - LoadOnfidoCheck(LoadOnfidoCheck), } /// Dispatching enum for action results. @@ -264,8 +156,6 @@ pub enum VaultResponse { CreateVault(CreateVaultResult), OpenVault(OpenVaultResult), SignTransaction(SignTransactionResult), - SaveOnfidoCheck(SaveOnfidoCheckResult), - LoadOnfidoCheck(LoadOnfidoCheckResult), } // Convenience conversions: @@ -287,15 +177,3 @@ impl From for VaultResponse { Self::SignTransaction(result) } } - -impl From for VaultResponse { - fn from(result: SaveOnfidoCheckResult) -> Self { - Self::SaveOnfidoCheck(result) - } -} - -impl From for VaultResponse { - fn from(result: LoadOnfidoCheckResult) -> Self { - Self::LoadOnfidoCheck(result) - } -} diff --git a/rust-sgx-workspace/crates/sgx-vault-impl/src/schema/entities.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/schema/entities.rs index 8101c8b..f386d20 100644 --- a/rust-sgx-workspace/crates/sgx-vault-impl/src/schema/entities.rs +++ b/rust-sgx-workspace/crates/sgx-vault-impl/src/schema/entities.rs @@ -1,22 +1,17 @@ //! Structures representing various entities. -use std::prelude::v1::{String, ToOwned, ToString}; +use std::prelude::v1::{String, ToString}; use algonaut::transaction::account::Account as AlgonautAccount; -use ripple_keypairs::{Entropy, EntropyArray, PrivateKey, PublicKey, Seed}; use serde::{Deserialize, Serialize}; use zeroize::{Zeroize, ZeroizeOnDrop}; -use crate::schema::actions::OnfidoCheckResult; use crate::schema::types::{ AlgorandAccountSeedBytes, AlgorandAddressBase32, AlgorandAddressBytes, VaultId, VaultPin, - XrplAddressBase58, - XrplKeyType, - XrplPublicKeyHex, }; /// A Nautilus vault's basic displayable details. @@ -31,8 +26,6 @@ pub struct VaultDisplay { // TODO(Pi): Decouple for multiple accounts per vault. pub algorand_address_base32: AlgorandAddressBase32, - - pub xrpl_account: XrplAccountDisplay, } impl From for VaultDisplay { @@ -43,7 +36,6 @@ impl From for VaultDisplay { phone_number: storable.phone_number.clone(), algorand_address_base32: storable.algorand_account.address_base32(), - xrpl_account: storable.xrpl_account.clone().into(), } } } @@ -62,10 +54,6 @@ pub struct VaultStorable { pub phone_number: Option, pub algorand_account: AlgorandAccount, - pub xrpl_account: XrplAccount, - - #[zeroize(skip)] - pub onfido_check_result: Option, } // Algorand entities: @@ -105,102 +93,3 @@ impl From for AlgonautAccount { account.as_algonaut_account() } } - -// XRPL entities: - -/// An XRPL account's displayable details. -#[derive(Clone, Eq, PartialEq, Debug)] // core -#[derive(Deserialize, Serialize)] // serde -pub struct XrplAccountDisplay { - pub key_type: XrplKeyType, - pub public_key_hex: XrplPublicKeyHex, - pub address_base58: XrplAddressBase58, -} - -impl From for XrplAccountDisplay { - fn from(xrpl_account: XrplAccount) -> Self { - Self { - key_type: xrpl_account.key_type, - public_key_hex: xrpl_account.to_public_key_hex(), - address_base58: xrpl_account.to_address_base58(), - } - } -} - -/// An XRPL account. -#[derive(Clone, Eq, PartialEq, Debug)] // core -#[derive(Deserialize, Serialize)] // serde -#[derive(Zeroize, ZeroizeOnDrop)] // zeroize -pub struct XrplAccount { - #[zeroize(skip)] - pub key_type: XrplKeyType, - - pub seed_bytes: EntropyArray, -} - -impl From for XrplAccount { - fn from(seed: Seed) -> Self { - let key_type = seed.as_kind().into(); - let seed_bytes = seed.as_entropy().to_owned(); - Self::new(key_type, seed_bytes) - } -} - -impl From for Seed { - fn from(xrpl_account: XrplAccount) -> Self { - let entropy = Entropy::Array(xrpl_account.seed_bytes); - let kind = xrpl_account.key_type.into(); - Seed::new(entropy, kind) - } -} - -impl XrplAccount { - pub(crate) fn new(key_type: XrplKeyType, seed_bytes: EntropyArray) -> Self { - Self { - key_type, - seed_bytes, - } - } - - /// Generate a new keypair of the given type. - pub(crate) fn generate_default() -> Self { - Self::generate(XrplKeyType::default()) - } - - /// Generate a new keypair of the given type. - pub(crate) fn generate(key_type: XrplKeyType) -> Self { - Seed::new(Entropy::Random, key_type.into()).into() - } - - pub(crate) fn to_seed(&self) -> Seed { - self.clone().into() - } - - pub(crate) fn to_keypair(&self) -> (PrivateKey, PublicKey) { - // XXX(Pi): Performance: Repeated key derivation? - self.to_seed() - .derive_keypair() - // Safety: This should not fail unless something is seriously wrong: treat as unrecoverable. - .expect("XrpAccount: derive_keypair failed!") - } - - pub(crate) fn to_private_key(&self) -> PrivateKey { - let (private_key, _) = self.to_keypair(); - private_key - } - - pub(crate) fn to_public_key(&self) -> PublicKey { - let (_, public_key) = self.to_keypair(); - public_key - } - - pub fn to_address_base58(&self) -> XrplAddressBase58 { - self.to_public_key().derive_address() - } - - // TODO: Support X-Address format? Docs: - - pub fn to_public_key_hex(&self) -> XrplPublicKeyHex { - self.to_public_key().to_string() - } -} diff --git a/rust-sgx-workspace/crates/sgx-vault-impl/src/schema/types.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/schema/types.rs index 1b945ea..169980d 100644 --- a/rust-sgx-workspace/crates/sgx-vault-impl/src/schema/types.rs +++ b/rust-sgx-workspace/crates/sgx-vault-impl/src/schema/types.rs @@ -3,9 +3,6 @@ use std::boxed::Box; use std::prelude::v1::String; -use ripple_keypairs::{Algorithm, EntropyArray}; -use serde::{Deserialize, Serialize}; - pub type Bytes = Box<[u8]>; /// Nautilus Vault ID. @@ -22,56 +19,3 @@ pub type AlgorandAddressBytes = [u8; 32]; /// Algorand account address, as base32 with checksum. pub type AlgorandAddressBase32 = String; - -/// XRPL key type (signing algorithm). -/// -/// Docs: -#[derive(Copy, Clone, Eq, PartialEq, Debug)] // core -#[derive(Deserialize, Serialize)] // serde -#[serde(rename_all = "lowercase")] -pub enum XrplKeyType { - Secp256k1, - Ed25519, -} - -/// Default to `secp256k1`, like the XRP Ledger. -impl Default for XrplKeyType { - fn default() -> Self { - Self::Secp256k1 - } -} - -// Convert between our representation and ripple-keypairs. - -/// Convert from `&Algorithm`, as used by ripple-keypairs. -impl From<&Algorithm> for XrplKeyType { - fn from(algorithm: &Algorithm) -> Self { - match algorithm { - Algorithm::Secp256k1 => Self::Secp256k1, - Algorithm::Ed25519 => Self::Ed25519, - } - } -} - -/// Convert to `&'static Algorithm`, as expected by ripple-keypairs. -impl From for &'static Algorithm { - fn from(key_type: XrplKeyType) -> Self { - match key_type { - XrplKeyType::Secp256k1 => &Algorithm::Secp256k1, - XrplKeyType::Ed25519 => &Algorithm::Ed25519, - } - } -} - -/// XRP account seed, as bytes. -pub type XrplAccountSeedBytes = EntropyArray; - -/// XRP account address, as base58 with checksum ("Base58Check"). -/// -/// Docs: -pub type XrplAddressBase58 = String; - -/// XRP public key, as a hexadecimal string. Used to prepare unsigned transactions. -/// -/// Docs: -pub type XrplPublicKeyHex = String; diff --git a/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/create_vault.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/create_vault.rs index 1afb60c..27e0c7f 100644 --- a/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/create_vault.rs +++ b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/create_vault.rs @@ -1,16 +1,15 @@ use std::prelude::v1::ToString; use crate::schema::actions::{CreateVault, CreateVaultResult}; -use crate::schema::entities::{AlgorandAccount, VaultDisplay, VaultStorable, XrplAccount}; +use crate::schema::entities::{AlgorandAccount, VaultDisplay, VaultStorable}; use crate::vault_operations::store::save_new_vault; type Result = CreateVaultResult; pub fn create_vault(request: &CreateVault) -> Result { // TODO(Pi): Pull account / keypair creation into a separate operation. - // For now, just generate both Algorand and XRP keypairs. + // For now, just generate Algorand keypairs. let new_algorand_account = AlgorandAccount::generate(); - let new_xrpl_account = XrplAccount::generate_default(); let storable = VaultStorable { vault_id: new_algorand_account.address_base32(), @@ -19,9 +18,6 @@ pub fn create_vault(request: &CreateVault) -> Result { phone_number: request.phone_number.clone(), algorand_account: new_algorand_account, - xrpl_account: new_xrpl_account, - - onfido_check_result: None, }; match save_new_vault(&storable) { Ok(()) => Result::Created(VaultDisplay::from(storable)), diff --git a/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/dispatch.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/dispatch.rs index 696f3c9..6bd1631 100644 --- a/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/dispatch.rs +++ b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/dispatch.rs @@ -9,9 +9,7 @@ use crate::schema::msgpack::{FromMessagePack, ToMessagePack}; use crate::schema::sealing::{seal_from_enclave, unseal_to_enclave, SealedMessage}; use crate::vault_operations::create_vault::create_vault; use crate::vault_operations::errors; -use crate::vault_operations::load_onfido_check::load_onfido_check; use crate::vault_operations::open_vault::open_vault; -use crate::vault_operations::save_onfido_check::save_onfido_check; use crate::vault_operations::sign_transaction::sign_transaction; /// Implementation for [`crate::ecalls::vault_operation::vault_operation`]. @@ -109,7 +107,5 @@ fn vault_operation_impl_dispatch(vault_request: &VaultRequest) -> VaultResponse VaultRequest::CreateVault(request) => create_vault(request).into(), VaultRequest::OpenVault(request) => open_vault(request).into(), VaultRequest::SignTransaction(request) => sign_transaction(request).into(), - VaultRequest::SaveOnfidoCheck(request) => save_onfido_check(request).into(), - VaultRequest::LoadOnfidoCheck(request) => load_onfido_check(request).into(), } } diff --git a/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/load_onfido_check.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/load_onfido_check.rs deleted file mode 100644 index 943e75e..0000000 --- a/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/load_onfido_check.rs +++ /dev/null @@ -1,14 +0,0 @@ -use crate::schema::actions::{LoadOnfidoCheck, LoadOnfidoCheckResult}; -use crate::vault_operations::store::unlock_vault; - -pub fn load_onfido_check(request: &LoadOnfidoCheck) -> LoadOnfidoCheckResult { - let stored = match unlock_vault(&request.vault_id, &request.auth_pin) { - Ok(stored) => stored, - Err(err) => return err.into(), - }; - - stored.onfido_check_result.clone().map_or( - LoadOnfidoCheckResult::NotFound, - LoadOnfidoCheckResult::Loaded, - ) -} diff --git a/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/mod.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/mod.rs index 63d0fdb..1d50ddd 100644 --- a/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/mod.rs +++ b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/mod.rs @@ -3,10 +3,7 @@ pub mod create_vault; pub mod dispatch; pub(crate) mod errors; -pub mod load_onfido_check; pub mod open_vault; -pub mod save_onfido_check; pub mod sign_transaction; pub mod sign_transaction_algorand; -pub(crate) mod sign_transaction_xrpl; pub mod store; diff --git a/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/save_onfido_check.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/save_onfido_check.rs deleted file mode 100644 index 9a3e6a5..0000000 --- a/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/save_onfido_check.rs +++ /dev/null @@ -1,21 +0,0 @@ -use crate::schema::actions::{SaveOnfidoCheck, SaveOnfidoCheckResult}; -use crate::vault_operations::store::{mutate_vault, unlock_vault}; - -pub fn save_onfido_check(request: &SaveOnfidoCheck) -> SaveOnfidoCheckResult { - let stored = match unlock_vault(&request.vault_id, &request.auth_pin) { - Ok(ok) => ok, - Err(err) => return err.into(), - }; - - match mutate_vault(&stored.vault_id, |mut stored| { - // FIXME: Avoid mut? - stored.onfido_check_result = Some(request.check.clone()); - stored - }) { - Ok(ok) => ok, - Err(err) => return err.into(), - } - .expect("save_onfido_check: vault disappeared!"); - - SaveOnfidoCheckResult::Saved -} diff --git a/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/sign_transaction.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/sign_transaction.rs index 851e322..76cdc51 100644 --- a/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/sign_transaction.rs +++ b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/sign_transaction.rs @@ -9,7 +9,6 @@ use crate::schema::actions::{ TransactionToSign, }; use crate::vault_operations::sign_transaction_algorand::sign_algorand; -use crate::vault_operations::sign_transaction_xrpl::sign_xrpl; use crate::vault_operations::store::unlock_vault; pub fn sign_transaction(request: &SignTransaction) -> SignTransactionResult { @@ -23,14 +22,6 @@ pub fn sign_transaction(request: &SignTransaction) -> SignTransactionResult { sign_algorand(&stored.algorand_account, transaction_bytes) .map(TransactionSigned::from_algorand_bytes) } - - TransactionToSign::XrplTransaction { transaction_bytes } => { - let signature_bytes = sign_xrpl(&stored.xrpl_account, transaction_bytes); - Ok(TransactionSigned::XrplTransactionSigned { - signed_transaction_bytes: transaction_bytes.clone(), - signature_bytes, - }) - } }; // `Result` → `SignTransactionResult` diff --git a/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/sign_transaction_xrpl.rs b/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/sign_transaction_xrpl.rs deleted file mode 100644 index f1c1da5..0000000 --- a/rust-sgx-workspace/crates/sgx-vault-impl/src/vault_operations/sign_transaction_xrpl.rs +++ /dev/null @@ -1,8 +0,0 @@ -use crate::schema::entities::XrplAccount; -use crate::schema::types::Bytes; - -pub(crate) fn sign_xrpl(signing_account: &XrplAccount, transaction_bytes: &Bytes) -> Bytes { - let signature = signing_account.to_private_key().sign(transaction_bytes); - let signature_bytes = Bytes::from(signature.as_ref()); - signature_bytes -} diff --git a/rust-sgx-workspace/projects/sgx-vault-test/enclave/Cargo.lock b/rust-sgx-workspace/projects/sgx-vault-test/enclave/Cargo.lock index ea2a785..216e4bf 100644 --- a/rust-sgx-workspace/projects/sgx-vault-test/enclave/Cargo.lock +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/Cargo.lock @@ -25,7 +25,7 @@ dependencies = [ "rmp-serde", "serde", "sgx_tstd", - "sha2 0.9.5", + "sha2", "static_assertions", "thiserror", ] @@ -43,7 +43,7 @@ dependencies = [ "ring", "serde", "sgx_tstd", - "sha2 0.9.5", + "sha2", "static_assertions", "thiserror", ] @@ -76,17 +76,11 @@ dependencies = [ "serde", "serde_bytes", "sgx_tstd", - "sha2 0.9.5", + "sha2", "thiserror", "url", ] -[[package]] -name = "arrayref" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" - [[package]] name = "autocfg" version = "0.1.7" @@ -99,12 +93,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" -[[package]] -name = "base-x" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" - [[package]] name = "base64" version = "0.13.0" @@ -123,32 +111,13 @@ version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2da1976d75adbe5fbc88130ecd119529cf1cc6a93ae1546d8696ee66f0d21af1" -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "git+https://github.com/mesalock-linux/rustcrypto-utils-sgx#07ebf780554e018037f750186d61ea9bdc031148" -dependencies = [ - "block-padding", - "byte-tools", - "byteorder 1.3.4", - "generic-array 0.12.4", -] - [[package]] name = "block-buffer" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.4", -] - -[[package]] -name = "block-padding" -version = "0.1.4" -source = "git+https://github.com/mesalock-linux/rustcrypto-utils-sgx#07ebf780554e018037f750186d61ea9bdc031148" -dependencies = [ - "byte-tools", + "generic-array", ] [[package]] @@ -157,11 +126,6 @@ version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631" -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "git+https://github.com/mesalock-linux/rustcrypto-utils-sgx#07ebf780554e018037f750186d61ea9bdc031148" - [[package]] name = "byteorder" version = "1.3.4" @@ -209,21 +173,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - -[[package]] -name = "crypto-mac" -version = "0.8.0" -source = "git+https://github.com/mesalock-linux/rustcrypto-traits-sgx#7a5cb154f438c2401b3d8e37de96dd0acf8f493e" -dependencies = [ - "generic-array 0.12.4", - "subtle", -] - [[package]] name = "data-encoding" version = "2.3.2" @@ -243,37 +192,13 @@ dependencies = [ "syn", ] -[[package]] -name = "digest" -version = "0.8.1" -source = "git+https://github.com/mesalock-linux/rustcrypto-traits-sgx#7a5cb154f438c2401b3d8e37de96dd0acf8f493e" -dependencies = [ - "generic-array 0.12.4", - "sgx_tstd", -] - [[package]] name = "digest" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.4", -] - -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - -[[package]] -name = "generic-array" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" -dependencies = [ - "typenum", + "generic-array", ] [[package]] @@ -327,24 +252,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "hmac" -version = "0.7.1" -source = "git+https://github.com/mesalock-linux/rustcrypto-MACs-sgx#e8e1410b9c82d2e59da42fa8b0d8ed38e80a203c" -dependencies = [ - "crypto-mac", - "digest 0.8.1", -] - -[[package]] -name = "hmac-drbg" -version = "0.1.2" -source = "git+https://github.com/mesalock-linux/hmac-drbg-rs-sgx#89d6b0113157599417af867a8d2b4afd5c6f1946" -dependencies = [ - "generic-array 0.12.4", - "hmac", -] - [[package]] name = "idna" version = "0.2.0" @@ -404,22 +311,6 @@ version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7f823d141fe0a24df1e23b4af4e3c7ba9e5966ec514ea068c93024aa7deb765" -[[package]] -name = "libsecp256k1" -version = "0.3.5" -source = "git+https://github.com/ntls-io/libsecp256k1-rs-sgx#2a6c35a1876b3553486d34142155b89eaae77965" -dependencies = [ - "arrayref", - "crunchy", - "digest 0.8.1", - "hmac-drbg", - "rand 0.7.3", - "sgx_tstd", - "sha2 0.8.0", - "subtle", - "typenum", -] - [[package]] name = "log" version = "0.4.14" @@ -434,27 +325,6 @@ name = "matches" version = "0.1.8" source = "git+https://github.com/mesalock-linux/rust-std-candidates-sgx#5747bcf37f3e18687758838da0339ff0f2c83924" -[[package]] -name = "num-bigint" -version = "0.2.5" -source = "git+https://github.com/mesalock-linux/num-bigint-sgx#76a5bed94dc31c32bd1670dbf72877abcf9bbc09" -dependencies = [ - "autocfg 1.0.1", - "num-integer", - "num-traits 0.2.10", - "sgx_tstd", -] - -[[package]] -name = "num-integer" -version = "0.1.41" -source = "git+https://github.com/mesalock-linux/num-integer-sgx#404c50e5378ca635261688b080dee328ff42b6bd" -dependencies = [ - "autocfg 0.1.7", - "num-traits 0.2.10", - "sgx_tstd", -] - [[package]] name = "num-traits" version = "0.2.10" @@ -473,12 +343,6 @@ dependencies = [ "autocfg 1.0.1", ] -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - [[package]] name = "opaque-debug" version = "0.3.0" @@ -629,42 +493,6 @@ dependencies = [ "untrusted", ] -[[package]] -name = "ripemd160" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eca4ecc81b7f313189bf73ce724400a07da2a6dac19588b03c8bd76a2dcc251" -dependencies = [ - "block-buffer 0.9.0", - "digest 0.9.0", - "opaque-debug 0.3.0", -] - -[[package]] -name = "ripple-address-codec" -version = "0.1.1" -source = "git+https://github.com/ntls-io/ripple-address-codec-rust-sgx?branch=v0.1.1-sgx#e2b03486a9e0627bbc922681863b4661be8a4e3b" -dependencies = [ - "base-x", - "ring", - "sgx_tstd", -] - -[[package]] -name = "ripple-keypairs" -version = "0.1.0" -source = "git+https://github.com/ntls-io/ripple-keypairs-rust-sgx?branch=v0.1.0-sgx#ef55261e2f0aa6b5c54cac43abc4c57b4f97b286" -dependencies = [ - "base-x", - "hex", - "libsecp256k1", - "num-bigint", - "ring", - "ripemd160", - "ripple-address-codec", - "sgx_tstd", -] - [[package]] name = "rmp" version = "0.8.9" @@ -799,8 +627,6 @@ dependencies = [ "base64", "hex", "rand 0.7.3", - "ripple-address-codec", - "ripple-keypairs", "rmp-serde", "secrecy", "serde", @@ -949,29 +775,17 @@ dependencies = [ "sgx_build_helper", ] -[[package]] -name = "sha2" -version = "0.8.0" -source = "git+https://github.com/mesalock-linux/rustcrypto-hashes-sgx#54ac4af765ec6b424add4e7559e82328bd052060" -dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "fake-simd", - "opaque-debug 0.2.3", - "sgx_tstd", -] - [[package]] name = "sha2" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" dependencies = [ - "block-buffer 0.9.0", + "block-buffer", "cfg-if 1.0.0", "cpufeatures", - "digest 0.9.0", - "opaque-debug 0.3.0", + "digest", + "opaque-debug", ] [[package]] @@ -1003,14 +817,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "subtle" -version = "2.2.2" -source = "git+https://github.com/mesalock-linux/subtle-sgx#8ee32fc0902a4594bd12e272357e2d76cde9dad1" -dependencies = [ - "sgx_tstd", -] - [[package]] name = "syn" version = "1.0.74" diff --git a/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/helpers/vault_store.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/helpers/vault_store.rs index 916e160..e53c875 100644 --- a/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/helpers/vault_store.rs +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/helpers/vault_store.rs @@ -1,18 +1,9 @@ use std::prelude::v1::ToString; use sgx_vault_impl::schema::actions; -use sgx_vault_impl::schema::actions::{ - CreateVaultResult, - LoadOnfidoCheck, - LoadOnfidoCheckResult, - OnfidoCheckResult, - SaveOnfidoCheck, - SaveOnfidoCheckResult, -}; +use sgx_vault_impl::schema::actions::CreateVaultResult; use sgx_vault_impl::schema::entities::VaultDisplay; use sgx_vault_impl::vault_operations::create_vault::create_vault; -use sgx_vault_impl::vault_operations::load_onfido_check::load_onfido_check; -use sgx_vault_impl::vault_operations::save_onfido_check::save_onfido_check; pub fn create_test_vault() -> VaultDisplay { type Result = CreateVaultResult; @@ -27,31 +18,3 @@ pub fn create_test_vault() -> VaultDisplay { otherwise => panic!("{:?}", otherwise), } } - -pub fn create_test_check(existing: &VaultDisplay) -> OnfidoCheckResult { - let check = OnfidoCheckResult { - id: "stub id".to_string(), - href: "stub href".to_string(), - result: "stub result".to_string(), - sub_result: None, - }; - match save_onfido_check(&SaveOnfidoCheck { - vault_id: existing.vault_id.clone(), - auth_pin: "123456".to_string(), - check: check.clone(), - }) { - SaveOnfidoCheckResult::Saved => {} - otherwise => panic!("{:?}", otherwise), - }; - check -} - -pub fn load_test_check(existing: &VaultDisplay) -> OnfidoCheckResult { - match load_onfido_check(&LoadOnfidoCheck { - vault_id: existing.vault_id.clone(), - auth_pin: "123456".to_string(), - }) { - LoadOnfidoCheckResult::Loaded(check) => check, - otherwise => panic!("{:?}", otherwise), - } -} diff --git a/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/lib.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/lib.rs index 57c2342..eee8850 100644 --- a/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/lib.rs +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/lib.rs @@ -30,25 +30,16 @@ pub extern "C" fn run_tests_ecall() -> usize { ported::test_kv_store_fs::prop_fs_safe_roundtrip, schema::test_sealing::prop_seal_unseal_msgpack_roundtrips, schema::test_sealing::prop_seal_unseal_roundtrips, - schema::test_types::test_xrpl_key_type_serde, vault_operations::test_create_vault::create_vault_works, vault_operations::test_dispatch::vault_operation_sealing_works, - vault_operations::test_load_onfido_check::load_onfido_check_bad_pin, - vault_operations::test_load_onfido_check::load_onfido_check_malformed_vault_id, - vault_operations::test_load_onfido_check::load_onfido_check_not_found, - vault_operations::test_load_onfido_check::load_onfido_check_works, vault_operations::test_open_vault::open_vault_bad_pin, vault_operations::test_open_vault::open_vault_malformed_vault_id, vault_operations::test_open_vault::open_vault_works, - vault_operations::test_save_onfido_check::save_onfido_check_bad_pin, - vault_operations::test_save_onfido_check::save_onfido_check_malformed_vault_id, - vault_operations::test_save_onfido_check::save_onfido_check_works, vault_operations::test_sign_transaction::sign_transaction_empty, vault_operations::test_sign_transaction::sign_transaction_malformed_transaction, vault_operations::test_sign_transaction::sign_transaction_without_tag, vault_operations::test_sign_transaction::sign_transaction_works, vault_operations::test_sign_transaction_msgpack::prop_transaction_msgpack_roundtrips, - vault_operations::test_sign_transaction_xrpl::sign_transaction_empty, vault_operations::test_store::unlock_vault_bad_auth_pin, vault_operations::test_store::unlock_vault_malformed_vault_id, vault_operations::test_store::unlock_vault_not_found, diff --git a/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/schema/mod.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/schema/mod.rs index 16edc33..e9760fa 100644 --- a/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/schema/mod.rs +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/schema/mod.rs @@ -1,2 +1 @@ pub(crate) mod test_sealing; -pub(crate) mod test_types; diff --git a/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/schema/test_types.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/schema/test_types.rs deleted file mode 100644 index 41dd896..0000000 --- a/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/schema/test_types.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! Test [`sgx_vault_impl::schema::types`] - -use serde_json::Value; -use sgx_vault_impl::schema::types::XrplKeyType; - -/// [`XrplKeyType`] serializes to the same lowercase string constants used throughout the XRP Ledger. -pub(crate) fn test_xrpl_key_type_serde() { - let pairs = [ - (XrplKeyType::Secp256k1, "secp256k1"), - (XrplKeyType::Ed25519, "ed25519"), - ]; - for (key_type, expected) in pairs { - let expected_json = Value::from(expected); - assert_eq!(serde_json::to_value(&key_type).unwrap(), expected_json); - assert_eq!( - serde_json::from_value::(expected_json).unwrap(), - key_type - ); - } -} diff --git a/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/mod.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/mod.rs index fc69779..ca835bc 100644 --- a/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/mod.rs +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/mod.rs @@ -1,9 +1,6 @@ pub(crate) mod test_create_vault; pub(crate) mod test_dispatch; -pub(crate) mod test_load_onfido_check; pub(crate) mod test_open_vault; -pub(crate) mod test_save_onfido_check; pub(crate) mod test_sign_transaction; pub(crate) mod test_sign_transaction_msgpack; -pub(crate) mod test_sign_transaction_xrpl; pub(crate) mod test_store; diff --git a/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_create_vault.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_create_vault.rs index bac2ef3..22b9340 100644 --- a/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_create_vault.rs +++ b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_create_vault.rs @@ -2,7 +2,6 @@ use std::prelude::v1::ToString; use sgx_vault_impl::schema::actions; use sgx_vault_impl::schema::actions::CreateVaultResult as Result; -use sgx_vault_impl::schema::entities::XrplAccountDisplay; use sgx_vault_impl::vault_operations::create_vault::create_vault; use sgx_vault_impl::vault_operations::store::load_vault; @@ -26,12 +25,4 @@ pub(crate) fn create_vault_works() { display.algorand_address_base32, stored.algorand_account.address_base32() ); - assert_eq!( - display.xrpl_account, - XrplAccountDisplay { - key_type: stored.xrpl_account.key_type, - public_key_hex: stored.xrpl_account.to_public_key_hex(), - address_base58: stored.xrpl_account.to_address_base58() - } - ); } diff --git a/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_load_onfido_check.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_load_onfido_check.rs deleted file mode 100644 index 6a2080a..0000000 --- a/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_load_onfido_check.rs +++ /dev/null @@ -1,63 +0,0 @@ -use std::prelude::v1::ToString; - -use sgx_vault_impl::schema::actions; -use sgx_vault_impl::schema::actions::LoadOnfidoCheckResult; -use sgx_vault_impl::vault_operations::load_onfido_check::load_onfido_check; - -use crate::helpers::vault_store; -use crate::helpers::vault_store::create_test_vault; - -pub(crate) fn load_onfido_check_works() { - let existing = create_test_vault(); - let existing_check = vault_store::create_test_check(&existing); - - let request = actions::LoadOnfidoCheck { - vault_id: existing.vault_id, - auth_pin: "123456".to_string(), - }; - let loaded_check = match load_onfido_check(&request) { - LoadOnfidoCheckResult::Loaded(loaded) => loaded, - otherwise => panic!("{:?}", otherwise), - }; - - assert_eq!(existing_check, loaded_check); -} - -pub(crate) fn load_onfido_check_not_found() { - let existing = create_test_vault(); - - let request = actions::LoadOnfidoCheck { - vault_id: existing.vault_id.clone(), - auth_pin: "123456".to_string(), - }; - match load_onfido_check(&request) { - LoadOnfidoCheckResult::NotFound => (), - otherwise => panic!("{:?}", otherwise), - }; -} - -pub(crate) fn load_onfido_check_malformed_vault_id() { - let request = actions::LoadOnfidoCheck { - vault_id: "malformed".to_string(), - auth_pin: "123456".to_string(), - }; - - match load_onfido_check(&request) { - LoadOnfidoCheckResult::Failed(_) => (), - otherwise => panic!("{:?}", otherwise), - } -} - -pub(crate) fn load_onfido_check_bad_pin() { - let existing = create_test_vault(); - - let request = actions::LoadOnfidoCheck { - vault_id: existing.vault_id.clone(), - auth_pin: "000000".to_string(), - }; - - match load_onfido_check(&request) { - LoadOnfidoCheckResult::InvalidAuth => (), - otherwise => panic!("{:?}", otherwise), - } -} diff --git a/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_save_onfido_check.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_save_onfido_check.rs deleted file mode 100644 index 45843a4..0000000 --- a/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_save_onfido_check.rs +++ /dev/null @@ -1,63 +0,0 @@ -use std::prelude::v1::ToString; - -use sgx_vault_impl::schema::actions; -use sgx_vault_impl::schema::actions::{OnfidoCheckResult, SaveOnfidoCheckResult}; -use sgx_vault_impl::schema::types::VaultPin; -use sgx_vault_impl::vault_operations::save_onfido_check::save_onfido_check; - -use crate::helpers::vault_store::{create_test_vault, load_test_check}; - -fn get_check() -> OnfidoCheckResult { - OnfidoCheckResult { - id: "stub id".to_string(), - href: "stub href".to_string(), - result: "stub result".to_string(), - sub_result: None, - } -} - -pub(crate) fn save_onfido_check_works() { - let existing = create_test_vault(); - let check = get_check(); - - let request = actions::SaveOnfidoCheck { - vault_id: existing.vault_id.clone(), - auth_pin: VaultPin::from("123456"), - check: check.clone(), - }; - match save_onfido_check(&request) { - SaveOnfidoCheckResult::Saved => {} - otherwise => panic!("{:?}", otherwise), - }; - - let saved = load_test_check(&existing); - assert_eq!(saved, check) -} - -pub(crate) fn save_onfido_check_malformed_vault_id() { - let request = actions::SaveOnfidoCheck { - vault_id: "malformed".into(), - auth_pin: "123456".into(), - check: get_check(), - }; - - match save_onfido_check(&request) { - SaveOnfidoCheckResult::Failed(_) => (), - otherwise => panic!("{:?}", otherwise), - } -} - -pub(crate) fn save_onfido_check_bad_pin() { - let existing = create_test_vault(); - - let request = actions::SaveOnfidoCheck { - vault_id: existing.vault_id, - auth_pin: "000000".to_string(), - check: get_check(), - }; - - match save_onfido_check(&request) { - SaveOnfidoCheckResult::InvalidAuth => (), - otherwise => panic!("{:?}", otherwise), - } -} diff --git a/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_sign_transaction_xrpl.rs b/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_sign_transaction_xrpl.rs deleted file mode 100644 index 1f55333..0000000 --- a/rust-sgx-workspace/projects/sgx-vault-test/enclave/src/vault_operations/test_sign_transaction_xrpl.rs +++ /dev/null @@ -1,32 +0,0 @@ -use std::prelude::v1::ToString; - -use sgx_vault_impl::schema::actions; -use sgx_vault_impl::schema::actions::{TransactionSigned, TransactionToSign}; -use sgx_vault_impl::vault_operations::sign_transaction::sign_transaction; - -use crate::helpers::vault_store::create_test_vault; - -pub(crate) fn sign_transaction_empty() { - let existing = &create_test_vault(); - - let transaction_bytes = Default::default(); - - let request = &actions::SignTransaction { - vault_id: existing.vault_id.clone(), - auth_pin: "123456".to_string(), - transaction_to_sign: TransactionToSign::XrplTransaction { transaction_bytes }, - }; - let signed = sign_transaction(request).unwrap_signed(); - - match signed { - TransactionSigned::XrplTransactionSigned { - signed_transaction_bytes: _, - signature_bytes, - } => { - assert_eq!(signature_bytes[0], 0x30); // DER tag for SEQUENCE - } - otherwise => panic!("unexpected: {:?}", otherwise), - } - - // TODO(Pi): Test more substantially. -} diff --git a/rust-sgx-workspace/projects/sgx-vault/enclave/Cargo.lock b/rust-sgx-workspace/projects/sgx-vault/enclave/Cargo.lock index 2001896..ad59d57 100644 --- a/rust-sgx-workspace/projects/sgx-vault/enclave/Cargo.lock +++ b/rust-sgx-workspace/projects/sgx-vault/enclave/Cargo.lock @@ -25,7 +25,7 @@ dependencies = [ "rmp-serde", "serde", "sgx_tstd", - "sha2 0.9.5", + "sha2", "static_assertions", "thiserror", ] @@ -43,7 +43,7 @@ dependencies = [ "ring", "serde", "sgx_tstd", - "sha2 0.9.5", + "sha2", "static_assertions", "thiserror", ] @@ -76,17 +76,11 @@ dependencies = [ "serde", "serde_bytes", "sgx_tstd", - "sha2 0.9.5", + "sha2", "thiserror", "url", ] -[[package]] -name = "arrayref" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" - [[package]] name = "autocfg" version = "0.1.7" @@ -99,44 +93,19 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" -[[package]] -name = "base-x" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" - [[package]] name = "base64" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "git+https://github.com/mesalock-linux/rustcrypto-utils-sgx#07ebf780554e018037f750186d61ea9bdc031148" -dependencies = [ - "block-padding", - "byte-tools", - "byteorder", - "generic-array 0.12.4", -] - [[package]] name = "block-buffer" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.4", -] - -[[package]] -name = "block-padding" -version = "0.1.4" -source = "git+https://github.com/mesalock-linux/rustcrypto-utils-sgx#07ebf780554e018037f750186d61ea9bdc031148" -dependencies = [ - "byte-tools", + "generic-array", ] [[package]] @@ -145,11 +114,6 @@ version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631" -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "git+https://github.com/mesalock-linux/rustcrypto-utils-sgx#07ebf780554e018037f750186d61ea9bdc031148" - [[package]] name = "byteorder" version = "1.3.4" @@ -191,21 +155,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - -[[package]] -name = "crypto-mac" -version = "0.8.0" -source = "git+https://github.com/mesalock-linux/rustcrypto-traits-sgx#7a5cb154f438c2401b3d8e37de96dd0acf8f493e" -dependencies = [ - "generic-array 0.12.4", - "subtle", -] - [[package]] name = "data-encoding" version = "2.3.2" @@ -225,37 +174,13 @@ dependencies = [ "syn", ] -[[package]] -name = "digest" -version = "0.8.1" -source = "git+https://github.com/mesalock-linux/rustcrypto-traits-sgx#7a5cb154f438c2401b3d8e37de96dd0acf8f493e" -dependencies = [ - "generic-array 0.12.4", - "sgx_tstd", -] - [[package]] name = "digest" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.4", -] - -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - -[[package]] -name = "generic-array" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" -dependencies = [ - "typenum", + "generic-array", ] [[package]] @@ -309,24 +234,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "hmac" -version = "0.7.1" -source = "git+https://github.com/mesalock-linux/rustcrypto-MACs-sgx#e8e1410b9c82d2e59da42fa8b0d8ed38e80a203c" -dependencies = [ - "crypto-mac", - "digest 0.8.1", -] - -[[package]] -name = "hmac-drbg" -version = "0.1.2" -source = "git+https://github.com/mesalock-linux/hmac-drbg-rs-sgx#89d6b0113157599417af867a8d2b4afd5c6f1946" -dependencies = [ - "generic-array 0.12.4", - "hmac", -] - [[package]] name = "idna" version = "0.2.0" @@ -386,22 +293,6 @@ version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7f823d141fe0a24df1e23b4af4e3c7ba9e5966ec514ea068c93024aa7deb765" -[[package]] -name = "libsecp256k1" -version = "0.3.5" -source = "git+https://github.com/ntls-io/libsecp256k1-rs-sgx#2a6c35a1876b3553486d34142155b89eaae77965" -dependencies = [ - "arrayref", - "crunchy", - "digest 0.8.1", - "hmac-drbg", - "rand", - "sgx_tstd", - "sha2 0.8.0", - "subtle", - "typenum", -] - [[package]] name = "log" version = "0.4.14" @@ -416,27 +307,6 @@ name = "matches" version = "0.1.8" source = "git+https://github.com/mesalock-linux/rust-std-candidates-sgx#5747bcf37f3e18687758838da0339ff0f2c83924" -[[package]] -name = "num-bigint" -version = "0.2.5" -source = "git+https://github.com/mesalock-linux/num-bigint-sgx#76a5bed94dc31c32bd1670dbf72877abcf9bbc09" -dependencies = [ - "autocfg 1.0.1", - "num-integer", - "num-traits", - "sgx_tstd", -] - -[[package]] -name = "num-integer" -version = "0.1.41" -source = "git+https://github.com/mesalock-linux/num-integer-sgx#404c50e5378ca635261688b080dee328ff42b6bd" -dependencies = [ - "autocfg 0.1.7", - "num-traits", - "sgx_tstd", -] - [[package]] name = "num-traits" version = "0.2.10" @@ -446,12 +316,6 @@ dependencies = [ "sgx_tstd", ] -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - [[package]] name = "opaque-debug" version = "0.3.0" @@ -536,42 +400,6 @@ dependencies = [ "untrusted", ] -[[package]] -name = "ripemd160" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eca4ecc81b7f313189bf73ce724400a07da2a6dac19588b03c8bd76a2dcc251" -dependencies = [ - "block-buffer 0.9.0", - "digest 0.9.0", - "opaque-debug 0.3.0", -] - -[[package]] -name = "ripple-address-codec" -version = "0.1.1" -source = "git+https://github.com/ntls-io/ripple-address-codec-rust-sgx?branch=v0.1.1-sgx#e2b03486a9e0627bbc922681863b4661be8a4e3b" -dependencies = [ - "base-x", - "ring", - "sgx_tstd", -] - -[[package]] -name = "ripple-keypairs" -version = "0.1.0" -source = "git+https://github.com/ntls-io/ripple-keypairs-rust-sgx?branch=v0.1.0-sgx#ef55261e2f0aa6b5c54cac43abc4c57b4f97b286" -dependencies = [ - "base-x", - "hex", - "libsecp256k1", - "num-bigint", - "ring", - "ripemd160", - "ripple-address-codec", - "sgx_tstd", -] - [[package]] name = "rmp" version = "0.8.9" @@ -691,8 +519,6 @@ dependencies = [ "base64", "hex", "rand", - "ripple-address-codec", - "ripple-keypairs", "rmp-serde", "secrecy", "serde", @@ -804,29 +630,17 @@ dependencies = [ "sgx_build_helper", ] -[[package]] -name = "sha2" -version = "0.8.0" -source = "git+https://github.com/mesalock-linux/rustcrypto-hashes-sgx#54ac4af765ec6b424add4e7559e82328bd052060" -dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "fake-simd", - "opaque-debug 0.2.3", - "sgx_tstd", -] - [[package]] name = "sha2" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" dependencies = [ - "block-buffer 0.9.0", + "block-buffer", "cfg-if 1.0.0", "cpufeatures", - "digest 0.9.0", - "opaque-debug 0.3.0", + "digest", + "opaque-debug", ] [[package]] @@ -858,14 +672,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "subtle" -version = "2.2.2" -source = "git+https://github.com/mesalock-linux/subtle-sgx#8ee32fc0902a4594bd12e272357e2d76cde9dad1" -dependencies = [ - "sgx_tstd", -] - [[package]] name = "syn" version = "1.0.74" From 266a57d184f923a620d34fa644515a80babb5696 Mon Sep 17 00:00:00 2001 From: Bill Guo Date: Tue, 6 Sep 2022 11:28:31 +0200 Subject: [PATCH 10/22] feat(rust-sgx-workspace): add Docker build definition for Vault server (#67) --- rust-sgx-workspace/.dockerignore | 73 +++++ rust-sgx-workspace/Dockerfile | 291 ++++++++++++++++++ rust-sgx-workspace/Dockerfile.pdf | Bin 0 -> 12082 bytes rust-sgx-workspace/docker-compose.yaml | 68 ++++ rust-sgx-workspace/generate-Dockerfile.pdf.sh | 9 + rust-sgx-workspace/generate-dockerignore.sh | 24 ++ 6 files changed, 465 insertions(+) create mode 100644 rust-sgx-workspace/.dockerignore create mode 100644 rust-sgx-workspace/Dockerfile create mode 100644 rust-sgx-workspace/Dockerfile.pdf create mode 100644 rust-sgx-workspace/docker-compose.yaml create mode 100755 rust-sgx-workspace/generate-Dockerfile.pdf.sh create mode 100755 rust-sgx-workspace/generate-dockerignore.sh diff --git a/rust-sgx-workspace/.dockerignore b/rust-sgx-workspace/.dockerignore new file mode 100644 index 0000000..c1fc071 --- /dev/null +++ b/rust-sgx-workspace/.dockerignore @@ -0,0 +1,73 @@ +# Generated by generate-dockerignore.sh +* +!Cargo.lock +!Cargo.toml +!crates/http-service-impl/Cargo.toml +!crates/http-service-impl/src/ +!crates/sgx-helpers/Cargo.toml +!crates/sgx-helpers/src/ +!crates/sgx-vault-impl/Cargo.lock +!crates/sgx-vault-impl/Cargo.toml +!crates/sgx-vault-impl/src/ +!projects/ntc-tee-server/Makefile +!projects/ntc-tee-server/app/Cargo.toml +!projects/ntc-tee-server/app/Makefile +!projects/ntc-tee-server/app/build.rs +!projects/ntc-tee-server/app/codegen/Enclave_u.c +!projects/ntc-tee-server/app/codegen/Enclave_u.h +!projects/ntc-tee-server/app/codegen/Enclave_u.rs +!projects/ntc-tee-server/app/src/ +!projects/ntc-tee-server/buildenv.mk +!projects/ntc-tee-server/buildenv_sgx.mk +!projects/ntc-tee-server/enclave/Cargo.toml +!projects/ntc-tee-server/enclave/Enclave.config.xml +!projects/ntc-tee-server/enclave/Enclave.edl +!projects/ntc-tee-server/enclave/Enclave.lds +!projects/ntc-tee-server/enclave/Makefile +!projects/ntc-tee-server/enclave/codegen/Enclave_t.c +!projects/ntc-tee-server/enclave/codegen/Enclave_t.h +!projects/ntc-tee-server/enclave/src/ +!projects/sgx-vault-test/Makefile +!projects/sgx-vault-test/Makefile.toml +!projects/sgx-vault-test/app/Cargo.lock +!projects/sgx-vault-test/app/Cargo.toml +!projects/sgx-vault-test/app/Makefile +!projects/sgx-vault-test/app/build.rs +!projects/sgx-vault-test/app/codegen/Enclave_u.c +!projects/sgx-vault-test/app/codegen/Enclave_u.h +!projects/sgx-vault-test/app/codegen/Enclave_u.rs +!projects/sgx-vault-test/app/src/ +!projects/sgx-vault-test/buildenv.mk +!projects/sgx-vault-test/buildenv_sgx.mk +!projects/sgx-vault-test/enclave/Cargo.lock +!projects/sgx-vault-test/enclave/Cargo.toml +!projects/sgx-vault-test/enclave/Enclave.config.xml +!projects/sgx-vault-test/enclave/Enclave.edl +!projects/sgx-vault-test/enclave/Enclave.lds +!projects/sgx-vault-test/enclave/Makefile +!projects/sgx-vault-test/enclave/codegen/Enclave_t.c +!projects/sgx-vault-test/enclave/codegen/Enclave_t.h +!projects/sgx-vault-test/enclave/src/ +!projects/sgx-vault/Makefile +!projects/sgx-vault/Makefile.toml +!projects/sgx-vault/app/Cargo.lock +!projects/sgx-vault/app/Cargo.toml +!projects/sgx-vault/app/Makefile +!projects/sgx-vault/app/build.rs +!projects/sgx-vault/app/codegen/Enclave_u.c +!projects/sgx-vault/app/codegen/Enclave_u.h +!projects/sgx-vault/app/codegen/Enclave_u.rs +!projects/sgx-vault/app/src/ +!projects/sgx-vault/buildenv.mk +!projects/sgx-vault/buildenv_sgx.mk +!projects/sgx-vault/enclave/Cargo.lock +!projects/sgx-vault/enclave/Cargo.toml +!projects/sgx-vault/enclave/Enclave.config.xml +!projects/sgx-vault/enclave/Enclave.edl +!projects/sgx-vault/enclave/Enclave.lds +!projects/sgx-vault/enclave/Makefile +!projects/sgx-vault/enclave/codegen/Enclave_t.c +!projects/sgx-vault/enclave/codegen/Enclave_t.h +!projects/sgx-vault/enclave/src/ +!rust-toolchain.toml +!rustfmt.toml diff --git a/rust-sgx-workspace/Dockerfile b/rust-sgx-workspace/Dockerfile new file mode 100644 index 0000000..3c14476 --- /dev/null +++ b/rust-sgx-workspace/Dockerfile @@ -0,0 +1,291 @@ +# Docker build for the Nautilus Vault server. +# +# See the top-level docker-compose.yaml for a simpler entrypoint into this Dockerfile. +# +# This build relies heavily on multi-stage build features. To help understand what's going on: +# +# - Run: grep -A1 'STAGE: .*' Dockerfile +# - See: Dockerfile.pdf (generated by `generate-Dockerfile.pdf.sh`) +# +# Stage naming convention: +# +# base-* A general base for later stages +# *-builder A base stage for building a kind of target +# *-runner A base stage for running a kind of target +# +# build-* Build a particular target +# run-* Run a particular target (probably built by a corresponding build-* stage) +# +# *-sw Variant for SW-mode SGX stages +# *-hw Variant for HW-mode SGX stages +# +# NOTE: This build uses a combination of both the `SGX_MODE` build arg for build stages, +# and SW/HW variants for run stages. Combining these incorrectly will result in an unusable image: +# a SW-mode runner can't run a target built for HW-mode, and vice versa. +# Docker doesn't allow eliminating this easily, so for now, the caller must match SGX_MODE with the runner variant. +# +# The enclave build stages optionally take an existing signing key as input. +# To pass this to the enclave build steps, use something like: +# +# --secret id=sgx-signing-key,src=/Enclave_private.pem +# +# (If an existing key is not provided, the build will generate a new key.) +# +# XXX: Note that changing the key does NOT invalidate the docker instruction cache: +# the key will only be used for uncached steps. +# +# This assumes an up-to-date `.dockerignore`: see `generate-dockerignore.sh` + +# Pre-stage build args: + +# This should match rust-toolchain.toml +ARG RUST_TOOLCHAIN="nightly-2021-11-01" + +# Intel SGX SDK 2.15.1 +# Docs: https://01.org/intel-softwareguard-extensions/downloads/intel-sgx-linux-2.15.1-release +ARG INTEL_SGX_SDK_INSTALLER_URL="https://download.01.org/intel-sgx/sgx-linux/2.15.1/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.101.1.bin" + +# Rust SGX SDK 1.1.4 (merge of v1.1.4-testing branch) +# Upstream issue: https://github.com/apache/incubator-teaclave-sgx-sdk/issues/360 +# Latest compatible revision since then: https://github.com/apache/incubator-teaclave-sgx-sdk/commit/e8a9fc22939befa27ff67f5509b2c2dfe8499945 +ARG RUST_SGX_SDK_REVISION="e8a9fc22939befa27ff67f5509b2c2dfe8499945" + +ARG SGX_MODE="SW" + +# STAGE: base +# Common base for both builder and runner stages, with apt caching, ca-certificates, and a non-root user +FROM ubuntu:20.04 AS base + +RUN rm /etc/apt/apt.conf.d/docker-clean + +RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ + --mount=type=cache,sharing=locked,target=/var/lib/apt \ + apt-get update && apt-get install -y -o APT::Keep-Downloaded-Packages=true \ + ca-certificates + +RUN useradd user --create-home --uid 1000 +USER user +WORKDIR /home/user + +# STAGE: base-builder (from base) +# Base for builder stages, with build-essential, building under /build +FROM base AS base-builder + +USER root +RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ + --mount=type=cache,sharing=locked,target=/var/lib/apt \ + apt-get update && apt-get install -y -o APT::Keep-Downloaded-Packages=true \ + build-essential +USER user + +WORKDIR /build + +# STAGE: intel-sgx-sdk-provider (from base-builder, arg INTEL_SGX_SDK_INSTALLER_URL) +# This provides the Intel SGX SDK under /build/intel/sgxsdk +FROM base-builder AS intel-sgx-sdk-provider + +ARG INTEL_SGX_SDK_INSTALLER_URL +ADD --chown=user:user "${INTEL_SGX_SDK_INSTALLER_URL}" /build/intel/sgx_linux_x64_sdk.bin + +RUN chmod +x "/build/intel/sgx_linux_x64_sdk.bin" +RUN /build/intel/sgx_linux_x64_sdk.bin --prefix /build/intel + +# STAGE: rust-sgx-sdk-provider (from base-builder, arg RUST_SGX_SDK_REVISION) +# This provides the Rust SGX SDK include files under /build/rust-sgx-sdk +FROM base-builder AS rust-sgx-sdk-provider + +USER root +RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ + --mount=type=cache,sharing=locked,target=/var/lib/apt \ + apt-get update && apt-get install -y -o APT::Keep-Downloaded-Packages=true \ + git +USER user + +RUN git clone --no-checkout --filter=tree:0 https://github.com/apache/incubator-teaclave-sgx-sdk /build/rust-sgx-sdk +RUN git -C /build/rust-sgx-sdk sparse-checkout set /common /edl +ARG RUST_SGX_SDK_REVISION +RUN git -C /build/rust-sgx-sdk switch -d "${RUST_SGX_SDK_REVISION}" + +# STAGE: rust-builder (from base-builder, arg RUST_TOOLCHAIN) +# Builder for Rust, with Rust toolchain and cargo build tools (bindgen, cargo make) under /home/user/.cargo +FROM base-builder AS rust-builder + +ADD --chown=user:user "https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init" /home/user/rustup-init +RUN chmod +rx /home/user/rustup-init +ARG RUST_TOOLCHAIN +RUN /home/user/rustup-init -y --no-modify-path --default-toolchain "${RUST_TOOLCHAIN}" + +# Hack to initialise the crates.io cache. +RUN --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/home/user/.cargo/registry \ + --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/home/user/.cargo/git \ + . ~/.cargo/env && \ + cargo search --limit 0 + +# Requirements for bindgen: https://rust-lang.github.io/rust-bindgen/requirements.html +USER root +RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ + --mount=type=cache,sharing=locked,target=/var/lib/apt \ + apt-get update && apt-get install -y -o APT::Keep-Downloaded-Packages=true \ + llvm-dev \ + libclang-dev \ + clang +USER user + +RUN --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/home/user/.cargo/registry \ + --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/home/user/.cargo/git \ + . ~/.cargo/env && \ + cargo install bindgen + +# Cargo make +USER root +RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ + --mount=type=cache,sharing=locked,target=/var/lib/apt \ + apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y -o APT::Keep-Downloaded-Packages=true \ + unzip +USER user +ADD --chown=user:user https://github.com/sagiegurari/cargo-make/releases/download/0.34.0/cargo-make-v0.34.0-x86_64-unknown-linux-musl.zip /build/cargo-make.zip +RUN unzip -j -d /home/user/.cargo/bin /build/cargo-make.zip '*/cargo-make' + +# STAGE: rust-sgx-builder (from rust-builder) +# Builder for Rust SGX, with the Intel and Rust SGX SDKs files +FROM rust-builder AS rust-sgx-builder + +# Requirements for building the Rust SGX SDK packages. +USER root +RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ + --mount=type=cache,sharing=locked,target=/var/lib/apt \ + apt-get update && apt-get install -y -o APT::Keep-Downloaded-Packages=true \ + libtool +USER user + +COPY --from=intel-sgx-sdk-provider /build/intel/sgxsdk /build/intel/sgxsdk +COPY --from=rust-sgx-sdk-provider /build/rust-sgx-sdk /build/rust-sgx-sdk + +# STAGE: web-server-builder (from rust-sgx-builder) +# Builder for this project, with source files under /build/web-server +FROM rust-sgx-builder AS web-server-builder + +WORKDIR /build/web-server +COPY --chown=user ./projects/sgx-vault-test ./projects/sgx-vault-test +COPY --chown=user ./projects/sgx-vault ./projects/sgx-vault +COPY --chown=user ./crates ./crates + +# STAGE: build-sgx-vault-server (from web-server-builder, arg SGX_MODE, secret sgx-signing-key) +# Build the sgx-vault server, in the given mode. +FROM web-server-builder AS build-sgx-vault-server + +ARG SGX_MODE +RUN --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/home/user/.cargo/registry \ + --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/home/user/.cargo/git \ + --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/build/web-server/projects/sgx-vault/app/target \ + --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/build/web-server/projects/sgx-vault/enclave/target \ + --mount=type=secret,uid=1000,gid=1000,id=sgx-signing-key,target=/build/web-server/projects/sgx-vault/keys/Enclave_private.pem \ + . ~/.cargo/env && \ + . /build/intel/sgxsdk/environment && \ + CUSTOM_COMMON_PATH="/build/rust-sgx-sdk/common" \ + CUSTOM_EDL_PATH="/build/rust-sgx-sdk/edl" \ + SGX_MODE="${SGX_MODE}" \ + make -C ./projects/sgx-vault + +# STAGE: build-sgx-vault-test (from web-server-builder, arg SGX_MODE, secret sgx-signing-key) +# Build the sgx-vault tests, in the given mode. +FROM web-server-builder AS build-sgx-vault-test + +ARG SGX_MODE +RUN --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/home/user/.cargo/registry \ + --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/home/user/.cargo/git \ + --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/build/web-server/projects/sgx-vault-test/app/target \ + --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/build/web-server/projects/sgx-vault-test/enclave/target \ + --mount=type=secret,uid=1000,gid=1000,id=sgx-signing-key,target=/build/web-server/projects/sgx-vault-test/keys/Enclave_private.pem \ + . ~/.cargo/env && \ + . /build/intel/sgxsdk/environment && \ + CUSTOM_COMMON_PATH="/build/rust-sgx-sdk/common" \ + CUSTOM_EDL_PATH="/build/rust-sgx-sdk/edl" \ + SGX_MODE="${SGX_MODE}" \ + make -C ./projects/sgx-vault-test + +# STAGE: base-sgx-runner-sw (FROM base) +# Base runner, with SW-mode SGX libraries. +FROM base AS base-sgx-runner-sw + +USER root +RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ + --mount=type=cache,sharing=locked,target=/var/lib/apt \ + apt-get update && apt-get install -y -o APT::Keep-Downloaded-Packages=true \ + libssl1.1 +USER user + +COPY --from=intel-sgx-sdk-provider /build/intel/sgxsdk/lib64 /build/intel/sgxsdk/lib64 +COPY --from=intel-sgx-sdk-provider /build/intel/sgxsdk/sdk_libs /build/intel/sgxsdk/sdk_libs + +ENV LD_LIBRARY_PATH=/build/intel/sgxsdk/sdk_libs + +# STAGE: base-sgx-runner-hw (FROM base) +# Base runner, with HW-mode SGX libraries. +FROM base AS base-sgx-runner-hw + +USER root +# Requirements for apt-key +RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ + --mount=type=cache,sharing=locked,target=/var/lib/apt \ + apt-get update && apt-get install -y -o APT::Keep-Downloaded-Packages=true \ + gnupg +# Docs: https://download.01.org/intel-sgx/sgx-linux/2.14/docs/Intel_SGX_SW_Installation_Guide_for_Linux.pdf +ADD "https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key" /build/intel/intel-sgx-deb.key +RUN apt-key add /build/intel/intel-sgx-deb.key +RUN echo 'deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu focal main' >/etc/apt/sources.list.d/intel-sgx.list +RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ + --mount=type=cache,sharing=locked,target=/var/lib/apt \ + apt-get update && apt-get install -y -o APT::Keep-Downloaded-Packages=true \ + libsgx-epid \ + libsgx-quote-ex \ + libsgx-dcap-ql +USER user + +CMD /app/sgx-vault-app + +# STAGE: run-sgx-vault-server-sw (from base-sgx-runner-sw) +# Run the sgx-vault server in SW mode. +FROM base-sgx-runner-sw AS run-sgx-vault-server-sw + +WORKDIR /app +COPY --from=build-sgx-vault-server /build/web-server/projects/sgx-vault/build/bin/enclave.signed.so /app +COPY --from=build-sgx-vault-server /build/web-server/projects/sgx-vault/build/bin/sgx-vault-app /app +RUN mkdir /app/vault_store +VOLUME /app/vault_store +CMD /app/sgx-vault-app + +# STAGE: run-sgx-vault-server-hw (from base-sgx-runner-hw) +# Run the sgx-vault server in HW mode. +FROM base-sgx-runner-hw AS run-sgx-vault-server-hw + +WORKDIR /app +COPY --from=build-sgx-vault-server /build/web-server/projects/sgx-vault/build/bin/enclave.signed.so /app +COPY --from=build-sgx-vault-server /build/web-server/projects/sgx-vault/build/bin/sgx-vault-app /app +RUN mkdir /app/vault_store +VOLUME /app/vault_store +CMD /app/sgx-vault-app + +# STAGE: run-sgx-vault-test-sw (from base-sgx-runner-sw) +# Run the sgx-vault tests in SW mode. +FROM base-sgx-runner-sw AS run-sgx-vault-test-sw + +WORKDIR /app +COPY --from=build-sgx-vault-test /build/web-server/projects/sgx-vault-test/build/bin/enclave.signed.so /app +COPY --from=build-sgx-vault-test /build/web-server/projects/sgx-vault-test/build/bin/sgx-vault-test-app /app +RUN mkdir /app/vault_store +VOLUME /app/vault_store +VOLUME /tmp +CMD /app/sgx-vault-test-app + +# STAGE: run-sgx-vault-test-hw (from base-sgx-runner-hw) +# Run the sgx-vault tests in HW mode. +FROM base-sgx-runner-hw AS run-sgx-vault-test-hw + +WORKDIR /app +COPY --from=build-sgx-vault-test /build/web-server/projects/sgx-vault-test/build/bin/enclave.signed.so /app +COPY --from=build-sgx-vault-test /build/web-server/projects/sgx-vault-test/build/bin/sgx-vault-test-app /app +RUN mkdir /app/vault_store +VOLUME /app/vault_store +VOLUME /tmp +CMD /app/sgx-vault-test-app diff --git a/rust-sgx-workspace/Dockerfile.pdf b/rust-sgx-workspace/Dockerfile.pdf new file mode 100644 index 0000000000000000000000000000000000000000..4401a3d6497a90fae75a82c3278bfcc38d9a3a75 GIT binary patch literal 12082 zcmbuF1yCGK*YA_yZV4`nJM7}_u7M!ISzwU>i(AkD!QGvp2~Kc#f#nl3@k0aih}K9+uytashwv87VCs?02(rmAmrdz;iRTF|?>fGD|Dv2o++EDdrT65xrU zC-CR-=$bG8b@z4mS$1#f(br%1_w2zHZJfarKDr01Grgp3U)p_HmPscly~9Cv1lE|o z!cuO?qh+Tj;5eS+BF>!&Jw-nFbVSH>L#3oe;90Fu&S<38=gk$xH+T##Sr-zTHQb}w zl5fm_$`RO1o-qK8U=@~|l07t{ra-=#AA1Ak-Z!iEzutZZbAM^T{!Wg?Vlp5WqU9{*y&`r9V7{4-ESoA>>X zv+bF1oKwC}cJ@@vV?Ea%r@JzLXmlW0KUQxVzc8FO|duOsY5pQlF!6y43gPaPh-gW4j=zVV*z2|3_8R5m(`TnI_b_MtsSLC>Kyy#+!JLXfULcKaqkSjQL69ibazRd{ zM}uGNiyqzmK<@`NEZ2|#U>3K z)h9=Z^@Uqg&sK5zP=3}Qc0WffjG4d)RAeVYgbRHs{Q+fOtcUs*jZn0bAP|2T9YAoDokCJh-ayKGJKC}B)%)r z;HL7m5+1Eay77cWkzv3ASs3ch@7cqZ=e|4N;Kd&6DAMNHVEU7oK?q0u=SZ6AZcQ`e_>TwU^$QVcLcVZB)I8l3*UCBdr3@<+G z1_rdaiOa;?A)`d!4=py<8S(3PtdInS zOOz>}Xr?E*5{G!muy0;&liYd!C|AGC5MtOrUWpjZQmfx10Pv71b(u}3IvZK{%smwE zbQ!6Y&PURTMF^Ie`Lgk(`91Piq*EJoHde8OuqGD$Mf{M9xg}>Cu{4ah7urS}pIAA* zxn`&dr+@ScFK0~Lnq>1+l~2Zr3>$eRWyVV$Mc6IU%~CHi`8sEd`DdfP0s zlRzZtc;`BzfdFU5m&oL)h%}A}*U0u@a6-WQhEn3gFScAJT*eDB)C3%B0RmhSxa>~o zkx!VCUT9EfMy^U=(+hFsF1(b^;}Oh7-&Q|{ z@fw*Un*6mO`VRKsWs5PMNI1v6ePw?tzae@6TL^PRz(qnYH(=+5Y_6Az`tZK~X+%mw z<5ATt?TLi4f6sURDEE|hbBxZ%k2#YVyj%!Xd|eWEwqhJnMtB}s#~Cg(Mqli9TGrI_hvk#UXwyz8jKG@^oH=-2C zOcnRPuu?8>pvA#8VaE?rN45g?&$IZJJtg%%n^iRPzs4Ud1$zZypdqZLnz9gS zzGLixgGjStnz(Lr7cF3z?b6J=Yr-%Uwy~2{@a~RwT~>|UKyD*j<+s& zU{?6Fxs$t>O`g#-;xn-Nsac%BWYuPZ%_Xqk$s+CN=e9-?_D=yTvm!{H7=v9FmPec@ zMPmCIOm)-+h}$xrDh9c6wQ#of57*zR&M;LU=Mdsdu0p2qAyp#j%U`UX~-b@wlyOeroM zORM&Oui^=E%;e`p#!6p~OJHk>4iI#o0X9MeP0wjL1$7yfu28sucJb+3N%c0`9%I=1 z(t$rHoDT4m3YFU+f_Y4KDUiv@`s;&*pu;U;iut|d)ra;N8Lx%un0LGRE3}2(+Zh(^ zKa$5VdA86ZB=@bVR}mQYu$ko>}XIzQ-J%K@i#< zfE(~Z-2;Pd`7F}L@cy{)o`IDGHMeg?pP!NDs@rj`pcWu6=+Htqus24xdl?hWJi&8PyB~?< zjX7e!1}>uY?}X?bq^__~B5W!~3g~qboy5=LOq9LKpzK`VCJ+g=<<2m`ENFqIG~hFs zS*P@tYF71{rzBRePO@El$T%#rI08Mo(K0OEuJ0)yRD9~r*hlBn6sPlGr+QFH*eW8i z(v73l%|S{0tsG7*=pl3&?q@M#f|ienWJ+Zn4Wbn5*Id{9%W9H=v1J8TvrG8V%#f71 zZnG!QYWm({a{_3Q6~gQK0rCr^`P-VW-f`QbT&G1APcp2`u>xN8y5{SSSz0VCoyFqv z%yn-B9$1Y4#xkwe`kJ<(8Cc79a4Em+=A7yd5SBKpQD%-0^~#q9`%_ai!jIIAWRAjw zNVE<1rj(~a&t`)CSmk2&GNpo1gfZ@vstw&KPBEtk8nE8Zc$k?`859pE@p{OS>S-f_ z-n2F6pev@o5#nU!!kRKMDQi}mq8j3|*(sL(0yn!{o~A-vofzYkmnMg`_c{&Vo`$Nm z$d&(MO5NeQTIS>O3!s`b%@>vOuyAkz|C?Fp>$fVz?C0kUBn9rS)Td?@@O`_VvFN^# ziz$AHET~>M`3kX8vh_N6H?sNlw!j$gXBVTiPj`12B7wMAK3x4^#{{v6$=6S~?FdtW z0zcfpch>4@&(pF#O`DpTg`YjM#t&`&q_{<(cWo|nxVfLiQo&sJ-Dme?ssCjt1%Ze& z7(v;qX~%7JQ;zPNSZ+7Z85|vc3nM0_qfFon`zr(tvZtf|$gKE{o-CqH8=2h|IGg*u zn?dCbT4bi61vRf2Y$Jkq%^z^;2`YhD+{j!W;#T5*gGWIUI@%YDArw11x9}IiOta4V z;Sn!sg$op7Yc+>XaNnU`BuF6CT~5~_wpjugjccE#(=}Wk?q8DVQtO|WCa3v{)(4jMzH@s zE93aPG61`Vhdl(q{t|2f0nh?Kzbk(Uc7(vn0{xYjT^V9#1(vXL2k5~hAOOSz1Oa$? zH~|K~%_U(K!|a^^kMa5+!MUuXos0cH8uLdbztz8b^9okABN*yr|5%x+$6vBMz}e9S z@>fa{W+er2wK9dM%St?ofA&=!;$-LIXbN!xJo-)jA6?^xrT=TqfbZ{S{h!th9zFZV z;sOZ3#{=a1k41z<9W?hBQ<{dYTGvZVO+jl-SQq=7^rls<2rosi z5c8XjniuacZ(ZA4>CgGLhcm84eYUTDW#dVpP;$&E`AH>}>sDMu@2 z?o($%mRqIdR<;AbmVe;$UTBY7xib6T&t;@B$uf*_DT_wePw2Cb_0o!YuxGVo|{2UMcwHW*3yWW z8suqe>$Vn~ksz&k`q#Y3U?VD0E3W2i8CUdz7jpgfC!%z96t7~ZoP-$3`2^kZ)J8G0 z$XL{bb+Q&%RJEv8gQmsZci^h^?7eT;jp{b>6uuaGXZxl{#{uSy&2EKxf?uuI$vw45 zPbZCC6AHc7d2ZsI!CWXs)=RlLv2v}r9ZZ+e9{PM8QmN7SdatO*2qkmM+UVsi3knWg zFh=axsRz`t*)VBU*Fev1ePP%AfuoZ9BB%*XvsKbZr7iC$Axp037 z+7fSC>o^j=y*!-r26RUBBx+)Wk7Vn&*|fDZth)O{cYLpTkMH&tvopkh#-s+G5L~~B zQ<)}|_J4(TDt51DW@#$hWk~Rq$D>|C2ydz;WrXZi-l&5Yi&=Oap>|x3zJTcKx8!6w z#^U4j`Yk)`WK~jEH_VDE_!h2am*&q}p=S~K1DuulN`_j7=8T1UVb>S=*F!>#-j!7= z?(DWqx6^}5>wQXX^h;q{svRv`7TQZc;*AVFK(QG~)>h zI(6UI)D9_wuf0N)sw|kU@PYxt;*EwQ;vPdnIyXSAFG&So&r4v-ZfVo0eX^>VBB}GV zM~gE~6dBM$&XM>L?Y;VuHrvy-GS482)8B1f*N@EH&CXbm>q#Ru{c1R032jZXty>k^lk#Al-ymet z*{WncFSqZ3GoIug*s9B;Kq@2313ViSX)G{|_IC<6XE5~TIc3N%{U+elj7cHjJS*^E z{DAl4ZWUK^IQruRu|PK42X6C<>yT^VYBxqfH#t;q- zq1_sswU?uq7{hy-c4gk`TOs|bDIb(lDtGA4Xx_3NiFv4dNBA4a{kRXE&q_DocRgD8 zoLC*tMl9$SRj^HSp~${BfP=LQa%@DDPqGYPQFQur0NB^}@0uQ9_QUfaIpyoLCE%}c z+&u_<_bvxzC;Iulj@+q6(r}s)GsB(i&q3Mns%(a&7y%WT{1DDH{~H?C(LEQIhHeS| ztOc|qu~N@?r-^V{Zu&^S%pgmIOmPpA?RA+!(*{%zVqOFMJ$d0Dax+31{@z4aVFR55 z%(WCoI%9|4v4!c!zDn$pmOJ%@tm01EoduMQb6)ck)j0Q!XdW_j)C1ZPYxYUPa?g=$ z(a5m{r%GG-JvjuP3`PBetyLM||N5g+P*c-CfXCVIGi1NNgZhO2w(-NCzZjCFx@D>?c$(56uuG{9K0 zBzCh?RQlZJea0CLz4)oDU>($`9jdwvI-l*y8;SmPx2BgMSh-p5nb>>!5&vONQsAmJ z(zfJyQBl?CTH0iBxaec_!^i+pnI7?x7q#fG!*4Bm!7Uf?dzq?B98ekesQzNdSx%0| z3%SHaaJH$NRFyl$Jstm`Kwg{Oo~&f%(&D(gc+XM40>ST^C#z#pA-Hk({6m1Ah!^C#aRYdQFzTL!4eh;SQE}J5;lv75~jc5^VD`?nB z8tCnJO)6t8E@xxP61tA2#?z{-U1J*L#5yMmB@CLGrYql+Cy_O!VG@f- z>}M1Y>J_6r;6nESp^wZ2&=Q&5ZWl0LzIg9=#+Lzk-UaiXEovzEg#=W4Tw& zjDI059QsEUdAD;&>lP*RyPJba0^qy12|Sl%v#oB+ZLKL{v{Ae)g{JIAg{Jtt_Sd1J zZB=W-s!R7%g6$ru=-a9%0wy4_HZbg0aFD^F-UIpk&{e@Ui`rFZ12q))JWNe?SQA%i zQ;ARqi3PLy^_#YzRD*Z9NQ|XDpI(MYyij@iUOOe1S){iDK1>o3^r@4`_ynwTD3{b%rOj!F-2M-4ot25Y`#STgGm zZl`B^fsb|#hl_D5jeDz0(hcO7QxflPKbg{n#>(We$Si1RPEf_DexEpR);Oi?93R+r zMu=^{Mw*O%uJB$$h9zz*D(kIsP-6$E&o8BC}IG254fxYhVtojUi$em;=vwAe{JTkTJyz5@%*bJ{$DadD$ z$bj16P}4^@E2o-*>|T^Bb+y}xO;CPzeZk+P2xuWZ11aUg*-Ngk zP+L1Wi<`+V%ph~OcyegG`86O#Lhs|g*{H}_GHTdQwLQ712h;gnn>Pqf8G)SUYD@$>Jc%XM30xlonM=~}0zitQ+y_0yDSRh|u4IaLGD z=DH|}*CeoOkjN-M9$_K|P?8ZuU2}cu1PFjkJEP2Q~m}fEgc9*q#o(r}K=@8)#gp9bP1aQeJ)a zZ17wm*DG;~w{G=pty-!!v>xZZ;eqE33k!^;G0Ipn)57V;291sqSG!Ry806_f!nb~ zUsJT8pABQEr`isiGTx4IWa6f0am@gqdDQMOS^4BaAS+E+Wz9m34Yh|T#51wS%R3Qx99 zP8EGG%MY5i=YH8eQ%S5B`I35C?tBB`QukQGrA=$SIljj#!`cr~WOS{r0h?fbBGWOT zRju_^_$^Ni{`bLJNx|hoUE4B=bW5{31(MC$ON^+<(a7@1BjrK5F}mZoF7b7*zEfV^ z>S9w*0Oc6EXy_3z61zw=u7CR6Ohs;WfX}P0=boOwSH5VKWm9J_KhNGaw1bit*IhE( zznJkVz%DMYNCz1f#81hv;=zXfqo-XV=QpMk>6T9&2wR?9{<9RB* zh!JldIYlnH_;>KP8&8_?nY>$?@x{CbX?f=#a&e#DWN25YKd)~d+^kC(*~Wj@ePX^n zZ(|LY=HF09af&-AHW9mJmflD2E*#i%Cy~(mfhM1({!PMzk6poxQD~}l+%8KoNzJ8g zIav6;1+!Z#qQl)ft6y_Be#b9EY})z_yn7MQ2IloykC$6pMVG;D$%U#L`*S-tc7o*Q zqa{&;nI$KkFq=LGR?+;-|XZ=5GeyF};H;I2R6&w6c=2 zVzWPAUE>3|&UY(KcO$uE5cDAm{hl*i3gMo;Q!!Zmm;)^kx-#_UT7 zc2~+?SOGK59t)9!x8PvccCE3&TjAQbRn+yo$&y}sya!^^6`L<+TtBHd zB(EYn@W+0$O<7lj3U142srLTRQ2JG!5rs_vL0g-&^;Zo+#R0cfYRobq=Q1dOMTVW_ zlR?hs2&H07F=+ZP@}*K$3i&^R0TnK+^vdOtcQSPY(^Pa%x0NKtAO>*iVW&Hg>e@s@ zK5^M`HQ^ek__?%=YW*YI@MU$ICq3UiT(Ps#!)MTQjl;v8V@jMw3?%e+w0C@tq>nP? z4D)F?*v{m%E~iSSvw-{x+v9wf^;lOWvqm1Rzs7#C7j^#ZMz^? zcE-gSdq&P9luz<@*2wF){U#nK9R6^nqncpGECqYLcrenUBV##Q8_Og?)jWz=?U!u( z{jV)qNEPPctgK<@nZVKr9ZFS_4Ylm)1DvB<)jhvq4QgFWZ>fb5y*C#{_IjyAcxdk% z(H@7v%40aMHk^Igfy{x2p_4aN3s@D7>Bvaj?%MHQ>kPXAr$Sg2g;5)N6)~Y3M2=le z78P+&FDSVO+>jZmHyyw7Qmzqo-wywT%4Lj8OM#d`;v9bht@x4IcHE}vS?@-2SslD! zFwO;o{D-WM4i~0Hu4$^<;-th@tZ(|q@ltT<`|;ye)?eoisAqm-FM#V?j9jLePHq|W zjvd<0yMXuUyZKVW_khBIvuP_O|8c!j=d2sS@i~hP;+&INA#if*15ZvSOUF`kPQ;R( zBE7=|CYpU<<7{28xn^<|=u4Ywg3Ei%!t~nf@MbPu`wOF8*s;k}7qaqGG)CjZ)Tnsi zeKl|JG=m*xz3&6ssU--X)>Ma%D0(Ipm=v*{1=vo>KIk$fsSg(lo{_&p%a6s%Ygdhz zIg(fJbBRlJkLbH1UUlJ^Y&tWd7N6In86pn$WuD{B`Xy+yY|Z|P@XhMe7h;-nWb*1$ccdc3<-}m*&v{W%*|=+6Je#_w1}_B;naArqB*zc4fdrcFU}JdCoTrAspYL!^ zsOg1%=_d#;KN*wGX(u18>9!KgsOsiawLVBych?PQQ~&u6gu;{FCKTKhuJfvS5WBDNzPUq%EhHmiJIq&xVoGv=DQ?@HO;fy3OS1i zR||*cSD)_}I$_vlTKreIywxGFW<&v92qyaPvp$?sG2Ntz_P< zs?8sj3o9f}U?P#40}d{(4t264E^sKyX|FU3v}=v(XB^58Ixh$Og>g(5I+o%fT|6i+ zc$KkXB=8yos2ZTBn6rfj)tbaKvhQ9~OOe=2Pvf~J;M>S?5SRc9(|t(Z%i@XmL}bW|SjWoLiG(Db4#NrS_qx3pPfNdX#~ z<8h@JpR7X&wRa)wdpT8I-At`7SKobBAvBe^wv0?n2R11|^0*n86LnHi3wY&AHG(D* ze4%k4^7%RxigOy|EP9_Z9Bqelm}%upj+?i=d}I865u2po^DGPDdxeMzX-;)N6;Zri>8teSP9=NEK zdqQ>ZMd!mZ3749FjZVaYE+ULHv4BnfG{+bPZ6p{FMa=Tf55?#1(=vSav!+5&D-o9_ zBn>gGvxLe0l>eCV#0Zn_B?dtv(%}!xI<WK)_j_x;_fXX$fy(g=2V(uDYTqev#t4)ZYdF2Ab%vhdyT)$?or*=>1l z7nO&G^KZQJxY++EUf}_9|BYAp|BVGek0|5+Z7-og+|ZkDAhz_?O_)w$_=+|aw=p{H zqWd_K%k9%TE(MHQ7Bh?0_6iw1^_{Nisqux?Ts2o{wjOVJOlz=?TZ2DYCQ8Hb%m*CA zmI#&Sv?*#8^#(WlMOReeTTnf%3|$KgwV4?2o^A*R$wAhz&`Q7)zXMi6^t|Sdqx}WY zUis3ml|blweJ%{bn$L@h$40j(l!{y4)@#=d&|AyflAjAg5~-I6vJ=&vy;sDN$7~FH zLUteO>Tq_3+pEv|lREc~MM8AROs%r|q`y@u39zYATSw@UHEdzKOwp4ie`;*Yy_*$J-CYqZJJ8HN&h91NwzSEsMkk%p<=<*u60*qnL!_xTw=ccTOIn?hXbL z+l+kui*)}zaKDG+FEGaS_rQT3Db!y;=MRkZ2)d*oPNt4l_Re;Wk5uS4`%(eh!a$aq zypFcwOJ*s^8?ctkD~O|&`QHXIU|TC24*Xh8!JH(l85uLYyUj|WzG5f z$zQ4e|0_2?4}gd3v7E;5?!tKQ$mHKg^&1 zt?|Kf{g(y=g8rp(@;$od@%XzuSbw-+&HoP#$OVFp(|>9pASVzu`~JfYrg6e%$A4+O zT(F;(|JHb6gZiHuh@1Ogc|klp|7f4HBN+B(JO19){>thtPatw5km1{{S(4_ap!S literal 0 HcmV?d00001 diff --git a/rust-sgx-workspace/docker-compose.yaml b/rust-sgx-workspace/docker-compose.yaml new file mode 100644 index 0000000..c27ec6b --- /dev/null +++ b/rust-sgx-workspace/docker-compose.yaml @@ -0,0 +1,68 @@ +# Bring up the server: +# +# docker-compose up server-sw +# +# Run the tests: +# +# docker-compose run test-sw +# +# For HW mode, replace `sw` with `hw`. + +services: + + server-sw: + profiles: ["sw"] + build: + context: . + args: + SGX_MODE: "SW" + target: run-sgx-vault-server-sw + read_only: true + init: true + environment: + BIND_ADDR: "0.0.0.0:8080" + volumes: + - vault-data-sw:/app/vault_store + ports: + - "8080:8080" + + server-hw: + profiles: ["hw"] + build: + context: . + args: + SGX_MODE: "HW" + target: run-sgx-vault-server-hw + read_only: true + init: true + environment: + BIND_ADDR: "0.0.0.0:8080" + devices: + - /dev/sgx/enclave + - /dev/sgx/provision + volumes: + - vault-data-hw:/app/vault_store + ports: + - "8080:8080" + + test-sw: + profiles: ["test-sw"] + build: + context: . + args: + SGX_MODE: "SW" + target: run-sgx-vault-test-sw + read_only: true + + test-hw: + profiles: ["test-hw"] + build: + context: . + args: + SGX_MODE: "HW" + target: run-sgx-vault-test-hw + read_only: true + +volumes: + vault-data-sw: + vault-data-hw: diff --git a/rust-sgx-workspace/generate-Dockerfile.pdf.sh b/rust-sgx-workspace/generate-Dockerfile.pdf.sh new file mode 100755 index 0000000..dfedd61 --- /dev/null +++ b/rust-sgx-workspace/generate-Dockerfile.pdf.sh @@ -0,0 +1,9 @@ +#!/bin/sh -e +# This generates a Dockerfile stage diagram using: +# https://github.com/patrickhoefler/dockerfilegraph + +docker run --rm \ + --user "$(id -u):$(id -g)" \ + --workdir /workspace \ + --mount type=bind,source="$(pwd)",target=/workspace \ + ghcr.io/patrickhoefler/dockerfilegraph diff --git a/rust-sgx-workspace/generate-dockerignore.sh b/rust-sgx-workspace/generate-dockerignore.sh new file mode 100755 index 0000000..cfd28b5 --- /dev/null +++ b/rust-sgx-workspace/generate-dockerignore.sh @@ -0,0 +1,24 @@ +#!/bin/sh -e +# Generate a .dockerignore file that only includes files tracked by git. +# +# Additionally, this also: +# +# - excludes specific files that aren't useful inside Docker build contexts +# - recursively includes src/**, for development convenience + +SCRIPT=' +1 i # Generated by generate-dockerignore.sh +1 i * + +/[.]gitignore$/ d +/^.*[.]md$/ d +/^Dockerfile/ d +/^[.]dockerignore$/ d +/^docker-compose[.]yaml$/ d +/^generate-.*[.]sh$/ d + +s#/src/.*#/src/# +s#^#!# +' + +git ls-files | sed "$SCRIPT" | uniq >.dockerignore From 7c3a0dba9895290cdf46926c5477ae6b35af5229 Mon Sep 17 00:00:00 2001 From: binglekruger Date: Wed, 28 Sep 2022 09:34:34 +0000 Subject: [PATCH 11/22] feat: Create two APIs for data operations --- .../src/resources/data_operation.rs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 rust-sgx-workspace/crates/http-service-impl/src/resources/data_operation.rs diff --git a/rust-sgx-workspace/crates/http-service-impl/src/resources/data_operation.rs b/rust-sgx-workspace/crates/http-service-impl/src/resources/data_operation.rs new file mode 100644 index 0000000..6ceeb5c --- /dev/null +++ b/rust-sgx-workspace/crates/http-service-impl/src/resources/data_operation.rs @@ -0,0 +1,20 @@ +// Upload data pool API // +// Encryt from client to enclave - seal using enclave key - upload to Azure Blob (or Cosmos DB) +// Data is uploaded in JSON format +// Encrypt: Use SSL or TLS + + + + +// Upload to Azure Blob storage or Cosmos DB - TBD // +// https://github.com/Azure/azure-sdk-for-rust +// https://crates.io/crates/azure_storage_blobs + + + + + +// Query data API // +// Frontend must show which data packages the data creator has uploaded to the system +// Option 1 - Query data service for list of data packages uploaded by the data creator +// Option 2 - Lookup smart contracts associated with data creator's NTLS wallet From 9327bad89d49a7d0ded11ce4e865940c0e0d37e2 Mon Sep 17 00:00:00 2001 From: binglekruger Date: Thu, 13 Oct 2022 11:39:50 +0000 Subject: [PATCH 12/22] Merge branch 'data-operations' of https://github.com/ntls-io/nautilus-trusted-compute into data-operations --- rust-workspace/projects/data-server/Cargo.toml | 8 ++++++++ .../projects/data-server/src/main.rs | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 rust-workspace/projects/data-server/Cargo.toml rename rust-sgx-workspace/crates/http-service-impl/src/resources/data_operation.rs => rust-workspace/projects/data-server/src/main.rs (90%) diff --git a/rust-workspace/projects/data-server/Cargo.toml b/rust-workspace/projects/data-server/Cargo.toml new file mode 100644 index 0000000..ecbfb87 --- /dev/null +++ b/rust-workspace/projects/data-server/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "data-server" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/rust-sgx-workspace/crates/http-service-impl/src/resources/data_operation.rs b/rust-workspace/projects/data-server/src/main.rs similarity index 90% rename from rust-sgx-workspace/crates/http-service-impl/src/resources/data_operation.rs rename to rust-workspace/projects/data-server/src/main.rs index 6ceeb5c..aaa8e39 100644 --- a/rust-sgx-workspace/crates/http-service-impl/src/resources/data_operation.rs +++ b/rust-workspace/projects/data-server/src/main.rs @@ -1,3 +1,7 @@ +fn main() { + println!("Hello, world!"); +} + // Upload data pool API // // Encryt from client to enclave - seal using enclave key - upload to Azure Blob (or Cosmos DB) // Data is uploaded in JSON format @@ -17,4 +21,4 @@ // Query data API // // Frontend must show which data packages the data creator has uploaded to the system // Option 1 - Query data service for list of data packages uploaded by the data creator -// Option 2 - Lookup smart contracts associated with data creator's NTLS wallet +// Option 2 - Lookup smart contracts associated with data creator's NTLS wallet \ No newline at end of file From 5a78c0046ae597c2f9c1842186688633d514f1eb Mon Sep 17 00:00:00 2001 From: binglekruger Date: Thu, 13 Oct 2022 11:55:23 +0000 Subject: [PATCH 13/22] feat(data-operations-api): create new project dir --- rust-workspace/Cargo.lock | 582 +++++++++++++++++- rust-workspace/Cargo.toml | 5 +- .../projects/data-server/Cargo.toml | 2 + .../projects/data-server/src/main.rs | 5 + 4 files changed, 588 insertions(+), 6 deletions(-) diff --git a/rust-workspace/Cargo.lock b/rust-workspace/Cargo.lock index 00cf752..c198071 100644 --- a/rust-workspace/Cargo.lock +++ b/rust-workspace/Cargo.lock @@ -173,6 +173,15 @@ dependencies = [ "urlencoding", ] +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anyhow" version = "1.0.57" @@ -308,6 +317,25 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bson" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d76085681585d39016f4d3841eb019201fc54d2dd0d92ad1e4fab3bfb32754" +dependencies = [ + "ahash", + "base64", + "hex", + "indexmap", + "lazy_static", + "rand", + "serde", + "serde_bytes", + "serde_json", + "time 0.3.9", + "uuid 1.2.1", +] + [[package]] name = "bstr" version = "0.2.17" @@ -355,6 +383,21 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-integer", + "num-traits", + "time 0.1.43", + "wasm-bindgen", + "winapi", +] + [[package]] name = "clap" version = "3.1.18" @@ -394,6 +437,16 @@ dependencies = [ "os_str_bytes", ] +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + [[package]] name = "colored" version = "1.9.3" @@ -495,6 +548,50 @@ dependencies = [ "typenum", ] +[[package]] +name = "cxx" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19f39818dcfc97d45b03953c1292efc4e80954e1583c4aa770bac1383e2310a4" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e580d70777c116df50c390d1211993f62d40302881e54d4b79727acb83d0199" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56a46460b88d1cec95112c8c363f0e2c39afdb237f60583b0b36343bf627ea9c" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "747b608fecf06b0d72d440f27acc99288207324b793be2c17991839f3d4995ea" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "darling" version = "0.13.4" @@ -536,6 +633,13 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" +[[package]] +name = "data-server" +version = "0.1.0" +dependencies = [ + "mongodb", +] + [[package]] name = "der" version = "0.5.1" @@ -554,6 +658,17 @@ dependencies = [ "const-oid 0.9.0", ] +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -563,7 +678,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "rustc_version", + "rustc_version 0.4.0", "syn", ] @@ -596,6 +711,7 @@ checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" dependencies = [ "block-buffer", "crypto-common", + "subtle", ] [[package]] @@ -679,6 +795,18 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "enum-as-inner" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21cdad81446a7f7dc43f6a77409efeb9733d2fa65553efef6018ef257c959b73" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "env-var-helpers" version = "0.1.0" @@ -762,6 +890,34 @@ version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" +[[package]] +name = "futures-executor" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68" + +[[package]] +name = "futures-macro" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "futures-sink" version = "0.3.21" @@ -787,9 +943,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" dependencies = [ "futures-core", + "futures-io", + "futures-macro", "futures-task", + "memchr", "pin-project-lite", "pin-utils", + "slab", ] [[package]] @@ -867,6 +1027,32 @@ dependencies = [ "libc", ] +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.3", +] + +[[package]] +name = "hostname" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" +dependencies = [ + "libc", + "match_cfg", + "winapi", +] + [[package]] name = "http" version = "0.2.8" @@ -944,6 +1130,30 @@ dependencies = [ "tokio-native-tls", ] +[[package]] +name = "iana-time-zone" +version = "0.1.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5a6ef98976b22b3b7f2f3a806f858cb862044cfa66805aa3ad84cb3d3b785ed" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fde6edd6cef363e9359ed3c98ba64590ba9eecba2293eb5a723ab32aee8926aa" +dependencies = [ + "cxx", + "cxx-build", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -989,6 +1199,18 @@ dependencies = [ "web-sys", ] +[[package]] +name = "ipconfig" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "723519edce41262b05d4143ceb95050e4c614f483e78e9fd9e39a8275a84ad98" +dependencies = [ + "socket2", + "widestring", + "winapi", + "winreg 0.7.0", +] + [[package]] name = "ipnet" version = "2.5.0" @@ -1050,9 +1272,9 @@ dependencies = [ "regex", "serde", "serde_json", - "time", + "time 0.3.9", "url", - "uuid", + "uuid 0.8.2", ] [[package]] @@ -1084,6 +1306,21 @@ version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" +[[package]] +name = "link-cplusplus" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" +dependencies = [ + "cc", +] + +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + [[package]] name = "lock_api" version = "0.4.7" @@ -1103,6 +1340,21 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "lru-cache" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" +dependencies = [ + "linked-hash-map", +] + +[[package]] +name = "match_cfg" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" + [[package]] name = "matches" version = "0.1.9" @@ -1115,6 +1367,15 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73cbba799671b762df5a175adf59ce145165747bb891505c43d09aefbbf38beb" +[[package]] +name = "md-5" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66b48670c893079d3c2ed79114e3644b7004df1c361a4e0ad52e2e6940d07c3d" +dependencies = [ + "digest 0.10.3", +] + [[package]] name = "memchr" version = "2.5.0" @@ -1145,6 +1406,52 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "mongodb" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5a1df476ac9541b0e4fdc8e2cc48884e66c92c933cd17a1fd75e68caf75752e" +dependencies = [ + "async-trait", + "base64", + "bitflags", + "bson", + "chrono", + "derivative", + "futures-core", + "futures-executor", + "futures-util", + "hex", + "hmac", + "lazy_static", + "md-5", + "os_info", + "pbkdf2", + "percent-encoding", + "rand", + "rustc_version_runtime", + "rustls", + "rustls-pemfile", + "serde", + "serde_bytes", + "serde_with", + "sha-1", + "sha2", + "socket2", + "stringprep", + "strsim", + "take_mut", + "thiserror", + "tokio", + "tokio-rustls", + "tokio-util", + "trust-dns-proto", + "trust-dns-resolver", + "typed-builder", + "uuid 0.8.2", + "webpki-roots", +] + [[package]] name = "native-tls" version = "0.2.10" @@ -1396,6 +1703,16 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "os_info" +version = "3.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4750134fb6a5d49afc80777394ad5d95b04bc12068c6abb92fae8f43817270f" +dependencies = [ + "log", + "winapi", +] + [[package]] name = "os_str_bytes" version = "6.1.0" @@ -1459,6 +1776,15 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" +[[package]] +name = "pbkdf2" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271779f35b581956db91a3e55737327a03aa051e90b1c47aeb189508533adfd7" +dependencies = [ + "digest 0.10.3", +] + [[package]] name = "percent-encoding" version = "2.1.0" @@ -1579,6 +1905,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + [[package]] name = "quote" version = "1.0.18" @@ -1703,7 +2035,17 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "winreg", + "winreg 0.10.1", +] + +[[package]] +name = "resolv-conf" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" +dependencies = [ + "hostname", + "quick-error", ] [[package]] @@ -1760,13 +2102,53 @@ dependencies = [ "serde", ] +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver 0.9.0", +] + [[package]] name = "rustc_version" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver", + "semver 1.0.9", +] + +[[package]] +name = "rustc_version_runtime" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d31b7153270ebf48bf91c65ae5b0c00e749c4cfad505f66530ac74950249582f" +dependencies = [ + "rustc_version 0.2.3", + "semver 0.9.0", +] + +[[package]] +name = "rustls" +version = "0.20.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aab8ee6c7097ed6057f43c187a62418d0c05a4bd5f18b3571db50ee0f9ce033" +dependencies = [ + "log", + "ring", + "sct", + "webpki", +] + +[[package]] +name = "rustls-pemfile" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ee86d63972a7c661d1536fefe8c3c8407321c3df668891286de28abcd087360" +dependencies = [ + "base64", ] [[package]] @@ -1808,6 +2190,22 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "scratch" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" + +[[package]] +name = "sct" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "sec1" version = "0.2.1" @@ -1843,12 +2241,27 @@ dependencies = [ "libc", ] +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + [[package]] name = "semver" version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8cb243bdfdb5936c8dc3c45762a19d12ab4550cdc753bc247637d4ec35a040fd" +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + [[package]] name = "serde" version = "1.0.137" @@ -1884,6 +2297,7 @@ version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" dependencies = [ + "indexmap", "itoa", "ryu", "serde", @@ -1924,6 +2338,17 @@ dependencies = [ "syn", ] +[[package]] +name = "sha-1" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.3", +] + [[package]] name = "sha2" version = "0.10.2" @@ -1996,6 +2421,16 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "stringprep" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ee348cb74b87454fff4b551cbf727025810a004f88aeacae7f85b87f4e9a1c1" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "strsim" version = "0.10.0" @@ -2025,6 +2460,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20518fe4a4c9acf048008599e464deb21beeae3d3578418951a189c235a7a9a8" +[[package]] +name = "take_mut" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" + [[package]] name = "tempfile" version = "3.3.0" @@ -2090,12 +2531,23 @@ dependencies = [ "syn", ] +[[package]] +name = "time" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "time" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2702e08a7a860f005826c6815dcac101b19b5eb330c27fe4a5928fec1d20ddd" dependencies = [ + "itoa", "libc", "num_threads", "time-macros", @@ -2161,6 +2613,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.23.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" +dependencies = [ + "rustls", + "tokio", + "webpki", +] + [[package]] name = "tokio-util" version = "0.7.3" @@ -2253,12 +2716,68 @@ dependencies = [ "once_cell", ] +[[package]] +name = "trust-dns-proto" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c31f240f59877c3d4bb3b3ea0ec5a6a0cff07323580ff8c7a605cd7d08b255d" +dependencies = [ + "async-trait", + "cfg-if", + "data-encoding", + "enum-as-inner", + "futures-channel", + "futures-io", + "futures-util", + "idna", + "ipnet", + "lazy_static", + "log", + "rand", + "smallvec", + "thiserror", + "tinyvec", + "tokio", + "url", +] + +[[package]] +name = "trust-dns-resolver" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4ba72c2ea84515690c9fcef4c6c660bb9df3036ed1051686de84605b74fd558" +dependencies = [ + "cfg-if", + "futures-util", + "ipconfig", + "lazy_static", + "log", + "lru-cache", + "parking_lot", + "resolv-conf", + "smallvec", + "thiserror", + "tokio", + "trust-dns-proto", +] + [[package]] name = "try-lock" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" +[[package]] +name = "typed-builder" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89851716b67b937e393b3daa8423e67ddfc4bbbf1654bcf05488e95e0828db0c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "typenum" version = "1.15.0" @@ -2286,6 +2805,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + [[package]] name = "untrusted" version = "0.7.1" @@ -2315,6 +2840,19 @@ name = "uuid" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +dependencies = [ + "getrandom", +] + +[[package]] +name = "uuid" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "feb41e78f93363bb2df8b0e86a2ca30eed7806ea16ea0c790d757cf93f79be83" +dependencies = [ + "getrandom", + "serde", +] [[package]] name = "vcpkg" @@ -2446,6 +2984,31 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "webpki-roots" +version = "0.22.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368bfe657969fb01238bb756d351dcade285e0f6fcbd36dcb23359a5169975be" +dependencies = [ + "webpki", +] + +[[package]] +name = "widestring" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17882f045410753661207383517a6f62ec3dbeb6a4ed2acce01f0728238d1983" + [[package]] name = "winapi" version = "0.3.9" @@ -2520,6 +3083,15 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" +[[package]] +name = "winreg" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" +dependencies = [ + "winapi", +] + [[package]] name = "winreg" version = "0.10.1" diff --git a/rust-workspace/Cargo.toml b/rust-workspace/Cargo.toml index 4216c62..528e859 100644 --- a/rust-workspace/Cargo.toml +++ b/rust-workspace/Cargo.toml @@ -1,2 +1,5 @@ [workspace] -members = ['crates/*'] +members = [ + 'crates/*', + 'projects/*', +] \ No newline at end of file diff --git a/rust-workspace/projects/data-server/Cargo.toml b/rust-workspace/projects/data-server/Cargo.toml index ecbfb87..c203bd7 100644 --- a/rust-workspace/projects/data-server/Cargo.toml +++ b/rust-workspace/projects/data-server/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "data-server" version = "0.1.0" +authors = ["Nautilus team"] edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +mongodb = "2.3" diff --git a/rust-workspace/projects/data-server/src/main.rs b/rust-workspace/projects/data-server/src/main.rs index aaa8e39..e7229d7 100644 --- a/rust-workspace/projects/data-server/src/main.rs +++ b/rust-workspace/projects/data-server/src/main.rs @@ -1,3 +1,8 @@ +use mongodb::error::Error; +use mongodb::options::ClientOptions; +use mongodb::{Client, Collection}; + + fn main() { println!("Hello, world!"); } From ebf31d56b75ba8287fa7fec6aaa4cbe5101686a5 Mon Sep 17 00:00:00 2001 From: binglekruger Date: Fri, 14 Oct 2022 09:45:22 +0000 Subject: [PATCH 14/22] feat: Add base crate --- rust-workspace/Cargo.lock | 23 +++++++++++-------- .../projects/data-server/Cargo.toml | 4 ++++ .../projects/data-server/src/main.rs | 13 +++++++---- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/rust-workspace/Cargo.lock b/rust-workspace/Cargo.lock index c198071..04c02ca 100644 --- a/rust-workspace/Cargo.lock +++ b/rust-workspace/Cargo.lock @@ -325,6 +325,7 @@ checksum = "99d76085681585d39016f4d3841eb019201fc54d2dd0d92ad1e4fab3bfb32754" dependencies = [ "ahash", "base64", + "chrono", "hex", "indexmap", "lazy_static", @@ -637,7 +638,11 @@ checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" name = "data-server" version = "0.1.0" dependencies = [ + "bson", + "chrono", "mongodb", + "serde", + "tokio", ] [[package]] @@ -1396,9 +1401,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "mio" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713d550d9b44d89174e066b7a6217ae06234c10cb47819a88290d2b353c31799" +checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" dependencies = [ "libc", "log", @@ -2264,9 +2269,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.137" +version = "1.0.145" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" +checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" dependencies = [ "serde_derive", ] @@ -2282,9 +2287,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.137" +version = "1.0.145" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" +checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" dependencies = [ "proc-macro2", "quote", @@ -2576,16 +2581,16 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.19.2" +version = "1.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c51a52ed6686dd62c320f9b89299e9dfb46f730c7a48e635c19f21d116cb1439" +checksum = "a9e03c497dc955702ba729190dc4aac6f2a0ce97f913e5b1b5912fc5039d9099" dependencies = [ + "autocfg", "bytes", "libc", "memchr", "mio", "num_cpus", - "once_cell", "pin-project-lite", "socket2", "tokio-macros", diff --git a/rust-workspace/projects/data-server/Cargo.toml b/rust-workspace/projects/data-server/Cargo.toml index c203bd7..7f7aff7 100644 --- a/rust-workspace/projects/data-server/Cargo.toml +++ b/rust-workspace/projects/data-server/Cargo.toml @@ -8,3 +8,7 @@ edition = "2021" [dependencies] mongodb = "2.3" +bson = "2.4" +serde = { version = "1.0", features = ["derive"] } + +env-var-helpers = { git = "https://github.com/PiDelport/rust-env-var-helpers" } \ No newline at end of file diff --git a/rust-workspace/projects/data-server/src/main.rs b/rust-workspace/projects/data-server/src/main.rs index e7229d7..20059d8 100644 --- a/rust-workspace/projects/data-server/src/main.rs +++ b/rust-workspace/projects/data-server/src/main.rs @@ -1,7 +1,12 @@ -use mongodb::error::Error; -use mongodb::options::ClientOptions; -use mongodb::{Client, Collection}; - +use bson::{doc, Bson, Document}; +use env_var_helpers::env_vars; +use mongodb::{error::Error, options::ClientOptions, Client, Collection, Database}; + +pub struct CosmosDBMongo { + connection_string: String, + database_name: String, + collection_name: String, +} fn main() { println!("Hello, world!"); From d713a866215cf60411ea812753c2687aae10f383 Mon Sep 17 00:00:00 2001 From: binglekruger Date: Mon, 24 Oct 2022 07:46:03 +0000 Subject: [PATCH 15/22] feat: Add basic Actix server --- rust-workspace/Cargo.lock | 1235 +++++++++++++++-- .../projects/data-server/Cargo.toml | 4 +- .../projects/data-server/src/main.rs | 19 +- 3 files changed, 1123 insertions(+), 135 deletions(-) diff --git a/rust-workspace/Cargo.lock b/rust-workspace/Cargo.lock index 04c02ca..26c895c 100644 --- a/rust-workspace/Cargo.lock +++ b/rust-workspace/Cargo.lock @@ -2,6 +2,316 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "actix-codec" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e55f0a5c2ca15795035d90c46bd0e73a5123b72f68f12596d6ba5282051380" +dependencies = [ + "bitflags", + "bytes 0.5.6", + "futures-core", + "futures-sink", + "log", + "tokio 0.2.25", + "tokio-util 0.2.0", +] + +[[package]] +name = "actix-codec" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78d1833b3838dbe990df0f1f87baf640cf6146e898166afe401839d1b001e570" +dependencies = [ + "bitflags", + "bytes 0.5.6", + "futures-core", + "futures-sink", + "log", + "pin-project 0.4.30", + "tokio 0.2.25", + "tokio-util 0.3.1", +] + +[[package]] +name = "actix-connect" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c95cc9569221e9802bf4c377f6c18b90ef10227d787611decf79fd47d2a8e76c" +dependencies = [ + "actix-codec 0.2.0", + "actix-rt", + "actix-service", + "actix-utils 1.0.6", + "derive_more", + "either", + "futures", + "http", + "log", + "trust-dns-proto 0.18.0-alpha.2", + "trust-dns-resolver 0.18.0-alpha.2", +] + +[[package]] +name = "actix-http" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c16664cc4fdea8030837ad5a845eb231fb93fc3c5c171edfefb52fad92ce9019" +dependencies = [ + "actix-codec 0.2.0", + "actix-connect", + "actix-rt", + "actix-service", + "actix-threadpool", + "actix-utils 1.0.6", + "base64 0.11.0", + "bitflags", + "brotli2", + "bytes 0.5.6", + "chrono", + "copyless", + "derive_more", + "either", + "encoding_rs", + "failure", + "flate2", + "futures-channel", + "futures-core", + "futures-util", + "fxhash", + "h2 0.2.7", + "http", + "httparse", + "indexmap", + "language-tags", + "lazy_static", + "log", + "mime", + "percent-encoding", + "pin-project 0.4.30", + "rand 0.7.3", + "regex", + "serde", + "serde_json", + "serde_urlencoded 0.6.1", + "sha1", + "slab", + "time 0.1.43", +] + +[[package]] +name = "actix-macros" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ca8ce00b267af8ccebbd647de0d61e0674b6e61185cc7a592ff88772bed655" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "actix-router" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ad299af73649e1fc893e333ccf86f377751eb95ff875d095131574c6f43452c" +dependencies = [ + "bytestring", + "http", + "log", + "regex", + "serde", +] + +[[package]] +name = "actix-rt" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "143fcc2912e0d1de2bcf4e2f720d2a60c28652ab4179685a1ee159e0fb3db227" +dependencies = [ + "actix-macros", + "actix-threadpool", + "copyless", + "futures-channel", + "futures-util", + "smallvec", + "tokio 0.2.25", +] + +[[package]] +name = "actix-server" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45407e6e672ca24784baa667c5d32ef109ccdd8d5e0b5ebb9ef8a67f4dfb708e" +dependencies = [ + "actix-codec 0.3.0", + "actix-rt", + "actix-service", + "actix-utils 2.0.0", + "futures-channel", + "futures-util", + "log", + "mio 0.6.23", + "mio-uds", + "num_cpus", + "slab", + "socket2 0.3.19", +] + +[[package]] +name = "actix-service" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0052435d581b5be835d11f4eb3bce417c8af18d87ddf8ace99f8e67e595882bb" +dependencies = [ + "futures-util", + "pin-project 0.4.30", +] + +[[package]] +name = "actix-testing" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47239ca38799ab74ee6a8a94d1ce857014b2ac36f242f70f3f75a66f691e791c" +dependencies = [ + "actix-macros", + "actix-rt", + "actix-server", + "actix-service", + "log", + "socket2 0.3.19", +] + +[[package]] +name = "actix-threadpool" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d209f04d002854b9afd3743032a27b066158817965bf5d036824d19ac2cc0e30" +dependencies = [ + "derive_more", + "futures-channel", + "lazy_static", + "log", + "num_cpus", + "parking_lot 0.11.2", + "threadpool", +] + +[[package]] +name = "actix-tls" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4e5b4faaf105e9a6d389c606c298dcdb033061b00d532af9df56ff3a54995a8" +dependencies = [ + "actix-codec 0.2.0", + "actix-rt", + "actix-service", + "actix-utils 1.0.6", + "derive_more", + "either", + "futures", + "log", +] + +[[package]] +name = "actix-utils" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcf8f5631bf01adec2267808f00e228b761c60c0584cc9fa0b5364f41d147f4e" +dependencies = [ + "actix-codec 0.2.0", + "actix-rt", + "actix-service", + "bitflags", + "bytes 0.5.6", + "either", + "futures", + "log", + "pin-project 0.4.30", + "slab", +] + +[[package]] +name = "actix-utils" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9022dec56632d1d7979e59af14f0597a28a830a9c1c7fec8b2327eb9f16b5a" +dependencies = [ + "actix-codec 0.3.0", + "actix-rt", + "actix-service", + "bitflags", + "bytes 0.5.6", + "either", + "futures-channel", + "futures-sink", + "futures-util", + "log", + "pin-project 0.4.30", + "slab", +] + +[[package]] +name = "actix-web" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3158e822461040822f0dbf1735b9c2ce1f95f93b651d7a7aded00b1efbb1f635" +dependencies = [ + "actix-codec 0.2.0", + "actix-http", + "actix-macros", + "actix-router", + "actix-rt", + "actix-server", + "actix-service", + "actix-testing", + "actix-threadpool", + "actix-tls", + "actix-utils 1.0.6", + "actix-web-codegen", + "awc", + "bytes 0.5.6", + "derive_more", + "encoding_rs", + "futures", + "fxhash", + "log", + "mime", + "net2", + "pin-project 0.4.30", + "regex", + "serde", + "serde_json", + "serde_urlencoded 0.6.1", + "time 0.1.43", + "url", +] + +[[package]] +name = "actix-web-codegen" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a71bf475cbe07281d0b3696abb48212db118e7e23219f13596ce865235ff5766" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "addr2line" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "aead" version = "0.4.3" @@ -17,7 +327,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom", + "getrandom 0.2.6", "once_cell", "serde", "version_check", @@ -159,10 +469,10 @@ dependencies = [ "algonaut_model", "data-encoding", "derive_more", - "getrandom", + "getrandom 0.2.6", "num-bigint 0.4.3", "num-traits", - "rand", + "rand 0.8.5", "ring", "rmp-serde", "serde", @@ -221,7 +531,7 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ "hermit-abi", "libc", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -230,6 +540,29 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "awc" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7601d4d1d7ef2335d6597a41b5fe069f6ab799b85f53565ab390e7b7065aac5" +dependencies = [ + "actix-codec 0.2.0", + "actix-http", + "actix-rt", + "actix-service", + "base64 0.11.0", + "bytes 0.5.6", + "derive_more", + "futures-core", + "log", + "mime", + "percent-encoding", + "rand 0.7.3", + "serde", + "serde_json", + "serde_urlencoded 0.6.1", +] + [[package]] name = "axum" version = "0.5.6" @@ -239,22 +572,22 @@ dependencies = [ "async-trait", "axum-core", "bitflags", - "bytes", + "bytes 1.1.0", "futures-util", "http", "http-body", "hyper", - "itoa", + "itoa 1.0.2", "matchit", "memchr", "mime", "percent-encoding", - "pin-project-lite", + "pin-project-lite 0.2.9", "serde", "serde_json", - "serde_urlencoded", + "serde_urlencoded 0.7.1", "sync_wrapper", - "tokio", + "tokio 1.21.2", "tower", "tower-http", "tower-layer", @@ -268,19 +601,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da31c0ed7b4690e2c78fe4b880d21cd7db04a346ebc658b4270251b695437f17" dependencies = [ "async-trait", - "bytes", + "bytes 1.1.0", "futures-util", "http", "http-body", "mime", ] +[[package]] +name = "backtrace" +version = "0.3.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" +dependencies = [ + "addr2line", + "cc", + "cfg-if 1.0.0", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "base16ct" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" +[[package]] +name = "base64" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" + [[package]] name = "base64" version = "0.13.0" @@ -317,6 +671,26 @@ dependencies = [ "generic-array", ] +[[package]] +name = "brotli-sys" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4445dea95f4c2b41cde57cc9fee236ae4dbae88d8fcbdb4750fc1bb5d86aaecd" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "brotli2" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cb036c3eade309815c15ddbacec5b22c4d1f3983a774ab2eac2e3e9ea85568e" +dependencies = [ + "brotli-sys", + "libc", +] + [[package]] name = "bson" version = "2.4.0" @@ -324,12 +698,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d76085681585d39016f4d3841eb019201fc54d2dd0d92ad1e4fab3bfb32754" dependencies = [ "ahash", - "base64", - "chrono", + "base64 0.13.0", "hex", "indexmap", "lazy_static", - "rand", + "rand 0.8.5", "serde", "serde_bytes", "serde_json", @@ -366,18 +739,39 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +[[package]] +name = "bytes" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" + [[package]] name = "bytes" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" +[[package]] +name = "bytestring" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b6a75fd3048808ef06af5cd79712be8111960adaf89d90250974b38fc3928a" +dependencies = [ + "bytes 1.1.0", +] + [[package]] name = "cc" version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + [[package]] name = "cfg-if" version = "1.0.0" @@ -396,7 +790,7 @@ dependencies = [ "num-traits", "time 0.1.43", "wasm-bindgen", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -456,7 +850,7 @@ checksum = "f4ffc801dacf156c5854b9df4f425a626539c3a6ef7893cc0c5084a23f0b6c59" dependencies = [ "atty", "lazy_static", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -502,6 +896,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" +[[package]] +name = "copyless" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2df960f5d869b2dd8532793fde43eb5427cceb126c929747a26823ab0eeb536" + [[package]] name = "core-foundation" version = "0.9.3" @@ -527,6 +927,15 @@ dependencies = [ "libc", ] +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if 1.0.0", +] + [[package]] name = "crypto-bigint" version = "0.3.2" @@ -534,7 +943,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03c6a1d5fa1de37e071642dfa44ec552ca5b299adb128fab16138e24b548fd21" dependencies = [ "generic-array", - "rand_core", + "rand_core 0.6.3", "subtle", "zeroize", ] @@ -638,11 +1047,11 @@ checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" name = "data-server" version = "0.1.0" dependencies = [ + "actix-rt", + "actix-web", "bson", - "chrono", "mongodb", "serde", - "tokio", ] [[package]] @@ -725,7 +1134,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "339ee130d97a610ea5a5872d2bbb130fdf68884ff09d3028b81bec8a1ac23bbc" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "dirs-sys-next", ] @@ -737,7 +1146,7 @@ checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" dependencies = [ "libc", "redox_users", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -746,6 +1155,12 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" +[[package]] +name = "dtoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" + [[package]] name = "ecdsa" version = "0.13.4" @@ -785,7 +1200,7 @@ dependencies = [ "crypto-bigint", "der 0.5.1", "generic-array", - "rand_core", + "rand_core 0.6.3", "sec1", "subtle", "zeroize", @@ -797,7 +1212,19 @@ version = "0.8.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", +] + +[[package]] +name = "enum-as-inner" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "570d109b813e904becc80d8d5da38376818a143348413f7149f1340fe04754d4" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -820,6 +1247,28 @@ dependencies = [ "thiserror", ] +[[package]] +name = "failure" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" +dependencies = [ + "backtrace", + "failure_derive", +] + +[[package]] +name = "failure_derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + [[package]] name = "fancy-regex" version = "0.8.0" @@ -839,6 +1288,16 @@ dependencies = [ "instant", ] +[[package]] +name = "flate2" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + [[package]] name = "fnv" version = "1.0.7" @@ -880,6 +1339,37 @@ dependencies = [ "num", ] +[[package]] +name = "fuchsia-zircon" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +dependencies = [ + "bitflags", + "fuchsia-zircon-sys", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" + +[[package]] +name = "futures" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + [[package]] name = "futures-channel" version = "0.3.21" @@ -887,6 +1377,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -947,16 +1438,27 @@ version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" dependencies = [ + "futures-channel", "futures-core", "futures-io", "futures-macro", + "futures-sink", "futures-task", "memchr", - "pin-project-lite", + "pin-project-lite 0.2.9", "pin-utils", "slab", ] +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + [[package]] name = "generic-array" version = "0.14.5" @@ -967,19 +1469,36 @@ dependencies = [ "version_check", ] +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + [[package]] name = "getrandom" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "js-sys", "libc", "wasi 0.10.2+wasi-snapshot-preview1", "wasm-bindgen", ] +[[package]] +name = "gimli" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" + [[package]] name = "gloo-timers" version = "0.2.4" @@ -992,13 +1511,33 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "h2" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e4728fd124914ad25e99e3d15a9361a879f6620f63cb56bbb08f95abb97a535" +dependencies = [ + "bytes 0.5.6", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio 0.2.25", + "tokio-util 0.3.1", + "tracing", + "tracing-futures", +] + [[package]] name = "h2" version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37a82c6d637fc9515a4694bbf1cb2457b79d81ce52b3108bdeea58b07dd34a57" dependencies = [ - "bytes", + "bytes 1.1.0", "fnv", "futures-core", "futures-sink", @@ -1006,8 +1545,8 @@ dependencies = [ "http", "indexmap", "slab", - "tokio", - "tokio-util", + "tokio 1.21.2", + "tokio-util 0.7.3", "tracing", ] @@ -1055,7 +1594,7 @@ checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" dependencies = [ "libc", "match_cfg", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -1064,9 +1603,9 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" dependencies = [ - "bytes", + "bytes 1.1.0", "fnv", - "itoa", + "itoa 1.0.2", ] [[package]] @@ -1075,9 +1614,9 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ - "bytes", + "bytes 1.1.0", "http", - "pin-project-lite", + "pin-project-lite 0.2.9", ] [[package]] @@ -1104,19 +1643,19 @@ version = "0.14.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42dc3c131584288d375f2d07f822b0cb012d8c6fb899a5b9fdb3cb7eb9b6004f" dependencies = [ - "bytes", + "bytes 1.1.0", "futures-channel", "futures-core", "futures-util", - "h2", + "h2 0.3.13", "http", "http-body", "httparse", "httpdate", - "itoa", - "pin-project-lite", - "socket2", - "tokio", + "itoa 1.0.2", + "pin-project-lite 0.2.9", + "socket2 0.4.4", + "tokio 1.21.2", "tower-service", "tracing", "want", @@ -1128,10 +1667,10 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ - "bytes", + "bytes 1.1.0", "hyper", "native-tls", - "tokio", + "tokio 1.21.2", "tokio-native-tls", ] @@ -1146,7 +1685,7 @@ dependencies = [ "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -1198,21 +1737,42 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "js-sys", "wasm-bindgen", "web-sys", ] +[[package]] +name = "iovec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +dependencies = [ + "libc", +] + +[[package]] +name = "ipconfig" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7e2f18aece9709094573a9f24f483c4f65caa4298e2f7ae1b71cc65d853fad7" +dependencies = [ + "socket2 0.3.19", + "widestring 0.4.3", + "winapi 0.3.9", + "winreg 0.6.2", +] + [[package]] name = "ipconfig" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "723519edce41262b05d4143ceb95050e4c614f483e78e9fd9e39a8275a84ad98" dependencies = [ - "socket2", - "widestring", - "winapi", + "socket2 0.4.4", + "widestring 0.5.1", + "winapi 0.3.9", "winreg 0.7.0", ] @@ -1240,6 +1800,12 @@ dependencies = [ "either", ] +[[package]] +name = "itoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" + [[package]] name = "itoa" version = "1.0.2" @@ -1263,16 +1829,16 @@ checksum = "4ebd40599e7f1230ce296f73b88c022b98ed66689f97eaa54bbeadc337a2ffa6" dependencies = [ "ahash", "anyhow", - "base64", + "base64 0.13.0", "bytecount", "fancy-regex", "fraction", "iso8601", - "itoa", + "itoa 1.0.2", "lazy_static", "memchr", "num-cmp", - "parking_lot", + "parking_lot 0.12.1", "percent-encoding", "regex", "serde", @@ -1299,6 +1865,22 @@ dependencies = [ "term_size", ] +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + +[[package]] +name = "language-tags" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" + [[package]] name = "lazy_static" version = "1.4.0" @@ -1342,7 +1924,7 @@ version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -1394,10 +1976,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" [[package]] -name = "minimal-lexical" -version = "0.2.1" +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "miniz_oxide" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.6.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" +checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" +dependencies = [ + "cfg-if 0.1.10", + "fuchsia-zircon", + "fuchsia-zircon-sys", + "iovec", + "kernel32-sys", + "libc", + "log", + "miow", + "net2", + "slab", + "winapi 0.2.8", +] [[package]] name = "mio" @@ -1411,6 +2021,29 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "mio-uds" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" +dependencies = [ + "iovec", + "libc", + "mio 0.6.23", +] + +[[package]] +name = "miow" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" +dependencies = [ + "kernel32-sys", + "net2", + "winapi 0.2.8", + "ws2_32-sys", +] + [[package]] name = "mongodb" version = "2.3.1" @@ -1418,7 +2051,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5a1df476ac9541b0e4fdc8e2cc48884e66c92c933cd17a1fd75e68caf75752e" dependencies = [ "async-trait", - "base64", + "base64 0.13.0", "bitflags", "bson", "chrono", @@ -1433,7 +2066,7 @@ dependencies = [ "os_info", "pbkdf2", "percent-encoding", - "rand", + "rand 0.8.5", "rustc_version_runtime", "rustls", "rustls-pemfile", @@ -1442,16 +2075,16 @@ dependencies = [ "serde_with", "sha-1", "sha2", - "socket2", + "socket2 0.4.4", "stringprep", "strsim", "take_mut", "thiserror", - "tokio", + "tokio 1.21.2", "tokio-rustls", - "tokio-util", - "trust-dns-proto", - "trust-dns-resolver", + "tokio-util 0.7.3", + "trust-dns-proto 0.21.2", + "trust-dns-resolver 0.21.2", "typed-builder", "uuid 0.8.2", "webpki-roots", @@ -1475,6 +2108,17 @@ dependencies = [ "tempfile", ] +[[package]] +name = "net2" +version = "0.2.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74d0df99cfcd2530b2e694f6e17e7f37b8e26bb23983ac530c0c97408837c631" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "winapi 0.3.9", +] + [[package]] name = "nom" version = "7.1.1" @@ -1506,7 +2150,7 @@ dependencies = [ "algonaut_client", "anyhow", "axum", - "base64", + "base64 0.13.0", "config", "ed25519", "env-var-helpers", @@ -1515,7 +2159,7 @@ dependencies = [ "serde_derive", "serde_json", "serde_with", - "tokio", + "tokio 1.21.2", "tower-http", ] @@ -1525,12 +2169,12 @@ version = "0.1.0" dependencies = [ "anyhow", "assert_cmd", - "base64", + "base64 0.13.0", "clap", "confy", "k9", "ntc-data-packages", - "rand", + "rand 0.8.5", "rusty-sodalite", "serde", "serde_with", @@ -1651,6 +2295,15 @@ dependencies = [ "libc", ] +[[package]] +name = "object" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.12.0" @@ -1670,7 +2323,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb81a6430ac911acb25fe5ac8f1d2af1b4ea8a4fdfda0f1ee4292af2e2d8eb0e" dependencies = [ "bitflags", - "cfg-if", + "cfg-if 1.0.0", "foreign-types", "libc", "once_cell", @@ -1715,7 +2368,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4750134fb6a5d49afc80777394ad5d95b04bc12068c6abb92fae8f43817270f" dependencies = [ "log", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -1746,6 +2399,17 @@ dependencies = [ "sec1", ] +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core 0.8.5", +] + [[package]] name = "parking_lot" version = "0.12.1" @@ -1753,7 +2417,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core", + "parking_lot_core 0.9.3", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +dependencies = [ + "cfg-if 1.0.0", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi 0.3.9", ] [[package]] @@ -1762,7 +2440,7 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "redox_syscall", "smallvec", @@ -1796,13 +2474,33 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +[[package]] +name = "pin-project" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ef0f924a5ee7ea9cbcea77529dba45f8a9ba9f622419fe3386ca581a3ae9d5a" +dependencies = [ + "pin-project-internal 0.4.30", +] + [[package]] name = "pin-project" version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58ad3879ad3baf4e44784bc6a718a8698867bb991f8ce24d1bcbe2cfb4c3a75e" dependencies = [ - "pin-project-internal", + "pin-project-internal 1.0.10", +] + +[[package]] +name = "pin-project-internal" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "851c8d0ce9bebe43790dedfc86614c23494ac9f423dd618d3a61fc693eafe61e" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -1816,6 +2514,12 @@ dependencies = [ "syn", ] +[[package]] +name = "pin-project-lite" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" + [[package]] name = "pin-project-lite" version = "0.2.9" @@ -1925,6 +2629,19 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", +] + [[package]] name = "rand" version = "0.8.5" @@ -1932,8 +2649,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha", - "rand_core", + "rand_chacha 0.3.1", + "rand_core 0.6.3", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", ] [[package]] @@ -1943,7 +2670,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.3", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", ] [[package]] @@ -1952,7 +2688,16 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" dependencies = [ - "getrandom", + "getrandom 0.2.6", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", ] [[package]] @@ -1970,7 +2715,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom", + "getrandom 0.2.6", "redox_syscall", "thiserror", ] @@ -2004,7 +2749,7 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" dependencies = [ - "winapi", + "winapi 0.3.9", ] [[package]] @@ -2013,12 +2758,12 @@ version = "0.11.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46a1f7aa4f35e5e8b4160449f51afc758f0ce6454315a9fa7d0d113e958c41eb" dependencies = [ - "base64", - "bytes", + "base64 0.13.0", + "bytes 1.1.0", "encoding_rs", "futures-core", "futures-util", - "h2", + "h2 0.3.13", "http", "http-body", "hyper", @@ -2030,11 +2775,11 @@ dependencies = [ "mime", "native-tls", "percent-encoding", - "pin-project-lite", + "pin-project-lite 0.2.9", "serde", "serde_json", - "serde_urlencoded", - "tokio", + "serde_urlencoded 0.7.1", + "tokio 1.21.2", "tokio-native-tls", "url", "wasm-bindgen", @@ -2043,6 +2788,16 @@ dependencies = [ "winreg 0.10.1", ] +[[package]] +name = "resolv-conf" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11834e137f3b14e309437a8276714eed3a80d1ef894869e510f2c0c0b98b9f4a" +dependencies = [ + "hostname", + "quick-error", +] + [[package]] name = "resolv-conf" version = "0.7.0" @@ -2065,7 +2820,7 @@ dependencies = [ "spin", "untrusted", "web-sys", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -2107,6 +2862,12 @@ dependencies = [ "serde", ] +[[package]] +name = "rustc-demangle" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" + [[package]] name = "rustc_version" version = "0.2.3" @@ -2153,7 +2914,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ee86d63972a7c661d1536fefe8c3c8407321c3df668891286de28abcd087360" dependencies = [ - "base64", + "base64 0.13.0", ] [[package]] @@ -2303,11 +3064,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" dependencies = [ "indexmap", - "itoa", + "itoa 1.0.2", "ryu", "serde", ] +[[package]] +name = "serde_urlencoded" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" +dependencies = [ + "dtoa", + "itoa 0.4.8", + "serde", + "url", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -2315,7 +3088,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ "form_urlencoded", - "itoa", + "itoa 1.0.2", "ryu", "serde", ] @@ -2326,7 +3099,7 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "678b5a069e50bf00ecd22d0cd8ddf7c236f68581b03db652061ed5eb13a312ff" dependencies = [ - "base64", + "base64 0.13.0", "serde", "serde_with_macros", ] @@ -2349,29 +3122,53 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest 0.10.3", ] +[[package]] +name = "sha1" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770" +dependencies = [ + "sha1_smol", +] + +[[package]] +name = "sha1_smol" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" + [[package]] name = "sha2" version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest 0.10.3", ] +[[package]] +name = "signal-hook-registry" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +dependencies = [ + "libc", +] + [[package]] name = "signature" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02658e48d89f2bec991f9a78e69cfa4c316f8d6a6c4ec12fae1aeb263d486788" dependencies = [ - "rand_core", + "rand_core 0.6.3", ] [[package]] @@ -2386,6 +3183,17 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" +[[package]] +name = "socket2" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "winapi 0.3.9", +] + [[package]] name = "socket2" version = "0.4.4" @@ -2393,7 +3201,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" dependencies = [ "libc", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -2465,6 +3273,18 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20518fe4a4c9acf048008599e464deb21beeae3d3578418951a189c235a7a9a8" +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + [[package]] name = "take_mut" version = "0.2.2" @@ -2477,12 +3297,12 @@ version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "fastrand", "libc", "redox_syscall", "remove_dir_all", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -2492,7 +3312,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e4129646ca0ed8f45d09b929036bafad5377103edd06e50bf574b353d2b08d9" dependencies = [ "libc", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -2536,6 +3356,15 @@ dependencies = [ "syn", ] +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", +] + [[package]] name = "time" version = "0.1.43" @@ -2543,7 +3372,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" dependencies = [ "libc", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -2552,7 +3381,7 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2702e08a7a860f005826c6815dcac101b19b5eb330c27fe4a5928fec1d20ddd" dependencies = [ - "itoa", + "itoa 1.0.2", "libc", "num_threads", "time-macros", @@ -2579,6 +3408,26 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +[[package]] +name = "tokio" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6703a273949a90131b290be1fe7b039d0fc884aa1935860dfcbe056f28cd8092" +dependencies = [ + "bytes 0.5.6", + "futures-core", + "iovec", + "lazy_static", + "libc", + "memchr", + "mio 0.6.23", + "mio-uds", + "pin-project-lite 0.1.12", + "signal-hook-registry", + "slab", + "winapi 0.3.9", +] + [[package]] name = "tokio" version = "1.21.2" @@ -2586,15 +3435,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9e03c497dc955702ba729190dc4aac6f2a0ce97f913e5b1b5912fc5039d9099" dependencies = [ "autocfg", - "bytes", + "bytes 1.1.0", "libc", "memchr", - "mio", + "mio 0.8.4", "num_cpus", - "pin-project-lite", - "socket2", + "pin-project-lite 0.2.9", + "socket2 0.4.4", "tokio-macros", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -2615,7 +3464,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" dependencies = [ "native-tls", - "tokio", + "tokio 1.21.2", ] [[package]] @@ -2625,21 +3474,49 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" dependencies = [ "rustls", - "tokio", + "tokio 1.21.2", "webpki", ] +[[package]] +name = "tokio-util" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "571da51182ec208780505a32528fc5512a8fe1443ab960b3f2f3ef093cd16930" +dependencies = [ + "bytes 0.5.6", + "futures-core", + "futures-sink", + "log", + "pin-project-lite 0.1.12", + "tokio 0.2.25", +] + +[[package]] +name = "tokio-util" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" +dependencies = [ + "bytes 0.5.6", + "futures-core", + "futures-sink", + "log", + "pin-project-lite 0.1.12", + "tokio 0.2.25", +] + [[package]] name = "tokio-util" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc463cd8deddc3770d20f9852143d50bf6094e640b485cb2e189a2099085ff45" dependencies = [ - "bytes", + "bytes 1.1.0", "futures-core", "futures-sink", - "pin-project-lite", - "tokio", + "pin-project-lite 0.2.9", + "tokio 1.21.2", "tracing", ] @@ -2660,10 +3537,10 @@ checksum = "9a89fd63ad6adf737582df5db40d286574513c69a11dac5214dc3b5603d6713e" dependencies = [ "futures-core", "futures-util", - "pin-project", - "pin-project-lite", - "tokio", - "tokio-util", + "pin-project 1.0.10", + "pin-project-lite 0.2.9", + "tokio 1.21.2", + "tokio-util 0.7.3", "tower-layer", "tower-service", "tracing", @@ -2676,13 +3553,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c530c8675c1dbf98facee631536fa116b5fb6382d7dd6dc1b118d970eafe3ba" dependencies = [ "bitflags", - "bytes", + "bytes 1.1.0", "futures-core", "futures-util", "http", "http-body", "http-range-header", - "pin-project-lite", + "pin-project-lite 0.2.9", "tower", "tower-layer", "tower-service", @@ -2706,9 +3583,9 @@ version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d0ecdcb44a79f0fe9844f0c4f33a342cbcbb5117de8001e6ba0dc2351327d09" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "log", - "pin-project-lite", + "pin-project-lite 0.2.9", "tracing-core", ] @@ -2721,6 +3598,36 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tracing-futures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" +dependencies = [ + "pin-project 1.0.10", + "tracing", +] + +[[package]] +name = "trust-dns-proto" +version = "0.18.0-alpha.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a7f3a2ab8a919f5eca52a468866a67ed7d3efa265d48a652a9a3452272b413f" +dependencies = [ + "async-trait", + "enum-as-inner 0.3.4", + "failure", + "futures", + "idna", + "lazy_static", + "log", + "rand 0.7.3", + "smallvec", + "socket2 0.3.19", + "tokio 0.2.25", + "url", +] + [[package]] name = "trust-dns-proto" version = "0.21.2" @@ -2728,9 +3635,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c31f240f59877c3d4bb3b3ea0ec5a6a0cff07323580ff8c7a605cd7d08b255d" dependencies = [ "async-trait", - "cfg-if", + "cfg-if 1.0.0", "data-encoding", - "enum-as-inner", + "enum-as-inner 0.4.0", "futures-channel", "futures-io", "futures-util", @@ -2738,32 +3645,51 @@ dependencies = [ "ipnet", "lazy_static", "log", - "rand", + "rand 0.8.5", "smallvec", "thiserror", "tinyvec", - "tokio", + "tokio 1.21.2", "url", ] +[[package]] +name = "trust-dns-resolver" +version = "0.18.0-alpha.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f90b1502b226f8b2514c6d5b37bafa8c200d7ca4102d57dc36ee0f3b7a04a2f" +dependencies = [ + "cfg-if 0.1.10", + "failure", + "futures", + "ipconfig 0.2.2", + "lazy_static", + "log", + "lru-cache", + "resolv-conf 0.6.3", + "smallvec", + "tokio 0.2.25", + "trust-dns-proto 0.18.0-alpha.2", +] + [[package]] name = "trust-dns-resolver" version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4ba72c2ea84515690c9fcef4c6c660bb9df3036ed1051686de84605b74fd558" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "futures-util", - "ipconfig", + "ipconfig 0.3.0", "lazy_static", "log", "lru-cache", - "parking_lot", - "resolv-conf", + "parking_lot 0.12.1", + "resolv-conf 0.7.0", "smallvec", "thiserror", - "tokio", - "trust-dns-proto", + "tokio 1.21.2", + "trust-dns-proto 0.21.2", ] [[package]] @@ -2816,6 +3742,12 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "untrusted" version = "0.7.1" @@ -2846,7 +3778,7 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" dependencies = [ - "getrandom", + "getrandom 0.2.6", ] [[package]] @@ -2855,7 +3787,7 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "feb41e78f93363bb2df8b0e86a2ca30eed7806ea16ea0c790d757cf93f79be83" dependencies = [ - "getrandom", + "getrandom 0.2.6", "serde", ] @@ -2887,7 +3819,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" dependencies = [ "same-file", - "winapi", + "winapi 0.3.9", "winapi-util", ] @@ -2901,6 +3833,12 @@ dependencies = [ "try-lock", ] +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + [[package]] name = "wasi" version = "0.10.2+wasi-snapshot-preview1" @@ -2919,7 +3857,7 @@ version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "wasm-bindgen-macro", ] @@ -2944,7 +3882,7 @@ version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f741de44b75e14c35df886aff5f1eb73aa114fa5d4d00dcd37b5e01259bf3b2" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "js-sys", "wasm-bindgen", "web-sys", @@ -3008,12 +3946,24 @@ dependencies = [ "webpki", ] +[[package]] +name = "widestring" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c" + [[package]] name = "widestring" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17882f045410753661207383517a6f62ec3dbeb6a4ed2acce01f0728238d1983" +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" + [[package]] name = "winapi" version = "0.3.9" @@ -3024,6 +3974,12 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu", ] +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" + [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" @@ -3036,7 +3992,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ - "winapi", + "winapi 0.3.9", ] [[package]] @@ -3088,13 +4044,22 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" +[[package]] +name = "winreg" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" +dependencies = [ + "winapi 0.3.9", +] + [[package]] name = "winreg" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" dependencies = [ - "winapi", + "winapi 0.3.9", ] [[package]] @@ -3103,7 +4068,17 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" dependencies = [ - "winapi", + "winapi 0.3.9", +] + +[[package]] +name = "ws2_32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +dependencies = [ + "winapi 0.2.8", + "winapi-build", ] [[package]] diff --git a/rust-workspace/projects/data-server/Cargo.toml b/rust-workspace/projects/data-server/Cargo.toml index 7f7aff7..0dd11c4 100644 --- a/rust-workspace/projects/data-server/Cargo.toml +++ b/rust-workspace/projects/data-server/Cargo.toml @@ -10,5 +10,5 @@ edition = "2021" mongodb = "2.3" bson = "2.4" serde = { version = "1.0", features = ["derive"] } - -env-var-helpers = { git = "https://github.com/PiDelport/rust-env-var-helpers" } \ No newline at end of file +actix-rt = "1.1.1" +actix-web = "2.0" \ No newline at end of file diff --git a/rust-workspace/projects/data-server/src/main.rs b/rust-workspace/projects/data-server/src/main.rs index 20059d8..1423e82 100644 --- a/rust-workspace/projects/data-server/src/main.rs +++ b/rust-workspace/projects/data-server/src/main.rs @@ -1,6 +1,7 @@ use bson::{doc, Bson, Document}; -use env_var_helpers::env_vars; use mongodb::{error::Error, options::ClientOptions, Client, Collection, Database}; +use actix_web::{get, web, App, HttpServer, Responder}; +use std::env; pub struct CosmosDBMongo { connection_string: String, @@ -8,8 +9,20 @@ pub struct CosmosDBMongo { collection_name: String, } -fn main() { - println!("Hello, world!"); +#[actix_rt::main] +async fn main() -> std::io::Result<()> { + // Create log for actix to output errors + env::set_var("RUST_LOG", "actix_web=debug"); + HttpServer::new(|| + App::new().route("/", web::get().to(hello))) + .bind("127.0.0.1:8000")? + .run() + .await +} + + +async fn hello() -> impl Responder { + format!("Hello fellow Rustacean!") } // Upload data pool API // From 3654c67b6a7be778cd40b7bad8cc52d2bcf73df1 Mon Sep 17 00:00:00 2001 From: binglekruger Date: Mon, 24 Oct 2022 08:46:14 +0000 Subject: [PATCH 16/22] feat: Configure server + add logs_handlers --- rust-workspace/Cargo.lock | 481 ++++++++++++------ .../projects/data-server/Cargo.toml | 5 +- .../data-server/src/logs_handlers/mod.rs | 17 + .../projects/data-server/src/main.rs | 29 +- 4 files changed, 367 insertions(+), 165 deletions(-) create mode 100644 rust-workspace/projects/data-server/src/logs_handlers/mod.rs diff --git a/rust-workspace/Cargo.lock b/rust-workspace/Cargo.lock index 26c895c..5abf47d 100644 --- a/rust-workspace/Cargo.lock +++ b/rust-workspace/Cargo.lock @@ -361,7 +361,7 @@ dependencies = [ "num-bigint 0.4.3", "num-traits", "rmp-serde", - "sha2", + "sha2 0.10.2", "thiserror", ] @@ -376,7 +376,7 @@ dependencies = [ "num-bigint 0.4.3", "regex", "serde", - "sha2", + "sha2 0.10.2", "thiserror", ] @@ -392,7 +392,7 @@ dependencies = [ "async-trait", "data-encoding", "derive_more", - "reqwest", + "reqwest 0.11.10", "serde", "serde_json", "thiserror", @@ -411,7 +411,7 @@ dependencies = [ "ring", "rmp-serde", "serde", - "sha2", + "sha2 0.10.2", "static_assertions", "thiserror", ] @@ -428,7 +428,7 @@ dependencies = [ "lazy_static", "ring", "serde", - "sha2", + "sha2 0.10.2", "static_assertions", "thiserror", ] @@ -477,7 +477,7 @@ dependencies = [ "rmp-serde", "serde", "serde_bytes", - "sha2", + "sha2 0.10.2", "thiserror", "url", "urlencoding", @@ -575,8 +575,8 @@ dependencies = [ "bytes 1.1.0", "futures-util", "http", - "http-body", - "hyper", + "http-body 0.4.5", + "hyper 0.14.19", "itoa 1.0.2", "matchit", "memchr", @@ -604,7 +604,7 @@ dependencies = [ "bytes 1.1.0", "futures-util", "http", - "http-body", + "http-body 0.4.5", "mime", ] @@ -635,6 +635,12 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" +[[package]] +name = "base64" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" + [[package]] name = "base64" version = "0.13.0" @@ -662,6 +668,15 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + [[package]] name = "block-buffer" version = "0.10.2" @@ -691,6 +706,23 @@ dependencies = [ "libc", ] +[[package]] +name = "bson" +version = "1.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de0aa578035b938855a710ba58d43cfb4d435f3619f99236fb35922a574d6cb1" +dependencies = [ + "base64 0.13.0", + "chrono", + "hex", + "lazy_static", + "linked-hash-map", + "rand 0.7.3", + "serde", + "serde_json", + "uuid 0.8.2", +] + [[package]] name = "bson" version = "2.4.0" @@ -958,6 +990,16 @@ dependencies = [ "typenum", ] +[[package]] +name = "crypto-mac" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +dependencies = [ + "generic-array", + "subtle", +] + [[package]] name = "cxx" version = "1.0.78" @@ -1049,7 +1091,8 @@ version = "0.1.0" dependencies = [ "actix-rt", "actix-web", - "bson", + "bson 2.4.0", + "futures", "mongodb", "serde", ] @@ -1092,7 +1135,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "rustc_version 0.4.0", + "rustc_version", "syn", ] @@ -1123,9 +1166,8 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" dependencies = [ - "block-buffer", + "block-buffer 0.10.2", "crypto-common", - "subtle", ] [[package]] @@ -1227,18 +1269,6 @@ dependencies = [ "syn", ] -[[package]] -name = "enum-as-inner" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21cdad81446a7f7dc43f6a77409efeb9733d2fa65553efef6018ef257c959b73" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "env-var-helpers" version = "0.1.0" @@ -1247,6 +1277,20 @@ dependencies = [ "thiserror", ] +[[package]] +name = "err-derive" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22deed3a8124cff5fa835713fa105621e43bbdc46690c3a6b68328a012d350d4" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "rustversion", + "syn", + "synstructure", +] + [[package]] name = "failure" version = "0.1.8" @@ -1579,11 +1623,12 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hmac" -version = "0.12.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" dependencies = [ - "digest 0.10.3", + "crypto-mac", + "digest 0.9.0", ] [[package]] @@ -1608,6 +1653,16 @@ dependencies = [ "itoa 1.0.2", ] +[[package]] +name = "http-body" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" +dependencies = [ + "bytes 0.5.6", + "http", +] + [[package]] name = "http-body" version = "0.4.5" @@ -1631,12 +1686,42 @@ version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "496ce29bb5a52785b44e0f7ca2847ae0bb839c9bd28f69acac9b99d461c0c04c" +[[package]] +name = "httpdate" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" + [[package]] name = "httpdate" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +[[package]] +name = "hyper" +version = "0.13.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a6f157065790a3ed2f88679250419b5cdd96e714a0d65f7797fd337186e96bb" +dependencies = [ + "bytes 0.5.6", + "futures-channel", + "futures-core", + "futures-util", + "h2 0.2.7", + "http", + "http-body 0.3.1", + "httparse", + "httpdate 0.3.2", + "itoa 0.4.8", + "pin-project 1.0.10", + "socket2 0.3.19", + "tokio 0.2.25", + "tower-service", + "tracing", + "want", +] + [[package]] name = "hyper" version = "0.14.19" @@ -1649,9 +1734,9 @@ dependencies = [ "futures-util", "h2 0.3.13", "http", - "http-body", + "http-body 0.4.5", "httparse", - "httpdate", + "httpdate 1.0.2", "itoa 1.0.2", "pin-project-lite 0.2.9", "socket2 0.4.4", @@ -1661,6 +1746,22 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-rustls" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37743cc83e8ee85eacfce90f2f4102030d9ff0a95244098d781e9bee4a90abb6" +dependencies = [ + "bytes 0.5.6", + "futures-util", + "hyper 0.13.10", + "log", + "rustls 0.18.1", + "tokio 0.2.25", + "tokio-rustls 0.14.1", + "webpki", +] + [[package]] name = "hyper-tls" version = "0.5.0" @@ -1668,7 +1769,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ "bytes 1.1.0", - "hyper", + "hyper 0.14.19", "native-tls", "tokio 1.21.2", "tokio-native-tls", @@ -1759,23 +1860,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7e2f18aece9709094573a9f24f483c4f65caa4298e2f7ae1b71cc65d853fad7" dependencies = [ "socket2 0.3.19", - "widestring 0.4.3", + "widestring", "winapi 0.3.9", "winreg 0.6.2", ] -[[package]] -name = "ipconfig" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "723519edce41262b05d4143ceb95050e4c614f483e78e9fd9e39a8275a84ad98" -dependencies = [ - "socket2 0.4.4", - "widestring 0.5.1", - "winapi 0.3.9", - "winreg 0.7.0", -] - [[package]] name = "ipnet" version = "2.5.0" @@ -1956,11 +2045,13 @@ checksum = "73cbba799671b762df5a175adf59ce145165747bb891505c43d09aefbbf38beb" [[package]] name = "md-5" -version = "0.10.4" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66b48670c893079d3c2ed79114e3644b7004df1c361a4e0ad52e2e6940d07c3d" +checksum = "7b5a279bb9607f9f53c22d496eade00d138d1bdcccd07d74650387cf94942a15" dependencies = [ - "digest 0.10.3", + "block-buffer 0.9.0", + "digest 0.9.0", + "opaque-debug", ] [[package]] @@ -1975,6 +2066,16 @@ version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" +[[package]] +name = "mime_guess" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" +dependencies = [ + "mime", + "unicase", +] + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -2046,19 +2147,18 @@ dependencies = [ [[package]] name = "mongodb" -version = "2.3.1" +version = "1.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a1df476ac9541b0e4fdc8e2cc48884e66c92c933cd17a1fd75e68caf75752e" +checksum = "88543485b334691ccd284ea2d6033a5d9b0e5e77db6a0aa7a2da4caaa458f4f9" dependencies = [ "async-trait", - "base64 0.13.0", + "base64 0.11.0", "bitflags", - "bson", + "bson 1.2.4", "chrono", "derivative", - "futures-core", - "futures-executor", - "futures-util", + "err-derive", + "futures", "hex", "hmac", "lazy_static", @@ -2066,28 +2166,29 @@ dependencies = [ "os_info", "pbkdf2", "percent-encoding", - "rand 0.8.5", - "rustc_version_runtime", - "rustls", + "rand 0.7.3", + "reqwest 0.10.10", + "rustls 0.17.0", "rustls-pemfile", "serde", "serde_bytes", "serde_with", "sha-1", - "sha2", - "socket2 0.4.4", + "sha2 0.9.9", + "socket2 0.3.19", "stringprep", "strsim", "take_mut", - "thiserror", - "tokio 1.21.2", - "tokio-rustls", - "tokio-util 0.7.3", - "trust-dns-proto 0.21.2", - "trust-dns-resolver 0.21.2", + "time 0.1.43", + "tokio 0.2.25", + "tokio-rustls 0.13.1", + "trust-dns-proto 0.19.7", + "trust-dns-resolver 0.19.7", "typed-builder", "uuid 0.8.2", - "webpki-roots", + "version_check", + "webpki", + "webpki-roots 0.21.1", ] [[package]] @@ -2461,11 +2562,11 @@ checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" [[package]] name = "pbkdf2" -version = "0.10.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271779f35b581956db91a3e55737327a03aa051e90b1c47aeb189508533adfd7" +checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" dependencies = [ - "digest 0.10.3", + "crypto-mac", ] [[package]] @@ -2640,6 +2741,7 @@ dependencies = [ "rand_chacha 0.2.2", "rand_core 0.5.1", "rand_hc", + "rand_pcg", ] [[package]] @@ -2700,6 +2802,15 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "rand_pcg" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" +dependencies = [ + "rand_core 0.5.1", +] + [[package]] name = "redox_syscall" version = "0.2.13" @@ -2752,6 +2863,43 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "reqwest" +version = "0.10.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0718f81a8e14c4dbb3b34cf23dc6aaf9ab8a0dfec160c534b3dbca1aaa21f47c" +dependencies = [ + "base64 0.13.0", + "bytes 0.5.6", + "encoding_rs", + "futures-core", + "futures-util", + "http", + "http-body 0.3.1", + "hyper 0.13.10", + "hyper-rustls", + "ipnet", + "js-sys", + "lazy_static", + "log", + "mime", + "mime_guess", + "percent-encoding", + "pin-project-lite 0.2.9", + "rustls 0.18.1", + "serde", + "serde_json", + "serde_urlencoded 0.7.1", + "tokio 0.2.25", + "tokio-rustls 0.14.1", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "webpki-roots 0.20.0", + "winreg 0.7.0", +] + [[package]] name = "reqwest" version = "0.11.10" @@ -2765,8 +2913,8 @@ dependencies = [ "futures-util", "h2 0.3.13", "http", - "http-body", - "hyper", + "http-body 0.4.5", + "hyper 0.14.19", "hyper-tls", "ipnet", "js-sys", @@ -2868,40 +3016,35 @@ version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver 0.9.0", -] - [[package]] name = "rustc_version" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.9", + "semver", ] [[package]] -name = "rustc_version_runtime" -version = "0.2.1" +name = "rustls" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d31b7153270ebf48bf91c65ae5b0c00e749c4cfad505f66530ac74950249582f" +checksum = "c0d4a31f5d68413404705d6982529b0e11a9aacd4839d1d6222ee3b8cb4015e1" dependencies = [ - "rustc_version 0.2.3", - "semver 0.9.0", + "base64 0.11.0", + "log", + "ring", + "sct", + "webpki", ] [[package]] name = "rustls" -version = "0.20.6" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aab8ee6c7097ed6057f43c187a62418d0c05a4bd5f18b3571db50ee0f9ce033" +checksum = "5d1126dcf58e93cee7d098dbda643b5f92ed724f1f6a63007c1116eed6700c81" dependencies = [ + "base64 0.12.3", "log", "ring", "sct", @@ -2910,13 +3053,19 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "0.3.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee86d63972a7c661d1536fefe8c3c8407321c3df668891286de28abcd087360" +checksum = "5eebeaeb360c87bfb72e84abdb3447159c0eaececf1bef2aecd65a8be949d1c9" dependencies = [ "base64 0.13.0", ] +[[package]] +name = "rustversion" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" + [[package]] name = "rusty-sodalite" version = "0.1.0" @@ -2964,9 +3113,9 @@ checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" [[package]] name = "sct" -version = "0.7.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" dependencies = [ "ring", "untrusted", @@ -3007,27 +3156,12 @@ dependencies = [ "libc", ] -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - [[package]] name = "semver" version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8cb243bdfdb5936c8dc3c45762a19d12ab4550cdc753bc247637d4ec35a040fd" -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - [[package]] name = "serde" version = "1.0.145" @@ -3118,13 +3252,15 @@ dependencies = [ [[package]] name = "sha-1" -version = "0.10.0" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f" +checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" dependencies = [ + "block-buffer 0.9.0", "cfg-if 1.0.0", "cpufeatures", - "digest 0.10.3", + "digest 0.9.0", + "opaque-debug", ] [[package]] @@ -3142,6 +3278,19 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + [[package]] name = "sha2" version = "0.10.2" @@ -3415,6 +3564,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6703a273949a90131b290be1fe7b039d0fc884aa1935860dfcbe056f28cd8092" dependencies = [ "bytes 0.5.6", + "fnv", "futures-core", "iovec", "lazy_static", @@ -3422,9 +3572,11 @@ dependencies = [ "memchr", "mio 0.6.23", "mio-uds", + "num_cpus", "pin-project-lite 0.1.12", "signal-hook-registry", "slab", + "tokio-macros 0.2.6", "winapi 0.3.9", ] @@ -3442,10 +3594,21 @@ dependencies = [ "num_cpus", "pin-project-lite 0.2.9", "socket2 0.4.4", - "tokio-macros", + "tokio-macros 1.8.0", "winapi 0.3.9", ] +[[package]] +name = "tokio-macros" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e44da00bfc73a25f814cd8d7e57a68a5c31b74b3152a0a1d1f590c97ed06265a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "tokio-macros" version = "1.8.0" @@ -3469,12 +3632,25 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.23.4" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" +checksum = "15cb62a0d2770787abc96e99c1cd98fcf17f94959f3af63ca85bdfb203f051b4" dependencies = [ - "rustls", - "tokio 1.21.2", + "futures-core", + "rustls 0.17.0", + "tokio 0.2.25", + "webpki", +] + +[[package]] +name = "tokio-rustls" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12831b255bcfa39dc0436b01e19fea231a37db570686c06ee72c423479f889a" +dependencies = [ + "futures-core", + "rustls 0.18.1", + "tokio 0.2.25", "webpki", ] @@ -3557,7 +3733,7 @@ dependencies = [ "futures-core", "futures-util", "http", - "http-body", + "http-body 0.4.5", "http-range-header", "pin-project-lite 0.2.9", "tower", @@ -3615,7 +3791,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a7f3a2ab8a919f5eca52a468866a67ed7d3efa265d48a652a9a3452272b413f" dependencies = [ "async-trait", - "enum-as-inner 0.3.4", + "enum-as-inner", "failure", "futures", "idna", @@ -3630,26 +3806,22 @@ dependencies = [ [[package]] name = "trust-dns-proto" -version = "0.21.2" +version = "0.19.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c31f240f59877c3d4bb3b3ea0ec5a6a0cff07323580ff8c7a605cd7d08b255d" +checksum = "1cad71a0c0d68ab9941d2fb6e82f8fb2e86d9945b94e1661dd0aaea2b88215a9" dependencies = [ "async-trait", + "backtrace", "cfg-if 1.0.0", - "data-encoding", - "enum-as-inner 0.4.0", - "futures-channel", - "futures-io", - "futures-util", + "enum-as-inner", + "futures", "idna", - "ipnet", "lazy_static", "log", - "rand 0.8.5", + "rand 0.7.3", "smallvec", "thiserror", - "tinyvec", - "tokio 1.21.2", + "tokio 0.2.25", "url", ] @@ -3662,7 +3834,7 @@ dependencies = [ "cfg-if 0.1.10", "failure", "futures", - "ipconfig 0.2.2", + "ipconfig", "lazy_static", "log", "lru-cache", @@ -3674,22 +3846,21 @@ dependencies = [ [[package]] name = "trust-dns-resolver" -version = "0.21.2" +version = "0.19.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4ba72c2ea84515690c9fcef4c6c660bb9df3036ed1051686de84605b74fd558" +checksum = "710f593b371175db53a26d0b38ed2978fafb9e9e8d3868b1acd753ea18df0ceb" dependencies = [ - "cfg-if 1.0.0", - "futures-util", - "ipconfig 0.3.0", + "cfg-if 0.1.10", + "futures", + "ipconfig", "lazy_static", "log", "lru-cache", - "parking_lot 0.12.1", "resolv-conf 0.7.0", "smallvec", "thiserror", - "tokio 1.21.2", - "trust-dns-proto 0.21.2", + "tokio 0.2.25", + "trust-dns-proto 0.19.7", ] [[package]] @@ -3700,9 +3871,9 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "typed-builder" -version = "0.10.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89851716b67b937e393b3daa8423e67ddfc4bbbf1654bcf05488e95e0828db0c" +checksum = "dfc955f27acc7a547f328f52f4a5a568986a31efec2fc6de865279f3995787b9" dependencies = [ "proc-macro2", "quote", @@ -3715,6 +3886,15 @@ version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +dependencies = [ + "version_check", +] + [[package]] name = "unicode-bidi" version = "0.3.8" @@ -3858,6 +4038,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad" dependencies = [ "cfg-if 1.0.0", + "serde", + "serde_json", "wasm-bindgen-macro", ] @@ -3929,9 +4111,9 @@ dependencies = [ [[package]] name = "webpki" -version = "0.22.0" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" dependencies = [ "ring", "untrusted", @@ -3939,24 +4121,27 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.22.5" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368bfe657969fb01238bb756d351dcade285e0f6fcbd36dcb23359a5169975be" +checksum = "0f20dea7535251981a9670857150d571846545088359b28e4951d350bdaf179f" dependencies = [ "webpki", ] [[package]] -name = "widestring" -version = "0.4.3" +name = "webpki-roots" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c" +checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940" +dependencies = [ + "webpki", +] [[package]] name = "widestring" -version = "0.5.1" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17882f045410753661207383517a6f62ec3dbeb6a4ed2acce01f0728238d1983" +checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c" [[package]] name = "winapi" diff --git a/rust-workspace/projects/data-server/Cargo.toml b/rust-workspace/projects/data-server/Cargo.toml index 0dd11c4..803443d 100644 --- a/rust-workspace/projects/data-server/Cargo.toml +++ b/rust-workspace/projects/data-server/Cargo.toml @@ -7,8 +7,9 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -mongodb = "2.3" +mongodb = "1.0.0" #Change version for compatibility bson = "2.4" serde = { version = "1.0", features = ["derive"] } actix-rt = "1.1.1" -actix-web = "2.0" \ No newline at end of file +actix-web = "2.0" +futures = "0.3.5" \ No newline at end of file diff --git a/rust-workspace/projects/data-server/src/logs_handlers/mod.rs b/rust-workspace/projects/data-server/src/logs_handlers/mod.rs new file mode 100644 index 0000000..2c468de --- /dev/null +++ b/rust-workspace/projects/data-server/src/logs_handlers/mod.rs @@ -0,0 +1,17 @@ +use actix_web::{web, Responder}; + +pub fn scoped_config(cfg: &mut web::ServiceConfig) { + cfg.service( + web::resource("/logs") + .route(web::get().to(get_logs)) + .route(web::post().to(add_log)), + ); +} + +async fn get_logs() -> impl Responder { + format!("Not yet implemented!") +} + +async fn add_log() -> impl Responder { + format!("Not yet implemented!") +} \ No newline at end of file diff --git a/rust-workspace/projects/data-server/src/main.rs b/rust-workspace/projects/data-server/src/main.rs index 1423e82..1093af5 100644 --- a/rust-workspace/projects/data-server/src/main.rs +++ b/rust-workspace/projects/data-server/src/main.rs @@ -2,27 +2,26 @@ use bson::{doc, Bson, Document}; use mongodb::{error::Error, options::ClientOptions, Client, Collection, Database}; use actix_web::{get, web, App, HttpServer, Responder}; use std::env; +use std::sync::*; -pub struct CosmosDBMongo { - connection_string: String, - database_name: String, - collection_name: String, -} +mod logs_handlers; #[actix_rt::main] async fn main() -> std::io::Result<()> { // Create log for actix to output errors env::set_var("RUST_LOG", "actix_web=debug"); - HttpServer::new(|| - App::new().route("/", web::get().to(hello))) - .bind("127.0.0.1:8000")? - .run() - .await -} - - -async fn hello() -> impl Responder { - format!("Hello fellow Rustacean!") + //Will remove connection string for production - included for testing + let mut client_options = ClientOptions::parse("mongodb://ntc-data:zkicQepvrK6B1SySo3vDLQpycrEsSt3WByUE1Zg7SYs47CceytRCzIuP3cu3p09GtY2cREJyJtdc9zSjqlxcvA==@ntc-data.mongo.cosmos.azure.com:10255/?ssl=true&replicaSet=globaldb&retrywrites=false&maxIdleTimeMS=120000&appName=@ntc-data@").await.unwrap(); + client_options.app_name = Some("ntc-data".to_string()); + let client = web::Data::new(Mutex::new(Client::with_options(client_options).unwrap())); + HttpServer::new(move || { + App::new() + .app_data(client.clone()) + .service(web::scope("/api").configure(logs_handlers::scoped_config)) + }) + .bind("127.0.0.1:8000")? + .run() + .await } // Upload data pool API // From 59ad78381b720f9ad05bc2a00f88b158725ded07 Mon Sep 17 00:00:00 2001 From: binglekruger Date: Mon, 24 Oct 2022 09:50:28 +0000 Subject: [PATCH 17/22] feat: Fetching logs --- rust-workspace/Cargo.lock | 41 +++-------------- .../projects/data-server/Cargo.toml | 5 +- .../data-server/src/logs_handlers/mod.rs | 46 +++++++++++++++++-- .../projects/data-server/src/main.rs | 5 +- 4 files changed, 54 insertions(+), 43 deletions(-) diff --git a/rust-workspace/Cargo.lock b/rust-workspace/Cargo.lock index 5abf47d..15fc79e 100644 --- a/rust-workspace/Cargo.lock +++ b/rust-workspace/Cargo.lock @@ -720,26 +720,7 @@ dependencies = [ "rand 0.7.3", "serde", "serde_json", - "uuid 0.8.2", -] - -[[package]] -name = "bson" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d76085681585d39016f4d3841eb019201fc54d2dd0d92ad1e4fab3bfb32754" -dependencies = [ - "ahash", - "base64 0.13.0", - "hex", - "indexmap", - "lazy_static", - "rand 0.8.5", - "serde", - "serde_bytes", - "serde_json", - "time 0.3.9", - "uuid 1.2.1", + "uuid", ] [[package]] @@ -1091,7 +1072,8 @@ version = "0.1.0" dependencies = [ "actix-rt", "actix-web", - "bson 2.4.0", + "bson", + "chrono", "futures", "mongodb", "serde", @@ -1934,7 +1916,7 @@ dependencies = [ "serde_json", "time 0.3.9", "url", - "uuid 0.8.2", + "uuid", ] [[package]] @@ -2154,7 +2136,7 @@ dependencies = [ "async-trait", "base64 0.11.0", "bitflags", - "bson 1.2.4", + "bson", "chrono", "derivative", "err-derive", @@ -2185,7 +2167,7 @@ dependencies = [ "trust-dns-proto 0.19.7", "trust-dns-resolver 0.19.7", "typed-builder", - "uuid 0.8.2", + "uuid", "version_check", "webpki", "webpki-roots 0.21.1", @@ -3530,7 +3512,6 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2702e08a7a860f005826c6815dcac101b19b5eb330c27fe4a5928fec1d20ddd" dependencies = [ - "itoa 1.0.2", "libc", "num_threads", "time-macros", @@ -3961,16 +3942,6 @@ dependencies = [ "getrandom 0.2.6", ] -[[package]] -name = "uuid" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feb41e78f93363bb2df8b0e86a2ca30eed7806ea16ea0c790d757cf93f79be83" -dependencies = [ - "getrandom 0.2.6", - "serde", -] - [[package]] name = "vcpkg" version = "0.2.15" diff --git a/rust-workspace/projects/data-server/Cargo.toml b/rust-workspace/projects/data-server/Cargo.toml index 803443d..a7a3b47 100644 --- a/rust-workspace/projects/data-server/Cargo.toml +++ b/rust-workspace/projects/data-server/Cargo.toml @@ -8,8 +8,9 @@ edition = "2021" [dependencies] mongodb = "1.0.0" #Change version for compatibility -bson = "2.4" +bson = "1.0.0" serde = { version = "1.0", features = ["derive"] } actix-rt = "1.1.1" actix-web = "2.0" -futures = "0.3.5" \ No newline at end of file +futures = "0.3.5" +chrono = "0.4.11" \ No newline at end of file diff --git a/rust-workspace/projects/data-server/src/logs_handlers/mod.rs b/rust-workspace/projects/data-server/src/logs_handlers/mod.rs index 2c468de..f398be0 100644 --- a/rust-workspace/projects/data-server/src/logs_handlers/mod.rs +++ b/rust-workspace/projects/data-server/src/logs_handlers/mod.rs @@ -1,4 +1,21 @@ -use actix_web::{web, Responder}; +use actix_web::{web, HttpResponse, Responder}; +use bson::{doc, Bson}; +use futures::stream::StreamExt; +use mongodb::{options::FindOptions, Client}; +use std::sync::Mutex; +use chrono::prelude::*; +use serde::Deserialize; + +#[derive(Deserialize)] +pub struct NewLog { + pub id: String, + pub sealedString: String, +} + +// Name for Mongo DB (CosmosDB) +const MONGO_DB: &'static str = "ntc-data"; +// Name for Mongo Collection +const MONGO_COLL_LOGS: &'static str = "datapools"; pub fn scoped_config(cfg: &mut web::ServiceConfig) { cfg.service( @@ -8,8 +25,31 @@ pub fn scoped_config(cfg: &mut web::ServiceConfig) { ); } -async fn get_logs() -> impl Responder { - format!("Not yet implemented!") +// This function accepts application data +async fn get_logs(data: web::Data>) -> impl Responder { + let logs_collection = data + .lock() + .unwrap() + .database(MONGO_DB) + .collection(MONGO_COLL_LOGS); + + let filter = doc! {}; + // Tweak find options to find specific user's data + let find_options = FindOptions::builder().sort(doc! { "_id": -1}).build(); + let mut cursor = logs_collection.find(filter, find_options).await.unwrap(); + + let mut results = Vec::new(); + while let Some(result) = cursor.next().await { + match result { + Ok(document) => { + results.push(document); + } + _ => { + return HttpResponse::InternalServerError().finish(); + } + } + } + HttpResponse::Ok().json(results) } async fn add_log() -> impl Responder { diff --git a/rust-workspace/projects/data-server/src/main.rs b/rust-workspace/projects/data-server/src/main.rs index 1093af5..4c4b10e 100644 --- a/rust-workspace/projects/data-server/src/main.rs +++ b/rust-workspace/projects/data-server/src/main.rs @@ -10,9 +10,8 @@ mod logs_handlers; async fn main() -> std::io::Result<()> { // Create log for actix to output errors env::set_var("RUST_LOG", "actix_web=debug"); - //Will remove connection string for production - included for testing - let mut client_options = ClientOptions::parse("mongodb://ntc-data:zkicQepvrK6B1SySo3vDLQpycrEsSt3WByUE1Zg7SYs47CceytRCzIuP3cu3p09GtY2cREJyJtdc9zSjqlxcvA==@ntc-data.mongo.cosmos.azure.com:10255/?ssl=true&replicaSet=globaldb&retrywrites=false&maxIdleTimeMS=120000&appName=@ntc-data@").await.unwrap(); - client_options.app_name = Some("ntc-data".to_string()); + let mongo_url = env::var("CONNECTION_STRING_LOGS").unwrap(); + let mut client_options = ClientOptions::parse(&mongo_url).await.unwrap(); let client = web::Data::new(Mutex::new(Client::with_options(client_options).unwrap())); HttpServer::new(move || { App::new() From 96d03a35093fd511b6a2be57b5d28ccb1dc7ab8d Mon Sep 17 00:00:00 2001 From: binglekruger Date: Mon, 24 Oct 2022 10:52:52 +0000 Subject: [PATCH 18/22] feat: Adding logs --- .../data-server/src/logs_handlers/mod.rs | 27 ++++++++++++++++--- .../projects/data-server/src/main.rs | 5 ++-- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/rust-workspace/projects/data-server/src/logs_handlers/mod.rs b/rust-workspace/projects/data-server/src/logs_handlers/mod.rs index f398be0..f204aab 100644 --- a/rust-workspace/projects/data-server/src/logs_handlers/mod.rs +++ b/rust-workspace/projects/data-server/src/logs_handlers/mod.rs @@ -7,9 +7,10 @@ use chrono::prelude::*; use serde::Deserialize; #[derive(Deserialize)] -pub struct NewLog { +pub struct NewDataPool { pub id: String, - pub sealedString: String, + pub poolName: String, //User defined pool name + pub sealedString: String, //Update data format to match sealed data } // Name for Mongo DB (CosmosDB) @@ -52,6 +53,24 @@ async fn get_logs(data: web::Data>) -> impl Responder { HttpResponse::Ok().json(results) } -async fn add_log() -> impl Responder { - format!("Not yet implemented!") +async fn add_log(data: web::Data>, new_log: web::Json) -> impl Responder { + let logs_collection = data + .lock() + .unwrap() + .database(MONGO_DB) + .collection(MONGO_COLL_LOGS); + + match logs_collection.insert_one(doc! {"deviceId": &new_log.id, "poolName": &new_log.poolName, "sealedString": &new_log.sealedString, "createdOn": Bson::DateTime(Utc::now())}, None).await { + Ok(db_result) => { + if let Some(new_id) = db_result.inserted_id.as_object_id() { + println!("New document inserted with id {}", new_id); + } + return HttpResponse::Created().json(db_result.inserted_id) + } + Err(err) => + { + println!("Failed! {}", err); + return HttpResponse::InternalServerError().finish() + } + } } \ No newline at end of file diff --git a/rust-workspace/projects/data-server/src/main.rs b/rust-workspace/projects/data-server/src/main.rs index 4c4b10e..08df90c 100644 --- a/rust-workspace/projects/data-server/src/main.rs +++ b/rust-workspace/projects/data-server/src/main.rs @@ -1,6 +1,5 @@ -use bson::{doc, Bson, Document}; -use mongodb::{error::Error, options::ClientOptions, Client, Collection, Database}; -use actix_web::{get, web, App, HttpServer, Responder}; +use mongodb::{options::ClientOptions, Client}; +use actix_web::{web, App, HttpServer}; use std::env; use std::sync::*; From 454e6b095e9bf5508363fe3f745e62fbc9a545ba Mon Sep 17 00:00:00 2001 From: binglekruger Date: Mon, 24 Oct 2022 13:53:49 +0000 Subject: [PATCH 19/22] refactor: Update log -> data --- .../{logs_handlers => data_handlers}/mod.rs | 33 ++++++++++--------- .../projects/data-server/src/main.rs | 30 +++-------------- 2 files changed, 22 insertions(+), 41 deletions(-) rename rust-workspace/projects/data-server/src/{logs_handlers => data_handlers}/mod.rs (63%) diff --git a/rust-workspace/projects/data-server/src/logs_handlers/mod.rs b/rust-workspace/projects/data-server/src/data_handlers/mod.rs similarity index 63% rename from rust-workspace/projects/data-server/src/logs_handlers/mod.rs rename to rust-workspace/projects/data-server/src/data_handlers/mod.rs index f204aab..9f2d4ea 100644 --- a/rust-workspace/projects/data-server/src/logs_handlers/mod.rs +++ b/rust-workspace/projects/data-server/src/data_handlers/mod.rs @@ -5,39 +5,40 @@ use mongodb::{options::FindOptions, Client}; use std::sync::Mutex; use chrono::prelude::*; use serde::Deserialize; +use std::env; #[derive(Deserialize)] pub struct NewDataPool { pub id: String, pub poolName: String, //User defined pool name - pub sealedString: String, //Update data format to match sealed data + pub sealedData: String, //Update data format to match sealed data } -// Name for Mongo DB (CosmosDB) +// Mongo DB (CosmosDB) Name const MONGO_DB: &'static str = "ntc-data"; -// Name for Mongo Collection -const MONGO_COLL_LOGS: &'static str = "datapools"; +// Mongo Collection Name +const MONGO_COLLECTION: &'static str = "datapools"; pub fn scoped_config(cfg: &mut web::ServiceConfig) { cfg.service( - web::resource("/logs") - .route(web::get().to(get_logs)) - .route(web::post().to(add_log)), + web::resource("/data") + .route(web::get().to(get_data)) + .route(web::post().to(add_data)), ); } // This function accepts application data -async fn get_logs(data: web::Data>) -> impl Responder { - let logs_collection = data +async fn get_data(data: web::Data>) -> impl Responder { + let data_collection = data .lock() .unwrap() .database(MONGO_DB) - .collection(MONGO_COLL_LOGS); + .collection(MONGO_COLLECTION); - let filter = doc! {}; + let filter = doc! { }; // Tweak find options to find specific user's data let find_options = FindOptions::builder().sort(doc! { "_id": -1}).build(); - let mut cursor = logs_collection.find(filter, find_options).await.unwrap(); + let mut cursor = data_collection.find(filter, find_options).await.unwrap(); let mut results = Vec::new(); while let Some(result) = cursor.next().await { @@ -53,14 +54,14 @@ async fn get_logs(data: web::Data>) -> impl Responder { HttpResponse::Ok().json(results) } -async fn add_log(data: web::Data>, new_log: web::Json) -> impl Responder { - let logs_collection = data +async fn add_data(data: web::Data>, new_pool: web::Json) -> impl Responder { + let data_collection = data .lock() .unwrap() .database(MONGO_DB) - .collection(MONGO_COLL_LOGS); + .collection(MONGO_COLLECTION); - match logs_collection.insert_one(doc! {"deviceId": &new_log.id, "poolName": &new_log.poolName, "sealedString": &new_log.sealedString, "createdOn": Bson::DateTime(Utc::now())}, None).await { + match data_collection.insert_one(doc! {"userId": &new_pool.id, "poolName": &new_pool.poolName, "sealedData": &new_pool.sealedData, "createdOn": Bson::DateTime(Utc::now())}, None).await { Ok(db_result) => { if let Some(new_id) = db_result.inserted_id.as_object_id() { println!("New document inserted with id {}", new_id); diff --git a/rust-workspace/projects/data-server/src/main.rs b/rust-workspace/projects/data-server/src/main.rs index 08df90c..6dd9577 100644 --- a/rust-workspace/projects/data-server/src/main.rs +++ b/rust-workspace/projects/data-server/src/main.rs @@ -3,42 +3,22 @@ use actix_web::{web, App, HttpServer}; use std::env; use std::sync::*; -mod logs_handlers; +mod data_handlers; #[actix_rt::main] async fn main() -> std::io::Result<()> { // Create log for actix to output errors env::set_var("RUST_LOG", "actix_web=debug"); - let mongo_url = env::var("CONNECTION_STRING_LOGS").unwrap(); + // Remember to set connection string when starting the server + let mongo_url = env::var("CONNECTION_STRING").unwrap(); let mut client_options = ClientOptions::parse(&mongo_url).await.unwrap(); let client = web::Data::new(Mutex::new(Client::with_options(client_options).unwrap())); HttpServer::new(move || { App::new() .app_data(client.clone()) - .service(web::scope("/api").configure(logs_handlers::scoped_config)) + .service(web::scope("/api").configure(data_handlers::scoped_config)) }) .bind("127.0.0.1:8000")? .run() .await -} - -// Upload data pool API // -// Encryt from client to enclave - seal using enclave key - upload to Azure Blob (or Cosmos DB) -// Data is uploaded in JSON format -// Encrypt: Use SSL or TLS - - - - -// Upload to Azure Blob storage or Cosmos DB - TBD // -// https://github.com/Azure/azure-sdk-for-rust -// https://crates.io/crates/azure_storage_blobs - - - - - -// Query data API // -// Frontend must show which data packages the data creator has uploaded to the system -// Option 1 - Query data service for list of data packages uploaded by the data creator -// Option 2 - Lookup smart contracts associated with data creator's NTLS wallet \ No newline at end of file +} \ No newline at end of file From d4aceb8e0e5e50064f157c95bb2d63ca1402e86a Mon Sep 17 00:00:00 2001 From: binglekruger Date: Mon, 24 Oct 2022 13:55:07 +0000 Subject: [PATCH 20/22] feat: Add filter functionality --- .../projects/data-server/src/data_handlers/mod.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/rust-workspace/projects/data-server/src/data_handlers/mod.rs b/rust-workspace/projects/data-server/src/data_handlers/mod.rs index 9f2d4ea..0bbc050 100644 --- a/rust-workspace/projects/data-server/src/data_handlers/mod.rs +++ b/rust-workspace/projects/data-server/src/data_handlers/mod.rs @@ -7,6 +7,11 @@ use chrono::prelude::*; use serde::Deserialize; use std::env; +#[derive(Deserialize)] +pub struct UserData { + pub id: String, +} + #[derive(Deserialize)] pub struct NewDataPool { pub id: String, @@ -28,15 +33,15 @@ pub fn scoped_config(cfg: &mut web::ServiceConfig) { } // This function accepts application data -async fn get_data(data: web::Data>) -> impl Responder { +async fn get_data(data: web::Data>, existingUser: web::Json) -> impl Responder { let data_collection = data .lock() .unwrap() .database(MONGO_DB) .collection(MONGO_COLLECTION); - let filter = doc! { }; - // Tweak find options to find specific user's data + let userId = &existingUser.id; + let filter = doc! {"userId": userId}; let find_options = FindOptions::builder().sort(doc! { "_id": -1}).build(); let mut cursor = data_collection.find(filter, find_options).await.unwrap(); @@ -74,4 +79,4 @@ async fn add_data(data: web::Data>, new_pool: web::Json Date: Tue, 1 Nov 2022 14:31:36 +0000 Subject: [PATCH 21/22] refactor: remove unused imports + fix snake_case --- .../projects/data-server/Cargo.toml | 4 +-- .../data-server/src/data_handlers/mod.rs | 25 +++++++++++-------- .../projects/data-server/src/main.rs | 6 ++--- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/rust-workspace/projects/data-server/Cargo.toml b/rust-workspace/projects/data-server/Cargo.toml index a7a3b47..2763d9a 100644 --- a/rust-workspace/projects/data-server/Cargo.toml +++ b/rust-workspace/projects/data-server/Cargo.toml @@ -7,10 +7,10 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -mongodb = "1.0.0" #Change version for compatibility +mongodb = "1.0.0" #Change version for compatibility bson = "1.0.0" serde = { version = "1.0", features = ["derive"] } actix-rt = "1.1.1" actix-web = "2.0" futures = "0.3.5" -chrono = "0.4.11" \ No newline at end of file +chrono = "0.4.11" diff --git a/rust-workspace/projects/data-server/src/data_handlers/mod.rs b/rust-workspace/projects/data-server/src/data_handlers/mod.rs index 0bbc050..701d966 100644 --- a/rust-workspace/projects/data-server/src/data_handlers/mod.rs +++ b/rust-workspace/projects/data-server/src/data_handlers/mod.rs @@ -1,11 +1,10 @@ use actix_web::{web, HttpResponse, Responder}; use bson::{doc, Bson}; +use chrono::prelude::*; use futures::stream::StreamExt; use mongodb::{options::FindOptions, Client}; -use std::sync::Mutex; -use chrono::prelude::*; use serde::Deserialize; -use std::env; +use std::sync::Mutex; #[derive(Deserialize)] pub struct UserData { @@ -15,8 +14,8 @@ pub struct UserData { #[derive(Deserialize)] pub struct NewDataPool { pub id: String, - pub poolName: String, //User defined pool name - pub sealedData: String, //Update data format to match sealed data + pub pool_name: String, //User defined pool name + pub sealed_data: String, //Update data format to match sealed data } // Mongo DB (CosmosDB) Name @@ -33,15 +32,18 @@ pub fn scoped_config(cfg: &mut web::ServiceConfig) { } // This function accepts application data -async fn get_data(data: web::Data>, existingUser: web::Json) -> impl Responder { +async fn get_data( + data: web::Data>, + existing_user: web::Json, +) -> impl Responder { let data_collection = data .lock() .unwrap() .database(MONGO_DB) .collection(MONGO_COLLECTION); - let userId = &existingUser.id; - let filter = doc! {"userId": userId}; + let user_id = &existing_user.id; + let filter = doc! {"user_id": user_id}; let find_options = FindOptions::builder().sort(doc! { "_id": -1}).build(); let mut cursor = data_collection.find(filter, find_options).await.unwrap(); @@ -59,14 +61,17 @@ async fn get_data(data: web::Data>, existingUser: web::Json>, new_pool: web::Json) -> impl Responder { +async fn add_data( + data: web::Data>, + new_pool: web::Json, +) -> impl Responder { let data_collection = data .lock() .unwrap() .database(MONGO_DB) .collection(MONGO_COLLECTION); - match data_collection.insert_one(doc! {"userId": &new_pool.id, "poolName": &new_pool.poolName, "sealedData": &new_pool.sealedData, "createdOn": Bson::DateTime(Utc::now())}, None).await { + match data_collection.insert_one(doc! {"user_id": &new_pool.id, "pool_name": &new_pool.pool_name, "sealed_data": &new_pool.sealed_data, "created_on": Bson::DateTime(Utc::now())}, None).await { Ok(db_result) => { if let Some(new_id) = db_result.inserted_id.as_object_id() { println!("New document inserted with id {}", new_id); diff --git a/rust-workspace/projects/data-server/src/main.rs b/rust-workspace/projects/data-server/src/main.rs index 6dd9577..5830d03 100644 --- a/rust-workspace/projects/data-server/src/main.rs +++ b/rust-workspace/projects/data-server/src/main.rs @@ -1,5 +1,5 @@ -use mongodb::{options::ClientOptions, Client}; use actix_web::{web, App, HttpServer}; +use mongodb::{options::ClientOptions, Client}; use std::env; use std::sync::*; @@ -11,7 +11,7 @@ async fn main() -> std::io::Result<()> { env::set_var("RUST_LOG", "actix_web=debug"); // Remember to set connection string when starting the server let mongo_url = env::var("CONNECTION_STRING").unwrap(); - let mut client_options = ClientOptions::parse(&mongo_url).await.unwrap(); + let client_options = ClientOptions::parse(&mongo_url).await.unwrap(); let client = web::Data::new(Mutex::new(Client::with_options(client_options).unwrap())); HttpServer::new(move || { App::new() @@ -21,4 +21,4 @@ async fn main() -> std::io::Result<()> { .bind("127.0.0.1:8000")? .run() .await -} \ No newline at end of file +} From 1b3a5fa6aa2e2b9fd66b51f5080ecd5c7ac0292f Mon Sep 17 00:00:00 2001 From: Joseph Bochenek Date: Tue, 14 Feb 2023 17:07:04 +0200 Subject: [PATCH 22/22] Initial fastapi (#73) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add Vault CLI & data package library (#1) * feat(ntc-vault-cli): initial layout * style(ntc-vault-cli): add rustfmt.toml * feat(ntc-vault-cli): add clap-based CLI skeleton * feat(ntc-vault-cli): flesh out structure, implement identity subcommand * refactor(ntc-vault-cli): separate code into two crates: core, cli * refactor(ntc-vault-cli): move rand-using code from core to cli * test(ntc-vault-cli): generate_secure_seed smoke test * feat(ntc-vault-cli): data package and JSON Schema work-in-progress * refactor: move crates into rust-workspace * docs: add comment about using "cargo +nightly fmt" * docs: add ARCHITECTURE.md * refactor: rename package "ntc-vault-core" → "ntc-data-packages" * feat(ntc-data-packages): replace anyhow with thiserror * build(ntc-data-packages): drop jsonschema's default features We don't need jsonschema's CLI, or the file / HTTP resolving features. This greatly reduces our dependency tree. * build: declare rust-version * docs: add package descriptions * feat(ntc-data-packages): better validation error messages * ci(rust-workspace): add check and test workflows for GitHub Actions * docs: fix rustdoc link issues * build(rust-workspace): add rust-toolchain.toml, with channel = "stable" * docs(README): add link to ARCHITECTURE.md * deps(ntc-vault-cli): update confy revision for store_path fix Upstream PR: https://github.com/rust-cli/confy/pull/60 (fix: `store_path` should create missing directories, like `load_path`) * refactor(ntc-data-packages): move tests to API-based integration tests Motivation: https://matklad.github.io/2021/02/27/delete-cargo-integration-tests.html * refactor(ntc-vault-cli): move try_exists to compat module * refactor(ntc-vault-cli): VaultIdentityConfig: make pub * deps(ntc-vault-cli): add dev dependencies for CLI tests * test(ntc-vault-cli): add snapshot-based CLI tests * deps(ntc-data-packages): add serde * feat(ntc-data-packages): add Metadata::from_json_bytes * feat(ntc-vault-cli): add fs_io, with read_metadata * feat(ntc-vault-cli): implement more of the "data" subcommand * chore: add todos to keep track of changes that needs to be made to allign with design * chore(deps): update dependencies and bump jsonschema to 0.16 Co-authored-by: Herman * feat: add initial TEE server (#3) * build(rust-sgx-workspace): add workspace for SGX code * build(ntc-tee-server): add SGX project for the TEE server * build(ntc-tee-server): bump Rust edition: "2018" → "2021" * build(ntc-tee-server): better error message for missing Enclave_u library * ci(rust-sgx-workspace): add check and test workflows for GitHub Actions * ci: use nested checkout for the multiple repositories to prevent _temp being deleted * style: fix clippy warnings * ci: remove --all-targets build arg to fix enclave builds and checks Co-authored-by: Herman * license: relicense to AGPL-3.0 (#17) * ci: use ntls-io fork of rust-sgx-sdk-env (#39) Co-authored-by: Jean-Pierre de Villiers * feat: create oracle-node API (#18) * feat(ntc-oracle-node): connect to PureStake Indexer using algonaut * feat(ntc-oracle-node): add config crate * feat(ntc-oracle-node): add initial server with axum * feat(ntc-oracle-node): implement get_auth_data * feat(ntc-oracle-node): use ed25519 to sign AuthData with ring-compat * style(ntc-oracle-node): apply rustfmt.toml * refactor(ntc-oracle-node): move auth_data functions into handler * feat(ntc-oracle-node): add anyhow error handling * feat(ntc-oracle-node): add unit test for sign_auth_data * feat(ntc-oracle-node): use serde_with to base64 encode SignedAuthData response * refactor(ntc-oracle-node): use cfg(test) in place of allow(dead_code) * feat: add Vault backend (#61) * feat(web-server): copy web-server from Nautilus Wallet * docs(web-server): fix comments in rust-toolchain and rustfmt toml files * refactor: move http-service-impl and sgx-helpers into rust-sgx-workspace * refactor: move sgx-wallet-impl into rust-sgx-workspace but exclude as member * refactor: move sgx-wallet into rust-sgx-workspace but exclude as member * refactor: move sgx-wallet-test into rust-sgx-workspace but exclude as member * refactor: remove web-server * docs(http-service-impl): fix sgx-wallet-impl broken intra doc link * fix(sgx-wallet): fix path to sgx-wallet-impl in Makefile * refactor(rust-sgx-workspace): rename 'wallet' to 'vault' (#62) * refactor(sgx-vault-impl): change vault id to algorand address (#65) * refactor: remove Onfido operations and XRP related code (#66) * feat(rust-sgx-workspace): add Docker build definition for Vault server (#67) * feat: Create two APIs for data operations * Merge branch 'data-operations' of https://github.com/ntls-io/nautilus-trusted-compute into data-operations * feat(data-operations-api): create new project dir * feat: Add base crate * feat: Add basic Actix server * feat: Configure server + add logs_handlers * feat: Fetching logs * feat: Adding logs * refactor: Update log -> data * feat: Add filter functionality * refactor: remove unused imports + fix snake_case * feat(backend-services): initial commit for api * feat(backend-services): initial commit for api * fix(backend-services): add env to .gitignore. * fix (backend-services): .gitignore and datetime * feature (backend-services): add example json and schema files --------- Co-authored-by: Pi Delport Co-authored-by: Herman Co-authored-by: Jean-Pierre de Villiers Co-authored-by: Jean-Pierre de Villiers Co-authored-by: Bill Guo Co-authored-by: Bill Guo Co-authored-by: binglekruger --- backend-services/.env | 4 + backend-services/.gitignore | 6 + backend-services/README.md | 110 + backend-services/poetry.lock | 2446 +++++++++++++++++ backend-services/pyproject.toml | 102 + .../schema_files/alumni_salary.json | 110 + .../schema_files/alumni_salary_scheme.json | 9 + .../schema_files/customer_accounts.json | 37 + .../customer_accounts_schema.json | 10 + .../schema_files/example-validation.ipynb | 511 ++++ .../schema_files/patient_genotype.json | 182 ++ .../schema_files/patient_genotype.tsv | 21 + .../schema_files/patient_genotype_schema.json | 12 + backend-services/src/common/__init__.py | 4 + .../__pycache__/__init__.cpython-311.pyc | Bin 0 -> 339 bytes .../__pycache__/settings.cpython-311.pyc | Bin 0 -> 1499 bytes .../common/__pycache__/types.cpython-311.pyc | Bin 0 -> 314 bytes backend-services/src/common/settings.py | 27 + backend-services/src/common/types.py | 6 + backend-services/src/data_service/__init__.py | 3 + .../__pycache__/__init__.cpython-311.pyc | Bin 0 -> 269 bytes .../src/data_service/operations/__init__.py | 3 + .../__pycache__/__init__.cpython-311.pyc | Bin 0 -> 303 bytes .../__pycache__/datapool.cpython-311.pyc | Bin 0 -> 2392 bytes .../__pycache__/dataset.cpython-311.pyc | Bin 0 -> 2706 bytes .../src/data_service/operations/datapool.py | 37 + .../src/data_service/operations/dataschema.py | 37 + .../src/data_service/operations/dataset.py | 44 + .../src/data_service/schema/__init__.py | 3 + .../__pycache__/__init__.cpython-311.pyc | Bin 0 -> 280 bytes .../__pycache__/actions.cpython-311.pyc | Bin 0 -> 3358 bytes .../__pycache__/entities.cpython-311.pyc | Bin 0 -> 2686 bytes .../schema/__pycache__/types.cpython-311.pyc | Bin 0 -> 391 bytes .../src/data_service/schema/actions.py | 74 + .../src/data_service/schema/entities.py | 65 + .../src/data_service/schema/types.py | 8 + backend-services/src/web_asgi/__init__.py | 4 + .../__pycache__/__init__.cpython-311.pyc | Bin 0 -> 306 bytes .../web_asgi/__pycache__/main.cpython-311.pyc | Bin 0 -> 4960 bytes .../__pycache__/settings.cpython-311.pyc | Bin 0 -> 861 bytes backend-services/src/web_asgi/main.py | 87 + backend-services/src/web_asgi/settings.py | 14 + backend-services/tests/__init__.py | 0 .../tests/data_service/__init__.py | 0 .../tests/data_service/operations/__init__.py | 0 .../tests/data_service/operations/helpers.py | 5 + .../data_service/operations/test_bookmark.py | 84 + 47 files changed, 4065 insertions(+) create mode 100644 backend-services/.env create mode 100644 backend-services/.gitignore create mode 100644 backend-services/README.md create mode 100644 backend-services/poetry.lock create mode 100644 backend-services/pyproject.toml create mode 100644 backend-services/schema_files/alumni_salary.json create mode 100644 backend-services/schema_files/alumni_salary_scheme.json create mode 100644 backend-services/schema_files/customer_accounts.json create mode 100644 backend-services/schema_files/customer_accounts_schema.json create mode 100644 backend-services/schema_files/example-validation.ipynb create mode 100644 backend-services/schema_files/patient_genotype.json create mode 100644 backend-services/schema_files/patient_genotype.tsv create mode 100644 backend-services/schema_files/patient_genotype_schema.json create mode 100644 backend-services/src/common/__init__.py create mode 100644 backend-services/src/common/__pycache__/__init__.cpython-311.pyc create mode 100644 backend-services/src/common/__pycache__/settings.cpython-311.pyc create mode 100644 backend-services/src/common/__pycache__/types.cpython-311.pyc create mode 100644 backend-services/src/common/settings.py create mode 100644 backend-services/src/common/types.py create mode 100644 backend-services/src/data_service/__init__.py create mode 100644 backend-services/src/data_service/__pycache__/__init__.cpython-311.pyc create mode 100644 backend-services/src/data_service/operations/__init__.py create mode 100644 backend-services/src/data_service/operations/__pycache__/__init__.cpython-311.pyc create mode 100644 backend-services/src/data_service/operations/__pycache__/datapool.cpython-311.pyc create mode 100644 backend-services/src/data_service/operations/__pycache__/dataset.cpython-311.pyc create mode 100644 backend-services/src/data_service/operations/datapool.py create mode 100644 backend-services/src/data_service/operations/dataschema.py create mode 100644 backend-services/src/data_service/operations/dataset.py create mode 100644 backend-services/src/data_service/schema/__init__.py create mode 100644 backend-services/src/data_service/schema/__pycache__/__init__.cpython-311.pyc create mode 100644 backend-services/src/data_service/schema/__pycache__/actions.cpython-311.pyc create mode 100644 backend-services/src/data_service/schema/__pycache__/entities.cpython-311.pyc create mode 100644 backend-services/src/data_service/schema/__pycache__/types.cpython-311.pyc create mode 100644 backend-services/src/data_service/schema/actions.py create mode 100644 backend-services/src/data_service/schema/entities.py create mode 100644 backend-services/src/data_service/schema/types.py create mode 100644 backend-services/src/web_asgi/__init__.py create mode 100644 backend-services/src/web_asgi/__pycache__/__init__.cpython-311.pyc create mode 100644 backend-services/src/web_asgi/__pycache__/main.cpython-311.pyc create mode 100644 backend-services/src/web_asgi/__pycache__/settings.cpython-311.pyc create mode 100644 backend-services/src/web_asgi/main.py create mode 100644 backend-services/src/web_asgi/settings.py create mode 100644 backend-services/tests/__init__.py create mode 100644 backend-services/tests/data_service/__init__.py create mode 100644 backend-services/tests/data_service/operations/__init__.py create mode 100644 backend-services/tests/data_service/operations/helpers.py create mode 100644 backend-services/tests/data_service/operations/test_bookmark.py diff --git a/backend-services/.env b/backend-services/.env new file mode 100644 index 0000000..6eaa608 --- /dev/null +++ b/backend-services/.env @@ -0,0 +1,4 @@ +PRIMARY_ORIGIN="http://www.localhost:8000" +VAULT_DB_CONNECTION_STRING="mongodb://ntls:Mw6fvOK3BQCyPYKsw7OjMFrwdWBNrWE9S3edoJWNsxp34jtDnDTfwZCXAIw4uQE1NWHxRPC0AcVuACDbM3LMQg==@ntls.mongo.cosmos.azure.com:10255/?ssl=true&replicaSet=globaldb&retrywrites=false&maxIdleTimeMS=120000&appName=@ntls@" +VAULT_DB_NAME="vault" +VAULT_DB_BOOKMARK_COLLECTION_NAME="datasets" diff --git a/backend-services/.gitignore b/backend-services/.gitignore new file mode 100644 index 0000000..99733ce --- /dev/null +++ b/backend-services/.gitignore @@ -0,0 +1,6 @@ +__pycache__ +/.env +/.mypy_cache +/.python-version +/.tox +/dist diff --git a/backend-services/README.md b/backend-services/README.md new file mode 100644 index 0000000..58250e8 --- /dev/null +++ b/backend-services/README.md @@ -0,0 +1,110 @@ +# Wallet Backend Services + +An HTTP server backend for the Nautilus Wallet powered by [FastAPI][fastapi] and +the [uvicorn ASGI server][uvicorn]. + +- [Setup](#setup) +- [Quick Start](#quick-start) + +[fastapi]: https://fastapi.tiangolo.com/ +[uvicorn]: https://www.uvicorn.org/ + +## Setup + +In order to proceed, one needs to have the `poetry` dependency management and +packaging tool installed. Unless a recent version is available via your OS +package manager, as it would be on Arch Linux and friends :), the recommended +means of installing `poetry` is via the well-established `pipx` tool as +described in [their documentation][pipx-install]. + +Once `pipx` is installed, installing `poetry` is as simple as + +```shell +pipx install poetry +``` + +If you are simply looking for the API docs you may now skip ahead to the +[following section][#quick-start], you should also install the `pyenv` tool as +it is invaluable in managing your project-specific and shell-specific virtual +environments. This is again as simple as + +```shell +pipx install pyenv +``` + +If you use `bash` as your shell then copy the following to your +`~/.bash_profile`, if it exists, or otherwise to `~/.profile` + +```bash +# you may ignore this line if it is already set in your config +export XDG_DATA_HOME="$HOME/.local/share" + +export PYENV_ROOT="$XDG_DATA_HOME/pyenv" +command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH" +eval "$(pyenv init -)" +``` + +and copy the same last line to your `~/.bashrc` + +```bash +eval "$(pyenv init -)" +``` + +Make sure to log out (and back in of course) or, alternatively, restart your +machine. Once you are back in the `backend-services` sub-directory of the +project run + +```shell +pyenv local 3.{10,11} +``` + +[pipx-install]: https://python-poetry.org/docs/#installation + +## Quick Start + +In the root of the Python project, where the `pyproject.toml` is located, run +the following command: + +```shell +poetry install +``` + +Make sure the following environment variables have been set in your local `.env` file: + +- `WALLET_DB_CONNECTION_STRING` +- `WALLET_DB_DATABASE_NAME` +- `WALLET_BOOKMARK_DB_COLLECTION_NAME` + +For examples you may consult the [python-dotenv] documentation. Once this is done, a local instance of the server may be started on `localhost:8000` by running + +```shell +poetry run uvicorn web_asgi.main:app +``` + +The **Swagger/OpenAPI documentation** for this server is now accessible via +[localhost][localhost-docs]. + +If you would like to run the tests for the project locally, simply invoke + +```shell +poetry run tox +``` + +Note that `poetry` creates and keeps track of project-related `python` virtual +environments on your behalf via your IDE (an IDE plugin might be necessary) or +from the command line. Run + +```shell +poetry env info +``` + +for details about available environments for your current project. If you would +like to spawn a shell inside the current `poetry` virtual environment this may +be done via + +```shell +poetry shell +``` + +[localhost-docs]: http://localhost:8000/docs +[python-dotenv]: https://github.com/theskumar/python-dotenv#getting-started diff --git a/backend-services/poetry.lock b/backend-services/poetry.lock new file mode 100644 index 0000000..339e00e --- /dev/null +++ b/backend-services/poetry.lock @@ -0,0 +1,2446 @@ +[[package]] +name = "anyio" +version = "3.6.2" +description = "High level compatibility layer for multiple asynchronous event loop implementations" +category = "main" +optional = false +python-versions = ">=3.6.2" + +[package.dependencies] +idna = ">=2.8" +sniffio = ">=1.1" + +[package.extras] +doc = ["packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphinx-rtd-theme"] +test = ["contextlib2", "coverage[toml] (>=4.5)", "hypothesis (>=4.0)", "mock (>=4)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "uvloop (<0.15)", "uvloop (>=0.15)"] +trio = ["trio (>=0.16,<0.22)"] + +[[package]] +name = "asttokens" +version = "2.2.1" +description = "Annotate AST trees with source code positions" +category = "dev" +optional = false +python-versions = "*" + +[package.dependencies] +six = "*" + +[package.extras] +test = ["astroid", "pytest"] + +[[package]] +name = "attrs" +version = "22.2.0" +description = "Classes Without Boilerplate" +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.extras] +cov = ["attrs[tests]", "coverage-enable-subprocess", "coverage[toml] (>=5.3)"] +dev = ["attrs[docs,tests]"] +docs = ["furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier", "zope.interface"] +tests = ["attrs[tests-no-zope]", "zope.interface"] +tests-no-zope = ["cloudpickle", "cloudpickle", "hypothesis", "hypothesis", "mypy (>=0.971,<0.990)", "mypy (>=0.971,<0.990)", "pympler", "pympler", "pytest (>=4.3.0)", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-mypy-plugins", "pytest-xdist[psutil]", "pytest-xdist[psutil]"] + +[[package]] +name = "bandit" +version = "1.7.4" +description = "Security oriented static analyser for python code." +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +colorama = {version = ">=0.3.9", markers = "platform_system == \"Windows\""} +GitPython = ">=1.0.1" +PyYAML = ">=5.3.1" +stevedore = ">=1.20.0" + +[package.extras] +test = ["beautifulsoup4 (>=4.8.0)", "coverage (>=4.5.4)", "fixtures (>=3.0.0)", "flake8 (>=4.0.0)", "pylint (==1.9.4)", "stestr (>=2.5.0)", "testscenarios (>=0.5.0)", "testtools (>=2.3.0)", "toml"] +toml = ["toml"] +yaml = ["PyYAML"] + +[[package]] +name = "black" +version = "22.12.0" +description = "The uncompromising code formatter." +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +click = ">=8.0.0" +mypy-extensions = ">=0.4.3" +pathspec = ">=0.9.0" +platformdirs = ">=2" +tomli = {version = ">=1.1.0", markers = "python_full_version < \"3.11.0a7\""} + +[package.extras] +colorama = ["colorama (>=0.4.3)"] +d = ["aiohttp (>=3.7.4)"] +jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] +uvloop = ["uvloop (>=0.15.2)"] + +[[package]] +name = "cachecontrol" +version = "0.12.11" +description = "httplib2 caching for requests" +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.dependencies] +lockfile = {version = ">=0.9", optional = true, markers = "extra == \"filecache\""} +msgpack = ">=0.5.2" +requests = "*" + +[package.extras] +filecache = ["lockfile (>=0.9)"] +redis = ["redis (>=2.10.5)"] + +[[package]] +name = "cachy" +version = "0.3.0" +description = "Cachy provides a simple yet effective caching library." +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" + +[package.extras] +memcached = ["python-memcached (>=1.59,<2.0)"] +msgpack = ["msgpack-python (>=0.5,<0.6)"] +redis = ["redis (>=3.3.6,<4.0.0)"] + +[[package]] +name = "certifi" +version = "2022.12.7" +description = "Python package for providing Mozilla's CA Bundle." +category = "dev" +optional = false +python-versions = ">=3.6" + +[[package]] +name = "cffi" +version = "1.15.1" +description = "Foreign Function Interface for Python calling C code." +category = "dev" +optional = false +python-versions = "*" + +[package.dependencies] +pycparser = "*" + +[[package]] +name = "charset-normalizer" +version = "3.0.1" +description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." +category = "dev" +optional = false +python-versions = "*" + +[[package]] +name = "cleo" +version = "1.0.0a5" +description = "Cleo allows you to create beautiful and testable command-line interfaces." +category = "dev" +optional = false +python-versions = ">=3.7,<4.0" + +[package.dependencies] +crashtest = ">=0.3.1,<0.4.0" +pylev = ">=1.3.0,<2.0.0" + +[[package]] +name = "click" +version = "8.1.3" +description = "Composable command line interface toolkit" +category = "main" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +colorama = {version = "*", markers = "platform_system == \"Windows\""} + +[[package]] +name = "colorama" +version = "0.4.6" +description = "Cross-platform colored terminal text." +category = "main" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" + +[[package]] +name = "commonmark" +version = "0.9.1" +description = "Python parser for the CommonMark Markdown spec" +category = "dev" +optional = false +python-versions = "*" + +[package.extras] +test = ["flake8 (==3.7.8)", "hypothesis (==3.55.3)"] + +[[package]] +name = "crashtest" +version = "0.3.1" +description = "Manage Python errors with ease" +category = "dev" +optional = false +python-versions = ">=3.6,<4.0" + +[[package]] +name = "cryptography" +version = "39.0.0" +description = "cryptography is a package which provides cryptographic recipes and primitives to Python developers." +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.dependencies] +cffi = ">=1.12" + +[package.extras] +docs = ["sphinx (>=1.6.5,!=1.8.0,!=3.1.0,!=3.1.1,!=5.2.0,!=5.2.0.post0)", "sphinx-rtd-theme"] +docstest = ["pyenchant (>=1.6.11)", "sphinxcontrib-spelling (>=4.0.1)", "twine (>=1.12.0)"] +pep8test = ["black", "ruff"] +sdist = ["setuptools-rust (>=0.11.4)"] +ssh = ["bcrypt (>=3.1.5)"] +test = ["hypothesis (>=1.11.4,!=3.79.2)", "iso8601", "pretend", "pytest (>=6.2.0)", "pytest-benchmark", "pytest-cov", "pytest-subtests", "pytest-xdist", "pytz"] + +[[package]] +name = "devtools" +version = "0.9.0" +description = "Python's missing debug print command, and more." +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +asttokens = ">=2.0.0,<3.0.0" +executing = ">=0.8.0,<1.0.0" + +[package.extras] +pygments = ["pygments (>=2.2.0)"] + +[[package]] +name = "distlib" +version = "0.3.6" +description = "Distribution utilities" +category = "dev" +optional = false +python-versions = "*" + +[[package]] +name = "dnspython" +version = "2.3.0" +description = "DNS toolkit" +category = "main" +optional = false +python-versions = ">=3.7,<4.0" + +[package.extras] +curio = ["curio (>=1.2,<2.0)", "sniffio (>=1.1,<2.0)"] +dnssec = ["cryptography (>=2.6,<40.0)"] +doh = ["h2 (>=4.1.0)", "httpx (>=0.21.1)", "requests (>=2.23.0,<3.0.0)", "requests-toolbelt (>=0.9.1,<0.11.0)"] +doq = ["aioquic (>=0.9.20)"] +idna = ["idna (>=2.1,<4.0)"] +trio = ["trio (>=0.14,<0.23)"] +wmi = ["wmi (>=1.5.1,<2.0.0)"] + +[[package]] +name = "dulwich" +version = "0.20.50" +description = "Python Git Library" +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.dependencies] +urllib3 = ">=1.25" + +[package.extras] +fastimport = ["fastimport"] +https = ["urllib3 (>=1.24.1)"] +paramiko = ["paramiko"] +pgp = ["gpg"] + +[[package]] +name = "exceptiongroup" +version = "1.1.0" +description = "Backport of PEP 654 (exception groups)" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.extras] +test = ["pytest (>=6)"] + +[[package]] +name = "executing" +version = "0.10.0" +description = "Get the currently executing AST node of a frame, and other information" +category = "dev" +optional = false +python-versions = "*" + +[[package]] +name = "fastapi" +version = "0.87.0" +description = "FastAPI framework, high performance, easy to learn, fast to code, ready for production" +category = "main" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +pydantic = ">=1.6.2,<1.7 || >1.7,<1.7.1 || >1.7.1,<1.7.2 || >1.7.2,<1.7.3 || >1.7.3,<1.8 || >1.8,<1.8.1 || >1.8.1,<2.0.0" +starlette = "0.21.0" + +[package.extras] +all = ["email-validator (>=1.1.1)", "httpx (>=0.23.0)", "itsdangerous (>=1.1.0)", "jinja2 (>=2.11.2)", "orjson (>=3.2.1)", "python-multipart (>=0.0.5)", "pyyaml (>=5.3.1)", "ujson (>=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0)", "uvicorn[standard] (>=0.12.0)"] +dev = ["pre-commit (>=2.17.0,<3.0.0)", "ruff (==0.0.114)", "uvicorn[standard] (>=0.12.0,<0.19.0)"] +doc = ["mdx-include (>=1.4.1,<2.0.0)", "mkdocs (>=1.1.2,<2.0.0)", "mkdocs-markdownextradata-plugin (>=0.1.7,<0.3.0)", "mkdocs-material (>=8.1.4,<9.0.0)", "pyyaml (>=5.3.1,<7.0.0)", "typer[all] (>=0.6.1,<0.7.0)"] +test = ["anyio[trio] (>=3.2.1,<4.0.0)", "black (==22.8.0)", "coverage[toml] (>=6.5.0,<7.0)", "databases[sqlite] (>=0.3.2,<0.7.0)", "email-validator (>=1.1.1,<2.0.0)", "flask (>=1.1.2,<3.0.0)", "httpx (>=0.23.0,<0.24.0)", "isort (>=5.0.6,<6.0.0)", "mypy (==0.982)", "orjson (>=3.2.1,<4.0.0)", "passlib[bcrypt] (>=1.7.2,<2.0.0)", "peewee (>=3.13.3,<4.0.0)", "pytest (>=7.1.3,<8.0.0)", "python-jose[cryptography] (>=3.3.0,<4.0.0)", "python-multipart (>=0.0.5,<0.0.6)", "pyyaml (>=5.3.1,<7.0.0)", "ruff (==0.0.114)", "sqlalchemy (>=1.3.18,<=1.4.41)", "types-orjson (==3.6.2)", "types-ujson (==5.5.0)", "ujson (>=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0,<6.0.0)"] + +[[package]] +name = "filelock" +version = "3.9.0" +description = "A platform independent file lock." +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.extras] +docs = ["furo (>=2022.12.7)", "sphinx (>=5.3)", "sphinx-autodoc-typehints (>=1.19.5)"] +testing = ["covdefaults (>=2.2.2)", "coverage (>=7.0.1)", "pytest (>=7.2)", "pytest-cov (>=4)", "pytest-timeout (>=2.1)"] + +[[package]] +name = "flake8" +version = "6.0.0" +description = "the modular source code checker: pep8 pyflakes and co" +category = "dev" +optional = false +python-versions = ">=3.8.1" + +[package.dependencies] +mccabe = ">=0.7.0,<0.8.0" +pycodestyle = ">=2.10.0,<2.11.0" +pyflakes = ">=3.0.0,<3.1.0" + +[[package]] +name = "gitdb" +version = "4.0.10" +description = "Git Object Database" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +smmap = ">=3.0.1,<6" + +[[package]] +name = "gitpython" +version = "3.1.30" +description = "GitPython is a python library used to interact with Git repositories" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +gitdb = ">=4.0.1,<5" + +[[package]] +name = "gunicorn" +version = "20.1.0" +description = "WSGI HTTP Server for UNIX" +category = "main" +optional = false +python-versions = ">=3.5" + +[package.dependencies] +setuptools = ">=3.0" + +[package.extras] +eventlet = ["eventlet (>=0.24.1)"] +gevent = ["gevent (>=1.4.0)"] +setproctitle = ["setproctitle"] +tornado = ["tornado (>=0.2)"] + +[[package]] +name = "h11" +version = "0.14.0" +description = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1" +category = "main" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "html5lib" +version = "1.1" +description = "HTML parser based on the WHATWG HTML specification" +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" + +[package.dependencies] +six = ">=1.9" +webencodings = "*" + +[package.extras] +all = ["chardet (>=2.2)", "genshi", "lxml"] +chardet = ["chardet (>=2.2)"] +genshi = ["genshi"] +lxml = ["lxml"] + +[[package]] +name = "httptools" +version = "0.5.0" +description = "A collection of framework independent HTTP protocol utils." +category = "main" +optional = false +python-versions = ">=3.5.0" + +[package.extras] +test = ["Cython (>=0.29.24,<0.30.0)"] + +[[package]] +name = "idna" +version = "3.4" +description = "Internationalized Domain Names in Applications (IDNA)" +category = "main" +optional = false +python-versions = ">=3.5" + +[[package]] +name = "importlib-metadata" +version = "6.0.0" +description = "Read metadata from Python packages" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +zipp = ">=0.5" + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +perf = ["ipython"] +testing = ["flake8 (<5)", "flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)", "pytest-perf (>=0.9.2)"] + +[[package]] +name = "iniconfig" +version = "2.0.0" +description = "brain-dead simple config-ini parsing" +category = "dev" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "isort" +version = "5.11.4" +description = "A Python utility / library to sort Python imports." +category = "dev" +optional = false +python-versions = ">=3.7.0" + +[package.extras] +colors = ["colorama (>=0.4.3,<0.5.0)"] +pipfile-deprecated-finder = ["pipreqs", "requirementslib"] +plugins = ["setuptools"] +requirements-deprecated-finder = ["pip-api", "pipreqs"] + +[[package]] +name = "jaraco-classes" +version = "3.2.3" +description = "Utility functions for Python class constructs" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +more-itertools = "*" + +[package.extras] +docs = ["jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)"] +testing = ["flake8 (<5)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)"] + +[[package]] +name = "jeepney" +version = "0.8.0" +description = "Low-level, pure Python DBus protocol wrapper." +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.extras] +test = ["async-timeout", "pytest", "pytest-asyncio (>=0.17)", "pytest-trio", "testpath", "trio"] +trio = ["async_generator", "trio"] + +[[package]] +name = "jinja2" +version = "3.1.2" +description = "A very fast and expressive template engine." +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +MarkupSafe = ">=2.0" + +[package.extras] +i18n = ["Babel (>=2.7)"] + +[[package]] +name = "jsonschema" +version = "4.17.3" +description = "An implementation of JSON Schema validation for Python" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +attrs = ">=17.4.0" +pyrsistent = ">=0.14.0,<0.17.0 || >0.17.0,<0.17.1 || >0.17.1,<0.17.2 || >0.17.2" + +[package.extras] +format = ["fqdn", "idna", "isoduration", "jsonpointer (>1.13)", "rfc3339-validator", "rfc3987", "uri-template", "webcolors (>=1.11)"] +format-nongpl = ["fqdn", "idna", "isoduration", "jsonpointer (>1.13)", "rfc3339-validator", "rfc3986-validator (>0.1.0)", "uri-template", "webcolors (>=1.11)"] + +[[package]] +name = "keyring" +version = "23.13.1" +description = "Store and access your passwords safely." +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +importlib-metadata = {version = ">=4.11.4", markers = "python_version < \"3.12\""} +"jaraco.classes" = "*" +jeepney = {version = ">=0.4.2", markers = "sys_platform == \"linux\""} +pywin32-ctypes = {version = ">=0.2.0", markers = "sys_platform == \"win32\""} +SecretStorage = {version = ">=3.2", markers = "sys_platform == \"linux\""} + +[package.extras] +completion = ["shtab"] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)"] +testing = ["flake8 (<5)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)"] + +[[package]] +name = "lockfile" +version = "0.12.2" +description = "Platform-independent file locking module" +category = "dev" +optional = false +python-versions = "*" + +[[package]] +name = "markupsafe" +version = "2.1.2" +description = "Safely add untrusted strings to HTML/XML markup." +category = "dev" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "mccabe" +version = "0.7.0" +description = "McCabe checker, plugin for flake8" +category = "dev" +optional = false +python-versions = ">=3.6" + +[[package]] +name = "mock" +version = "4.0.3" +description = "Rolling backport of unittest.mock for all Pythons" +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.extras] +build = ["blurb", "twine", "wheel"] +docs = ["sphinx"] +test = ["pytest (<5.4)", "pytest-cov"] + +[[package]] +name = "more-itertools" +version = "9.0.0" +description = "More routines for operating on iterables, beyond itertools" +category = "dev" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "motor" +version = "3.1.1" +description = "Non-blocking MongoDB driver for Tornado or asyncio" +category = "main" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +pymongo = ">=4.1,<5" + +[package.extras] +aws = ["pymongo[aws] (>=4.1,<5)"] +encryption = ["pymongo[encryption] (>=4.1,<5)"] +gssapi = ["pymongo[gssapi] (>=4.1,<5)"] +ocsp = ["pymongo[ocsp] (>=4.1,<5)"] +snappy = ["pymongo[snappy] (>=4.1,<5)"] +srv = ["pymongo[srv] (>=4.1,<5)"] +zstd = ["pymongo[zstd] (>=4.1,<5)"] + +[[package]] +name = "msgpack" +version = "1.0.4" +description = "MessagePack serializer" +category = "dev" +optional = false +python-versions = "*" + +[[package]] +name = "mypy" +version = "0.991" +description = "Optional static typing for Python" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +mypy-extensions = ">=0.4.3" +tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} +typing-extensions = ">=3.10" + +[package.extras] +dmypy = ["psutil (>=4.0)"] +install-types = ["pip"] +python2 = ["typed-ast (>=1.4.0,<2)"] +reports = ["lxml"] + +[[package]] +name = "mypy-extensions" +version = "0.4.3" +description = "Experimental type system extensions for programs checked with the mypy typechecker." +category = "dev" +optional = false +python-versions = "*" + +[[package]] +name = "odmantic" +version = "0.9.2" +description = "ODMantic, an AsyncIO MongoDB Object Document Mapper for Python using type hints " +category = "main" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +motor = ">=2.1.0,<3.2.0" +pydantic = ">=1.6.2,<1.7 || >1.7,<1.7.1 || >1.7.1,<1.7.2 || >1.7.2,<1.7.3 || >1.7.3,<1.8 || >1.8,<1.8.1 || >1.8.1" +pymongo = ">=3.11.0,<5.0.0" +typing-extensions = {version = ">=4.2.0", markers = "python_version < \"3.11\""} + +[package.extras] +dev = ["ipython (>=7.16.1,<7.17.0)"] +doc = ["mkdocs-macros-plugin (>=0.5.0,<0.6.0)", "mkdocs-material (>=8.4.0,<8.5.0)", "mkdocstrings[python] (>=0.19.0,<0.20.0)", "pydocstyle[toml] (>=6.1.1,<6.2.0)"] +fastapi = ["fastapi (>=0.61.1)"] +test = ["async-asgi-testclient (>=1.4.4,<1.5.0)", "asyncmock (>=0.4.2,<0.5.0)", "black (>=22.3.0,<22.4.0)", "coverage[toml] (>=6.2,<7.0)", "darglint (>=1.8.1,<1.9.0)", "fastapi (>=0.61.1,<0.69.0)", "isort (>=5.8.0,<5.9.0)", "mypy (>=0.961,<1.0)", "pytest (>=7.0,<8.0)", "pytest-asyncio (>=0.16.0,<0.17.0)", "pytest-sugar (>=0.9.5,<0.10.0)", "pytest-xdist (>=2.1.0,<2.2.0)", "pytz (>=2022.1,<2023.0)", "requests (>=2.24.0,<2.25.0)", "ruff (>=0.0.137,<0.1.0)", "semver (>=2.13.0,<2.14.0)", "typer (>=0.4.1,<0.5.0)", "types-pytz (>=2022.1.1,<2022.2.0)", "uvicorn (>=0.17.0,<0.18.0)"] + +[[package]] +name = "packaging" +version = "23.0" +description = "Core utilities for Python packages" +category = "dev" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "pathspec" +version = "0.10.3" +description = "Utility library for gitignore style pattern matching of file paths." +category = "dev" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "pbr" +version = "5.11.1" +description = "Python Build Reasonableness" +category = "dev" +optional = false +python-versions = ">=2.6" + +[[package]] +name = "pdoc" +version = "12.3.1" +description = "API Documentation for Python Projects" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +Jinja2 = ">=2.11.0" +MarkupSafe = "*" +pygments = ">=2.12.0" + +[package.extras] +dev = ["black", "hypothesis", "mypy", "pytest", "pytest-cov", "pytest-timeout", "ruff", "tox", "types-pygments"] + +[[package]] +name = "pexpect" +version = "4.8.0" +description = "Pexpect allows easy control of interactive console applications." +category = "dev" +optional = false +python-versions = "*" + +[package.dependencies] +ptyprocess = ">=0.5" + +[[package]] +name = "pkginfo" +version = "1.9.6" +description = "Query metadata from sdists / bdists / installed packages." +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.extras] +testing = ["pytest", "pytest-cov"] + +[[package]] +name = "platformdirs" +version = "2.6.2" +description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.extras] +docs = ["furo (>=2022.12.7)", "proselint (>=0.13)", "sphinx (>=5.3)", "sphinx-autodoc-typehints (>=1.19.5)"] +test = ["appdirs (==1.4.4)", "covdefaults (>=2.2.2)", "pytest (>=7.2)", "pytest-cov (>=4)", "pytest-mock (>=3.10)"] + +[[package]] +name = "pluggy" +version = "1.0.0" +description = "plugin and hook calling mechanisms for python" +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.extras] +dev = ["pre-commit", "tox"] +testing = ["pytest", "pytest-benchmark"] + +[[package]] +name = "poetry" +version = "1.2.2" +description = "Python dependency management and packaging made easy." +category = "dev" +optional = false +python-versions = ">=3.7,<4.0" + +[package.dependencies] +cachecontrol = {version = ">=0.12.9,<0.13.0", extras = ["filecache"]} +cachy = ">=0.3.0,<0.4.0" +cleo = ">=1.0.0a5,<2.0.0" +crashtest = ">=0.3.0,<0.4.0" +dulwich = ">=0.20.46,<0.21.0" +html5lib = ">=1.0,<2.0" +jsonschema = ">=4.10.0,<5.0.0" +keyring = ">=21.2.0" +packaging = ">=20.4" +pexpect = ">=4.7.0,<5.0.0" +pkginfo = ">=1.5,<2.0" +platformdirs = ">=2.5.2,<3.0.0" +poetry-core = "1.3.2" +poetry-plugin-export = ">=1.1.2,<2.0.0" +requests = ">=2.18,<3.0" +requests-toolbelt = ">=0.9.1,<0.10.0" +shellingham = ">=1.5,<2.0" +tomlkit = ">=0.11.1,<0.11.2 || >0.11.2,<0.11.3 || >0.11.3,<1.0.0" +urllib3 = ">=1.26.0,<2.0.0" +virtualenv = ">=20.4.3,<20.4.5 || >20.4.5,<20.4.6 || >20.4.6" +xattr = {version = ">=0.9.7,<0.10.0", markers = "sys_platform == \"darwin\""} + +[[package]] +name = "poetry-core" +version = "1.3.2" +description = "Poetry PEP 517 Build Backend" +category = "dev" +optional = false +python-versions = ">=3.7,<4.0" + +[[package]] +name = "poetry-plugin-export" +version = "1.2.0" +description = "Poetry plugin to export the dependencies to various formats" +category = "dev" +optional = false +python-versions = ">=3.7,<4.0" + +[package.dependencies] +poetry = ">=1.2.2,<2.0.0" +poetry-core = ">=1.3.0,<2.0.0" + +[[package]] +name = "ptyprocess" +version = "0.7.0" +description = "Run a subprocess in a pseudo terminal" +category = "dev" +optional = false +python-versions = "*" + +[[package]] +name = "py" +version = "1.11.0" +description = "library with cross-python path, ini-parsing, io, code, log facilities" +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" + +[[package]] +name = "pycodestyle" +version = "2.10.0" +description = "Python style guide checker" +category = "dev" +optional = false +python-versions = ">=3.6" + +[[package]] +name = "pycparser" +version = "2.21" +description = "C parser in Python" +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" + +[[package]] +name = "pydantic" +version = "1.10.4" +description = "Data validation and settings management using python type hints" +category = "main" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +typing-extensions = ">=4.2.0" + +[package.extras] +dotenv = ["python-dotenv (>=0.10.4)"] +email = ["email-validator (>=1.0.3)"] + +[[package]] +name = "pyflakes" +version = "3.0.1" +description = "passive checker of Python programs" +category = "dev" +optional = false +python-versions = ">=3.6" + +[[package]] +name = "pygments" +version = "2.14.0" +description = "Pygments is a syntax highlighting package written in Python." +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.extras] +plugins = ["importlib-metadata"] + +[[package]] +name = "pylev" +version = "1.4.0" +description = "A pure Python Levenshtein implementation that's not freaking GPL'd." +category = "dev" +optional = false +python-versions = "*" + +[[package]] +name = "pymongo" +version = "4.3.3" +description = "Python driver for MongoDB " +category = "main" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +dnspython = ">=1.16.0,<3.0.0" + +[package.extras] +aws = ["pymongo-auth-aws (<2.0.0)"] +encryption = ["pymongo-auth-aws (<2.0.0)", "pymongocrypt (>=1.3.0,<2.0.0)"] +gssapi = ["pykerberos"] +ocsp = ["certifi", "pyopenssl (>=17.2.0)", "requests (<3.0.0)", "service-identity (>=18.1.0)"] +snappy = ["python-snappy"] +zstd = ["zstandard"] + +[[package]] +name = "pyrsistent" +version = "0.19.3" +description = "Persistent/Functional/Immutable data structures" +category = "dev" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "pytest" +version = "7.2.1" +description = "pytest: simple powerful testing with Python" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +attrs = ">=19.2.0" +colorama = {version = "*", markers = "sys_platform == \"win32\""} +exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} +iniconfig = "*" +packaging = "*" +pluggy = ">=0.12,<2.0" +tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} + +[package.extras] +testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"] + +[[package]] +name = "pytest-asyncio" +version = "0.20.3" +description = "Pytest support for asyncio" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +pytest = ">=6.1.0" + +[package.extras] +docs = ["sphinx (>=5.3)", "sphinx-rtd-theme (>=1.0)"] +testing = ["coverage (>=6.2)", "flaky (>=3.5.0)", "hypothesis (>=5.7.1)", "mypy (>=0.931)", "pytest-trio (>=0.7.0)"] + +[[package]] +name = "pytest-mock" +version = "3.10.0" +description = "Thin-wrapper around the mock package for easier use with pytest" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +pytest = ">=5.0" + +[package.extras] +dev = ["pre-commit", "pytest-asyncio", "tox"] + +[[package]] +name = "python-dotenv" +version = "0.21.0" +description = "Read key-value pairs from a .env file and set them as environment variables" +category = "main" +optional = false +python-versions = ">=3.7" + +[package.extras] +cli = ["click (>=5.0)"] + +[[package]] +name = "pywin32-ctypes" +version = "0.2.0" +description = "" +category = "dev" +optional = false +python-versions = "*" + +[[package]] +name = "pyyaml" +version = "6.0" +description = "YAML parser and emitter for Python" +category = "main" +optional = false +python-versions = ">=3.6" + +[[package]] +name = "requests" +version = "2.28.2" +description = "Python HTTP for Humans." +category = "dev" +optional = false +python-versions = ">=3.7, <4" + +[package.dependencies] +certifi = ">=2017.4.17" +charset-normalizer = ">=2,<4" +idna = ">=2.5,<4" +urllib3 = ">=1.21.1,<1.27" + +[package.extras] +socks = ["PySocks (>=1.5.6,!=1.5.7)"] +use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] + +[[package]] +name = "requests-toolbelt" +version = "0.9.1" +description = "A utility belt for advanced users of python-requests" +category = "dev" +optional = false +python-versions = "*" + +[package.dependencies] +requests = ">=2.0.1,<3.0.0" + +[[package]] +name = "rich" +version = "12.6.0" +description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" +category = "dev" +optional = false +python-versions = ">=3.6.3,<4.0.0" + +[package.dependencies] +commonmark = ">=0.9.0,<0.10.0" +pygments = ">=2.6.0,<3.0.0" + +[package.extras] +jupyter = ["ipywidgets (>=7.5.1,<8.0.0)"] + +[[package]] +name = "ruff" +version = "0.0.166" +description = "An extremely fast Python linter, written in Rust." +category = "dev" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "secretstorage" +version = "3.3.3" +description = "Python bindings to FreeDesktop.org Secret Service API" +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.dependencies] +cryptography = ">=2.0" +jeepney = ">=0.6" + +[[package]] +name = "setuptools" +version = "66.1.0" +description = "Easily download, build, install, upgrade, and uninstall Python packages" +category = "main" +optional = false +python-versions = ">=3.7" + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-hoverxref (<2)", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (==0.8.3)", "sphinx-reredirects", "sphinxcontrib-towncrier"] +testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8 (<5)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pip (>=19.1)", "pip-run (>=8.8)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] +testing-integration = ["build[virtualenv]", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] + +[[package]] +name = "shellingham" +version = "1.5.0.post1" +description = "Tool to Detect Surrounding Shell" +category = "dev" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "six" +version = "1.16.0" +description = "Python 2 and 3 compatibility utilities" +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" + +[[package]] +name = "smmap" +version = "5.0.0" +description = "A pure Python implementation of a sliding window memory map manager" +category = "dev" +optional = false +python-versions = ">=3.6" + +[[package]] +name = "sniffio" +version = "1.3.0" +description = "Sniff out which async library your code is running under" +category = "main" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "starlette" +version = "0.21.0" +description = "The little ASGI library that shines." +category = "main" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +anyio = ">=3.4.0,<5" + +[package.extras] +full = ["httpx (>=0.22.0)", "itsdangerous", "jinja2", "python-multipart", "pyyaml"] + +[[package]] +name = "stevedore" +version = "4.1.1" +description = "Manage dynamic plugins for Python applications" +category = "dev" +optional = false +python-versions = ">=3.8" + +[package.dependencies] +pbr = ">=2.0.0,<2.1.0 || >2.1.0" + +[[package]] +name = "tomli" +version = "2.0.1" +description = "A lil' TOML parser" +category = "dev" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "tomlkit" +version = "0.11.6" +description = "Style preserving TOML library" +category = "dev" +optional = false +python-versions = ">=3.6" + +[[package]] +name = "tox" +version = "3.28.0" +description = "tox is a generic virtualenv management and test command line tool" +category = "dev" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" + +[package.dependencies] +colorama = {version = ">=0.4.1", markers = "platform_system == \"Windows\""} +filelock = ">=3.0.0" +packaging = ">=14" +pluggy = ">=0.12.0" +py = ">=1.4.17" +six = ">=1.14.0" +tomli = {version = ">=2.0.1", markers = "python_version >= \"3.7\" and python_version < \"3.11\""} +virtualenv = ">=16.0.0,<20.0.0 || >20.0.0,<20.0.1 || >20.0.1,<20.0.2 || >20.0.2,<20.0.3 || >20.0.3,<20.0.4 || >20.0.4,<20.0.5 || >20.0.5,<20.0.6 || >20.0.6,<20.0.7 || >20.0.7" + +[package.extras] +docs = ["pygments-github-lexers (>=0.0.5)", "sphinx (>=2.0.0)", "sphinxcontrib-autoprogram (>=0.1.5)", "towncrier (>=18.5.0)"] +testing = ["flaky (>=3.4.0)", "freezegun (>=0.3.11)", "pathlib2 (>=2.3.3)", "psutil (>=5.6.1)", "pytest (>=4.0.0)", "pytest-cov (>=2.5.1)", "pytest-mock (>=1.10.0)", "pytest-randomly (>=1.0.0)"] + +[[package]] +name = "tox-poetry-installer" +version = "0.10.0" +description = "A plugin for Tox that lets you install test environment dependencies from the Poetry lockfile" +category = "dev" +optional = false +python-versions = ">=3.7,<4.0" + +[package.dependencies] +cleo = {version = ">=1.0.0a5,<2.0.0", optional = true, markers = "extra == \"poetry\""} +poetry = {version = ">=1.2.0,<2.0.0", optional = true, markers = "extra == \"poetry\""} +poetry-core = ">=1.1.0,<2.0.0" +tox = ">=3.8.0,<4.0.0" + +[package.extras] +poetry = ["cleo (>=1.0.0a5,<2.0.0)", "poetry (>=1.2.0,<2.0.0)"] + +[[package]] +name = "typing-extensions" +version = "4.4.0" +description = "Backported and Experimental Type Hints for Python 3.7+" +category = "main" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "urllib3" +version = "1.26.14" +description = "HTTP library with thread-safe connection pooling, file post, and more." +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" + +[package.extras] +brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)", "brotlipy (>=0.6.0)"] +secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "ipaddress", "pyOpenSSL (>=0.14)", "urllib3-secure-extra"] +socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] + +[[package]] +name = "uvicorn" +version = "0.20.0" +description = "The lightning-fast ASGI server." +category = "main" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +click = ">=7.0" +colorama = {version = ">=0.4", optional = true, markers = "sys_platform == \"win32\" and extra == \"standard\""} +h11 = ">=0.8" +httptools = {version = ">=0.5.0", optional = true, markers = "extra == \"standard\""} +python-dotenv = {version = ">=0.13", optional = true, markers = "extra == \"standard\""} +pyyaml = {version = ">=5.1", optional = true, markers = "extra == \"standard\""} +uvloop = {version = ">=0.14.0,<0.15.0 || >0.15.0,<0.15.1 || >0.15.1", optional = true, markers = "sys_platform != \"win32\" and sys_platform != \"cygwin\" and platform_python_implementation != \"PyPy\" and extra == \"standard\""} +watchfiles = {version = ">=0.13", optional = true, markers = "extra == \"standard\""} +websockets = {version = ">=10.4", optional = true, markers = "extra == \"standard\""} + +[package.extras] +standard = ["colorama (>=0.4)", "httptools (>=0.5.0)", "python-dotenv (>=0.13)", "pyyaml (>=5.1)", "uvloop (>=0.14.0,!=0.15.0,!=0.15.1)", "watchfiles (>=0.13)", "websockets (>=10.4)"] + +[[package]] +name = "uvloop" +version = "0.17.0" +description = "Fast implementation of asyncio event loop on top of libuv" +category = "main" +optional = false +python-versions = ">=3.7" + +[package.extras] +dev = ["Cython (>=0.29.32,<0.30.0)", "Sphinx (>=4.1.2,<4.2.0)", "aiohttp", "flake8 (>=3.9.2,<3.10.0)", "mypy (>=0.800)", "psutil", "pyOpenSSL (>=22.0.0,<22.1.0)", "pycodestyle (>=2.7.0,<2.8.0)", "pytest (>=3.6.0)", "sphinx-rtd-theme (>=0.5.2,<0.6.0)", "sphinxcontrib-asyncio (>=0.3.0,<0.4.0)"] +docs = ["Sphinx (>=4.1.2,<4.2.0)", "sphinx-rtd-theme (>=0.5.2,<0.6.0)", "sphinxcontrib-asyncio (>=0.3.0,<0.4.0)"] +test = ["Cython (>=0.29.32,<0.30.0)", "aiohttp", "flake8 (>=3.9.2,<3.10.0)", "mypy (>=0.800)", "psutil", "pyOpenSSL (>=22.0.0,<22.1.0)", "pycodestyle (>=2.7.0,<2.8.0)"] + +[[package]] +name = "virtualenv" +version = "20.17.1" +description = "Virtual Python Environment builder" +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.dependencies] +distlib = ">=0.3.6,<1" +filelock = ">=3.4.1,<4" +platformdirs = ">=2.4,<3" + +[package.extras] +docs = ["proselint (>=0.13)", "sphinx (>=5.3)", "sphinx-argparse (>=0.3.2)", "sphinx-rtd-theme (>=1)", "towncrier (>=22.8)"] +testing = ["coverage (>=6.2)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=21.3)", "pytest (>=7.0.1)", "pytest-env (>=0.6.2)", "pytest-freezegun (>=0.4.2)", "pytest-mock (>=3.6.1)", "pytest-randomly (>=3.10.3)", "pytest-timeout (>=2.1)"] + +[[package]] +name = "watchfiles" +version = "0.18.1" +description = "Simple, modern and high performance file watching and code reload in python." +category = "main" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +anyio = ">=3.0.0" + +[[package]] +name = "webencodings" +version = "0.5.1" +description = "Character encoding aliases for legacy web content" +category = "dev" +optional = false +python-versions = "*" + +[[package]] +name = "websockets" +version = "10.4" +description = "An implementation of the WebSocket Protocol (RFC 6455 & 7692)" +category = "main" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "xattr" +version = "0.9.9" +description = "Python wrapper for extended filesystem attributes" +category = "dev" +optional = false +python-versions = "*" + +[package.dependencies] +cffi = ">=1.0" + +[[package]] +name = "zipp" +version = "3.11.0" +description = "Backport of pathlib-compatible object wrapper for zip files" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)"] +testing = ["flake8 (<5)", "func-timeout", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)"] + +[metadata] +lock-version = "1.1" +python-versions = "^3.10" +content-hash = "e9629a660d2ef0ab1fa09a6d279536ba21ae3b7b7126e2f9ef027cbc72f21cac" + +[metadata.files] +anyio = [ + {file = "anyio-3.6.2-py3-none-any.whl", hash = "sha256:fbbe32bd270d2a2ef3ed1c5d45041250284e31fc0a4df4a5a6071842051a51e3"}, + {file = "anyio-3.6.2.tar.gz", hash = "sha256:25ea0d673ae30af41a0c442f81cf3b38c7e79fdc7b60335a4c14e05eb0947421"}, +] +asttokens = [ + {file = "asttokens-2.2.1-py2.py3-none-any.whl", hash = "sha256:6b0ac9e93fb0335014d382b8fa9b3afa7df546984258005da0b9e7095b3deb1c"}, + {file = "asttokens-2.2.1.tar.gz", hash = "sha256:4622110b2a6f30b77e1473affaa97e711bc2f07d3f10848420ff1898edbe94f3"}, +] +attrs = [ + {file = "attrs-22.2.0-py3-none-any.whl", hash = "sha256:29e95c7f6778868dbd49170f98f8818f78f3dc5e0e37c0b1f474e3561b240836"}, + {file = "attrs-22.2.0.tar.gz", hash = "sha256:c9227bfc2f01993c03f68db37d1d15c9690188323c067c641f1a35ca58185f99"}, +] +bandit = [ + {file = "bandit-1.7.4-py3-none-any.whl", hash = "sha256:412d3f259dab4077d0e7f0c11f50f650cc7d10db905d98f6520a95a18049658a"}, + {file = "bandit-1.7.4.tar.gz", hash = "sha256:2d63a8c573417bae338962d4b9b06fbc6080f74ecd955a092849e1e65c717bd2"}, +] +black = [ + {file = "black-22.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9eedd20838bd5d75b80c9f5487dbcb06836a43833a37846cf1d8c1cc01cef59d"}, + {file = "black-22.12.0-cp310-cp310-win_amd64.whl", hash = "sha256:159a46a4947f73387b4d83e87ea006dbb2337eab6c879620a3ba52699b1f4351"}, + {file = "black-22.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d30b212bffeb1e252b31dd269dfae69dd17e06d92b87ad26e23890f3efea366f"}, + {file = "black-22.12.0-cp311-cp311-win_amd64.whl", hash = "sha256:7412e75863aa5c5411886804678b7d083c7c28421210180d67dfd8cf1221e1f4"}, + {file = "black-22.12.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c116eed0efb9ff870ded8b62fe9f28dd61ef6e9ddd28d83d7d264a38417dcee2"}, + {file = "black-22.12.0-cp37-cp37m-win_amd64.whl", hash = "sha256:1f58cbe16dfe8c12b7434e50ff889fa479072096d79f0a7f25e4ab8e94cd8350"}, + {file = "black-22.12.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:77d86c9f3db9b1bf6761244bc0b3572a546f5fe37917a044e02f3166d5aafa7d"}, + {file = "black-22.12.0-cp38-cp38-win_amd64.whl", hash = "sha256:82d9fe8fee3401e02e79767016b4907820a7dc28d70d137eb397b92ef3cc5bfc"}, + {file = "black-22.12.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:101c69b23df9b44247bd88e1d7e90154336ac4992502d4197bdac35dd7ee3320"}, + {file = "black-22.12.0-cp39-cp39-win_amd64.whl", hash = "sha256:559c7a1ba9a006226f09e4916060982fd27334ae1998e7a38b3f33a37f7a2148"}, + {file = "black-22.12.0-py3-none-any.whl", hash = "sha256:436cc9167dd28040ad90d3b404aec22cedf24a6e4d7de221bec2730ec0c97bcf"}, + {file = "black-22.12.0.tar.gz", hash = "sha256:229351e5a18ca30f447bf724d007f890f97e13af070bb6ad4c0a441cd7596a2f"}, +] +cachecontrol = [ + {file = "CacheControl-0.12.11-py2.py3-none-any.whl", hash = "sha256:2c75d6a8938cb1933c75c50184549ad42728a27e9f6b92fd677c3151aa72555b"}, + {file = "CacheControl-0.12.11.tar.gz", hash = "sha256:a5b9fcc986b184db101aa280b42ecdcdfc524892596f606858e0b7a8b4d9e144"}, +] +cachy = [ + {file = "cachy-0.3.0-py2.py3-none-any.whl", hash = "sha256:338ca09c8860e76b275aff52374330efedc4d5a5e45dc1c5b539c1ead0786fe7"}, + {file = "cachy-0.3.0.tar.gz", hash = "sha256:186581f4ceb42a0bbe040c407da73c14092379b1e4c0e327fdb72ae4a9b269b1"}, +] +certifi = [ + {file = "certifi-2022.12.7-py3-none-any.whl", hash = "sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18"}, + {file = "certifi-2022.12.7.tar.gz", hash = "sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3"}, +] +cffi = [ + {file = "cffi-1.15.1-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:a66d3508133af6e8548451b25058d5812812ec3798c886bf38ed24a98216fab2"}, + {file = "cffi-1.15.1-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:470c103ae716238bbe698d67ad020e1db9d9dba34fa5a899b5e21577e6d52ed2"}, + {file = "cffi-1.15.1-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:9ad5db27f9cabae298d151c85cf2bad1d359a1b9c686a275df03385758e2f914"}, + {file = "cffi-1.15.1-cp27-cp27m-win32.whl", hash = "sha256:b3bbeb01c2b273cca1e1e0c5df57f12dce9a4dd331b4fa1635b8bec26350bde3"}, + {file = "cffi-1.15.1-cp27-cp27m-win_amd64.whl", hash = "sha256:e00b098126fd45523dd056d2efba6c5a63b71ffe9f2bbe1a4fe1716e1d0c331e"}, + {file = "cffi-1.15.1-cp27-cp27mu-manylinux1_i686.whl", hash = "sha256:d61f4695e6c866a23a21acab0509af1cdfd2c013cf256bbf5b6b5e2695827162"}, + {file = "cffi-1.15.1-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:ed9cb427ba5504c1dc15ede7d516b84757c3e3d7868ccc85121d9310d27eed0b"}, + {file = "cffi-1.15.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:39d39875251ca8f612b6f33e6b1195af86d1b3e60086068be9cc053aa4376e21"}, + {file = "cffi-1.15.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:285d29981935eb726a4399badae8f0ffdff4f5050eaa6d0cfc3f64b857b77185"}, + {file = "cffi-1.15.1-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3eb6971dcff08619f8d91607cfc726518b6fa2a9eba42856be181c6d0d9515fd"}, + {file = "cffi-1.15.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:21157295583fe8943475029ed5abdcf71eb3911894724e360acff1d61c1d54bc"}, + {file = "cffi-1.15.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5635bd9cb9731e6d4a1132a498dd34f764034a8ce60cef4f5319c0541159392f"}, + {file = "cffi-1.15.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2012c72d854c2d03e45d06ae57f40d78e5770d252f195b93f581acf3ba44496e"}, + {file = "cffi-1.15.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dd86c085fae2efd48ac91dd7ccffcfc0571387fe1193d33b6394db7ef31fe2a4"}, + {file = "cffi-1.15.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:fa6693661a4c91757f4412306191b6dc88c1703f780c8234035eac011922bc01"}, + {file = "cffi-1.15.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:59c0b02d0a6c384d453fece7566d1c7e6b7bae4fc5874ef2ef46d56776d61c9e"}, + {file = "cffi-1.15.1-cp310-cp310-win32.whl", hash = "sha256:cba9d6b9a7d64d4bd46167096fc9d2f835e25d7e4c121fb2ddfc6528fb0413b2"}, + {file = "cffi-1.15.1-cp310-cp310-win_amd64.whl", hash = "sha256:ce4bcc037df4fc5e3d184794f27bdaab018943698f4ca31630bc7f84a7b69c6d"}, + {file = "cffi-1.15.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:3d08afd128ddaa624a48cf2b859afef385b720bb4b43df214f85616922e6a5ac"}, + {file = "cffi-1.15.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3799aecf2e17cf585d977b780ce79ff0dc9b78d799fc694221ce814c2c19db83"}, + {file = "cffi-1.15.1-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a591fe9e525846e4d154205572a029f653ada1a78b93697f3b5a8f1f2bc055b9"}, + {file = "cffi-1.15.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3548db281cd7d2561c9ad9984681c95f7b0e38881201e157833a2342c30d5e8c"}, + {file = "cffi-1.15.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:91fc98adde3d7881af9b59ed0294046f3806221863722ba7d8d120c575314325"}, + {file = "cffi-1.15.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:94411f22c3985acaec6f83c6df553f2dbe17b698cc7f8ae751ff2237d96b9e3c"}, + {file = "cffi-1.15.1-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:03425bdae262c76aad70202debd780501fabeaca237cdfddc008987c0e0f59ef"}, + {file = "cffi-1.15.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:cc4d65aeeaa04136a12677d3dd0b1c0c94dc43abac5860ab33cceb42b801c1e8"}, + {file = "cffi-1.15.1-cp311-cp311-win32.whl", hash = "sha256:a0f100c8912c114ff53e1202d0078b425bee3649ae34d7b070e9697f93c5d52d"}, + {file = "cffi-1.15.1-cp311-cp311-win_amd64.whl", hash = "sha256:04ed324bda3cda42b9b695d51bb7d54b680b9719cfab04227cdd1e04e5de3104"}, + {file = "cffi-1.15.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50a74364d85fd319352182ef59c5c790484a336f6db772c1a9231f1c3ed0cbd7"}, + {file = "cffi-1.15.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e263d77ee3dd201c3a142934a086a4450861778baaeeb45db4591ef65550b0a6"}, + {file = "cffi-1.15.1-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:cec7d9412a9102bdc577382c3929b337320c4c4c4849f2c5cdd14d7368c5562d"}, + {file = "cffi-1.15.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4289fc34b2f5316fbb762d75362931e351941fa95fa18789191b33fc4cf9504a"}, + {file = "cffi-1.15.1-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:173379135477dc8cac4bc58f45db08ab45d228b3363adb7af79436135d028405"}, + {file = "cffi-1.15.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:6975a3fac6bc83c4a65c9f9fcab9e47019a11d3d2cf7f3c0d03431bf145a941e"}, + {file = "cffi-1.15.1-cp36-cp36m-win32.whl", hash = "sha256:2470043b93ff09bf8fb1d46d1cb756ce6132c54826661a32d4e4d132e1977adf"}, + {file = "cffi-1.15.1-cp36-cp36m-win_amd64.whl", hash = "sha256:30d78fbc8ebf9c92c9b7823ee18eb92f2e6ef79b45ac84db507f52fbe3ec4497"}, + {file = "cffi-1.15.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:198caafb44239b60e252492445da556afafc7d1e3ab7a1fb3f0584ef6d742375"}, + {file = "cffi-1.15.1-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5ef34d190326c3b1f822a5b7a45f6c4535e2f47ed06fec77d3d799c450b2651e"}, + {file = "cffi-1.15.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8102eaf27e1e448db915d08afa8b41d6c7ca7a04b7d73af6514df10a3e74bd82"}, + {file = "cffi-1.15.1-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5df2768244d19ab7f60546d0c7c63ce1581f7af8b5de3eb3004b9b6fc8a9f84b"}, + {file = "cffi-1.15.1-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a8c4917bd7ad33e8eb21e9a5bbba979b49d9a97acb3a803092cbc1133e20343c"}, + {file = "cffi-1.15.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0e2642fe3142e4cc4af0799748233ad6da94c62a8bec3a6648bf8ee68b1c7426"}, + {file = "cffi-1.15.1-cp37-cp37m-win32.whl", hash = "sha256:e229a521186c75c8ad9490854fd8bbdd9a0c9aa3a524326b55be83b54d4e0ad9"}, + {file = "cffi-1.15.1-cp37-cp37m-win_amd64.whl", hash = "sha256:a0b71b1b8fbf2b96e41c4d990244165e2c9be83d54962a9a1d118fd8657d2045"}, + {file = "cffi-1.15.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:320dab6e7cb2eacdf0e658569d2575c4dad258c0fcc794f46215e1e39f90f2c3"}, + {file = "cffi-1.15.1-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1e74c6b51a9ed6589199c787bf5f9875612ca4a8a0785fb2d4a84429badaf22a"}, + {file = "cffi-1.15.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a5c84c68147988265e60416b57fc83425a78058853509c1b0629c180094904a5"}, + {file = "cffi-1.15.1-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3b926aa83d1edb5aa5b427b4053dc420ec295a08e40911296b9eb1b6170f6cca"}, + {file = "cffi-1.15.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:87c450779d0914f2861b8526e035c5e6da0a3199d8f1add1a665e1cbc6fc6d02"}, + {file = "cffi-1.15.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4f2c9f67e9821cad2e5f480bc8d83b8742896f1242dba247911072d4fa94c192"}, + {file = "cffi-1.15.1-cp38-cp38-win32.whl", hash = "sha256:8b7ee99e510d7b66cdb6c593f21c043c248537a32e0bedf02e01e9553a172314"}, + {file = "cffi-1.15.1-cp38-cp38-win_amd64.whl", hash = "sha256:00a9ed42e88df81ffae7a8ab6d9356b371399b91dbdf0c3cb1e84c03a13aceb5"}, + {file = "cffi-1.15.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:54a2db7b78338edd780e7ef7f9f6c442500fb0d41a5a4ea24fff1c929d5af585"}, + {file = "cffi-1.15.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:fcd131dd944808b5bdb38e6f5b53013c5aa4f334c5cad0c72742f6eba4b73db0"}, + {file = "cffi-1.15.1-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7473e861101c9e72452f9bf8acb984947aa1661a7704553a9f6e4baa5ba64415"}, + {file = "cffi-1.15.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6c9a799e985904922a4d207a94eae35c78ebae90e128f0c4e521ce339396be9d"}, + {file = "cffi-1.15.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3bcde07039e586f91b45c88f8583ea7cf7a0770df3a1649627bf598332cb6984"}, + {file = "cffi-1.15.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:33ab79603146aace82c2427da5ca6e58f2b3f2fb5da893ceac0c42218a40be35"}, + {file = "cffi-1.15.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5d598b938678ebf3c67377cdd45e09d431369c3b1a5b331058c338e201f12b27"}, + {file = "cffi-1.15.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:db0fbb9c62743ce59a9ff687eb5f4afbe77e5e8403d6697f7446e5f609976f76"}, + {file = "cffi-1.15.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:98d85c6a2bef81588d9227dde12db8a7f47f639f4a17c9ae08e773aa9c697bf3"}, + {file = "cffi-1.15.1-cp39-cp39-win32.whl", hash = "sha256:40f4774f5a9d4f5e344f31a32b5096977b5d48560c5592e2f3d2c4374bd543ee"}, + {file = "cffi-1.15.1-cp39-cp39-win_amd64.whl", hash = "sha256:70df4e3b545a17496c9b3f41f5115e69a4f2e77e94e1d2a8e1070bc0c38c8a3c"}, + {file = "cffi-1.15.1.tar.gz", hash = "sha256:d400bfb9a37b1351253cb402671cea7e89bdecc294e8016a707f6d1d8ac934f9"}, +] +charset-normalizer = [ + {file = "charset-normalizer-3.0.1.tar.gz", hash = "sha256:ebea339af930f8ca5d7a699b921106c6e29c617fe9606fa7baa043c1cdae326f"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:88600c72ef7587fe1708fd242b385b6ed4b8904976d5da0893e31df8b3480cb6"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c75ffc45f25324e68ab238cb4b5c0a38cd1c3d7f1fb1f72b5541de469e2247db"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:db72b07027db150f468fbada4d85b3b2729a3db39178abf5c543b784c1254539"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:62595ab75873d50d57323a91dd03e6966eb79c41fa834b7a1661ed043b2d404d"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ff6f3db31555657f3163b15a6b7c6938d08df7adbfc9dd13d9d19edad678f1e8"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:772b87914ff1152b92a197ef4ea40efe27a378606c39446ded52c8f80f79702e"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:70990b9c51340e4044cfc394a81f614f3f90d41397104d226f21e66de668730d"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:292d5e8ba896bbfd6334b096e34bffb56161c81408d6d036a7dfa6929cff8783"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:2edb64ee7bf1ed524a1da60cdcd2e1f6e2b4f66ef7c077680739f1641f62f555"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:31a9ddf4718d10ae04d9b18801bd776693487cbb57d74cc3458a7673f6f34639"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:44ba614de5361b3e5278e1241fda3dc1838deed864b50a10d7ce92983797fa76"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:12db3b2c533c23ab812c2b25934f60383361f8a376ae272665f8e48b88e8e1c6"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:c512accbd6ff0270939b9ac214b84fb5ada5f0409c44298361b2f5e13f9aed9e"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-win32.whl", hash = "sha256:502218f52498a36d6bf5ea77081844017bf7982cdbe521ad85e64cabee1b608b"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:601f36512f9e28f029d9481bdaf8e89e5148ac5d89cffd3b05cd533eeb423b59"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:0298eafff88c99982a4cf66ba2efa1128e4ddaca0b05eec4c456bbc7db691d8d"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:a8d0fc946c784ff7f7c3742310cc8a57c5c6dc31631269876a88b809dbeff3d3"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:87701167f2a5c930b403e9756fab1d31d4d4da52856143b609e30a1ce7160f3c"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:14e76c0f23218b8f46c4d87018ca2e441535aed3632ca134b10239dfb6dadd6b"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:0c0a590235ccd933d9892c627dec5bc7511ce6ad6c1011fdf5b11363022746c1"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8c7fe7afa480e3e82eed58e0ca89f751cd14d767638e2550c77a92a9e749c317"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:79909e27e8e4fcc9db4addea88aa63f6423ebb171db091fb4373e3312cb6d603"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8ac7b6a045b814cf0c47f3623d21ebd88b3e8cf216a14790b455ea7ff0135d18"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:72966d1b297c741541ca8cf1223ff262a6febe52481af742036a0b296e35fa5a"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:f9d0c5c045a3ca9bedfc35dca8526798eb91a07aa7a2c0fee134c6c6f321cbd7"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:5995f0164fa7df59db4746112fec3f49c461dd6b31b841873443bdb077c13cfc"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:4a8fcf28c05c1f6d7e177a9a46a1c52798bfe2ad80681d275b10dcf317deaf0b"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:761e8904c07ad053d285670f36dd94e1b6ab7f16ce62b9805c475b7aa1cffde6"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-win32.whl", hash = "sha256:71140351489970dfe5e60fc621ada3e0f41104a5eddaca47a7acb3c1b851d6d3"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:9ab77acb98eba3fd2a85cd160851816bfce6871d944d885febf012713f06659c"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:84c3990934bae40ea69a82034912ffe5a62c60bbf6ec5bc9691419641d7d5c9a"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:74292fc76c905c0ef095fe11e188a32ebd03bc38f3f3e9bcb85e4e6db177b7ea"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c95a03c79bbe30eec3ec2b7f076074f4281526724c8685a42872974ef4d36b72"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f4c39b0e3eac288fedc2b43055cfc2ca7a60362d0e5e87a637beac5d801ef478"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:df2c707231459e8a4028eabcd3cfc827befd635b3ef72eada84ab13b52e1574d"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:93ad6d87ac18e2a90b0fe89df7c65263b9a99a0eb98f0a3d2e079f12a0735837"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:59e5686dd847347e55dffcc191a96622f016bc0ad89105e24c14e0d6305acbc6"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:cd6056167405314a4dc3c173943f11249fa0f1b204f8b51ed4bde1a9cd1834dc"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-musllinux_1_1_ppc64le.whl", hash = "sha256:083c8d17153ecb403e5e1eb76a7ef4babfc2c48d58899c98fcaa04833e7a2f9a"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-musllinux_1_1_s390x.whl", hash = "sha256:f5057856d21e7586765171eac8b9fc3f7d44ef39425f85dbcccb13b3ebea806c"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:7eb33a30d75562222b64f569c642ff3dc6689e09adda43a082208397f016c39a"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-win32.whl", hash = "sha256:95dea361dd73757c6f1c0a1480ac499952c16ac83f7f5f4f84f0658a01b8ef41"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-win_amd64.whl", hash = "sha256:eaa379fcd227ca235d04152ca6704c7cb55564116f8bc52545ff357628e10602"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:3e45867f1f2ab0711d60c6c71746ac53537f1684baa699f4f668d4c6f6ce8e14"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cadaeaba78750d58d3cc6ac4d1fd867da6fc73c88156b7a3212a3cd4819d679d"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:911d8a40b2bef5b8bbae2e36a0b103f142ac53557ab421dc16ac4aafee6f53dc"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:503e65837c71b875ecdd733877d852adbc465bd82c768a067badd953bf1bc5a3"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a60332922359f920193b1d4826953c507a877b523b2395ad7bc716ddd386d866"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:16a8663d6e281208d78806dbe14ee9903715361cf81f6d4309944e4d1e59ac5b"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:a16418ecf1329f71df119e8a65f3aa68004a3f9383821edcb20f0702934d8087"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:9d9153257a3f70d5f69edf2325357251ed20f772b12e593f3b3377b5f78e7ef8"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:02a51034802cbf38db3f89c66fb5d2ec57e6fe7ef2f4a44d070a593c3688667b"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:2e396d70bc4ef5325b72b593a72c8979999aa52fb8bcf03f701c1b03e1166918"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:11b53acf2411c3b09e6af37e4b9005cba376c872503c8f28218c7243582df45d"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-win32.whl", hash = "sha256:0bf2dae5291758b6f84cf923bfaa285632816007db0330002fa1de38bfcb7154"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:2c03cc56021a4bd59be889c2b9257dae13bf55041a3372d3295416f86b295fb5"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:024e606be3ed92216e2b6952ed859d86b4cfa52cd5bc5f050e7dc28f9b43ec42"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:4b0d02d7102dd0f997580b51edc4cebcf2ab6397a7edf89f1c73b586c614272c"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:358a7c4cb8ba9b46c453b1dd8d9e431452d5249072e4f56cfda3149f6ab1405e"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:81d6741ab457d14fdedc215516665050f3822d3e56508921cc7239f8c8e66a58"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8b8af03d2e37866d023ad0ddea594edefc31e827fee64f8de5611a1dbc373174"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9cf4e8ad252f7c38dd1f676b46514f92dc0ebeb0db5552f5f403509705e24753"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e696f0dd336161fca9adbb846875d40752e6eba585843c768935ba5c9960722b"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c22d3fe05ce11d3671297dc8973267daa0f938b93ec716e12e0f6dee81591dc1"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:109487860ef6a328f3eec66f2bf78b0b72400280d8f8ea05f69c51644ba6521a"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:37f8febc8ec50c14f3ec9637505f28e58d4f66752207ea177c1d67df25da5aed"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:f97e83fa6c25693c7a35de154681fcc257c1c41b38beb0304b9c4d2d9e164479"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:a152f5f33d64a6be73f1d30c9cc82dfc73cec6477ec268e7c6e4c7d23c2d2291"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:39049da0ffb96c8cbb65cbf5c5f3ca3168990adf3551bd1dee10c48fce8ae820"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-win32.whl", hash = "sha256:4457ea6774b5611f4bed5eaa5df55f70abde42364d498c5134b7ef4c6958e20e"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:e62164b50f84e20601c1ff8eb55620d2ad25fb81b59e3cd776a1902527a788af"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:8eade758719add78ec36dc13201483f8e9b5d940329285edcd5f70c0a9edbd7f"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:8499ca8f4502af841f68135133d8258f7b32a53a1d594aa98cc52013fff55678"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3fc1c4a2ffd64890aebdb3f97e1278b0cc72579a08ca4de8cd2c04799a3a22be"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:00d3ffdaafe92a5dc603cb9bd5111aaa36dfa187c8285c543be562e61b755f6b"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c2ac1b08635a8cd4e0cbeaf6f5e922085908d48eb05d44c5ae9eabab148512ca"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f6f45710b4459401609ebebdbcfb34515da4fc2aa886f95107f556ac69a9147e"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3ae1de54a77dc0d6d5fcf623290af4266412a7c4be0b1ff7444394f03f5c54e3"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3b590df687e3c5ee0deef9fc8c547d81986d9a1b56073d82de008744452d6541"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:ab5de034a886f616a5668aa5d098af2b5385ed70142090e2a31bcbd0af0fdb3d"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:9cb3032517f1627cc012dbc80a8ec976ae76d93ea2b5feaa9d2a5b8882597579"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:608862a7bf6957f2333fc54ab4399e405baad0163dc9f8d99cb236816db169d4"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:0f438ae3532723fb6ead77e7c604be7c8374094ef4ee2c5e03a3a17f1fca256c"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:356541bf4381fa35856dafa6a965916e54bed415ad8a24ee6de6e37deccf2786"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-win32.whl", hash = "sha256:39cf9ed17fe3b1bc81f33c9ceb6ce67683ee7526e65fde1447c772afc54a1bb8"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:0a11e971ed097d24c534c037d298ad32c6ce81a45736d31e0ff0ad37ab437d59"}, + {file = "charset_normalizer-3.0.1-py3-none-any.whl", hash = "sha256:7e189e2e1d3ed2f4aebabd2d5b0f931e883676e51c7624826e0a4e5fe8a0bf24"}, +] +cleo = [ + {file = "cleo-1.0.0a5-py3-none-any.whl", hash = "sha256:ff53056589300976e960f75afb792dfbfc9c78dcbb5a448e207a17b643826360"}, + {file = "cleo-1.0.0a5.tar.gz", hash = "sha256:097c9d0e0332fd53cc89fc11eb0a6ba0309e6a3933c08f7b38558555486925d3"}, +] +click = [ + {file = "click-8.1.3-py3-none-any.whl", hash = "sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48"}, + {file = "click-8.1.3.tar.gz", hash = "sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e"}, +] +colorama = [ + {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, +] +commonmark = [ + {file = "commonmark-0.9.1-py2.py3-none-any.whl", hash = "sha256:da2f38c92590f83de410ba1a3cbceafbc74fee9def35f9251ba9a971d6d66fd9"}, + {file = "commonmark-0.9.1.tar.gz", hash = "sha256:452f9dc859be7f06631ddcb328b6919c67984aca654e5fefb3914d54691aed60"}, +] +crashtest = [ + {file = "crashtest-0.3.1-py3-none-any.whl", hash = "sha256:300f4b0825f57688b47b6d70c6a31de33512eb2fa1ac614f780939aa0cf91680"}, + {file = "crashtest-0.3.1.tar.gz", hash = "sha256:42ca7b6ce88b6c7433e2ce47ea884e91ec93104a4b754998be498a8e6c3d37dd"}, +] +cryptography = [ + {file = "cryptography-39.0.0-cp36-abi3-macosx_10_12_universal2.whl", hash = "sha256:c52a1a6f81e738d07f43dab57831c29e57d21c81a942f4602fac7ee21b27f288"}, + {file = "cryptography-39.0.0-cp36-abi3-macosx_10_12_x86_64.whl", hash = "sha256:80ee674c08aaef194bc4627b7f2956e5ba7ef29c3cc3ca488cf15854838a8f72"}, + {file = "cryptography-39.0.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl", hash = "sha256:887cbc1ea60786e534b00ba8b04d1095f4272d380ebd5f7a7eb4cc274710fad9"}, + {file = "cryptography-39.0.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6f97109336df5c178ee7c9c711b264c502b905c2d2a29ace99ed761533a3460f"}, + {file = "cryptography-39.0.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1a6915075c6d3a5e1215eab5d99bcec0da26036ff2102a1038401d6ef5bef25b"}, + {file = "cryptography-39.0.0-cp36-abi3-manylinux_2_24_x86_64.whl", hash = "sha256:76c24dd4fd196a80f9f2f5405a778a8ca132f16b10af113474005635fe7e066c"}, + {file = "cryptography-39.0.0-cp36-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:bae6c7f4a36a25291b619ad064a30a07110a805d08dc89984f4f441f6c1f3f96"}, + {file = "cryptography-39.0.0-cp36-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:875aea1039d78557c7c6b4db2fe0e9d2413439f4676310a5f269dd342ca7a717"}, + {file = "cryptography-39.0.0-cp36-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:f6c0db08d81ead9576c4d94bbb27aed8d7a430fa27890f39084c2d0e2ec6b0df"}, + {file = "cryptography-39.0.0-cp36-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:f3ed2d864a2fa1666e749fe52fb8e23d8e06b8012e8bd8147c73797c506e86f1"}, + {file = "cryptography-39.0.0-cp36-abi3-win32.whl", hash = "sha256:f671c1bb0d6088e94d61d80c606d65baacc0d374e67bf895148883461cd848de"}, + {file = "cryptography-39.0.0-cp36-abi3-win_amd64.whl", hash = "sha256:e324de6972b151f99dc078defe8fb1b0a82c6498e37bff335f5bc6b1e3ab5a1e"}, + {file = "cryptography-39.0.0-pp38-pypy38_pp73-macosx_10_12_x86_64.whl", hash = "sha256:754978da4d0457e7ca176f58c57b1f9de6556591c19b25b8bcce3c77d314f5eb"}, + {file = "cryptography-39.0.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1ee1fd0de9851ff32dbbb9362a4d833b579b4a6cc96883e8e6d2ff2a6bc7104f"}, + {file = "cryptography-39.0.0-pp38-pypy38_pp73-manylinux_2_24_x86_64.whl", hash = "sha256:fec8b932f51ae245121c4671b4bbc030880f363354b2f0e0bd1366017d891458"}, + {file = "cryptography-39.0.0-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:407cec680e811b4fc829de966f88a7c62a596faa250fc1a4b520a0355b9bc190"}, + {file = "cryptography-39.0.0-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:7dacfdeee048814563eaaec7c4743c8aea529fe3dd53127313a792f0dadc1773"}, + {file = "cryptography-39.0.0-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:ad04f413436b0781f20c52a661660f1e23bcd89a0e9bb1d6d20822d048cf2856"}, + {file = "cryptography-39.0.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:50386acb40fbabbceeb2986332f0287f50f29ccf1497bae31cf5c3e7b4f4b34f"}, + {file = "cryptography-39.0.0-pp39-pypy39_pp73-manylinux_2_24_x86_64.whl", hash = "sha256:e5d71c5d5bd5b5c3eebcf7c5c2bb332d62ec68921a8c593bea8c394911a005ce"}, + {file = "cryptography-39.0.0-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:844ad4d7c3850081dffba91cdd91950038ee4ac525c575509a42d3fc806b83c8"}, + {file = "cryptography-39.0.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:e0a05aee6a82d944f9b4edd6a001178787d1546ec7c6223ee9a848a7ade92e39"}, + {file = "cryptography-39.0.0.tar.gz", hash = "sha256:f964c7dcf7802d133e8dbd1565914fa0194f9d683d82411989889ecd701e8adf"}, +] +devtools = [ + {file = "devtools-0.9.0-py3-none-any.whl", hash = "sha256:689cf4e7c75024237c42093ba19f4fa9cf15980269f02463aeab4d97d4b0a215"}, + {file = "devtools-0.9.0.tar.gz", hash = "sha256:86ede6e0273e023db766344d14098228785b48a80f31716f28e8b9453d52fa1e"}, +] +distlib = [ + {file = "distlib-0.3.6-py2.py3-none-any.whl", hash = "sha256:f35c4b692542ca110de7ef0bea44d73981caeb34ca0b9b6b2e6d7790dda8f80e"}, + {file = "distlib-0.3.6.tar.gz", hash = "sha256:14bad2d9b04d3a36127ac97f30b12a19268f211063d8f8ee4f47108896e11b46"}, +] +dnspython = [ + {file = "dnspython-2.3.0-py3-none-any.whl", hash = "sha256:89141536394f909066cabd112e3e1a37e4e654db00a25308b0f130bc3152eb46"}, + {file = "dnspython-2.3.0.tar.gz", hash = "sha256:224e32b03eb46be70e12ef6d64e0be123a64e621ab4c0822ff6d450d52a540b9"}, +] +dulwich = [ + {file = "dulwich-0.20.50-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:97f02f8d500d4af08dc022d697c56e8539171acc3f575c2fe9acf3b078e5c8c9"}, + {file = "dulwich-0.20.50-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:7301773e5cc16d521bc6490e73772a86a4d1d0263de506f08b54678cc4e2f061"}, + {file = "dulwich-0.20.50-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:b70106580ed11f45f4c32d2831d0c9c9f359bc2415fff4a6be443e3a36811398"}, + {file = "dulwich-0.20.50-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0f9c4f2455f966cad94648278fa9972e4695b35d04f82792fa58e1ea15dd83f0"}, + {file = "dulwich-0.20.50-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9163fbb021a8ad9c35a0814a5eedf45a8eb3a0b764b865d7016d901fc5a947fc"}, + {file = "dulwich-0.20.50-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:322ff8ff6aa4d6d36294cd36de1c84767eb1903c7db3e7b4475ad091febf5363"}, + {file = "dulwich-0.20.50-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:5d3290a45651c8e534f8e83ae2e30322aefdd162f0f338bae2e79a6ee5a87513"}, + {file = "dulwich-0.20.50-cp310-cp310-win32.whl", hash = "sha256:80ab07131a6e68594441f5c4767e9e44e87fceafc3e347e541c928a18c679bd8"}, + {file = "dulwich-0.20.50-cp310-cp310-win_amd64.whl", hash = "sha256:eefe786a6010f8546baac4912113eeed4e397ddb8c433a345b548a04d4176496"}, + {file = "dulwich-0.20.50-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:df3562dde3079d57287c233d45b790bc967c5aae975c9a7b07ca30e60e055512"}, + {file = "dulwich-0.20.50-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:e1ae18d5805f0c0c5dac65795f8d48660437166b12ee2c0ffea95bfdbf9c1051"}, + {file = "dulwich-0.20.50-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:d2f7df39bd1378d3b0bfb3e7fc930fd0191924af1f0ef587bcd9946afe076c06"}, + {file = "dulwich-0.20.50-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:731e7f319b34251fadeb362ada1d52cc932369d9cdfa25c0e41150cda28773d0"}, + {file = "dulwich-0.20.50-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b4d11d44176e5d2fa8271fc86ad1e0a8731b9ad8f77df64c12846b30e16135eb"}, + {file = "dulwich-0.20.50-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:7aaabb8e4beadd53f75f853a981caaadef3ef130e5645c902705704eaf136daa"}, + {file = "dulwich-0.20.50-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:c3dc9f97ec8d3db08d9723b9fd06f3e52c15b84c800d153cfb59b0a3dc8b8d40"}, + {file = "dulwich-0.20.50-cp311-cp311-win32.whl", hash = "sha256:3b1964fa80cafd5a1fd71615b0313daf6f3295c6ab05656ea0c1d2423539904a"}, + {file = "dulwich-0.20.50-cp311-cp311-win_amd64.whl", hash = "sha256:a24a3893108f3b97beb958670d5f3f2a3bec73a1fe18637a572a85abd949a1c4"}, + {file = "dulwich-0.20.50-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:6d409a282f8848fd6c8d7c7545ad2f75c16de5d5977de202642f1d50fdaac554"}, + {file = "dulwich-0.20.50-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5411d0f1092152e1c0bb916ae490fe181953ae1b8d13f4e68661253e10b78dbb"}, + {file = "dulwich-0.20.50-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6343569f998ce429e2a5d813c56768ac51b496522401db950f0aa44240bfa901"}, + {file = "dulwich-0.20.50-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:a405cd236766060894411614a272cfb86fe86cde5ca73ef264fc4fa5a715fff4"}, + {file = "dulwich-0.20.50-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:ee0f9b02019c0ea84cdd31c00a0c283669b771c85612997a911715cf84e33d99"}, + {file = "dulwich-0.20.50-cp36-cp36m-win32.whl", hash = "sha256:2644466270267270f2157ea6f1c0aa224f6f3bf06a307fc39954e6b4b3d82bae"}, + {file = "dulwich-0.20.50-cp36-cp36m-win_amd64.whl", hash = "sha256:d4629635a97e3af1b5da48071e00c8e70fad85f3266fadabe1f5a8f49172c507"}, + {file = "dulwich-0.20.50-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:0e4862f318d99cc8a500e3622a89613a88c07d957a0f628cdc2ed86addff790f"}, + {file = "dulwich-0.20.50-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c96e3fb9d48c0454dc242c7accc7819780c9a7f29e441a9eff12361ed0fa35f9"}, + {file = "dulwich-0.20.50-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8cc6092a4f0bbbff2e553e87a9c6325955b64ea43fca21297c8182e19ae8a43c"}, + {file = "dulwich-0.20.50-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:519b627d49d273e2fd01c79d09e578675ca6cd05193c1787e9ef165c9a1d66ea"}, + {file = "dulwich-0.20.50-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:6a75cab01b909c4c683c2083e060e378bc01701b7366b5a7d9846ef6d3b9e3d5"}, + {file = "dulwich-0.20.50-cp37-cp37m-win32.whl", hash = "sha256:ea8ffe26d91dbcd5580dbd5a07270a12ea57b091604d77184da0a0d9fad50ed3"}, + {file = "dulwich-0.20.50-cp37-cp37m-win_amd64.whl", hash = "sha256:8f3af857f94021cae1322d86925bfc0dd31e501e885ab5db275473bfac0bb39d"}, + {file = "dulwich-0.20.50-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:3fb35cedb1243bc420d885ef5b4afd642c6ac8f07ddfc7fdbca1becf9948bf7e"}, + {file = "dulwich-0.20.50-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:4bb23a9cec63e16c0e432335f068169b73dd44fa9318dd7cd7a4ca83607ff367"}, + {file = "dulwich-0.20.50-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:5267619b34ddaf8d9a6b841492cd17a971fd25bf9a5657f2de928385c3a08b94"}, + {file = "dulwich-0.20.50-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9091f1d53a3c0747cbf0bd127c64e7f09b770264d8fb53e284383fcdf69154e7"}, + {file = "dulwich-0.20.50-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a6ec7c8fea2b44187a3b545e6c11ab9947ffb122647b07abcdb7cc3aaa770c0e"}, + {file = "dulwich-0.20.50-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:11b180b80363b4fc70664197028181a17ae4c52df9965a29b62a6c52e40c2dbe"}, + {file = "dulwich-0.20.50-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:c83e7840d9d0a94d7033bc109efe0c22dfcdcd816bcd4469085e42809e3bf5ba"}, + {file = "dulwich-0.20.50-cp38-cp38-win32.whl", hash = "sha256:c075f69c2de19d9fd97e3b70832d2b42c6a4a5d909b3ffd1963b67d86029f95f"}, + {file = "dulwich-0.20.50-cp38-cp38-win_amd64.whl", hash = "sha256:06775c5713cfeda778c7c67d4422b5e7554d3a7f644f1dde646cdf486a30285a"}, + {file = "dulwich-0.20.50-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:49f66f1c057c18d7d60363f461f4ab8329320fbe1f02a7a33c255864a7d3c942"}, + {file = "dulwich-0.20.50-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:4e541cd690a5e3d55082ed51732d755917e933cddeb4b0204f2a5ec5d5d7b60b"}, + {file = "dulwich-0.20.50-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:80e8750ee2fa0ab2784a095956077758e5f6107de27f637c4b9d18406652c22c"}, + {file = "dulwich-0.20.50-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fbb6368f18451dc44c95c55e1a609d1a01d3821f7ed480b22b2aea1baca0f4a7"}, + {file = "dulwich-0.20.50-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d3ee45001411b638641819b7b3b33f31f13467c84066e432256580fcab7d8815"}, + {file = "dulwich-0.20.50-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:4842e22ed863a776b36ef8ffe9ed7b772eb452b42c8d02975c29d27e3bc50ab4"}, + {file = "dulwich-0.20.50-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:790e4a641284a7fb4d56ebdaf8b324a5826fbbb9c54307c06f586f9f6a5e56db"}, + {file = "dulwich-0.20.50-cp39-cp39-win32.whl", hash = "sha256:f08406b6b789dea5c95ba1130a0801d8748a67f18be940fe7486a8b481fde875"}, + {file = "dulwich-0.20.50-cp39-cp39-win_amd64.whl", hash = "sha256:78c388ad421199000fb7b5ed5f0c7b509b3e31bd7cad303786a4d0bf89b82f60"}, + {file = "dulwich-0.20.50-pp37-pypy37_pp73-macosx_10_9_x86_64.whl", hash = "sha256:cb194c53109131bcbcd1ca430fcd437cdaf2d33e204e45fbe121c47eaa43e9af"}, + {file = "dulwich-0.20.50-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c7542a72c5640dd0620862d6df8688f02a6c336359b5af9b3fcfe11b7fa6652f"}, + {file = "dulwich-0.20.50-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4aa1d0861517ebbbe0e0084cc9ab4f7ab720624a3eda2bd10e45f774ab858db8"}, + {file = "dulwich-0.20.50-pp37-pypy37_pp73-win_amd64.whl", hash = "sha256:583c6bbc27f13fe2e41a19f6987a42681c6e4f6959beae0a6e5bb033b8b081a8"}, + {file = "dulwich-0.20.50-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:0c61c193d02c0e1e0d758cdd57ae76685c368d09a01f00d704ba88bd96767cfe"}, + {file = "dulwich-0.20.50-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c2edbff3053251985f10702adfafbee118298d383ef5b5b432a5f22d1f1915df"}, + {file = "dulwich-0.20.50-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a344230cadfc5d315752add6ce9d4cfcfc6c85e36bbf57fce9444bcc7c6ea8fb"}, + {file = "dulwich-0.20.50-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:57bff9bde0b6b05b00c6acbb1a94357caddb2908ed7026a48c715ff50d220335"}, + {file = "dulwich-0.20.50-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:e29a3c2037761fa816aa556e78364dfc8e3f44b873db2d17aed96f9b06ac83a3"}, + {file = "dulwich-0.20.50-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2aa2a4a84029625bf9c63771f8a628db1f3be2d2ea3cb8b17942cd4317797152"}, + {file = "dulwich-0.20.50-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dd9fa00971ecf059bb358085a942ecac5be4ff71acdf299f44c8cbc45c18659f"}, + {file = "dulwich-0.20.50-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:af4adac92fb95671ea3a24f2f8e5e5e8f638711ce9c33a3ca6cd68bf1ff7d99f"}, + {file = "dulwich-0.20.50.tar.gz", hash = "sha256:50a941796b2c675be39be728d540c16b5b7ce77eb9e1b3f855650ece6832d2be"}, +] +exceptiongroup = [ + {file = "exceptiongroup-1.1.0-py3-none-any.whl", hash = "sha256:327cbda3da756e2de031a3107b81ab7b3770a602c4d16ca618298c526f4bec1e"}, + {file = "exceptiongroup-1.1.0.tar.gz", hash = "sha256:bcb67d800a4497e1b404c2dd44fca47d3b7a5e5433dbab67f96c1a685cdfdf23"}, +] +executing = [ + {file = "executing-0.10.0-py2.py3-none-any.whl", hash = "sha256:9c745f80cda11eb22b62cbecf21156491a794eb56ab06f9d286a44e62822b24e"}, + {file = "executing-0.10.0.tar.gz", hash = "sha256:d1cd87c2e371e9966261410c5b3769d6df2f9e4a79a83eebd2662dd3388f9833"}, +] +fastapi = [ + {file = "fastapi-0.87.0-py3-none-any.whl", hash = "sha256:254453a2e22f64e2a1b4e1d8baf67d239e55b6c8165c079d25746a5220c81bb4"}, + {file = "fastapi-0.87.0.tar.gz", hash = "sha256:07032e53df9a57165047b4f38731c38bdcc3be5493220471015e2b4b51b486a4"}, +] +filelock = [ + {file = "filelock-3.9.0-py3-none-any.whl", hash = "sha256:f58d535af89bb9ad5cd4df046f741f8553a418c01a7856bf0d173bbc9f6bd16d"}, + {file = "filelock-3.9.0.tar.gz", hash = "sha256:7b319f24340b51f55a2bf7a12ac0755a9b03e718311dac567a0f4f7fabd2f5de"}, +] +flake8 = [ + {file = "flake8-6.0.0-py2.py3-none-any.whl", hash = "sha256:3833794e27ff64ea4e9cf5d410082a8b97ff1a06c16aa3d2027339cd0f1195c7"}, + {file = "flake8-6.0.0.tar.gz", hash = "sha256:c61007e76655af75e6785a931f452915b371dc48f56efd765247c8fe68f2b181"}, +] +gitdb = [ + {file = "gitdb-4.0.10-py3-none-any.whl", hash = "sha256:c286cf298426064079ed96a9e4a9d39e7f3e9bf15ba60701e95f5492f28415c7"}, + {file = "gitdb-4.0.10.tar.gz", hash = "sha256:6eb990b69df4e15bad899ea868dc46572c3f75339735663b81de79b06f17eb9a"}, +] +gitpython = [ + {file = "GitPython-3.1.30-py3-none-any.whl", hash = "sha256:cd455b0000615c60e286208ba540271af9fe531fa6a87cc590a7298785ab2882"}, + {file = "GitPython-3.1.30.tar.gz", hash = "sha256:769c2d83e13f5d938b7688479da374c4e3d49f71549aaf462b646db9602ea6f8"}, +] +gunicorn = [ + {file = "gunicorn-20.1.0-py3-none-any.whl", hash = "sha256:9dcc4547dbb1cb284accfb15ab5667a0e5d1881cc443e0677b4882a4067a807e"}, + {file = "gunicorn-20.1.0.tar.gz", hash = "sha256:e0a968b5ba15f8a328fdfd7ab1fcb5af4470c28aaf7e55df02a99bc13138e6e8"}, +] +h11 = [ + {file = "h11-0.14.0-py3-none-any.whl", hash = "sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761"}, + {file = "h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d"}, +] +html5lib = [ + {file = "html5lib-1.1-py2.py3-none-any.whl", hash = "sha256:0d78f8fde1c230e99fe37986a60526d7049ed4bf8a9fadbad5f00e22e58e041d"}, + {file = "html5lib-1.1.tar.gz", hash = "sha256:b2e5b40261e20f354d198eae92afc10d750afb487ed5e50f9c4eaf07c184146f"}, +] +httptools = [ + {file = "httptools-0.5.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:8f470c79061599a126d74385623ff4744c4e0f4a0997a353a44923c0b561ee51"}, + {file = "httptools-0.5.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e90491a4d77d0cb82e0e7a9cb35d86284c677402e4ce7ba6b448ccc7325c5421"}, + {file = "httptools-0.5.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c1d2357f791b12d86faced7b5736dea9ef4f5ecdc6c3f253e445ee82da579449"}, + {file = "httptools-0.5.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1f90cd6fd97c9a1b7fe9215e60c3bd97336742a0857f00a4cb31547bc22560c2"}, + {file = "httptools-0.5.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:5230a99e724a1bdbbf236a1b58d6e8504b912b0552721c7c6b8570925ee0ccde"}, + {file = "httptools-0.5.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:3a47a34f6015dd52c9eb629c0f5a8a5193e47bf2a12d9a3194d231eaf1bc451a"}, + {file = "httptools-0.5.0-cp310-cp310-win_amd64.whl", hash = "sha256:24bb4bb8ac3882f90aa95403a1cb48465de877e2d5298ad6ddcfdebec060787d"}, + {file = "httptools-0.5.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:e67d4f8734f8054d2c4858570cc4b233bf753f56e85217de4dfb2495904cf02e"}, + {file = "httptools-0.5.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:7e5eefc58d20e4c2da82c78d91b2906f1a947ef42bd668db05f4ab4201a99f49"}, + {file = "httptools-0.5.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0297822cea9f90a38df29f48e40b42ac3d48a28637368f3ec6d15eebefd182f9"}, + {file = "httptools-0.5.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:557be7fbf2bfa4a2ec65192c254e151684545ebab45eca5d50477d562c40f986"}, + {file = "httptools-0.5.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:54465401dbbec9a6a42cf737627fb0f014d50dc7365a6b6cd57753f151a86ff0"}, + {file = "httptools-0.5.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:4d9ebac23d2de960726ce45f49d70eb5466725c0087a078866043dad115f850f"}, + {file = "httptools-0.5.0-cp311-cp311-win_amd64.whl", hash = "sha256:e8a34e4c0ab7b1ca17b8763613783e2458e77938092c18ac919420ab8655c8c1"}, + {file = "httptools-0.5.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:f659d7a48401158c59933904040085c200b4be631cb5f23a7d561fbae593ec1f"}, + {file = "httptools-0.5.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ef1616b3ba965cd68e6f759eeb5d34fbf596a79e84215eeceebf34ba3f61fdc7"}, + {file = "httptools-0.5.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3625a55886257755cb15194efbf209584754e31d336e09e2ffe0685a76cb4b60"}, + {file = "httptools-0.5.0-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:72ad589ba5e4a87e1d404cc1cb1b5780bfcb16e2aec957b88ce15fe879cc08ca"}, + {file = "httptools-0.5.0-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:850fec36c48df5a790aa735417dca8ce7d4b48d59b3ebd6f83e88a8125cde324"}, + {file = "httptools-0.5.0-cp36-cp36m-win_amd64.whl", hash = "sha256:f222e1e9d3f13b68ff8a835574eda02e67277d51631d69d7cf7f8e07df678c86"}, + {file = "httptools-0.5.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:3cb8acf8f951363b617a8420768a9f249099b92e703c052f9a51b66342eea89b"}, + {file = "httptools-0.5.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:550059885dc9c19a072ca6d6735739d879be3b5959ec218ba3e013fd2255a11b"}, + {file = "httptools-0.5.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a04fe458a4597aa559b79c7f48fe3dceabef0f69f562daf5c5e926b153817281"}, + {file = "httptools-0.5.0-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:7d0c1044bce274ec6711f0770fd2d5544fe392591d204c68328e60a46f88843b"}, + {file = "httptools-0.5.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:c6eeefd4435055a8ebb6c5cc36111b8591c192c56a95b45fe2af22d9881eee25"}, + {file = "httptools-0.5.0-cp37-cp37m-win_amd64.whl", hash = "sha256:5b65be160adcd9de7a7e6413a4966665756e263f0d5ddeffde277ffeee0576a5"}, + {file = "httptools-0.5.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:fe9c766a0c35b7e3d6b6939393c8dfdd5da3ac5dec7f971ec9134f284c6c36d6"}, + {file = "httptools-0.5.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:85b392aba273566c3d5596a0a490978c085b79700814fb22bfd537d381dd230c"}, + {file = "httptools-0.5.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f5e3088f4ed33947e16fd865b8200f9cfae1144f41b64a8cf19b599508e096bc"}, + {file = "httptools-0.5.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8c2a56b6aad7cc8f5551d8e04ff5a319d203f9d870398b94702300de50190f63"}, + {file = "httptools-0.5.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:9b571b281a19762adb3f48a7731f6842f920fa71108aff9be49888320ac3e24d"}, + {file = "httptools-0.5.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:aa47ffcf70ba6f7848349b8a6f9b481ee0f7637931d91a9860a1838bfc586901"}, + {file = "httptools-0.5.0-cp38-cp38-win_amd64.whl", hash = "sha256:bede7ee075e54b9a5bde695b4fc8f569f30185891796b2e4e09e2226801d09bd"}, + {file = "httptools-0.5.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:64eba6f168803a7469866a9c9b5263a7463fa8b7a25b35e547492aa7322036b6"}, + {file = "httptools-0.5.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:4b098e4bb1174096a93f48f6193e7d9aa7071506a5877da09a783509ca5fff42"}, + {file = "httptools-0.5.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9423a2de923820c7e82e18980b937893f4aa8251c43684fa1772e341f6e06887"}, + {file = "httptools-0.5.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ca1b7becf7d9d3ccdbb2f038f665c0f4857e08e1d8481cbcc1a86a0afcfb62b2"}, + {file = "httptools-0.5.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:50d4613025f15f4b11f1c54bbed4761c0020f7f921b95143ad6d58c151198142"}, + {file = "httptools-0.5.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:8ffce9d81c825ac1deaa13bc9694c0562e2840a48ba21cfc9f3b4c922c16f372"}, + {file = "httptools-0.5.0-cp39-cp39-win_amd64.whl", hash = "sha256:1af91b3650ce518d226466f30bbba5b6376dbd3ddb1b2be8b0658c6799dd450b"}, + {file = "httptools-0.5.0.tar.gz", hash = "sha256:295874861c173f9101960bba332429bb77ed4dcd8cdf5cee9922eb00e4f6bc09"}, +] +idna = [ + {file = "idna-3.4-py3-none-any.whl", hash = "sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"}, + {file = "idna-3.4.tar.gz", hash = "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4"}, +] +importlib-metadata = [ + {file = "importlib_metadata-6.0.0-py3-none-any.whl", hash = "sha256:7efb448ec9a5e313a57655d35aa54cd3e01b7e1fbcf72dce1bf06119420f5bad"}, + {file = "importlib_metadata-6.0.0.tar.gz", hash = "sha256:e354bedeb60efa6affdcc8ae121b73544a7aa74156d047311948f6d711cd378d"}, +] +iniconfig = [ + {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, + {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, +] +isort = [ + {file = "isort-5.11.4-py3-none-any.whl", hash = "sha256:c033fd0edb91000a7f09527fe5c75321878f98322a77ddcc81adbd83724afb7b"}, + {file = "isort-5.11.4.tar.gz", hash = "sha256:6db30c5ded9815d813932c04c2f85a360bcdd35fed496f4d8f35495ef0a261b6"}, +] +jaraco-classes = [ + {file = "jaraco.classes-3.2.3-py3-none-any.whl", hash = "sha256:2353de3288bc6b82120752201c6b1c1a14b058267fa424ed5ce5984e3b922158"}, + {file = "jaraco.classes-3.2.3.tar.gz", hash = "sha256:89559fa5c1d3c34eff6f631ad80bb21f378dbcbb35dd161fd2c6b93f5be2f98a"}, +] +jeepney = [ + {file = "jeepney-0.8.0-py3-none-any.whl", hash = "sha256:c0a454ad016ca575060802ee4d590dd912e35c122fa04e70306de3d076cce755"}, + {file = "jeepney-0.8.0.tar.gz", hash = "sha256:5efe48d255973902f6badc3ce55e2aa6c5c3b3bc642059ef3a91247bcfcc5806"}, +] +jinja2 = [ + {file = "Jinja2-3.1.2-py3-none-any.whl", hash = "sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61"}, + {file = "Jinja2-3.1.2.tar.gz", hash = "sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852"}, +] +jsonschema = [ + {file = "jsonschema-4.17.3-py3-none-any.whl", hash = "sha256:a870ad254da1a8ca84b6a2905cac29d265f805acc57af304784962a2aa6508f6"}, + {file = "jsonschema-4.17.3.tar.gz", hash = "sha256:0f864437ab8b6076ba6707453ef8f98a6a0d512a80e93f8abdb676f737ecb60d"}, +] +keyring = [ + {file = "keyring-23.13.1-py3-none-any.whl", hash = "sha256:771ed2a91909389ed6148631de678f82ddc73737d85a927f382a8a1b157898cd"}, + {file = "keyring-23.13.1.tar.gz", hash = "sha256:ba2e15a9b35e21908d0aaf4e0a47acc52d6ae33444df0da2b49d41a46ef6d678"}, +] +lockfile = [ + {file = "lockfile-0.12.2-py2.py3-none-any.whl", hash = "sha256:6c3cb24f344923d30b2785d5ad75182c8ea7ac1b6171b08657258ec7429d50fa"}, + {file = "lockfile-0.12.2.tar.gz", hash = "sha256:6aed02de03cba24efabcd600b30540140634fc06cfa603822d508d5361e9f799"}, +] +markupsafe = [ + {file = "MarkupSafe-2.1.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:665a36ae6f8f20a4676b53224e33d456a6f5a72657d9c83c2aa00765072f31f7"}, + {file = "MarkupSafe-2.1.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:340bea174e9761308703ae988e982005aedf427de816d1afe98147668cc03036"}, + {file = "MarkupSafe-2.1.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:22152d00bf4a9c7c83960521fc558f55a1adbc0631fbb00a9471e097b19d72e1"}, + {file = "MarkupSafe-2.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:28057e985dace2f478e042eaa15606c7efccb700797660629da387eb289b9323"}, + {file = "MarkupSafe-2.1.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ca244fa73f50a800cf8c3ebf7fd93149ec37f5cb9596aa8873ae2c1d23498601"}, + {file = "MarkupSafe-2.1.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:d9d971ec1e79906046aa3ca266de79eac42f1dbf3612a05dc9368125952bd1a1"}, + {file = "MarkupSafe-2.1.2-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:7e007132af78ea9df29495dbf7b5824cb71648d7133cf7848a2a5dd00d36f9ff"}, + {file = "MarkupSafe-2.1.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:7313ce6a199651c4ed9d7e4cfb4aa56fe923b1adf9af3b420ee14e6d9a73df65"}, + {file = "MarkupSafe-2.1.2-cp310-cp310-win32.whl", hash = "sha256:c4a549890a45f57f1ebf99c067a4ad0cb423a05544accaf2b065246827ed9603"}, + {file = "MarkupSafe-2.1.2-cp310-cp310-win_amd64.whl", hash = "sha256:835fb5e38fd89328e9c81067fd642b3593c33e1e17e2fdbf77f5676abb14a156"}, + {file = "MarkupSafe-2.1.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:2ec4f2d48ae59bbb9d1f9d7efb9236ab81429a764dedca114f5fdabbc3788013"}, + {file = "MarkupSafe-2.1.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:608e7073dfa9e38a85d38474c082d4281f4ce276ac0010224eaba11e929dd53a"}, + {file = "MarkupSafe-2.1.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:65608c35bfb8a76763f37036547f7adfd09270fbdbf96608be2bead319728fcd"}, + {file = "MarkupSafe-2.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f2bfb563d0211ce16b63c7cb9395d2c682a23187f54c3d79bfec33e6705473c6"}, + {file = "MarkupSafe-2.1.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:da25303d91526aac3672ee6d49a2f3db2d9502a4a60b55519feb1a4c7714e07d"}, + {file = "MarkupSafe-2.1.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:9cad97ab29dfc3f0249b483412c85c8ef4766d96cdf9dcf5a1e3caa3f3661cf1"}, + {file = "MarkupSafe-2.1.2-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:085fd3201e7b12809f9e6e9bc1e5c96a368c8523fad5afb02afe3c051ae4afcc"}, + {file = "MarkupSafe-2.1.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:1bea30e9bf331f3fef67e0a3877b2288593c98a21ccb2cf29b74c581a4eb3af0"}, + {file = "MarkupSafe-2.1.2-cp311-cp311-win32.whl", hash = "sha256:7df70907e00c970c60b9ef2938d894a9381f38e6b9db73c5be35e59d92e06625"}, + {file = "MarkupSafe-2.1.2-cp311-cp311-win_amd64.whl", hash = "sha256:e55e40ff0cc8cc5c07996915ad367fa47da6b3fc091fdadca7f5403239c5fec3"}, + {file = "MarkupSafe-2.1.2-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:a6e40afa7f45939ca356f348c8e23048e02cb109ced1eb8420961b2f40fb373a"}, + {file = "MarkupSafe-2.1.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cf877ab4ed6e302ec1d04952ca358b381a882fbd9d1b07cccbfd61783561f98a"}, + {file = "MarkupSafe-2.1.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:63ba06c9941e46fa389d389644e2d8225e0e3e5ebcc4ff1ea8506dce646f8c8a"}, + {file = "MarkupSafe-2.1.2-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f1cd098434e83e656abf198f103a8207a8187c0fc110306691a2e94a78d0abb2"}, + {file = "MarkupSafe-2.1.2-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:55f44b440d491028addb3b88f72207d71eeebfb7b5dbf0643f7c023ae1fba619"}, + {file = "MarkupSafe-2.1.2-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:a6f2fcca746e8d5910e18782f976489939d54a91f9411c32051b4aab2bd7c513"}, + {file = "MarkupSafe-2.1.2-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:0b462104ba25f1ac006fdab8b6a01ebbfbce9ed37fd37fd4acd70c67c973e460"}, + {file = "MarkupSafe-2.1.2-cp37-cp37m-win32.whl", hash = "sha256:7668b52e102d0ed87cb082380a7e2e1e78737ddecdde129acadb0eccc5423859"}, + {file = "MarkupSafe-2.1.2-cp37-cp37m-win_amd64.whl", hash = "sha256:6d6607f98fcf17e534162f0709aaad3ab7a96032723d8ac8750ffe17ae5a0666"}, + {file = "MarkupSafe-2.1.2-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:a806db027852538d2ad7555b203300173dd1b77ba116de92da9afbc3a3be3eed"}, + {file = "MarkupSafe-2.1.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:a4abaec6ca3ad8660690236d11bfe28dfd707778e2442b45addd2f086d6ef094"}, + {file = "MarkupSafe-2.1.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f03a532d7dee1bed20bc4884194a16160a2de9ffc6354b3878ec9682bb623c54"}, + {file = "MarkupSafe-2.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4cf06cdc1dda95223e9d2d3c58d3b178aa5dacb35ee7e3bbac10e4e1faacb419"}, + {file = "MarkupSafe-2.1.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:22731d79ed2eb25059ae3df1dfc9cb1546691cc41f4e3130fe6bfbc3ecbbecfa"}, + {file = "MarkupSafe-2.1.2-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:f8ffb705ffcf5ddd0e80b65ddf7bed7ee4f5a441ea7d3419e861a12eaf41af58"}, + {file = "MarkupSafe-2.1.2-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:8db032bf0ce9022a8e41a22598eefc802314e81b879ae093f36ce9ddf39ab1ba"}, + {file = "MarkupSafe-2.1.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:2298c859cfc5463f1b64bd55cb3e602528db6fa0f3cfd568d3605c50678f8f03"}, + {file = "MarkupSafe-2.1.2-cp38-cp38-win32.whl", hash = "sha256:50c42830a633fa0cf9e7d27664637532791bfc31c731a87b202d2d8ac40c3ea2"}, + {file = "MarkupSafe-2.1.2-cp38-cp38-win_amd64.whl", hash = "sha256:bb06feb762bade6bf3c8b844462274db0c76acc95c52abe8dbed28ae3d44a147"}, + {file = "MarkupSafe-2.1.2-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:99625a92da8229df6d44335e6fcc558a5037dd0a760e11d84be2260e6f37002f"}, + {file = "MarkupSafe-2.1.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:8bca7e26c1dd751236cfb0c6c72d4ad61d986e9a41bbf76cb445f69488b2a2bd"}, + {file = "MarkupSafe-2.1.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:40627dcf047dadb22cd25ea7ecfe9cbf3bbbad0482ee5920b582f3809c97654f"}, + {file = "MarkupSafe-2.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:40dfd3fefbef579ee058f139733ac336312663c6706d1163b82b3003fb1925c4"}, + {file = "MarkupSafe-2.1.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:090376d812fb6ac5f171e5938e82e7f2d7adc2b629101cec0db8b267815c85e2"}, + {file = "MarkupSafe-2.1.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:2e7821bffe00aa6bd07a23913b7f4e01328c3d5cc0b40b36c0bd81d362faeb65"}, + {file = "MarkupSafe-2.1.2-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:c0a33bc9f02c2b17c3ea382f91b4db0e6cde90b63b296422a939886a7a80de1c"}, + {file = "MarkupSafe-2.1.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:b8526c6d437855442cdd3d87eede9c425c4445ea011ca38d937db299382e6fa3"}, + {file = "MarkupSafe-2.1.2-cp39-cp39-win32.whl", hash = "sha256:137678c63c977754abe9086a3ec011e8fd985ab90631145dfb9294ad09c102a7"}, + {file = "MarkupSafe-2.1.2-cp39-cp39-win_amd64.whl", hash = "sha256:0576fe974b40a400449768941d5d0858cc624e3249dfd1e0c33674e5c7ca7aed"}, + {file = "MarkupSafe-2.1.2.tar.gz", hash = "sha256:abcabc8c2b26036d62d4c746381a6f7cf60aafcc653198ad678306986b09450d"}, +] +mccabe = [ + {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, + {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, +] +mock = [ + {file = "mock-4.0.3-py3-none-any.whl", hash = "sha256:122fcb64ee37cfad5b3f48d7a7d51875d7031aaf3d8be7c42e2bee25044eee62"}, + {file = "mock-4.0.3.tar.gz", hash = "sha256:7d3fbbde18228f4ff2f1f119a45cdffa458b4c0dee32eb4d2bb2f82554bac7bc"}, +] +more-itertools = [ + {file = "more-itertools-9.0.0.tar.gz", hash = "sha256:5a6257e40878ef0520b1803990e3e22303a41b5714006c32a3fd8304b26ea1ab"}, + {file = "more_itertools-9.0.0-py3-none-any.whl", hash = "sha256:250e83d7e81d0c87ca6bd942e6aeab8cc9daa6096d12c5308f3f92fa5e5c1f41"}, +] +motor = [ + {file = "motor-3.1.1-py3-none-any.whl", hash = "sha256:01d93d7c512810dcd85f4d634a7244ba42ff6be7340c869791fe793561e734da"}, + {file = "motor-3.1.1.tar.gz", hash = "sha256:a4bdadf8a08ebb186ba16e557ba432aa867f689a42b80f2e9f8b24bbb1604742"}, +] +msgpack = [ + {file = "msgpack-1.0.4-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:4ab251d229d10498e9a2f3b1e68ef64cb393394ec477e3370c457f9430ce9250"}, + {file = "msgpack-1.0.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:112b0f93202d7c0fef0b7810d465fde23c746a2d482e1e2de2aafd2ce1492c88"}, + {file = "msgpack-1.0.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:002b5c72b6cd9b4bafd790f364b8480e859b4712e91f43014fe01e4f957b8467"}, + {file = "msgpack-1.0.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:35bc0faa494b0f1d851fd29129b2575b2e26d41d177caacd4206d81502d4c6a6"}, + {file = "msgpack-1.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4733359808c56d5d7756628736061c432ded018e7a1dff2d35a02439043321aa"}, + {file = "msgpack-1.0.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:eb514ad14edf07a1dbe63761fd30f89ae79b42625731e1ccf5e1f1092950eaa6"}, + {file = "msgpack-1.0.4-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:c23080fdeec4716aede32b4e0ef7e213c7b1093eede9ee010949f2a418ced6ba"}, + {file = "msgpack-1.0.4-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:49565b0e3d7896d9ea71d9095df15b7f75a035c49be733051c34762ca95bbf7e"}, + {file = "msgpack-1.0.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:aca0f1644d6b5a73eb3e74d4d64d5d8c6c3d577e753a04c9e9c87d07692c58db"}, + {file = "msgpack-1.0.4-cp310-cp310-win32.whl", hash = "sha256:0dfe3947db5fb9ce52aaea6ca28112a170db9eae75adf9339a1aec434dc954ef"}, + {file = "msgpack-1.0.4-cp310-cp310-win_amd64.whl", hash = "sha256:4dea20515f660aa6b7e964433b1808d098dcfcabbebeaaad240d11f909298075"}, + {file = "msgpack-1.0.4-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:e83f80a7fec1a62cf4e6c9a660e39c7f878f603737a0cdac8c13131d11d97f52"}, + {file = "msgpack-1.0.4-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3c11a48cf5e59026ad7cb0dc29e29a01b5a66a3e333dc11c04f7e991fc5510a9"}, + {file = "msgpack-1.0.4-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1276e8f34e139aeff1c77a3cefb295598b504ac5314d32c8c3d54d24fadb94c9"}, + {file = "msgpack-1.0.4-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6c9566f2c39ccced0a38d37c26cc3570983b97833c365a6044edef3574a00c08"}, + {file = "msgpack-1.0.4-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:fcb8a47f43acc113e24e910399376f7277cf8508b27e5b88499f053de6b115a8"}, + {file = "msgpack-1.0.4-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:76ee788122de3a68a02ed6f3a16bbcd97bc7c2e39bd4d94be2f1821e7c4a64e6"}, + {file = "msgpack-1.0.4-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:0a68d3ac0104e2d3510de90a1091720157c319ceeb90d74f7b5295a6bee51bae"}, + {file = "msgpack-1.0.4-cp36-cp36m-win32.whl", hash = "sha256:85f279d88d8e833ec015650fd15ae5eddce0791e1e8a59165318f371158efec6"}, + {file = "msgpack-1.0.4-cp36-cp36m-win_amd64.whl", hash = "sha256:c1683841cd4fa45ac427c18854c3ec3cd9b681694caf5bff04edb9387602d661"}, + {file = "msgpack-1.0.4-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:a75dfb03f8b06f4ab093dafe3ddcc2d633259e6c3f74bb1b01996f5d8aa5868c"}, + {file = "msgpack-1.0.4-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9667bdfdf523c40d2511f0e98a6c9d3603be6b371ae9a238b7ef2dc4e7a427b0"}, + {file = "msgpack-1.0.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:11184bc7e56fd74c00ead4f9cc9a3091d62ecb96e97653add7a879a14b003227"}, + {file = "msgpack-1.0.4-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ac5bd7901487c4a1dd51a8c58f2632b15d838d07ceedaa5e4c080f7190925bff"}, + {file = "msgpack-1.0.4-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:1e91d641d2bfe91ba4c52039adc5bccf27c335356055825c7f88742c8bb900dd"}, + {file = "msgpack-1.0.4-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:2a2df1b55a78eb5f5b7d2a4bb221cd8363913830145fad05374a80bf0877cb1e"}, + {file = "msgpack-1.0.4-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:545e3cf0cf74f3e48b470f68ed19551ae6f9722814ea969305794645da091236"}, + {file = "msgpack-1.0.4-cp37-cp37m-win32.whl", hash = "sha256:2cc5ca2712ac0003bcb625c96368fd08a0f86bbc1a5578802512d87bc592fe44"}, + {file = "msgpack-1.0.4-cp37-cp37m-win_amd64.whl", hash = "sha256:eba96145051ccec0ec86611fe9cf693ce55f2a3ce89c06ed307de0e085730ec1"}, + {file = "msgpack-1.0.4-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:7760f85956c415578c17edb39eed99f9181a48375b0d4a94076d84148cf67b2d"}, + {file = "msgpack-1.0.4-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:449e57cc1ff18d3b444eb554e44613cffcccb32805d16726a5494038c3b93dab"}, + {file = "msgpack-1.0.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:d603de2b8d2ea3f3bcb2efe286849aa7a81531abc52d8454da12f46235092bcb"}, + {file = "msgpack-1.0.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:48f5d88c99f64c456413d74a975bd605a9b0526293218a3b77220a2c15458ba9"}, + {file = "msgpack-1.0.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6916c78f33602ecf0509cc40379271ba0f9ab572b066bd4bdafd7434dee4bc6e"}, + {file = "msgpack-1.0.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:81fc7ba725464651190b196f3cd848e8553d4d510114a954681fd0b9c479d7e1"}, + {file = "msgpack-1.0.4-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:d5b5b962221fa2c5d3a7f8133f9abffc114fe218eb4365e40f17732ade576c8e"}, + {file = "msgpack-1.0.4-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:77ccd2af37f3db0ea59fb280fa2165bf1b096510ba9fe0cc2bf8fa92a22fdb43"}, + {file = "msgpack-1.0.4-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:b17be2478b622939e39b816e0aa8242611cc8d3583d1cd8ec31b249f04623243"}, + {file = "msgpack-1.0.4-cp38-cp38-win32.whl", hash = "sha256:2bb8cdf50dd623392fa75525cce44a65a12a00c98e1e37bf0fb08ddce2ff60d2"}, + {file = "msgpack-1.0.4-cp38-cp38-win_amd64.whl", hash = "sha256:26b8feaca40a90cbe031b03d82b2898bf560027160d3eae1423f4a67654ec5d6"}, + {file = "msgpack-1.0.4-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:462497af5fd4e0edbb1559c352ad84f6c577ffbbb708566a0abaaa84acd9f3ae"}, + {file = "msgpack-1.0.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:2999623886c5c02deefe156e8f869c3b0aaeba14bfc50aa2486a0415178fce55"}, + {file = "msgpack-1.0.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:f0029245c51fd9473dc1aede1160b0a29f4a912e6b1dd353fa6d317085b219da"}, + {file = "msgpack-1.0.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ed6f7b854a823ea44cf94919ba3f727e230da29feb4a99711433f25800cf747f"}, + {file = "msgpack-1.0.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0df96d6eaf45ceca04b3f3b4b111b86b33785683d682c655063ef8057d61fd92"}, + {file = "msgpack-1.0.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6a4192b1ab40f8dca3f2877b70e63799d95c62c068c84dc028b40a6cb03ccd0f"}, + {file = "msgpack-1.0.4-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:0e3590f9fb9f7fbc36df366267870e77269c03172d086fa76bb4eba8b2b46624"}, + {file = "msgpack-1.0.4-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:1576bd97527a93c44fa856770197dec00d223b0b9f36ef03f65bac60197cedf8"}, + {file = "msgpack-1.0.4-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:63e29d6e8c9ca22b21846234913c3466b7e4ee6e422f205a2988083de3b08cae"}, + {file = "msgpack-1.0.4-cp39-cp39-win32.whl", hash = "sha256:fb62ea4b62bfcb0b380d5680f9a4b3f9a2d166d9394e9bbd9666c0ee09a3645c"}, + {file = "msgpack-1.0.4-cp39-cp39-win_amd64.whl", hash = "sha256:4d5834a2a48965a349da1c5a79760d94a1a0172fbb5ab6b5b33cbf8447e109ce"}, + {file = "msgpack-1.0.4.tar.gz", hash = "sha256:f5d869c18f030202eb412f08b28d2afeea553d6613aee89e200d7aca7ef01f5f"}, +] +mypy = [ + {file = "mypy-0.991-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:7d17e0a9707d0772f4a7b878f04b4fd11f6f5bcb9b3813975a9b13c9332153ab"}, + {file = "mypy-0.991-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0714258640194d75677e86c786e80ccf294972cc76885d3ebbb560f11db0003d"}, + {file = "mypy-0.991-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:0c8f3be99e8a8bd403caa8c03be619544bc2c77a7093685dcf308c6b109426c6"}, + {file = "mypy-0.991-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc9ec663ed6c8f15f4ae9d3c04c989b744436c16d26580eaa760ae9dd5d662eb"}, + {file = "mypy-0.991-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:4307270436fd7694b41f913eb09210faff27ea4979ecbcd849e57d2da2f65305"}, + {file = "mypy-0.991-cp310-cp310-win_amd64.whl", hash = "sha256:901c2c269c616e6cb0998b33d4adbb4a6af0ac4ce5cd078afd7bc95830e62c1c"}, + {file = "mypy-0.991-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:d13674f3fb73805ba0c45eb6c0c3053d218aa1f7abead6e446d474529aafc372"}, + {file = "mypy-0.991-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:1c8cd4fb70e8584ca1ed5805cbc7c017a3d1a29fb450621089ffed3e99d1857f"}, + {file = "mypy-0.991-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:209ee89fbb0deed518605edddd234af80506aec932ad28d73c08f1400ef80a33"}, + {file = "mypy-0.991-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:37bd02ebf9d10e05b00d71302d2c2e6ca333e6c2a8584a98c00e038db8121f05"}, + {file = "mypy-0.991-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:26efb2fcc6b67e4d5a55561f39176821d2adf88f2745ddc72751b7890f3194ad"}, + {file = "mypy-0.991-cp311-cp311-win_amd64.whl", hash = "sha256:3a700330b567114b673cf8ee7388e949f843b356a73b5ab22dd7cff4742a5297"}, + {file = "mypy-0.991-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:1f7d1a520373e2272b10796c3ff721ea1a0712288cafaa95931e66aa15798813"}, + {file = "mypy-0.991-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:641411733b127c3e0dab94c45af15fea99e4468f99ac88b39efb1ad677da5711"}, + {file = "mypy-0.991-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:3d80e36b7d7a9259b740be6d8d906221789b0d836201af4234093cae89ced0cd"}, + {file = "mypy-0.991-cp37-cp37m-win_amd64.whl", hash = "sha256:e62ebaad93be3ad1a828a11e90f0e76f15449371ffeecca4a0a0b9adc99abcef"}, + {file = "mypy-0.991-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:b86ce2c1866a748c0f6faca5232059f881cda6dda2a893b9a8373353cfe3715a"}, + {file = "mypy-0.991-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:ac6e503823143464538efda0e8e356d871557ef60ccd38f8824a4257acc18d93"}, + {file = "mypy-0.991-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:0cca5adf694af539aeaa6ac633a7afe9bbd760df9d31be55ab780b77ab5ae8bf"}, + {file = "mypy-0.991-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a12c56bf73cdab116df96e4ff39610b92a348cc99a1307e1da3c3768bbb5b135"}, + {file = "mypy-0.991-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:652b651d42f155033a1967739788c436491b577b6a44e4c39fb340d0ee7f0d70"}, + {file = "mypy-0.991-cp38-cp38-win_amd64.whl", hash = "sha256:4175593dc25d9da12f7de8de873a33f9b2b8bdb4e827a7cae952e5b1a342e243"}, + {file = "mypy-0.991-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:98e781cd35c0acf33eb0295e8b9c55cdbef64fcb35f6d3aa2186f289bed6e80d"}, + {file = "mypy-0.991-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:6d7464bac72a85cb3491c7e92b5b62f3dcccb8af26826257760a552a5e244aa5"}, + {file = "mypy-0.991-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:c9166b3f81a10cdf9b49f2d594b21b31adadb3d5e9db9b834866c3258b695be3"}, + {file = "mypy-0.991-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b8472f736a5bfb159a5e36740847808f6f5b659960115ff29c7cecec1741c648"}, + {file = "mypy-0.991-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5e80e758243b97b618cdf22004beb09e8a2de1af481382e4d84bc52152d1c476"}, + {file = "mypy-0.991-cp39-cp39-win_amd64.whl", hash = "sha256:74e259b5c19f70d35fcc1ad3d56499065c601dfe94ff67ae48b85596b9ec1461"}, + {file = "mypy-0.991-py3-none-any.whl", hash = "sha256:de32edc9b0a7e67c2775e574cb061a537660e51210fbf6006b0b36ea695ae9bb"}, + {file = "mypy-0.991.tar.gz", hash = "sha256:3c0165ba8f354a6d9881809ef29f1a9318a236a6d81c690094c5df32107bde06"}, +] +mypy-extensions = [ + {file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"}, + {file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"}, +] +odmantic = [ + {file = "odmantic-0.9.2-py3-none-any.whl", hash = "sha256:a82f4fe6a6face24cf0cd0738c9bb32564219cb5a5ed6b0a58e92a4c2048e4d8"}, + {file = "odmantic-0.9.2.tar.gz", hash = "sha256:9780087e1bc2afbd0c1f16b2d18137889dbe7e0df12af0762d6b6b17dadd36be"}, +] +packaging = [ + {file = "packaging-23.0-py3-none-any.whl", hash = "sha256:714ac14496c3e68c99c29b00845f7a2b85f3bb6f1078fd9f72fd20f0570002b2"}, + {file = "packaging-23.0.tar.gz", hash = "sha256:b6ad297f8907de0fa2fe1ccbd26fdaf387f5f47c7275fedf8cce89f99446cf97"}, +] +pathspec = [ + {file = "pathspec-0.10.3-py3-none-any.whl", hash = "sha256:3c95343af8b756205e2aba76e843ba9520a24dd84f68c22b9f93251507509dd6"}, + {file = "pathspec-0.10.3.tar.gz", hash = "sha256:56200de4077d9d0791465aa9095a01d421861e405b5096955051deefd697d6f6"}, +] +pbr = [ + {file = "pbr-5.11.1-py2.py3-none-any.whl", hash = "sha256:567f09558bae2b3ab53cb3c1e2e33e726ff3338e7bae3db5dc954b3a44eef12b"}, + {file = "pbr-5.11.1.tar.gz", hash = "sha256:aefc51675b0b533d56bb5fd1c8c6c0522fe31896679882e1c4c63d5e4a0fccb3"}, +] +pdoc = [ + {file = "pdoc-12.3.1-py3-none-any.whl", hash = "sha256:c3f24f31286e634de9c76fa6e67bd5c0c5e74360b41dc91e6b82499831eb52d8"}, + {file = "pdoc-12.3.1.tar.gz", hash = "sha256:453236f225feddb8a9071428f1982a78d74b9b3da4bc4433aedb64dbd0cc87ab"}, +] +pexpect = [ + {file = "pexpect-4.8.0-py2.py3-none-any.whl", hash = "sha256:0b48a55dcb3c05f3329815901ea4fc1537514d6ba867a152b581d69ae3710937"}, + {file = "pexpect-4.8.0.tar.gz", hash = "sha256:fc65a43959d153d0114afe13997d439c22823a27cefceb5ff35c2178c6784c0c"}, +] +pkginfo = [ + {file = "pkginfo-1.9.6-py3-none-any.whl", hash = "sha256:4b7a555a6d5a22169fcc9cf7bfd78d296b0361adad412a346c1226849af5e546"}, + {file = "pkginfo-1.9.6.tar.gz", hash = "sha256:8fd5896e8718a4372f0ea9cc9d96f6417c9b986e23a4d116dda26b62cc29d046"}, +] +platformdirs = [ + {file = "platformdirs-2.6.2-py3-none-any.whl", hash = "sha256:83c8f6d04389165de7c9b6f0c682439697887bca0aa2f1c87ef1826be3584490"}, + {file = "platformdirs-2.6.2.tar.gz", hash = "sha256:e1fea1fe471b9ff8332e229df3cb7de4f53eeea4998d3b6bfff542115e998bd2"}, +] +pluggy = [ + {file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"}, + {file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"}, +] +poetry = [ + {file = "poetry-1.2.2-py3-none-any.whl", hash = "sha256:93ea3c4a622485c2a7b7249f1e34e4ac84f8229ded76153b67506313201b154f"}, + {file = "poetry-1.2.2.tar.gz", hash = "sha256:6d9ed0b1b826a0a79190f2078d7d78483fa24bf2494f3b170e354eaa5e7b5ea1"}, +] +poetry-core = [ + {file = "poetry-core-1.3.2.tar.gz", hash = "sha256:0ab006a40cb38d6a38b97264f6835da2f08a96912f2728ce668e9ac6a34f686f"}, + {file = "poetry_core-1.3.2-py3-none-any.whl", hash = "sha256:ea0f5a90b339cde132b4e43cff78a1b440cd928db864bb67cfc97fdfcefe7218"}, +] +poetry-plugin-export = [ + {file = "poetry_plugin_export-1.2.0-py3-none-any.whl", hash = "sha256:109fb43ebfd0e79d8be2e7f9d43ba2ae357c4975a18dfc0cfdd9597dd086790e"}, + {file = "poetry_plugin_export-1.2.0.tar.gz", hash = "sha256:9a1dd42765408931d7831738749022651d43a2968b67c988db1b7a567dfe41ef"}, +] +ptyprocess = [ + {file = "ptyprocess-0.7.0-py2.py3-none-any.whl", hash = "sha256:4b41f3967fce3af57cc7e94b888626c18bf37a083e3651ca8feeb66d492fef35"}, + {file = "ptyprocess-0.7.0.tar.gz", hash = "sha256:5c5d0a3b48ceee0b48485e0c26037c0acd7d29765ca3fbb5cb3831d347423220"}, +] +py = [ + {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, + {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, +] +pycodestyle = [ + {file = "pycodestyle-2.10.0-py2.py3-none-any.whl", hash = "sha256:8a4eaf0d0495c7395bdab3589ac2db602797d76207242c17d470186815706610"}, + {file = "pycodestyle-2.10.0.tar.gz", hash = "sha256:347187bdb476329d98f695c213d7295a846d1152ff4fe9bacb8a9590b8ee7053"}, +] +pycparser = [ + {file = "pycparser-2.21-py2.py3-none-any.whl", hash = "sha256:8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9"}, + {file = "pycparser-2.21.tar.gz", hash = "sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206"}, +] +pydantic = [ + {file = "pydantic-1.10.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:b5635de53e6686fe7a44b5cf25fcc419a0d5e5c1a1efe73d49d48fe7586db854"}, + {file = "pydantic-1.10.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:6dc1cc241440ed7ca9ab59d9929075445da6b7c94ced281b3dd4cfe6c8cff817"}, + {file = "pydantic-1.10.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:51bdeb10d2db0f288e71d49c9cefa609bca271720ecd0c58009bd7504a0c464c"}, + {file = "pydantic-1.10.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:78cec42b95dbb500a1f7120bdf95c401f6abb616bbe8785ef09887306792e66e"}, + {file = "pydantic-1.10.4-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:8775d4ef5e7299a2f4699501077a0defdaac5b6c4321173bcb0f3c496fbadf85"}, + {file = "pydantic-1.10.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:572066051eeac73d23f95ba9a71349c42a3e05999d0ee1572b7860235b850cc6"}, + {file = "pydantic-1.10.4-cp310-cp310-win_amd64.whl", hash = "sha256:7feb6a2d401f4d6863050f58325b8d99c1e56f4512d98b11ac64ad1751dc647d"}, + {file = "pydantic-1.10.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:39f4a73e5342b25c2959529f07f026ef58147249f9b7431e1ba8414a36761f53"}, + {file = "pydantic-1.10.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:983e720704431a6573d626b00662eb78a07148c9115129f9b4351091ec95ecc3"}, + {file = "pydantic-1.10.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:75d52162fe6b2b55964fbb0af2ee58e99791a3138588c482572bb6087953113a"}, + {file = "pydantic-1.10.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fdf8d759ef326962b4678d89e275ffc55b7ce59d917d9f72233762061fd04a2d"}, + {file = "pydantic-1.10.4-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:05a81b006be15655b2a1bae5faa4280cf7c81d0e09fcb49b342ebf826abe5a72"}, + {file = "pydantic-1.10.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:d88c4c0e5c5dfd05092a4b271282ef0588e5f4aaf345778056fc5259ba098857"}, + {file = "pydantic-1.10.4-cp311-cp311-win_amd64.whl", hash = "sha256:6a05a9db1ef5be0fe63e988f9617ca2551013f55000289c671f71ec16f4985e3"}, + {file = "pydantic-1.10.4-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:887ca463c3bc47103c123bc06919c86720e80e1214aab79e9b779cda0ff92a00"}, + {file = "pydantic-1.10.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fdf88ab63c3ee282c76d652fc86518aacb737ff35796023fae56a65ced1a5978"}, + {file = "pydantic-1.10.4-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a48f1953c4a1d9bd0b5167ac50da9a79f6072c63c4cef4cf2a3736994903583e"}, + {file = "pydantic-1.10.4-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:a9f2de23bec87ff306aef658384b02aa7c32389766af3c5dee9ce33e80222dfa"}, + {file = "pydantic-1.10.4-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:cd8702c5142afda03dc2b1ee6bc358b62b3735b2cce53fc77b31ca9f728e4bc8"}, + {file = "pydantic-1.10.4-cp37-cp37m-win_amd64.whl", hash = "sha256:6e7124d6855b2780611d9f5e1e145e86667eaa3bd9459192c8dc1a097f5e9903"}, + {file = "pydantic-1.10.4-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:0b53e1d41e97063d51a02821b80538053ee4608b9a181c1005441f1673c55423"}, + {file = "pydantic-1.10.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:55b1625899acd33229c4352ce0ae54038529b412bd51c4915349b49ca575258f"}, + {file = "pydantic-1.10.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:301d626a59edbe5dfb48fcae245896379a450d04baeed50ef40d8199f2733b06"}, + {file = "pydantic-1.10.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b6f9d649892a6f54a39ed56b8dfd5e08b5f3be5f893da430bed76975f3735d15"}, + {file = "pydantic-1.10.4-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:d7b5a3821225f5c43496c324b0d6875fde910a1c2933d726a743ce328fbb2a8c"}, + {file = "pydantic-1.10.4-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:f2f7eb6273dd12472d7f218e1fef6f7c7c2f00ac2e1ecde4db8824c457300416"}, + {file = "pydantic-1.10.4-cp38-cp38-win_amd64.whl", hash = "sha256:4b05697738e7d2040696b0a66d9f0a10bec0efa1883ca75ee9e55baf511909d6"}, + {file = "pydantic-1.10.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:a9a6747cac06c2beb466064dda999a13176b23535e4c496c9d48e6406f92d42d"}, + {file = "pydantic-1.10.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:eb992a1ef739cc7b543576337bebfc62c0e6567434e522e97291b251a41dad7f"}, + {file = "pydantic-1.10.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:990406d226dea0e8f25f643b370224771878142155b879784ce89f633541a024"}, + {file = "pydantic-1.10.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2e82a6d37a95e0b1b42b82ab340ada3963aea1317fd7f888bb6b9dfbf4fff57c"}, + {file = "pydantic-1.10.4-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:9193d4f4ee8feca58bc56c8306bcb820f5c7905fd919e0750acdeeeef0615b28"}, + {file = "pydantic-1.10.4-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:2b3ce5f16deb45c472dde1a0ee05619298c864a20cded09c4edd820e1454129f"}, + {file = "pydantic-1.10.4-cp39-cp39-win_amd64.whl", hash = "sha256:9cbdc268a62d9a98c56e2452d6c41c0263d64a2009aac69246486f01b4f594c4"}, + {file = "pydantic-1.10.4-py3-none-any.whl", hash = "sha256:4948f264678c703f3877d1c8877c4e3b2e12e549c57795107f08cf70c6ec7774"}, + {file = "pydantic-1.10.4.tar.gz", hash = "sha256:b9a3859f24eb4e097502a3be1fb4b2abb79b6103dd9e2e0edb70613a4459a648"}, +] +pyflakes = [ + {file = "pyflakes-3.0.1-py2.py3-none-any.whl", hash = "sha256:ec55bf7fe21fff7f1ad2f7da62363d749e2a470500eab1b555334b67aa1ef8cf"}, + {file = "pyflakes-3.0.1.tar.gz", hash = "sha256:ec8b276a6b60bd80defed25add7e439881c19e64850afd9b346283d4165fd0fd"}, +] +pygments = [ + {file = "Pygments-2.14.0-py3-none-any.whl", hash = "sha256:fa7bd7bd2771287c0de303af8bfdfc731f51bd2c6a47ab69d117138893b82717"}, + {file = "Pygments-2.14.0.tar.gz", hash = "sha256:b3ed06a9e8ac9a9aae5a6f5dbe78a8a58655d17b43b93c078f094ddc476ae297"}, +] +pylev = [ + {file = "pylev-1.4.0-py2.py3-none-any.whl", hash = "sha256:7b2e2aa7b00e05bb3f7650eb506fc89f474f70493271a35c242d9a92188ad3dd"}, + {file = "pylev-1.4.0.tar.gz", hash = "sha256:9e77e941042ad3a4cc305dcdf2b2dec1aec2fbe3dd9015d2698ad02b173006d1"}, +] +pymongo = [ + {file = "pymongo-4.3.3-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:74731c9e423c93cbe791f60c27030b6af6a948cef67deca079da6cd1bb583a8e"}, + {file = "pymongo-4.3.3-cp310-cp310-manylinux1_i686.whl", hash = "sha256:66413c50d510e5bcb0afc79880d1693a2185bcea003600ed898ada31338c004e"}, + {file = "pymongo-4.3.3-cp310-cp310-manylinux2014_aarch64.whl", hash = "sha256:9b87b23570565a6ddaa9244d87811c2ee9cffb02a753c8a2da9c077283d85845"}, + {file = "pymongo-4.3.3-cp310-cp310-manylinux2014_i686.whl", hash = "sha256:695939036a320f4329ccf1627edefbbb67cc7892b8222d297b0dd2313742bfee"}, + {file = "pymongo-4.3.3-cp310-cp310-manylinux2014_ppc64le.whl", hash = "sha256:ffcc8394123ea8d43fff8e5d000095fe7741ce3f8988366c5c919c4f5eb179d3"}, + {file = "pymongo-4.3.3-cp310-cp310-manylinux2014_s390x.whl", hash = "sha256:943f208840777f34312c103a2d1caab02d780c4e9be26b3714acf6c4715ba7e1"}, + {file = "pymongo-4.3.3-cp310-cp310-manylinux2014_x86_64.whl", hash = "sha256:01f7cbe88d22440b6594c955e37312d932fd632ffed1a86d0c361503ca82cc9d"}, + {file = "pymongo-4.3.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cdb87309de97c63cb9a69132e1cb16be470e58cffdfbad68fdd1dc292b22a840"}, + {file = "pymongo-4.3.3-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d86c35d94b5499689354ccbc48438a79f449481ee6300f3e905748edceed78e7"}, + {file = "pymongo-4.3.3-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a966d5304b7d90c45c404914e06bbf02c5bf7e99685c6c12f0047ef2aa837142"}, + {file = "pymongo-4.3.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:be1d2ce7e269215c3ee9a215e296b7a744aff4f39233486d2c4d77f5f0c561a6"}, + {file = "pymongo-4.3.3-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:55b6163dac53ef1e5d834297810c178050bd0548a4136cd4e0f56402185916ca"}, + {file = "pymongo-4.3.3-cp310-cp310-win32.whl", hash = "sha256:dc0cff74cd36d7e1edba91baa09622c35a8a57025f2f2b7a41e3f83b1db73186"}, + {file = "pymongo-4.3.3-cp310-cp310-win_amd64.whl", hash = "sha256:cafa52873ae12baa512a8721afc20de67a36886baae6a5f394ddef0ce9391f91"}, + {file = "pymongo-4.3.3-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:599d3f6fbef31933b96e2d906b0f169b3371ff79ea6aaf6ecd76c947a3508a3d"}, + {file = "pymongo-4.3.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c0640b4e9d008e13956b004d1971a23377b3d45491f87082161c92efb1e6c0d6"}, + {file = "pymongo-4.3.3-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:341221e2f2866a5960e6f8610f4cbac0bb13097f3b1a289aa55aba984fc0d969"}, + {file = "pymongo-4.3.3-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e7fac06a539daef4fcf5d8288d0d21b412f9b750454cd5a3cf90484665db442a"}, + {file = "pymongo-4.3.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d3a51901066696c4af38c6c63a1f0aeffd5e282367ff475de8c191ec9609b56d"}, + {file = "pymongo-4.3.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f3055510fdfdb1775bc8baa359783022f70bb553f2d46e153c094dfcb08578ff"}, + {file = "pymongo-4.3.3-cp311-cp311-win32.whl", hash = "sha256:524d78673518dcd352a91541ecd2839c65af92dc883321c2109ef6e5cd22ef23"}, + {file = "pymongo-4.3.3-cp311-cp311-win_amd64.whl", hash = "sha256:b8a03af1ce79b902a43f5f694c4ca8d92c2a4195db0966f08f266549e2fc49bc"}, + {file = "pymongo-4.3.3-cp37-cp37m-macosx_10_6_intel.whl", hash = "sha256:39b03045c71f761aee96a12ebfbc2f4be89e724ff6f5e31c2574c1a0e2add8bd"}, + {file = "pymongo-4.3.3-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:6fcfbf435eebf8a1765c6d1f46821740ebe9f54f815a05c8fc30d789ef43cb12"}, + {file = "pymongo-4.3.3-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:7d43ac9c7eeda5100fb0a7152fab7099c9cf9e5abd3bb36928eb98c7d7a339c6"}, + {file = "pymongo-4.3.3-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:3b93043b14ba7eb08c57afca19751658ece1cfa2f0b7b1fb5c7a41452fbb8482"}, + {file = "pymongo-4.3.3-cp37-cp37m-manylinux2014_i686.whl", hash = "sha256:c09956606c08c4a7c6178a04ba2dd9388fcc5db32002ade9c9bc865ab156ab6d"}, + {file = "pymongo-4.3.3-cp37-cp37m-manylinux2014_ppc64le.whl", hash = "sha256:b0cfe925610f2fd59555bb7fc37bd739e4b197d33f2a8b2fae7b9c0c6640318c"}, + {file = "pymongo-4.3.3-cp37-cp37m-manylinux2014_s390x.whl", hash = "sha256:4d00b91c77ceb064c9b0459f0d6ea5bfdbc53ea9e17cf75731e151ef25a830c7"}, + {file = "pymongo-4.3.3-cp37-cp37m-manylinux2014_x86_64.whl", hash = "sha256:c6258a3663780ae47ba73d43eb63c79c40ffddfb764e09b56df33be2f9479837"}, + {file = "pymongo-4.3.3-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c29e758f0e734e1e90357ae01ec9c6daf19ff60a051192fe110d8fb25c62600e"}, + {file = "pymongo-4.3.3-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:12f3621a46cdc7a9ba8080422262398a91762a581d27e0647746588d3f995c88"}, + {file = "pymongo-4.3.3-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:47f7aa217b25833cd6f0e72b0d224be55393c2692b4f5e0561cb3beeb10296e9"}, + {file = "pymongo-4.3.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2c2fdc855149efe7cdcc2a01ca02bfa24761c640203ea94df467f3baf19078be"}, + {file = "pymongo-4.3.3-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5effd87c7d363890259eac16c56a4e8da307286012c076223997f8cc4a8c435b"}, + {file = "pymongo-4.3.3-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:6dd1cf2995fdbd64fc0802313e8323f5fa18994d51af059b5b8862b73b5e53f0"}, + {file = "pymongo-4.3.3-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:bb869707d8e30645ed6766e44098600ca6cdf7989c22a3ea2b7966bb1d98d4b2"}, + {file = "pymongo-4.3.3-cp37-cp37m-win32.whl", hash = "sha256:49210feb0be8051a64d71691f0acbfbedc33e149f0a5d6e271fddf6a12493fed"}, + {file = "pymongo-4.3.3-cp37-cp37m-win_amd64.whl", hash = "sha256:54c377893f2cbbffe39abcff5ff2e917b082c364521fa079305f6f064e1a24a9"}, + {file = "pymongo-4.3.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:c184ec5be465c0319440734491e1aa4709b5f3ba75fdfc9dbbc2ae715a7f6829"}, + {file = "pymongo-4.3.3-cp38-cp38-manylinux1_i686.whl", hash = "sha256:dca34367a4e77fcab0693e603a959878eaf2351585e7d752cac544bc6b2dee46"}, + {file = "pymongo-4.3.3-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:cd6a4afb20fb3c26a7bfd4611a0bbb24d93cbd746f5eb881f114b5e38fd55501"}, + {file = "pymongo-4.3.3-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:0c466710871d0026c190fc4141e810cf9d9affbf4935e1d273fbdc7d7cda6143"}, + {file = "pymongo-4.3.3-cp38-cp38-manylinux2014_i686.whl", hash = "sha256:d07d06dba5b5f7d80f9cc45501456e440f759fe79f9895922ed486237ac378a8"}, + {file = "pymongo-4.3.3-cp38-cp38-manylinux2014_ppc64le.whl", hash = "sha256:711bc52cb98e7892c03e9b669bebd89c0a890a90dbc6d5bb2c47f30239bac6e9"}, + {file = "pymongo-4.3.3-cp38-cp38-manylinux2014_s390x.whl", hash = "sha256:34b040e095e1671df0c095ec0b04fc4ebb19c4c160f87c2b55c079b16b1a6b00"}, + {file = "pymongo-4.3.3-cp38-cp38-manylinux2014_x86_64.whl", hash = "sha256:4ed00f96e147f40b565fe7530d1da0b0f3ab803d5dd5b683834500fa5d195ec4"}, + {file = "pymongo-4.3.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ef888f48eb9203ee1e04b9fb27429017b290fb916f1e7826c2f7808c88798394"}, + {file = "pymongo-4.3.3-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:316498b642c00401370b2156b5233b256f9b33799e0a8d9d0b8a7da217a20fca"}, + {file = "pymongo-4.3.3-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fa7e202feb683dad74f00dea066690448d0cfa310f8a277db06ec8eb466601b5"}, + {file = "pymongo-4.3.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:52896e22115c97f1c829db32aa2760b0d61839cfe08b168c2b1d82f31dbc5f55"}, + {file = "pymongo-4.3.3-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7c051fe37c96b9878f37fa58906cb53ecd13dcb7341d3a85f1e2e2f6b10782d9"}, + {file = "pymongo-4.3.3-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:5134d33286c045393c7beb51be29754647cec5ebc051cf82799c5ce9820a2ca2"}, + {file = "pymongo-4.3.3-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:a9c2885b4a8e6e39db5662d8b02ca6dcec796a45e48c2de12552841f061692ba"}, + {file = "pymongo-4.3.3-cp38-cp38-win32.whl", hash = "sha256:a6cd6f1db75eb07332bd3710f58f5fce4967eadbf751bad653842750a61bda62"}, + {file = "pymongo-4.3.3-cp38-cp38-win_amd64.whl", hash = "sha256:d5571b6978750601f783cea07fb6b666837010ca57e5cefa389c1d456f6222e2"}, + {file = "pymongo-4.3.3-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:81d1a7303bd02ca1c5be4aacd4db73593f573ba8e0c543c04c6da6275fd7a47e"}, + {file = "pymongo-4.3.3-cp39-cp39-manylinux1_i686.whl", hash = "sha256:016c412118e1c23fef3a1eada4f83ae6e8844fd91986b2e066fc1b0013cdd9ae"}, + {file = "pymongo-4.3.3-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:8fd6e191b92a10310f5a6cfe10d6f839d79d192fb02480bda325286bd1c7b385"}, + {file = "pymongo-4.3.3-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:e2961b05f9c04a53da8bfc72f1910b6aec7205fcf3ac9c036d24619979bbee4b"}, + {file = "pymongo-4.3.3-cp39-cp39-manylinux2014_i686.whl", hash = "sha256:b38a96b3eed8edc515b38257f03216f382c4389d022a8834667e2bc63c0c0c31"}, + {file = "pymongo-4.3.3-cp39-cp39-manylinux2014_ppc64le.whl", hash = "sha256:c1a70c51da9fa95bd75c167edb2eb3f3c4d27bc4ddd29e588f21649d014ec0b7"}, + {file = "pymongo-4.3.3-cp39-cp39-manylinux2014_s390x.whl", hash = "sha256:8a06a0c02f5606330e8f2e2f3b7949877ca7e4024fa2bff5a4506bec66c49ec7"}, + {file = "pymongo-4.3.3-cp39-cp39-manylinux2014_x86_64.whl", hash = "sha256:6c2216d8b6a6d019c6f4b1ad55f890e5e77eb089309ffc05b6911c09349e7474"}, + {file = "pymongo-4.3.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:eac0a143ef4f28f49670bf89cb15847eb80b375d55eba401ca2f777cd425f338"}, + {file = "pymongo-4.3.3-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:08fc250b5552ee97ceeae0f52d8b04f360291285fc7437f13daa516ce38fdbc6"}, + {file = "pymongo-4.3.3-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:704d939656e21b073bfcddd7228b29e0e8a93dd27b54240eaafc0b9a631629a6"}, + {file = "pymongo-4.3.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1074f1a6f23e28b983c96142f2d45be03ec55d93035b471c26889a7ad2365db3"}, + {file = "pymongo-4.3.3-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7b16250238de8dafca225647608dddc7bbb5dce3dd53b4d8e63c1cc287394c2f"}, + {file = "pymongo-4.3.3-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:7761cacb8745093062695b11574effea69db636c2fd0a9269a1f0183712927b4"}, + {file = "pymongo-4.3.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:fd7bb378d82b88387dc10227cfd964f6273eb083e05299e9b97cbe075da12d11"}, + {file = "pymongo-4.3.3-cp39-cp39-win32.whl", hash = "sha256:dc24d245026a72d9b4953729d31813edd4bd4e5c13622d96e27c284942d33f24"}, + {file = "pymongo-4.3.3-cp39-cp39-win_amd64.whl", hash = "sha256:fc28e8d85d392a06434e9a934908d97e2cf453d69488d2bcd0bfb881497fd975"}, + {file = "pymongo-4.3.3.tar.gz", hash = "sha256:34e95ffb0a68bffbc3b437f2d1f25fc916fef3df5cdeed0992da5f42fae9b807"}, +] +pyrsistent = [ + {file = "pyrsistent-0.19.3-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:20460ac0ea439a3e79caa1dbd560344b64ed75e85d8703943e0b66c2a6150e4a"}, + {file = "pyrsistent-0.19.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4c18264cb84b5e68e7085a43723f9e4c1fd1d935ab240ce02c0324a8e01ccb64"}, + {file = "pyrsistent-0.19.3-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4b774f9288dda8d425adb6544e5903f1fb6c273ab3128a355c6b972b7df39dcf"}, + {file = "pyrsistent-0.19.3-cp310-cp310-win32.whl", hash = "sha256:5a474fb80f5e0d6c9394d8db0fc19e90fa540b82ee52dba7d246a7791712f74a"}, + {file = "pyrsistent-0.19.3-cp310-cp310-win_amd64.whl", hash = "sha256:49c32f216c17148695ca0e02a5c521e28a4ee6c5089f97e34fe24163113722da"}, + {file = "pyrsistent-0.19.3-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:f0774bf48631f3a20471dd7c5989657b639fd2d285b861237ea9e82c36a415a9"}, + {file = "pyrsistent-0.19.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3ab2204234c0ecd8b9368dbd6a53e83c3d4f3cab10ecaf6d0e772f456c442393"}, + {file = "pyrsistent-0.19.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e42296a09e83028b3476f7073fcb69ffebac0e66dbbfd1bd847d61f74db30f19"}, + {file = "pyrsistent-0.19.3-cp311-cp311-win32.whl", hash = "sha256:64220c429e42a7150f4bfd280f6f4bb2850f95956bde93c6fda1b70507af6ef3"}, + {file = "pyrsistent-0.19.3-cp311-cp311-win_amd64.whl", hash = "sha256:016ad1afadf318eb7911baa24b049909f7f3bb2c5b1ed7b6a8f21db21ea3faa8"}, + {file = "pyrsistent-0.19.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:c4db1bd596fefd66b296a3d5d943c94f4fac5bcd13e99bffe2ba6a759d959a28"}, + {file = "pyrsistent-0.19.3-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:aeda827381f5e5d65cced3024126529ddc4289d944f75e090572c77ceb19adbf"}, + {file = "pyrsistent-0.19.3-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:42ac0b2f44607eb92ae88609eda931a4f0dfa03038c44c772e07f43e738bcac9"}, + {file = "pyrsistent-0.19.3-cp37-cp37m-win32.whl", hash = "sha256:e8f2b814a3dc6225964fa03d8582c6e0b6650d68a232df41e3cc1b66a5d2f8d1"}, + {file = "pyrsistent-0.19.3-cp37-cp37m-win_amd64.whl", hash = "sha256:c9bb60a40a0ab9aba40a59f68214eed5a29c6274c83b2cc206a359c4a89fa41b"}, + {file = "pyrsistent-0.19.3-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:a2471f3f8693101975b1ff85ffd19bb7ca7dd7c38f8a81701f67d6b4f97b87d8"}, + {file = "pyrsistent-0.19.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cc5d149f31706762c1f8bda2e8c4f8fead6e80312e3692619a75301d3dbb819a"}, + {file = "pyrsistent-0.19.3-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3311cb4237a341aa52ab8448c27e3a9931e2ee09561ad150ba94e4cfd3fc888c"}, + {file = "pyrsistent-0.19.3-cp38-cp38-win32.whl", hash = "sha256:f0e7c4b2f77593871e918be000b96c8107da48444d57005b6a6bc61fb4331b2c"}, + {file = "pyrsistent-0.19.3-cp38-cp38-win_amd64.whl", hash = "sha256:c147257a92374fde8498491f53ffa8f4822cd70c0d85037e09028e478cababb7"}, + {file = "pyrsistent-0.19.3-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:b735e538f74ec31378f5a1e3886a26d2ca6351106b4dfde376a26fc32a044edc"}, + {file = "pyrsistent-0.19.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:99abb85579e2165bd8522f0c0138864da97847875ecbd45f3e7e2af569bfc6f2"}, + {file = "pyrsistent-0.19.3-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3a8cb235fa6d3fd7aae6a4f1429bbb1fec1577d978098da1252f0489937786f3"}, + {file = "pyrsistent-0.19.3-cp39-cp39-win32.whl", hash = "sha256:c74bed51f9b41c48366a286395c67f4e894374306b197e62810e0fdaf2364da2"}, + {file = "pyrsistent-0.19.3-cp39-cp39-win_amd64.whl", hash = "sha256:878433581fc23e906d947a6814336eee031a00e6defba224234169ae3d3d6a98"}, + {file = "pyrsistent-0.19.3-py3-none-any.whl", hash = "sha256:ccf0d6bd208f8111179f0c26fdf84ed7c3891982f2edaeae7422575f47e66b64"}, + {file = "pyrsistent-0.19.3.tar.gz", hash = "sha256:1a2994773706bbb4995c31a97bc94f1418314923bd1048c6d964837040376440"}, +] +pytest = [ + {file = "pytest-7.2.1-py3-none-any.whl", hash = "sha256:c7c6ca206e93355074ae32f7403e8ea12163b1163c976fee7d4d84027c162be5"}, + {file = "pytest-7.2.1.tar.gz", hash = "sha256:d45e0952f3727241918b8fd0f376f5ff6b301cc0777c6f9a556935c92d8a7d42"}, +] +pytest-asyncio = [ + {file = "pytest-asyncio-0.20.3.tar.gz", hash = "sha256:83cbf01169ce3e8eb71c6c278ccb0574d1a7a3bb8eaaf5e50e0ad342afb33b36"}, + {file = "pytest_asyncio-0.20.3-py3-none-any.whl", hash = "sha256:f129998b209d04fcc65c96fc85c11e5316738358909a8399e93be553d7656442"}, +] +pytest-mock = [ + {file = "pytest-mock-3.10.0.tar.gz", hash = "sha256:fbbdb085ef7c252a326fd8cdcac0aa3b1333d8811f131bdcc701002e1be7ed4f"}, + {file = "pytest_mock-3.10.0-py3-none-any.whl", hash = "sha256:f4c973eeae0282963eb293eb173ce91b091a79c1334455acfac9ddee8a1c784b"}, +] +python-dotenv = [ + {file = "python-dotenv-0.21.0.tar.gz", hash = "sha256:b77d08274639e3d34145dfa6c7008e66df0f04b7be7a75fd0d5292c191d79045"}, + {file = "python_dotenv-0.21.0-py3-none-any.whl", hash = "sha256:1684eb44636dd462b66c3ee016599815514527ad99965de77f43e0944634a7e5"}, +] +pywin32-ctypes = [ + {file = "pywin32-ctypes-0.2.0.tar.gz", hash = "sha256:24ffc3b341d457d48e8922352130cf2644024a4ff09762a2261fd34c36ee5942"}, + {file = "pywin32_ctypes-0.2.0-py2.py3-none-any.whl", hash = "sha256:9dc2d991b3479cc2df15930958b674a48a227d5361d413827a4cfd0b5876fc98"}, +] +pyyaml = [ + {file = "PyYAML-6.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53"}, + {file = "PyYAML-6.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c"}, + {file = "PyYAML-6.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc"}, + {file = "PyYAML-6.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b"}, + {file = "PyYAML-6.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5"}, + {file = "PyYAML-6.0-cp310-cp310-win32.whl", hash = "sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513"}, + {file = "PyYAML-6.0-cp310-cp310-win_amd64.whl", hash = "sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a"}, + {file = "PyYAML-6.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358"}, + {file = "PyYAML-6.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1"}, + {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d"}, + {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f"}, + {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782"}, + {file = "PyYAML-6.0-cp311-cp311-win32.whl", hash = "sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7"}, + {file = "PyYAML-6.0-cp311-cp311-win_amd64.whl", hash = "sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf"}, + {file = "PyYAML-6.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86"}, + {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f"}, + {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92"}, + {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4"}, + {file = "PyYAML-6.0-cp36-cp36m-win32.whl", hash = "sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293"}, + {file = "PyYAML-6.0-cp36-cp36m-win_amd64.whl", hash = "sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57"}, + {file = "PyYAML-6.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c"}, + {file = "PyYAML-6.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0"}, + {file = "PyYAML-6.0-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4"}, + {file = "PyYAML-6.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9"}, + {file = "PyYAML-6.0-cp37-cp37m-win32.whl", hash = "sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737"}, + {file = "PyYAML-6.0-cp37-cp37m-win_amd64.whl", hash = "sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d"}, + {file = "PyYAML-6.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b"}, + {file = "PyYAML-6.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba"}, + {file = "PyYAML-6.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34"}, + {file = "PyYAML-6.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287"}, + {file = "PyYAML-6.0-cp38-cp38-win32.whl", hash = "sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78"}, + {file = "PyYAML-6.0-cp38-cp38-win_amd64.whl", hash = "sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07"}, + {file = "PyYAML-6.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b"}, + {file = "PyYAML-6.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174"}, + {file = "PyYAML-6.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803"}, + {file = "PyYAML-6.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3"}, + {file = "PyYAML-6.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0"}, + {file = "PyYAML-6.0-cp39-cp39-win32.whl", hash = "sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb"}, + {file = "PyYAML-6.0-cp39-cp39-win_amd64.whl", hash = "sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c"}, + {file = "PyYAML-6.0.tar.gz", hash = "sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2"}, +] +requests = [ + {file = "requests-2.28.2-py3-none-any.whl", hash = "sha256:64299f4909223da747622c030b781c0d7811e359c37124b4bd368fb8c6518baa"}, + {file = "requests-2.28.2.tar.gz", hash = "sha256:98b1b2782e3c6c4904938b84c0eb932721069dfdb9134313beff7c83c2df24bf"}, +] +requests-toolbelt = [ + {file = "requests-toolbelt-0.9.1.tar.gz", hash = "sha256:968089d4584ad4ad7c171454f0a5c6dac23971e9472521ea3b6d49d610aa6fc0"}, + {file = "requests_toolbelt-0.9.1-py2.py3-none-any.whl", hash = "sha256:380606e1d10dc85c3bd47bf5a6095f815ec007be7a8b69c878507068df059e6f"}, +] +rich = [ + {file = "rich-12.6.0-py3-none-any.whl", hash = "sha256:a4eb26484f2c82589bd9a17c73d32a010b1e29d89f1604cd9bf3a2097b81bb5e"}, + {file = "rich-12.6.0.tar.gz", hash = "sha256:ba3a3775974105c221d31141f2c116f4fd65c5ceb0698657a11e9f295ec93fd0"}, +] +ruff = [ + {file = "ruff-0.0.166-py3-none-macosx_10_7_x86_64.whl", hash = "sha256:4005be450e79104ccd6c205e227103f9d0412e06a14603cecb35e59339263498"}, + {file = "ruff-0.0.166-py3-none-macosx_10_9_x86_64.macosx_10_9_arm64.macosx_10_9_universal2.whl", hash = "sha256:01a007751e296ee0cc01997edb22c7030cca788934fd7ff68d4948bf1e1b0fe2"}, + {file = "ruff-0.0.166-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:47f8b29f03d9e5f7bc340f6ce0b1b1752909f8ab23911b002b1348473ba08b1b"}, + {file = "ruff-0.0.166-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e0e4f41aa129d1b0f5618e706ffe1a6883c67bc0f9a2c8f2ab79627e09d8e22d"}, + {file = "ruff-0.0.166-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:59745975201324cee4a43e32ee215e04867e91c4c6f549e92c6675e5b5d5012c"}, + {file = "ruff-0.0.166-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:a40bebf70e1a7cf9151bad250bbd3edcc8a1f17a0317b2f3888eb142f04f513d"}, + {file = "ruff-0.0.166-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:484e31d60a6bf943da04f8a1a4b420ceadb2d5ef93b8592410a86a4242d2a948"}, + {file = "ruff-0.0.166-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f51b90ece15da8739a9a4aa8a05e7f62875926b8c31156b6b4eb92b8612856df"}, + {file = "ruff-0.0.166-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c8ddac5b6b4436d8a61286261736cb125d8b2acb2462a777d7559243e82c1824"}, + {file = "ruff-0.0.166-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:5abd15580f3fbce798a8dd94f51fed6d994e900c8b7beb3b804ca7cd5162dd8f"}, + {file = "ruff-0.0.166-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:1badee41d38d2295f471f328fbea84f317b87d2aa7c3d09426ea44626a9f172d"}, + {file = "ruff-0.0.166-py3-none-musllinux_1_2_i686.whl", hash = "sha256:17d310343c4fec74c88ee21eb98d10b825fa734d92d7048ee5db28a706d8ccbc"}, + {file = "ruff-0.0.166-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:9404787fbeeb78af804d79fb275943683b48ab33237fcdca6fb76452f69ecb4c"}, + {file = "ruff-0.0.166-py3-none-win32.whl", hash = "sha256:fc624d95a4f7ebfd3e0807ae767e9f47361165cdc9a419fc406461bec47a31d1"}, + {file = "ruff-0.0.166-py3-none-win_amd64.whl", hash = "sha256:d18b8d450b2e7dcc699e61dfee16da461ed6d37ff80dc6b8401fc236198e2156"}, + {file = "ruff-0.0.166.tar.gz", hash = "sha256:804fa54aa04e0253b2f39a0ce7089359ea6ba2f037f299f5d8606605e5e37bfa"}, +] +secretstorage = [ + {file = "SecretStorage-3.3.3-py3-none-any.whl", hash = "sha256:f356e6628222568e3af06f2eba8df495efa13b3b63081dafd4f7d9a7b7bc9f99"}, + {file = "SecretStorage-3.3.3.tar.gz", hash = "sha256:2403533ef369eca6d2ba81718576c5e0f564d5cca1b58f73a8b23e7d4eeebd77"}, +] +setuptools = [ + {file = "setuptools-66.1.0-py3-none-any.whl", hash = "sha256:fc19f9f62120a763300fd78e234b3cbd3417be098f08c156eaaf36420627e57b"}, + {file = "setuptools-66.1.0.tar.gz", hash = "sha256:78a02bdea8a5cb66dec1c507598c443bcc75562817d2556c1a17f7a344615bb4"}, +] +shellingham = [ + {file = "shellingham-1.5.0.post1-py2.py3-none-any.whl", hash = "sha256:368bf8c00754fd4f55afb7bbb86e272df77e4dc76ac29dbcbb81a59e9fc15744"}, + {file = "shellingham-1.5.0.post1.tar.gz", hash = "sha256:823bc5fb5c34d60f285b624e7264f4dda254bc803a3774a147bf99c0e3004a28"}, +] +six = [ + {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, + {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, +] +smmap = [ + {file = "smmap-5.0.0-py3-none-any.whl", hash = "sha256:2aba19d6a040e78d8b09de5c57e96207b09ed71d8e55ce0959eeee6c8e190d94"}, + {file = "smmap-5.0.0.tar.gz", hash = "sha256:c840e62059cd3be204b0c9c9f74be2c09d5648eddd4580d9314c3ecde0b30936"}, +] +sniffio = [ + {file = "sniffio-1.3.0-py3-none-any.whl", hash = "sha256:eecefdce1e5bbfb7ad2eeaabf7c1eeb404d7757c379bd1f7e5cce9d8bf425384"}, + {file = "sniffio-1.3.0.tar.gz", hash = "sha256:e60305c5e5d314f5389259b7f22aaa33d8f7dee49763119234af3755c55b9101"}, +] +starlette = [ + {file = "starlette-0.21.0-py3-none-any.whl", hash = "sha256:0efc058261bbcddeca93cad577efd36d0c8a317e44376bcfc0e097a2b3dc24a7"}, + {file = "starlette-0.21.0.tar.gz", hash = "sha256:b1b52305ee8f7cfc48cde383496f7c11ab897cd7112b33d998b1317dc8ef9027"}, +] +stevedore = [ + {file = "stevedore-4.1.1-py3-none-any.whl", hash = "sha256:aa6436565c069b2946fe4ebff07f5041e0c8bf18c7376dd29edf80cf7d524e4e"}, + {file = "stevedore-4.1.1.tar.gz", hash = "sha256:7f8aeb6e3f90f96832c301bff21a7eb5eefbe894c88c506483d355565d88cc1a"}, +] +tomli = [ + {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, + {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, +] +tomlkit = [ + {file = "tomlkit-0.11.6-py3-none-any.whl", hash = "sha256:07de26b0d8cfc18f871aec595fda24d95b08fef89d147caa861939f37230bf4b"}, + {file = "tomlkit-0.11.6.tar.gz", hash = "sha256:71b952e5721688937fb02cf9d354dbcf0785066149d2855e44531ebdd2b65d73"}, +] +tox = [ + {file = "tox-3.28.0-py2.py3-none-any.whl", hash = "sha256:57b5ab7e8bb3074edc3c0c0b4b192a4f3799d3723b2c5b76f1fa9f2d40316eea"}, + {file = "tox-3.28.0.tar.gz", hash = "sha256:d0d28f3fe6d6d7195c27f8b054c3e99d5451952b54abdae673b71609a581f640"}, +] +tox-poetry-installer = [ + {file = "tox-poetry-installer-0.10.0.tar.gz", hash = "sha256:c15714973f5b0f7dbd07d6e7c4bc7d5bb8a878f71d5513d8d7f1a5e81ed1c521"}, + {file = "tox_poetry_installer-0.10.0-py3-none-any.whl", hash = "sha256:3baff43f7926c09d66027b7a837719a2b373d7f284898b2cd9dd2f0caad49bb9"}, +] +typing-extensions = [ + {file = "typing_extensions-4.4.0-py3-none-any.whl", hash = "sha256:16fa4864408f655d35ec496218b85f79b3437c829e93320c7c9215ccfd92489e"}, + {file = "typing_extensions-4.4.0.tar.gz", hash = "sha256:1511434bb92bf8dd198c12b1cc812e800d4181cfcb867674e0f8279cc93087aa"}, +] +urllib3 = [ + {file = "urllib3-1.26.14-py2.py3-none-any.whl", hash = "sha256:75edcdc2f7d85b137124a6c3c9fc3933cdeaa12ecb9a6a959f22797a0feca7e1"}, + {file = "urllib3-1.26.14.tar.gz", hash = "sha256:076907bf8fd355cde77728471316625a4d2f7e713c125f51953bb5b3eecf4f72"}, +] +uvicorn = [ + {file = "uvicorn-0.20.0-py3-none-any.whl", hash = "sha256:c3ed1598a5668208723f2bb49336f4509424ad198d6ab2615b7783db58d919fd"}, + {file = "uvicorn-0.20.0.tar.gz", hash = "sha256:a4e12017b940247f836bc90b72e725d7dfd0c8ed1c51eb365f5ba30d9f5127d8"}, +] +uvloop = [ + {file = "uvloop-0.17.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:ce9f61938d7155f79d3cb2ffa663147d4a76d16e08f65e2c66b77bd41b356718"}, + {file = "uvloop-0.17.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:68532f4349fd3900b839f588972b3392ee56042e440dd5873dfbbcd2cc67617c"}, + {file = "uvloop-0.17.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0949caf774b9fcefc7c5756bacbbbd3fc4c05a6b7eebc7c7ad6f825b23998d6d"}, + {file = "uvloop-0.17.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ff3d00b70ce95adce264462c930fbaecb29718ba6563db354608f37e49e09024"}, + {file = "uvloop-0.17.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:a5abddb3558d3f0a78949c750644a67be31e47936042d4f6c888dd6f3c95f4aa"}, + {file = "uvloop-0.17.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:8efcadc5a0003d3a6e887ccc1fb44dec25594f117a94e3127954c05cf144d811"}, + {file = "uvloop-0.17.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:3378eb62c63bf336ae2070599e49089005771cc651c8769aaad72d1bd9385a7c"}, + {file = "uvloop-0.17.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6aafa5a78b9e62493539456f8b646f85abc7093dd997f4976bb105537cf2635e"}, + {file = "uvloop-0.17.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c686a47d57ca910a2572fddfe9912819880b8765e2f01dc0dd12a9bf8573e539"}, + {file = "uvloop-0.17.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:864e1197139d651a76c81757db5eb199db8866e13acb0dfe96e6fc5d1cf45fc4"}, + {file = "uvloop-0.17.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:2a6149e1defac0faf505406259561bc14b034cdf1d4711a3ddcdfbaa8d825a05"}, + {file = "uvloop-0.17.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:6708f30db9117f115eadc4f125c2a10c1a50d711461699a0cbfaa45b9a78e376"}, + {file = "uvloop-0.17.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:23609ca361a7fc587031429fa25ad2ed7242941adec948f9d10c045bfecab06b"}, + {file = "uvloop-0.17.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2deae0b0fb00a6af41fe60a675cec079615b01d68beb4cc7b722424406b126a8"}, + {file = "uvloop-0.17.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:45cea33b208971e87a31c17622e4b440cac231766ec11e5d22c76fab3bf9df62"}, + {file = "uvloop-0.17.0-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:9b09e0f0ac29eee0451d71798878eae5a4e6a91aa275e114037b27f7db72702d"}, + {file = "uvloop-0.17.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:dbbaf9da2ee98ee2531e0c780455f2841e4675ff580ecf93fe5c48fe733b5667"}, + {file = "uvloop-0.17.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:a4aee22ece20958888eedbad20e4dbb03c37533e010fb824161b4f05e641f738"}, + {file = "uvloop-0.17.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:307958f9fc5c8bb01fad752d1345168c0abc5d62c1b72a4a8c6c06f042b45b20"}, + {file = "uvloop-0.17.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3ebeeec6a6641d0adb2ea71dcfb76017602ee2bfd8213e3fcc18d8f699c5104f"}, + {file = "uvloop-0.17.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1436c8673c1563422213ac6907789ecb2b070f5939b9cbff9ef7113f2b531595"}, + {file = "uvloop-0.17.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:8887d675a64cfc59f4ecd34382e5b4f0ef4ae1da37ed665adba0c2badf0d6578"}, + {file = "uvloop-0.17.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:3db8de10ed684995a7f34a001f15b374c230f7655ae840964d51496e2f8a8474"}, + {file = "uvloop-0.17.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:7d37dccc7ae63e61f7b96ee2e19c40f153ba6ce730d8ba4d3b4e9738c1dccc1b"}, + {file = "uvloop-0.17.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:cbbe908fda687e39afd6ea2a2f14c2c3e43f2ca88e3a11964b297822358d0e6c"}, + {file = "uvloop-0.17.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3d97672dc709fa4447ab83276f344a165075fd9f366a97b712bdd3fee05efae8"}, + {file = "uvloop-0.17.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f1e507c9ee39c61bfddd79714e4f85900656db1aec4d40c6de55648e85c2799c"}, + {file = "uvloop-0.17.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:c092a2c1e736086d59ac8e41f9c98f26bbf9b9222a76f21af9dfe949b99b2eb9"}, + {file = "uvloop-0.17.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:30babd84706115626ea78ea5dbc7dd8d0d01a2e9f9b306d24ca4ed5796c66ded"}, + {file = "uvloop-0.17.0.tar.gz", hash = "sha256:0ddf6baf9cf11a1a22c71487f39f15b2cf78eb5bde7e5b45fbb99e8a9d91b9e1"}, +] +virtualenv = [ + {file = "virtualenv-20.17.1-py3-none-any.whl", hash = "sha256:ce3b1684d6e1a20a3e5ed36795a97dfc6af29bc3970ca8dab93e11ac6094b3c4"}, + {file = "virtualenv-20.17.1.tar.gz", hash = "sha256:f8b927684efc6f1cc206c9db297a570ab9ad0e51c16fa9e45487d36d1905c058"}, +] +watchfiles = [ + {file = "watchfiles-0.18.1-cp37-abi3-macosx_10_7_x86_64.whl", hash = "sha256:9891d3c94272108bcecf5597a592e61105279def1313521e637f2d5acbe08bc9"}, + {file = "watchfiles-0.18.1-cp37-abi3-macosx_11_0_arm64.whl", hash = "sha256:7102342d60207fa635e24c02a51c6628bf0472e5fef067f78a612386840407fc"}, + {file = "watchfiles-0.18.1-cp37-abi3-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:00ea0081eca5e8e695cffbc3a726bb90da77f4e3f78ce29b86f0d95db4e70ef7"}, + {file = "watchfiles-0.18.1-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1b8e6db99e49cd7125d8a4c9d33c0735eea7b75a942c6ad68b75be3e91c242fb"}, + {file = "watchfiles-0.18.1-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:bc7c726855f04f22ac79131b51bf0c9f728cb2117419ed830a43828b2c4a5fcb"}, + {file = "watchfiles-0.18.1-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cbaff354d12235002e62d9d3fa8bcf326a8490c1179aa5c17195a300a9e5952f"}, + {file = "watchfiles-0.18.1-cp37-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:888db233e06907c555eccd10da99b9cd5ed45deca47e41766954292dc9f7b198"}, + {file = "watchfiles-0.18.1-cp37-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:dde79930d1b28f15994ad6613aa2865fc7a403d2bb14585a8714a53233b15717"}, + {file = "watchfiles-0.18.1-cp37-abi3-win32.whl", hash = "sha256:e2b2bdd26bf8d6ed90763e6020b475f7634f919dbd1730ea1b6f8cb88e21de5d"}, + {file = "watchfiles-0.18.1-cp37-abi3-win_amd64.whl", hash = "sha256:c541e0f2c3e95e83e4f84561c893284ba984e9d0025352057396d96dceb09f44"}, + {file = "watchfiles-0.18.1-cp37-abi3-win_arm64.whl", hash = "sha256:9a26272ef3e930330fc0c2c148cc29706cc2c40d25760c7ccea8d768a8feef8b"}, + {file = "watchfiles-0.18.1-pp38-pypy38_pp73-macosx_10_7_x86_64.whl", hash = "sha256:9fb12a5e2b42e0b53769455ff93546e6bc9ab14007fbd436978d827a95ca5bd1"}, + {file = "watchfiles-0.18.1-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:548d6b42303d40264118178053c78820533b683b20dfbb254a8706ca48467357"}, + {file = "watchfiles-0.18.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6e0d8fdfebc50ac7569358f5c75f2b98bb473befccf9498cf23b3e39993bb45a"}, + {file = "watchfiles-0.18.1-pp39-pypy39_pp73-macosx_10_7_x86_64.whl", hash = "sha256:0f9a22fff1745e2bb930b1e971c4c5b67ea3b38ae17a6adb9019371f80961219"}, + {file = "watchfiles-0.18.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b02e7fa03cd4059dd61ff0600080a5a9e7a893a85cb8e5178943533656eec65e"}, + {file = "watchfiles-0.18.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a868ce2c7565137f852bd4c863a164dc81306cae7378dbdbe4e2aca51ddb8857"}, + {file = "watchfiles-0.18.1.tar.gz", hash = "sha256:4ec0134a5e31797eb3c6c624dbe9354f2a8ee9c720e0b46fc5b7bab472b7c6d4"}, +] +webencodings = [ + {file = "webencodings-0.5.1-py2.py3-none-any.whl", hash = "sha256:a0af1213f3c2226497a97e2b3aa01a7e4bee4f403f95be16fc9acd2947514a78"}, + {file = "webencodings-0.5.1.tar.gz", hash = "sha256:b36a1c245f2d304965eb4e0a82848379241dc04b865afcc4aab16748587e1923"}, +] +websockets = [ + {file = "websockets-10.4-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:d58804e996d7d2307173d56c297cf7bc132c52df27a3efaac5e8d43e36c21c48"}, + {file = "websockets-10.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:bc0b82d728fe21a0d03e65f81980abbbcb13b5387f733a1a870672c5be26edab"}, + {file = "websockets-10.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ba089c499e1f4155d2a3c2a05d2878a3428cf321c848f2b5a45ce55f0d7d310c"}, + {file = "websockets-10.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:33d69ca7612f0ddff3316b0c7b33ca180d464ecac2d115805c044bf0a3b0d032"}, + {file = "websockets-10.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:62e627f6b6d4aed919a2052efc408da7a545c606268d5ab5bfab4432734b82b4"}, + {file = "websockets-10.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:38ea7b82bfcae927eeffc55d2ffa31665dc7fec7b8dc654506b8e5a518eb4d50"}, + {file = "websockets-10.4-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:e0cb5cc6ece6ffa75baccfd5c02cffe776f3f5c8bf486811f9d3ea3453676ce8"}, + {file = "websockets-10.4-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:ae5e95cfb53ab1da62185e23b3130e11d64431179debac6dc3c6acf08760e9b1"}, + {file = "websockets-10.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:7c584f366f46ba667cfa66020344886cf47088e79c9b9d39c84ce9ea98aaa331"}, + {file = "websockets-10.4-cp310-cp310-win32.whl", hash = "sha256:b029fb2032ae4724d8ae8d4f6b363f2cc39e4c7b12454df8df7f0f563ed3e61a"}, + {file = "websockets-10.4-cp310-cp310-win_amd64.whl", hash = "sha256:8dc96f64ae43dde92530775e9cb169979f414dcf5cff670455d81a6823b42089"}, + {file = "websockets-10.4-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:47a2964021f2110116cc1125b3e6d87ab5ad16dea161949e7244ec583b905bb4"}, + {file = "websockets-10.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:e789376b52c295c4946403bd0efecf27ab98f05319df4583d3c48e43c7342c2f"}, + {file = "websockets-10.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:7d3f0b61c45c3fa9a349cf484962c559a8a1d80dae6977276df8fd1fa5e3cb8c"}, + {file = "websockets-10.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f55b5905705725af31ccef50e55391621532cd64fbf0bc6f4bac935f0fccec46"}, + {file = "websockets-10.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:00c870522cdb69cd625b93f002961ffb0c095394f06ba8c48f17eef7c1541f96"}, + {file = "websockets-10.4-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8f38706e0b15d3c20ef6259fd4bc1700cd133b06c3c1bb108ffe3f8947be15fa"}, + {file = "websockets-10.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:f2c38d588887a609191d30e902df2a32711f708abfd85d318ca9b367258cfd0c"}, + {file = "websockets-10.4-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:fe10ddc59b304cb19a1bdf5bd0a7719cbbc9fbdd57ac80ed436b709fcf889106"}, + {file = "websockets-10.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:90fcf8929836d4a0e964d799a58823547df5a5e9afa83081761630553be731f9"}, + {file = "websockets-10.4-cp311-cp311-win32.whl", hash = "sha256:b9968694c5f467bf67ef97ae7ad4d56d14be2751000c1207d31bf3bb8860bae8"}, + {file = "websockets-10.4-cp311-cp311-win_amd64.whl", hash = "sha256:a7a240d7a74bf8d5cb3bfe6be7f21697a28ec4b1a437607bae08ac7acf5b4882"}, + {file = "websockets-10.4-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:74de2b894b47f1d21cbd0b37a5e2b2392ad95d17ae983e64727e18eb281fe7cb"}, + {file = "websockets-10.4-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e3a686ecb4aa0d64ae60c9c9f1a7d5d46cab9bfb5d91a2d303d00e2cd4c4c5cc"}, + {file = "websockets-10.4-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b0d15c968ea7a65211e084f523151dbf8ae44634de03c801b8bd070b74e85033"}, + {file = "websockets-10.4-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:00213676a2e46b6ebf6045bc11d0f529d9120baa6f58d122b4021ad92adabd41"}, + {file = "websockets-10.4-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:e23173580d740bf8822fd0379e4bf30aa1d5a92a4f252d34e893070c081050df"}, + {file = "websockets-10.4-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:dd500e0a5e11969cdd3320935ca2ff1e936f2358f9c2e61f100a1660933320ea"}, + {file = "websockets-10.4-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:4239b6027e3d66a89446908ff3027d2737afc1a375f8fd3eea630a4842ec9a0c"}, + {file = "websockets-10.4-cp37-cp37m-win32.whl", hash = "sha256:8a5cc00546e0a701da4639aa0bbcb0ae2bb678c87f46da01ac2d789e1f2d2038"}, + {file = "websockets-10.4-cp37-cp37m-win_amd64.whl", hash = "sha256:a9f9a735deaf9a0cadc2d8c50d1a5bcdbae8b6e539c6e08237bc4082d7c13f28"}, + {file = "websockets-10.4-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:5c1289596042fad2cdceb05e1ebf7aadf9995c928e0da2b7a4e99494953b1b94"}, + {file = "websockets-10.4-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:0cff816f51fb33c26d6e2b16b5c7d48eaa31dae5488ace6aae468b361f422b63"}, + {file = "websockets-10.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:dd9becd5fe29773d140d68d607d66a38f60e31b86df75332703757ee645b6faf"}, + {file = "websockets-10.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:45ec8e75b7dbc9539cbfafa570742fe4f676eb8b0d3694b67dabe2f2ceed8aa6"}, + {file = "websockets-10.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4f72e5cd0f18f262f5da20efa9e241699e0cf3a766317a17392550c9ad7b37d8"}, + {file = "websockets-10.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:185929b4808b36a79c65b7865783b87b6841e852ef5407a2fb0c03381092fa3b"}, + {file = "websockets-10.4-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:7d27a7e34c313b3a7f91adcd05134315002aaf8540d7b4f90336beafaea6217c"}, + {file = "websockets-10.4-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:884be66c76a444c59f801ac13f40c76f176f1bfa815ef5b8ed44321e74f1600b"}, + {file = "websockets-10.4-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:931c039af54fc195fe6ad536fde4b0de04da9d5916e78e55405436348cfb0e56"}, + {file = "websockets-10.4-cp38-cp38-win32.whl", hash = "sha256:db3c336f9eda2532ec0fd8ea49fef7a8df8f6c804cdf4f39e5c5c0d4a4ad9a7a"}, + {file = "websockets-10.4-cp38-cp38-win_amd64.whl", hash = "sha256:48c08473563323f9c9debac781ecf66f94ad5a3680a38fe84dee5388cf5acaf6"}, + {file = "websockets-10.4-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:40e826de3085721dabc7cf9bfd41682dadc02286d8cf149b3ad05bff89311e4f"}, + {file = "websockets-10.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:56029457f219ade1f2fc12a6504ea61e14ee227a815531f9738e41203a429112"}, + {file = "websockets-10.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:f5fc088b7a32f244c519a048c170f14cf2251b849ef0e20cbbb0fdf0fdaf556f"}, + {file = "websockets-10.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2fc8709c00704194213d45e455adc106ff9e87658297f72d544220e32029cd3d"}, + {file = "websockets-10.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0154f7691e4fe6c2b2bc275b5701e8b158dae92a1ab229e2b940efe11905dff4"}, + {file = "websockets-10.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4c6d2264f485f0b53adf22697ac11e261ce84805c232ed5dbe6b1bcb84b00ff0"}, + {file = "websockets-10.4-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:9bc42e8402dc5e9905fb8b9649f57efcb2056693b7e88faa8fb029256ba9c68c"}, + {file = "websockets-10.4-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:edc344de4dac1d89300a053ac973299e82d3db56330f3494905643bb68801269"}, + {file = "websockets-10.4-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:84bc2a7d075f32f6ed98652db3a680a17a4edb21ca7f80fe42e38753a58ee02b"}, + {file = "websockets-10.4-cp39-cp39-win32.whl", hash = "sha256:c94ae4faf2d09f7c81847c63843f84fe47bf6253c9d60b20f25edfd30fb12588"}, + {file = "websockets-10.4-cp39-cp39-win_amd64.whl", hash = "sha256:bbccd847aa0c3a69b5f691a84d2341a4f8a629c6922558f2a70611305f902d74"}, + {file = "websockets-10.4-pp37-pypy37_pp73-macosx_10_9_x86_64.whl", hash = "sha256:82ff5e1cae4e855147fd57a2863376ed7454134c2bf49ec604dfe71e446e2193"}, + {file = "websockets-10.4-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d210abe51b5da0ffdbf7b43eed0cfdff8a55a1ab17abbec4301c9ff077dd0342"}, + {file = "websockets-10.4-pp37-pypy37_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:942de28af58f352a6f588bc72490ae0f4ccd6dfc2bd3de5945b882a078e4e179"}, + {file = "websockets-10.4-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c9b27d6c1c6cd53dc93614967e9ce00ae7f864a2d9f99fe5ed86706e1ecbf485"}, + {file = "websockets-10.4-pp37-pypy37_pp73-win_amd64.whl", hash = "sha256:3d3cac3e32b2c8414f4f87c1b2ab686fa6284a980ba283617404377cd448f631"}, + {file = "websockets-10.4-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:da39dd03d130162deb63da51f6e66ed73032ae62e74aaccc4236e30edccddbb0"}, + {file = "websockets-10.4-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:389f8dbb5c489e305fb113ca1b6bdcdaa130923f77485db5b189de343a179393"}, + {file = "websockets-10.4-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:09a1814bb15eff7069e51fed0826df0bc0702652b5cb8f87697d469d79c23576"}, + {file = "websockets-10.4-pp38-pypy38_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ff64a1d38d156d429404aaa84b27305e957fd10c30e5880d1765c9480bea490f"}, + {file = "websockets-10.4-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:b343f521b047493dc4022dd338fc6db9d9282658862756b4f6fd0e996c1380e1"}, + {file = "websockets-10.4-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:932af322458da7e4e35df32f050389e13d3d96b09d274b22a7aa1808f292fee4"}, + {file = "websockets-10.4-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d6a4162139374a49eb18ef5b2f4da1dd95c994588f5033d64e0bbfda4b6b6fcf"}, + {file = "websockets-10.4-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c57e4c1349fbe0e446c9fa7b19ed2f8a4417233b6984277cce392819123142d3"}, + {file = "websockets-10.4-pp39-pypy39_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b627c266f295de9dea86bd1112ed3d5fafb69a348af30a2422e16590a8ecba13"}, + {file = "websockets-10.4-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:05a7233089f8bd355e8cbe127c2e8ca0b4ea55467861906b80d2ebc7db4d6b72"}, + {file = "websockets-10.4.tar.gz", hash = "sha256:eef610b23933c54d5d921c92578ae5f89813438fded840c2e9809d378dc765d3"}, +] +xattr = [ + {file = "xattr-0.9.9-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:58a9fb4fd19b467e88f4b75b5243706caa57e312d3aee757b53b57c7fd0f4ba9"}, + {file = "xattr-0.9.9-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:e71efca59705c7abde5b7f76323ebe00ed2977f10cba4204b9421dada036b5ca"}, + {file = "xattr-0.9.9-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:1aad96b6603961c3d1ca1aaa8369b1a8d684a7b37357b2428087c286bf0e561c"}, + {file = "xattr-0.9.9-cp27-cp27m-manylinux2010_i686.whl", hash = "sha256:46cb74f98d31d9d70f975ec3e6554360a9bdcbb4b9fb50a69fabe54f9f928c97"}, + {file = "xattr-0.9.9-cp27-cp27m-manylinux2010_x86_64.whl", hash = "sha256:80c2db56058a687d7439be041f916cbeb2943fbe2623e53d5da721a4552d8991"}, + {file = "xattr-0.9.9-cp27-cp27mu-manylinux1_i686.whl", hash = "sha256:c360d1cc42e885b64d84f64de3c501dd7bce576248327ef583b4625ee63aa023"}, + {file = "xattr-0.9.9-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:debd87afe6bdf88c3689bde52eecf2b166388b13ef7388259d23223374db417d"}, + {file = "xattr-0.9.9-cp27-cp27mu-manylinux2010_i686.whl", hash = "sha256:4280c9f33a8678828f1bbc3d3dc8b823b5e4a113ee5ecb0fb98bff60cc2b9ad1"}, + {file = "xattr-0.9.9-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:e0916ec1656d2071cd3139d1f52426825985d8ed076f981ef7f0bc13dfa8e96c"}, + {file = "xattr-0.9.9-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:a517916fbf2f58a3222bb2048fe1eeff4e23e07a4ce6228a27de004c80bf53ab"}, + {file = "xattr-0.9.9-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e886c882b3b28c7a684c3e3daf46347da5428a46b88bc6d62c4867d574b90c54"}, + {file = "xattr-0.9.9-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:373e3d1fd9258438fc38d1438142d3659f36743f374a20457346ef26741ed441"}, + {file = "xattr-0.9.9-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1a7beeb54ca140273b2f6320bb98b701ec30628af2ebe4eb30f7051419eb4ef3"}, + {file = "xattr-0.9.9-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ef3ca29cdaae9c47c625d84bb6c9046f7275cccde0ea805caa23ca58d3671f3f"}, + {file = "xattr-0.9.9-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5c381d890931cd18b137ce3fb5c5f08b672c3c61e2e47b1a7442ee46e827abfe"}, + {file = "xattr-0.9.9-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:59c5783ccf57cf2700ce57d51a92134900ed26f6ab20d209f383fb898903fea6"}, + {file = "xattr-0.9.9-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:966b885b69d95362e2a12d39f84889cf857090e57263b5ac33409498aa00c160"}, + {file = "xattr-0.9.9-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:efaaf0cb1ea8e9febb7baad301ae8cc9ad7a96fdfc5c6399d165e7a19e3e61ce"}, + {file = "xattr-0.9.9-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:f19fa75ed1e9db86354efab29869cb2be6976d456bd7c89e67b118d5384a1d98"}, + {file = "xattr-0.9.9-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7ca28ad06828244b315214ee35388f57e81e90aac2ceac3f32e42ae394e31b9c"}, + {file = "xattr-0.9.9-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:532c7f1656dd2fe937116b9e210229f716d7fc7ac142f9cdace7da92266d32e8"}, + {file = "xattr-0.9.9-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:11c28033c17e98c67e0def9d6ebd415ad3c006a7bc3fee6bad79c5e52d0dff49"}, + {file = "xattr-0.9.9-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:473cabb30e544ea08c8c01c1ef18053147cdc8552d443ac97815e46fbb13c7d4"}, + {file = "xattr-0.9.9-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:c4a308522b444d090fbd66a385c9519b6b977818226921b0d2fc403667c93564"}, + {file = "xattr-0.9.9-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:82493434488aca72d88b5129dac8f212e7b8bdca7ceffe7bb977c850f2452e4e"}, + {file = "xattr-0.9.9-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:e41d289706c7e8940f4d08e865da6a8ae988123e40a44f9a97ddc09e67795d7d"}, + {file = "xattr-0.9.9-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ef08698e360cf43688dca3db3421b156b29948a714d5d089348073f463c11646"}, + {file = "xattr-0.9.9-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4eb10ac16ca8d534c0395425d52121e0c1981f808e1b3f577f6a5ec33d3853e4"}, + {file = "xattr-0.9.9-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5605fec07b0e964bd980cc70ec335b9eb1b7ac7c6f314c7c2d8f54b09104fe4c"}, + {file = "xattr-0.9.9-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:974e7d577ddb15e4552fb0ec10a4cfe09bdf6267365aa2b8394bb04637785aad"}, + {file = "xattr-0.9.9-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:ad6777de922c638bfa87a0d7faebc5722ddef04a1210b2a8909289b58b769af0"}, + {file = "xattr-0.9.9-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:3887e70873ebf0efbde32f9929ec1c7e45ec0013561743e2cc0406a91e51113b"}, + {file = "xattr-0.9.9-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:83caa8e93a45a0f25f91b92d9b45f490c87bff74f02555df6312efeba0dacc31"}, + {file = "xattr-0.9.9-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:e33ec0a1d913d946d1ab7509f37ee37306c45af735347f13b963df34ffe6e029"}, + {file = "xattr-0.9.9-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:263c58dca83372260c5c195e0b59959e38e1f107f0b7350de82e3db38479036c"}, + {file = "xattr-0.9.9-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:125dfb9905428162349d3b8b825d9a18280893f0cb0db2a2467d5ef253fa6ce2"}, + {file = "xattr-0.9.9-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e243524e0dde16d7a2e1b52512ad2c6964df2143dd1c79b820dcb4c6c0822c20"}, + {file = "xattr-0.9.9-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:01ec07d24a14406bdc6a123041c63a88e1c4a3f820e4a7d30f7609d57311b499"}, + {file = "xattr-0.9.9-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:85c1df5f1d209345ea96de137419e886a27bb55076b3ae01faacf35aafcf3a61"}, + {file = "xattr-0.9.9-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:ca74d3eff92d6dc16e271fbad9cbab547fb9a0c983189c4031c3ff3d150dd871"}, + {file = "xattr-0.9.9-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:7d17505e49ac70c0e71939c5aac96417a863583fb30a2d6304d5ac881230548f"}, + {file = "xattr-0.9.9-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:1ae47a6398d3c04623fa386a4aa2f66e5cd3cdb1a7e69d1bfaeb8c73983bf271"}, + {file = "xattr-0.9.9-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:809e2537d0aff9fca97dacf3245cbbaf711bbced5d1b0235a8d1906b04e26114"}, + {file = "xattr-0.9.9-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:de3af84364f06d67b3662ccf7c1a73e1d389d8d274394e952651e7bf1bbd2718"}, + {file = "xattr-0.9.9-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3b62cdad232d2d2dedd39b543701db8e3883444ec0d57ce3fab8f75e5f8b0301"}, + {file = "xattr-0.9.9-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6b11d2eda397d47f7075743409683c233519ca52aa1dac109b413a4d8c15b740"}, + {file = "xattr-0.9.9-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:661c0a939aefdf071887121f534bb10588d69c7b2dfca5c486af2fc81a0786e8"}, + {file = "xattr-0.9.9-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:5db7c2db320a8d5264d437d71f1eb7270a7e4a6545296e7766161d17752590b7"}, + {file = "xattr-0.9.9-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:83203e60cbaca9536d297e5039b285a600ff84e6e9e8536fe2d521825eeeb437"}, + {file = "xattr-0.9.9-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:42bfb4e4da06477e739770ac6942edbdc71e9fc3b497b67db5fba712fa8109c2"}, + {file = "xattr-0.9.9-pp37-pypy37_pp73-macosx_10_9_x86_64.whl", hash = "sha256:67047d04d1c56ad4f0f5886085e91b0077238ab3faaec6492c3c21920c6566eb"}, + {file = "xattr-0.9.9-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:885782bc82ded1a3f684d54a1af259ae9fcc347fa54b5a05b8aad82b8a42044c"}, + {file = "xattr-0.9.9-pp37-pypy37_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5bc84ccec618b5aa089e7cee8b07fcc92d4069aac4053da604c8143a0d6b1381"}, + {file = "xattr-0.9.9-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:baeff3e5dda8ea7e9424cfaee51829f46afe3836c30d02f343f9049c685681ca"}, + {file = "xattr-0.9.9.tar.gz", hash = "sha256:09cb7e1efb3aa1b4991d6be4eb25b73dc518b4fe894f0915f5b0dcede972f346"}, +] +zipp = [ + {file = "zipp-3.11.0-py3-none-any.whl", hash = "sha256:83a28fcb75844b5c0cdaf5aa4003c2d728c77e05f5aeabe8e95e56727005fbaa"}, + {file = "zipp-3.11.0.tar.gz", hash = "sha256:a7a22e05929290a67401440b39690ae6563279bced5f314609d9d03798f56766"}, +] diff --git a/backend-services/pyproject.toml b/backend-services/pyproject.toml new file mode 100644 index 0000000..7e43590 --- /dev/null +++ b/backend-services/pyproject.toml @@ -0,0 +1,102 @@ +[tool.poetry] +name = "wallet-backend-services" +version = "0.1.0" +description = "" +authors = ["Nautilus"] +readme = "README.md" +packages = [ + {include = "common", from = "src"}, + {include = "data_service", from = "src"}, + {include = "web_asgi", from = "src"}, + {include = "tests"}, + ] + +[tool.poetry.dependencies] +python = "^3.10" +motor = "^3.1.1" +fastapi = "^0.87.0" +pydantic = "^1.10.2" +python-dotenv = "^0.21.0" +uvicorn = {extras = ["standard"], version = "^0.20.0"} +gunicorn = "^20.1.0" +odmantic = "^0.9.1" + +[tool.poetry.group.test.dependencies] +pytest = "^7.2.0" +pytest-mock = "^3.10.0" +mock = "^4.0.3" +pytest-asyncio = "^0.20.2" + +[tool.poetry.group.dev.dependencies] +mypy = "^0.991" +black = "^22.10.0" +tox = "^3.27.1" +tox-poetry-installer = {extras = ["poetry"], version = "^0.10.0"} +isort = "^5.10.1" +bandit = "^1.7.4" +rich = "^12.6.0" +devtools = "^0.9.0" +pdoc = "^12.3.0" +flake8 = "^6.0.0" +ruff = "^0.0.166" + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" + +[tool.isort] +profile = "black" + +[tool.mypy] +plugins = [ + "pydantic.mypy" +] + +follow_imports = "silent" +warn_redundant_casts = true +warn_unused_ignores = true +disallow_any_generics = true +check_untyped_defs = true +no_implicit_reexport = true + +disallow_untyped_defs = true + +[tool.pydantic-mypy] +init_forbid_extra = true +init_typed = true +warn_required_dynamic_aliases = true +warn_untyped_fields = true + +[tool.ruff] +# start with the rules used by `fastapi` +select = [ + "E", # pycodestyle errors + "W", # pycodestyle warnings + "F", # pyflakes + "C", # flake8-comprehensions + "B", # flake8-bugbear +] +# start with the ignores used by `fastapi` +ignore = [ + "E501", # line too long, handled by black + "B008", # do not perform function calls in argument defaults + "C901", # too complex +] +# our additional lint checks +extend-select = [ + "UP", # modern syntax + "N", # naming conforms to PEP8 + "ANN", # type annotations + "BLE", # blind exceptions + "FBT", # booleans traps + "A", # clashes with python builtins + "T", # left-over debugging + "Q", # uniform quotes + "RET", # function returns + "I25", # tidy imports + "ERA", # commented code + "PLC", # pylint checks + "RUF", # ruff-specific checks +] +# Assume Python 3.10. +target-version = "py310" diff --git a/backend-services/schema_files/alumni_salary.json b/backend-services/schema_files/alumni_salary.json new file mode 100644 index 0000000..d26528f --- /dev/null +++ b/backend-services/schema_files/alumni_salary.json @@ -0,0 +1,110 @@ +[ + { + "name": "John Smith", + "gpa": 3.5, + "age": 25, + "salary": 50000 + }, + { + "name": "Jane Doe", + "gpa": 3.2, + "age": 22, + "salary": 45000 + }, + { + "name": "Bob Johnson", + "gpa": 3.8, + "age": 30, + "salary": 55000 + }, + { + "name": "Sara Lee", + "gpa": 3.0, + "age": 27, + "salary": 40000 + }, + { + "name": "Tom Brown", + "gpa": 3.7, + "age": 32, + "salary": 60000 + }, + { + "name": "Emily Davis", + "gpa": 3.4, + "age": 23, + "salary": 42000 + }, + { + "name": "Michael Miller", + "gpa": 3.9, + "age": 28, + "salary": 65000 + }, + { + "name": "Jessica Wilson", + "gpa": 3.1, + "age": 24, + "salary": 46000 + }, + { + "name": "Matthew Anderson", + "gpa": 3.6, + "age": 29, + "salary": 58000 + }, + { + "name": "Nicholas Thompson", + "gpa": 3.3, + "age": 26, + "salary": 49000 + }, + { + "name": "Ashley Moore", + "gpa": 3.8, + "age": 35, + "salary": 62000 + }, + { + "name": "David Taylor", + "gpa": 3.0, + "age": 31, + "salary": 52000 + }, + { + "name": "Joseph Hernandez", + "gpa": 3.7, + "age": 33, + "salary": 57000 + }, + { + "name": "Brian Martinez", + "gpa": 3.4, + "age": 30, + "salary": 50000 + }, + { + "name": "Brandon Lee", + "gpa": 3.9, + "age": 25, + "salary": 60000 + }, + { + "name": "Adam Clark", + "gpa": 3.1, + "age": 22, + "salary": 45000 + }, + { + "name": "Natalie Rodriguez", + "gpa": 3.6, + "age": 27, + "salary": 48000 + }, + { + "name": "Justin Green", + "gpa": 3.3, + "age": 32, + "salary": 55000 + } +] diff --git a/backend-services/schema_files/alumni_salary_scheme.json b/backend-services/schema_files/alumni_salary_scheme.json new file mode 100644 index 0000000..a15bb6c --- /dev/null +++ b/backend-services/schema_files/alumni_salary_scheme.json @@ -0,0 +1,9 @@ +schema = { + "type": "object", + "properties": { + "name": {"type": "string"}, + "gpa": {"type": "number"}, + "age": {"type": "number"}, + "salary": {"type": "number"}, + }, +} \ No newline at end of file diff --git a/backend-services/schema_files/customer_accounts.json b/backend-services/schema_files/customer_accounts.json new file mode 100644 index 0000000..7bf9e4c --- /dev/null +++ b/backend-services/schema_files/customer_accounts.json @@ -0,0 +1,37 @@ +[ + { + "Name": "John Smith", + "Email": "johnsmith@email.com", + "Account": 25098313, + "Balance": 50000, + "Credit Score": 300 + }, + { + "name": "Jane Doe", + "Email": "janedoe@email.com", + "Account": 25023515, + "Balance": 20500, + "Credit Score": 290 + }, + { + "name": "Bob Johnson", + "Email": "bobjohnson@email.com", + "Account": 25092814, + "Balance": 24000, + "Credit Score": 200 + }, + { + "name": "Sara Lee", + "Email": "saralee@email.com", + "Account": 25068194, + "Balance": 54000, + "Credit Score": 302 + }, + { + "name": "Tom Brown", + "Email": "tombrown@email.com", + "Account": 25020920, + "Balance": 33000, + "Credit Score": 360 + } +] diff --git a/backend-services/schema_files/customer_accounts_schema.json b/backend-services/schema_files/customer_accounts_schema.json new file mode 100644 index 0000000..7e691a8 --- /dev/null +++ b/backend-services/schema_files/customer_accounts_schema.json @@ -0,0 +1,10 @@ +{ + "type": "object", + "properties": { + "Name": {"type": "string"}, + "Email": {"type": "string"}, + "Account": {"type": "number"}, + "Balance": {"type": "number"}, + "Credit Score": {"type": "number"}, + }, +} \ No newline at end of file diff --git a/backend-services/schema_files/example-validation.ipynb b/backend-services/schema_files/example-validation.ipynb new file mode 100644 index 0000000..1d79bf1 --- /dev/null +++ b/backend-services/schema_files/example-validation.ipynb @@ -0,0 +1,511 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "7009a50c", + "metadata": {}, + "source": [ + "# JSON Schema Validation\n", + "\n", + "Play with schema validation using the json-schema language. This notebook uses the jsonschema library, https://github.com/python-jsonschema/jsonschema. " + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "af47689b", + "metadata": {}, + "outputs": [], + "source": [ + "import sys" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "dfeccff0", + "metadata": {}, + "outputs": [], + "source": [ + "import json" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "53749d68", + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "7b1daffd", + "metadata": {}, + "outputs": [], + "source": [ + "import jsonschema" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "e76ef7df", + "metadata": {}, + "outputs": [], + "source": [ + "from jsonschema import validate" + ] + }, + { + "cell_type": "code", + "execution_count": 64, + "id": "32841f60", + "metadata": {}, + "outputs": [], + "source": [ + "data=pd.read_csv('mock_genotype.tsv',sep='\\t')" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "id": "d8093c88", + "metadata": {}, + "outputs": [], + "source": [ + "schema = {\n", + " \"type\": \"object\",\n", + " \"properties\": {\n", + " \"FID\": {\"type\": \"number\"},\n", + " \"IID\": {\"type\": \"string\"},\n", + " \"Miss_Pheno\": {\"type\": \"number\"},\n", + " \"N_Miss\": {\"type\": \"number\"},\n", + " \"N_Geno\": {\"type\": \"number\"},\n", + " \"MAF\": {\"type\": \"string\"},\n", + " },\n", + " \"required\": [\"FID\", \"TID\", \"MAF\"]\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "6f3beb1e", + "metadata": {}, + "outputs": [], + "source": [ + "jsonschema.Draft7Validator.check_schema(schema)" + ] + }, + { + "cell_type": "code", + "execution_count": 60, + "id": "ffa78f94", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
FID (string)IID (string)Miss_Pheno (boolean)N_Miss (int)N_GENO (int)MAF (float)
0P554P554N4096977220.02191
1P557P557N4011977220.02105
2P558P558N4327977220.02428
3P562P562N4099977220.02195
4P564P564N4100977220.02391
5P567P567N4013977220.02705
6P568P568Y4227977220.02478
7P572P572N4199977220.02096
8P574P574N4034977220.02783
9P577P577N4245977220.02209
10P578P578N4127977220.02109
11P582P582N4091977220.02164
12P584P584Y4024977220.02309
13P587P587Y4123977220.02037
14P588P588N4330977220.02023
15P592P592N4013977220.02283
16P594P594N4056977220.02923
17P597P597N4163977220.02501
18P598P598N4356977220.02840
19P602P602N4037977220.02152
\n", + "
" + ], + "text/plain": [ + " FID (string) IID (string) Miss_Pheno (boolean) N_Miss (int) N_GENO (int) \\\n", + "0 P554 P554 N 4096 97722 \n", + "1 P557 P557 N 4011 97722 \n", + "2 P558 P558 N 4327 97722 \n", + "3 P562 P562 N 4099 97722 \n", + "4 P564 P564 N 4100 97722 \n", + "5 P567 P567 N 4013 97722 \n", + "6 P568 P568 Y 4227 97722 \n", + "7 P572 P572 N 4199 97722 \n", + "8 P574 P574 N 4034 97722 \n", + "9 P577 P577 N 4245 97722 \n", + "10 P578 P578 N 4127 97722 \n", + "11 P582 P582 N 4091 97722 \n", + "12 P584 P584 Y 4024 97722 \n", + "13 P587 P587 Y 4123 97722 \n", + "14 P588 P588 N 4330 97722 \n", + "15 P592 P592 N 4013 97722 \n", + "16 P594 P594 N 4056 97722 \n", + "17 P597 P597 N 4163 97722 \n", + "18 P598 P598 N 4356 97722 \n", + "19 P602 P602 N 4037 97722 \n", + "\n", + " MAF (float) \n", + "0 0.02191 \n", + "1 0.02105 \n", + "2 0.02428 \n", + "3 0.02195 \n", + "4 0.02391 \n", + "5 0.02705 \n", + "6 0.02478 \n", + "7 0.02096 \n", + "8 0.02783 \n", + "9 0.02209 \n", + "10 0.02109 \n", + "11 0.02164 \n", + "12 0.02309 \n", + "13 0.02037 \n", + "14 0.02023 \n", + "15 0.02283 \n", + "16 0.02923 \n", + "17 0.02501 \n", + "18 0.02840 \n", + "19 0.02152 " + ] + }, + "execution_count": 60, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data" + ] + }, + { + "cell_type": "code", + "execution_count": 65, + "id": "4f051a82", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'[{\"index\":0,\"FID\":\"P554\",\"IID\":\"P554\",\"Miss_Pheno\":\"N\",\"N_Miss\":4096,\"N_Geno\":97722,\"MAF\":0.02191},{\"index\":1,\"FID\":\"P557\",\"IID\":\"P557\",\"Miss_Pheno\":\"N\",\"N_Miss\":4011,\"N_Geno\":97722,\"MAF\":0.02105},{\"index\":2,\"FID\":\"P558\",\"IID\":\"P558\",\"Miss_Pheno\":\"N\",\"N_Miss\":4327,\"N_Geno\":97722,\"MAF\":0.02428},{\"index\":3,\"FID\":\"P562\",\"IID\":\"P562\",\"Miss_Pheno\":\"N\",\"N_Miss\":4099,\"N_Geno\":97722,\"MAF\":0.02195},{\"index\":4,\"FID\":\"P564\",\"IID\":\"P564\",\"Miss_Pheno\":\"N\",\"N_Miss\":4100,\"N_Geno\":97722,\"MAF\":0.02391},{\"index\":5,\"FID\":\"P567\",\"IID\":\"P567\",\"Miss_Pheno\":\"N\",\"N_Miss\":4013,\"N_Geno\":97722,\"MAF\":0.02705},{\"index\":6,\"FID\":\"P568\",\"IID\":\"P568\",\"Miss_Pheno\":\"Y\",\"N_Miss\":4227,\"N_Geno\":97722,\"MAF\":0.02478},{\"index\":7,\"FID\":\"P572\",\"IID\":\"P572\",\"Miss_Pheno\":\"N\",\"N_Miss\":4199,\"N_Geno\":97722,\"MAF\":0.02096},{\"index\":8,\"FID\":\"P574\",\"IID\":\"P574\",\"Miss_Pheno\":\"N\",\"N_Miss\":4034,\"N_Geno\":97722,\"MAF\":0.02783},{\"index\":9,\"FID\":\"P577\",\"IID\":\"P577\",\"Miss_Pheno\":\"N\",\"N_Miss\":4245,\"N_Geno\":97722,\"MAF\":0.02209},{\"index\":10,\"FID\":\"P578\",\"IID\":\"P578\",\"Miss_Pheno\":\"N\",\"N_Miss\":4127,\"N_Geno\":97722,\"MAF\":0.02109},{\"index\":11,\"FID\":\"P582\",\"IID\":\"P582\",\"Miss_Pheno\":\"N\",\"N_Miss\":4091,\"N_Geno\":97722,\"MAF\":0.02164},{\"index\":12,\"FID\":\"P584\",\"IID\":\"P584\",\"Miss_Pheno\":\"Y\",\"N_Miss\":4024,\"N_Geno\":97722,\"MAF\":0.02309},{\"index\":13,\"FID\":\"P587\",\"IID\":\"P587\",\"Miss_Pheno\":\"Y\",\"N_Miss\":4123,\"N_Geno\":97722,\"MAF\":0.02037},{\"index\":14,\"FID\":\"P588\",\"IID\":\"P588\",\"Miss_Pheno\":\"N\",\"N_Miss\":4330,\"N_Geno\":97722,\"MAF\":0.02023},{\"index\":15,\"FID\":\"P592\",\"IID\":\"P592\",\"Miss_Pheno\":\"N\",\"N_Miss\":4013,\"N_Geno\":97722,\"MAF\":0.02283},{\"index\":16,\"FID\":\"P594\",\"IID\":\"P594\",\"Miss_Pheno\":\"N\",\"N_Miss\":4056,\"N_Geno\":97722,\"MAF\":0.02923},{\"index\":17,\"FID\":\"P597\",\"IID\":\"P597\",\"Miss_Pheno\":\"N\",\"N_Miss\":4163,\"N_Geno\":97722,\"MAF\":0.02501},{\"index\":18,\"FID\":\"P598\",\"IID\":\"P598\",\"Miss_Pheno\":\"N\",\"N_Miss\":4356,\"N_Geno\":97722,\"MAF\":0.0284},{\"index\":19,\"FID\":\"P602\",\"IID\":\"P602\",\"Miss_Pheno\":\"N\",\"N_Miss\":4037,\"N_Geno\":97722,\"MAF\":0.02152}]'" + ] + }, + "execution_count": 65, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data.reset_index().to_json(orient='records')" + ] + }, + { + "cell_type": "code", + "execution_count": 66, + "id": "19216468", + "metadata": {}, + "outputs": [], + "source": [ + "import json" + ] + }, + { + "cell_type": "code", + "execution_count": 70, + "id": "f13934e6", + "metadata": {}, + "outputs": [], + "source": [ + "f = open('alumni_salary.json')\n", + "jsondata = json.load(f)\n", + "f.close()" + ] + }, + { + "cell_type": "code", + "execution_count": 77, + "id": "e76f2189", + "metadata": {}, + "outputs": [], + "source": [ + "schema = {\n", + " \"type\": \"object\",\n", + " \"properties\": {\n", + " \"name\": {\"type\": \"string\"},\n", + " \"gpa\": {\"type\": \"number\"},\n", + " \"age\": {\"type\": \"number\"},\n", + " \"salary\": {\"type\": \"number\"},\n", + " },\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": 78, + "id": "f6544710", + "metadata": {}, + "outputs": [ + { + "ename": "ValidationError", + "evalue": "[{'name': 'John Smith', 'gpa': 3.5, 'age': 25, 'salary': 50000}, {'name': 'Jane Doe', 'gpa': 3.2, 'age': 22, 'salary': 45000}, {'name': 'Bob Johnson', 'gpa': 3.8, 'age': 30, 'salary': 55000}, {'name': 'Sara Lee', 'gpa': 3.0, 'age': 27, 'salary': 40000}, {'name': 'Tom Brown', 'gpa': 3.7, 'age': 32, 'salary': 60000}, {'name': 'Emily Davis', 'gpa': 3.4, 'age': 23, 'salary': 42000}, {'name': 'Michael Miller', 'gpa': 3.9, 'age': 28, 'salary': 65000}, {'name': 'Jessica Wilson', 'gpa': 3.1, 'age': 24, 'salary': 46000}, {'name': 'Matthew Anderson', 'gpa': 3.6, 'age': 29, 'salary': 58000}, {'name': 'Nicholas Thompson', 'gpa': 3.3, 'age': 26, 'salary': 49000}, {'name': 'Ashley Moore', 'gpa': 3.8, 'age': 35, 'salary': 62000}, {'name': 'David Taylor', 'gpa': 3.0, 'age': 31, 'salary': 52000}, {'name': 'Joseph Hernandez', 'gpa': 3.7, 'age': 33, 'salary': 57000}, {'name': 'Brian Martinez', 'gpa': 3.4, 'age': 30, 'salary': 50000}, {'name': 'Brandon Lee', 'gpa': 3.9, 'age': 25, 'salary': 60000}, {'name': 'Adam Clark', 'gpa': 3.1, 'age': 22, 'salary': 45000}, {'name': 'Natalie Rodriguez', 'gpa': 3.6, 'age': 27, 'salary': 48000}, {'name': 'Justin Green', 'gpa': 3.3, 'age': 32, 'salary': 55000}] is not of type 'object'\n\nFailed validating 'type' in schema:\n {'properties': {'age': {'type': 'number'},\n 'gpa': {'type': 'number'},\n 'name': {'type': 'string'},\n 'salary': {'type': 'number'}},\n 'type': 'object'}\n\nOn instance:\n [{'age': 25, 'gpa': 3.5, 'name': 'John Smith', 'salary': 50000},\n {'age': 22, 'gpa': 3.2, 'name': 'Jane Doe', 'salary': 45000},\n {'age': 30, 'gpa': 3.8, 'name': 'Bob Johnson', 'salary': 55000},\n {'age': 27, 'gpa': 3.0, 'name': 'Sara Lee', 'salary': 40000},\n {'age': 32, 'gpa': 3.7, 'name': 'Tom Brown', 'salary': 60000},\n {'age': 23, 'gpa': 3.4, 'name': 'Emily Davis', 'salary': 42000},\n {'age': 28, 'gpa': 3.9, 'name': 'Michael Miller', 'salary': 65000},\n {'age': 24, 'gpa': 3.1, 'name': 'Jessica Wilson', 'salary': 46000},\n {'age': 29, 'gpa': 3.6, 'name': 'Matthew Anderson', 'salary': 58000},\n {'age': 26, 'gpa': 3.3, 'name': 'Nicholas Thompson', 'salary': 49000},\n {'age': 35, 'gpa': 3.8, 'name': 'Ashley Moore', 'salary': 62000},\n {'age': 31, 'gpa': 3.0, 'name': 'David Taylor', 'salary': 52000},\n {'age': 33, 'gpa': 3.7, 'name': 'Joseph Hernandez', 'salary': 57000},\n {'age': 30, 'gpa': 3.4, 'name': 'Brian Martinez', 'salary': 50000},\n {'age': 25, 'gpa': 3.9, 'name': 'Brandon Lee', 'salary': 60000},\n {'age': 22, 'gpa': 3.1, 'name': 'Adam Clark', 'salary': 45000},\n {'age': 27, 'gpa': 3.6, 'name': 'Natalie Rodriguez', 'salary': 48000},\n {'age': 32, 'gpa': 3.3, 'name': 'Justin Green', 'salary': 55000}]", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mValidationError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[78], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mvalidate\u001b[49m\u001b[43m(\u001b[49m\u001b[43mjsondata\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mschema\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mschema\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m/opt/homebrew/lib/python3.10/site-packages/jsonschema/validators.py:1121\u001b[0m, in \u001b[0;36mvalidate\u001b[0;34m(instance, schema, cls, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1119\u001b[0m error \u001b[38;5;241m=\u001b[39m exceptions\u001b[38;5;241m.\u001b[39mbest_match(validator\u001b[38;5;241m.\u001b[39miter_errors(instance))\n\u001b[1;32m 1120\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m error \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m-> 1121\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m error\n", + "\u001b[0;31mValidationError\u001b[0m: [{'name': 'John Smith', 'gpa': 3.5, 'age': 25, 'salary': 50000}, {'name': 'Jane Doe', 'gpa': 3.2, 'age': 22, 'salary': 45000}, {'name': 'Bob Johnson', 'gpa': 3.8, 'age': 30, 'salary': 55000}, {'name': 'Sara Lee', 'gpa': 3.0, 'age': 27, 'salary': 40000}, {'name': 'Tom Brown', 'gpa': 3.7, 'age': 32, 'salary': 60000}, {'name': 'Emily Davis', 'gpa': 3.4, 'age': 23, 'salary': 42000}, {'name': 'Michael Miller', 'gpa': 3.9, 'age': 28, 'salary': 65000}, {'name': 'Jessica Wilson', 'gpa': 3.1, 'age': 24, 'salary': 46000}, {'name': 'Matthew Anderson', 'gpa': 3.6, 'age': 29, 'salary': 58000}, {'name': 'Nicholas Thompson', 'gpa': 3.3, 'age': 26, 'salary': 49000}, {'name': 'Ashley Moore', 'gpa': 3.8, 'age': 35, 'salary': 62000}, {'name': 'David Taylor', 'gpa': 3.0, 'age': 31, 'salary': 52000}, {'name': 'Joseph Hernandez', 'gpa': 3.7, 'age': 33, 'salary': 57000}, {'name': 'Brian Martinez', 'gpa': 3.4, 'age': 30, 'salary': 50000}, {'name': 'Brandon Lee', 'gpa': 3.9, 'age': 25, 'salary': 60000}, {'name': 'Adam Clark', 'gpa': 3.1, 'age': 22, 'salary': 45000}, {'name': 'Natalie Rodriguez', 'gpa': 3.6, 'age': 27, 'salary': 48000}, {'name': 'Justin Green', 'gpa': 3.3, 'age': 32, 'salary': 55000}] is not of type 'object'\n\nFailed validating 'type' in schema:\n {'properties': {'age': {'type': 'number'},\n 'gpa': {'type': 'number'},\n 'name': {'type': 'string'},\n 'salary': {'type': 'number'}},\n 'type': 'object'}\n\nOn instance:\n [{'age': 25, 'gpa': 3.5, 'name': 'John Smith', 'salary': 50000},\n {'age': 22, 'gpa': 3.2, 'name': 'Jane Doe', 'salary': 45000},\n {'age': 30, 'gpa': 3.8, 'name': 'Bob Johnson', 'salary': 55000},\n {'age': 27, 'gpa': 3.0, 'name': 'Sara Lee', 'salary': 40000},\n {'age': 32, 'gpa': 3.7, 'name': 'Tom Brown', 'salary': 60000},\n {'age': 23, 'gpa': 3.4, 'name': 'Emily Davis', 'salary': 42000},\n {'age': 28, 'gpa': 3.9, 'name': 'Michael Miller', 'salary': 65000},\n {'age': 24, 'gpa': 3.1, 'name': 'Jessica Wilson', 'salary': 46000},\n {'age': 29, 'gpa': 3.6, 'name': 'Matthew Anderson', 'salary': 58000},\n {'age': 26, 'gpa': 3.3, 'name': 'Nicholas Thompson', 'salary': 49000},\n {'age': 35, 'gpa': 3.8, 'name': 'Ashley Moore', 'salary': 62000},\n {'age': 31, 'gpa': 3.0, 'name': 'David Taylor', 'salary': 52000},\n {'age': 33, 'gpa': 3.7, 'name': 'Joseph Hernandez', 'salary': 57000},\n {'age': 30, 'gpa': 3.4, 'name': 'Brian Martinez', 'salary': 50000},\n {'age': 25, 'gpa': 3.9, 'name': 'Brandon Lee', 'salary': 60000},\n {'age': 22, 'gpa': 3.1, 'name': 'Adam Clark', 'salary': 45000},\n {'age': 27, 'gpa': 3.6, 'name': 'Natalie Rodriguez', 'salary': 48000},\n {'age': 32, 'gpa': 3.3, 'name': 'Justin Green', 'salary': 55000}]" + ] + } + ], + "source": [ + "validate(jsondata, schema=schema)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5dc8972f", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 23, + "id": "eedebe10", + "metadata": {}, + "outputs": [], + "source": [ + "validate(\"127.0.0.1\", {\"format\" : \"ipv4\"}, format_checker=jsonschema.Draft202012Validator.FORMAT_CHECKER)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d56d0083", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.9" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/backend-services/schema_files/patient_genotype.json b/backend-services/schema_files/patient_genotype.json new file mode 100644 index 0000000..90da073 --- /dev/null +++ b/backend-services/schema_files/patient_genotype.json @@ -0,0 +1,182 @@ +[ + { + "index": 0, + "FID": "P554", + "IID": "P554", + "Miss_Pheno": "N", + "N_Miss": 4096, + "N_Geno": 97722, + "MAF": 0.02191 + }, + { + "index": 1, + "FID": "P557", + "IID": "P557", + "Miss_Pheno": "N", + "N_Miss": 4011, + "N_Geno": 97722, + "MAF": 0.02105 + }, + { + "index": 2, + "FID": "P558", + "IID": "P558", + "Miss_Pheno": "N", + "N_Miss": 4327, + "N_Geno": 97722, + "MAF": 0.02428 + }, + { + "index": 3, + "FID": "P562", + "IID": "P562", + "Miss_Pheno": "N", + "N_Miss": 4099, + "N_Geno": 97722, + "MAF": 0.02195 + }, + { + "index": 4, + "FID": "P564", + "IID": "P564", + "Miss_Pheno": "N", + "N_Miss": 4100, + "N_Geno": 97722, + "MAF": 0.02391 + }, + { + "index": 5, + "FID": "P567", + "IID": "P567", + "Miss_Pheno": "N", + "N_Miss": 4013, + "N_Geno": 97722, + "MAF": 0.02705 + }, + { + "index": 6, + "FID": "P568", + "IID": "P568", + "Miss_Pheno": "Y", + "N_Miss": 4227, + "N_Geno": 97722, + "MAF": 0.02478 + }, + { + "index": 7, + "FID": "P572", + "IID": "P572", + "Miss_Pheno": "N", + "N_Miss": 4199, + "N_Geno": 97722, + "MAF": 0.02096 + }, + { + "index": 8, + "FID": "P574", + "IID": "P574", + "Miss_Pheno": "N", + "N_Miss": 4034, + "N_Geno": 97722, + "MAF": 0.02783 + }, + { + "index": 9, + "FID": "P577", + "IID": "P577", + "Miss_Pheno": "N", + "N_Miss": 4245, + "N_Geno": 97722, + "MAF": 0.02209 + }, + { + "index": 10, + "FID": "P578", + "IID": "P578", + "Miss_Pheno": "N", + "N_Miss": 4127, + "N_Geno": 97722, + "MAF": 0.02109 + }, + { + "index": 11, + "FID": "P582", + "IID": "P582", + "Miss_Pheno": "N", + "N_Miss": 4091, + "N_Geno": 97722, + "MAF": 0.02164 + }, + { + "index": 12, + "FID": "P584", + "IID": "P584", + "Miss_Pheno": "Y", + "N_Miss": 4024, + "N_Geno": 97722, + "MAF": 0.02309 + }, + { + "index": 13, + "FID": "P587", + "IID": "P587", + "Miss_Pheno": "Y", + "N_Miss": 4123, + "N_Geno": 97722, + "MAF": 0.02037 + }, + { + "index": 14, + "FID": "P588", + "IID": "P588", + "Miss_Pheno": "N", + "N_Miss": 4330, + "N_Geno": 97722, + "MAF": 0.02023 + }, + { + "index": 15, + "FID": "P592", + "IID": "P592", + "Miss_Pheno": "N", + "N_Miss": 4013, + "N_Geno": 97722, + "MAF": 0.02283 + }, + { + "index": 16, + "FID": "P594", + "IID": "P594", + "Miss_Pheno": "N", + "N_Miss": 4056, + "N_Geno": 97722, + "MAF": 0.02923 + }, + { + "index": 17, + "FID": "P597", + "IID": "P597", + "Miss_Pheno": "N", + "N_Miss": 4163, + "N_Geno": 97722, + "MAF": 0.02501 + }, + { + "index": 18, + "FID": "P598", + "IID": "P598", + "Miss_Pheno": "N", + "N_Miss": 4356, + "N_Geno": 97722, + "MAF": 0.0284 + }, + { + "index": 19, + "FID": "P602", + "IID": "P602", + "Miss_Pheno": "N", + "N_Miss": 4037, + "N_Geno": 97722, + "MAF": 0.02152 + } +] \ No newline at end of file diff --git a/backend-services/schema_files/patient_genotype.tsv b/backend-services/schema_files/patient_genotype.tsv new file mode 100644 index 0000000..4d600f3 --- /dev/null +++ b/backend-services/schema_files/patient_genotype.tsv @@ -0,0 +1,21 @@ +FID IID Miss_Pheno N_Miss N_Geno MAF +P554 P554 N 4096 97722 0.02191 +P557 P557 N 4011 97722 0.02105 +P558 P558 N 4327 97722 0.02428 +P562 P562 N 4099 97722 0.02195 +P564 P564 N 4100 97722 0.02391 +P567 P567 N 4013 97722 0.02705 +P568 P568 Y 4227 97722 0.02478 +P572 P572 N 4199 97722 0.02096 +P574 P574 N 4034 97722 0.02783 +P577 P577 N 4245 97722 0.02209 +P578 P578 N 4127 97722 0.02109 +P582 P582 N 4091 97722 0.02164 +P584 P584 Y 4024 97722 0.02309 +P587 P587 Y 4123 97722 0.02037 +P588 P588 N 4330 97722 0.02023 +P592 P592 N 4013 97722 0.02283 +P594 P594 N 4056 97722 0.02923 +P597 P597 N 4163 97722 0.02501 +P598 P598 N 4356 97722 0.02840 +P602 P602 N 4037 97722 0.02152 \ No newline at end of file diff --git a/backend-services/schema_files/patient_genotype_schema.json b/backend-services/schema_files/patient_genotype_schema.json new file mode 100644 index 0000000..b18b677 --- /dev/null +++ b/backend-services/schema_files/patient_genotype_schema.json @@ -0,0 +1,12 @@ +schema = { + "type": "object", + "properties": { + "FID": {"type": "number"}, + "IID": {"type": "string"}, + "Miss_Pheno": {"type": "number"}, + "N_Miss": {"type": "number"}, + "N_Geno": {"type": "number"}, + "MAF": {"type": "string"}, + }, + "required": ["FID", "TID", "MAF"] +} \ No newline at end of file diff --git a/backend-services/src/common/__init__.py b/backend-services/src/common/__init__.py new file mode 100644 index 0000000..4e2423d --- /dev/null +++ b/backend-services/src/common/__init__.py @@ -0,0 +1,4 @@ +""" +A collection of various helpers, convenience libraries or otherwise commonly +reused code for the Nautilus Vault backend. +""" diff --git a/backend-services/src/common/__pycache__/__init__.cpython-311.pyc b/backend-services/src/common/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0fdfc2c0b22d541cecb39bfee40e36a56e4283c2 GIT binary patch literal 339 zcmY*VJ5B>J5VeyC&`LP~o!dxkd;t_G7f6FhL1XRO6RnBYUiq^q>9_zbM?hSKBhb=O zt&}bmV`)<`#eDSMyf>PU`Me+)Z@*vi73)tPE1-hX IlAj^^2M#f4J^%m! literal 0 HcmV?d00001 diff --git a/backend-services/src/common/__pycache__/settings.cpython-311.pyc b/backend-services/src/common/__pycache__/settings.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..964d6c7af4ff7ebf5a86ff0370c2ad4eeee9c0e6 GIT binary patch literal 1499 zcmZ`(y>Ht_6u;w#Owp23S8@QuXv?6JfS790r7eO0ZJc&9iW<$Jg`n?F_SGa$y(1Oa z@ZceX5d>Ymc5++fZ|FbJNka#LQ-Ds{Xeg7Xz9U83N|O`s$Mi2frMKGSf z{+s-2BJ{6T>R~U0`PU$vBZ?@FP>hEdYuSj5*c_S|8R&aN&1Z;O3}3(*FJV?=Xi<9? z^&79X+Q)h8+fcDxmZm(}SD@dm~YoW~VgK&-*8e)ou2E{|O z3~WGP^TL3zFslJ!EeLDpPJRCIU#Yt)Wm>-H zJ-+3hgp%uQl_w@lN=}(qv#5je#4nFnDoA^g<@`qwmJ33Sp~Y-!vIgA63bkQ2V6HF+ z&>0yUi>(NaT-tnQU4Z`b+BR%b7s|GJb*Cl2E9z_ z1N22+JsJF@m{fzG_XIg$2|FARLD?V)vy?}f+Dc`nQbxCkh{svV274hnWC`7ZO%qO- z8YoF%OB{=2Q0L;0kMcDF`$WtYWKs5{I==T-HT?fAS<}=$1UN-S5B0p?KAL{EJ?(B! zTibK6qMg2*J3)|yF$;p+4T4zE4C)l*tswX%3!{an1N|?a262{_O_@8owz{JEDv6*C zW0oEWnp^47m`PoV+)lG`#H1!5?`Y60=j0{`54dE)(cY$uQop~Y%LTG1ma35I_T4{ie@RgsMDQx`+s~f?fU<;2gPb>MK^e9 zB6t18W_4_F%Te*$1SUIuTXx|sdm7dO@|7T1gqRsA7c_j`E>6}9E+UpWt|JANoX qf$bQk+6O31jPVTJn=U^y^yPH0>e literal 0 HcmV?d00001 diff --git a/backend-services/src/common/__pycache__/types.cpython-311.pyc b/backend-services/src/common/__pycache__/types.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fd5e2f64d163e67cc4a7065f058a8cafb6b324e3 GIT binary patch literal 314 zcmY*UyGq1R5S@Dy+(ifmECl}`LcCxtfOb4 z@=gLgasOcA8E*`c|JkpRXa^&lA2$`Y!D*6Z=njpsNHmK4cFi?aTAW#rFI$hCwSC$n zEPLx}tWF3msf%f;&#}On(xpLFB(+Pknqp^ba%f^*=2h)bO%pxC!o+O4Of`}stJ#w0 zWuZ6-X}4-t!~MK8b%qDFe_3$T9#iKDA>Ls7<$t}0Ti1izjfc%e7{7+`RnSQ({0^Ax GkZs>yh*Z1) literal 0 HcmV?d00001 diff --git a/backend-services/src/common/settings.py b/backend-services/src/common/settings.py new file mode 100644 index 0000000..9d37d85 --- /dev/null +++ b/backend-services/src/common/settings.py @@ -0,0 +1,27 @@ +from pydantic import BaseSettings +from pydantic.env_settings import SettingsSourceCallable + + +class Settings(BaseSettings): + """ + Application configuration settings. + + Values not passed as keyword arguments are read from the environment if + available. Environment variables override settings passed in. + """ + + class Config: + allow_mutation = False + env_file = ".env" + + @classmethod + def customise_sources( + cls: type, + init_settings: SettingsSourceCallable, + env_settings: SettingsSourceCallable, + file_secret_settings: SettingsSourceCallable, + ) -> tuple[SettingsSourceCallable, ...]: + # Environment variables should take precedence: + # + # https://pydantic-docs.helpmanual.io/usage/settings/#changing-priority + return env_settings, init_settings, file_secret_settings diff --git a/backend-services/src/common/types.py b/backend-services/src/common/types.py new file mode 100644 index 0000000..9de818f --- /dev/null +++ b/backend-services/src/common/types.py @@ -0,0 +1,6 @@ +from typing import NewType + +WalletAddress = NewType("WalletAddress", str) +""" +A type for vault wallet addresses. +""" diff --git a/backend-services/src/data_service/__init__.py b/backend-services/src/data_service/__init__.py new file mode 100644 index 0000000..40c4e6e --- /dev/null +++ b/backend-services/src/data_service/__init__.py @@ -0,0 +1,3 @@ +""" +Data service for the Nautilus Vault backend. +""" diff --git a/backend-services/src/data_service/__pycache__/__init__.cpython-311.pyc b/backend-services/src/data_service/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..498e8face7dadaf8b8b7ad39687f29046db6d61f GIT binary patch literal 269 zcmZ3^%ge<81dXpwC7S~2#~=<2FhUuhK}x1Gq%cG=q%a0EXfjplak(UxBq|iA7L{ct zrz)i77b%ovq$>C&mX>7Zlol(5C6?xtC?q8&XQ$?+=yCaJGTvg3k59=@j*nl-@EK(6 zuNeJMp!Q<@tfc(pjMTi;Z2jc?lvMpZs1dp)MWw|hsVTb2`MCw9C8_#Q!*ro`7V8%m zCF`dET@eoz(T|VM%*!l^kJl@x{Ka9Do1apelWJGQ2DA+1kzz?8@qw9J5Ve;G&`LP~o!b-}UjWh3AsV2evAi<_G1+)lwl`9^2uDDifIDymS}MAg z(xt+d79pm1^LsOI=5;==MYi|v54g(yt0ccBr(j#|jY#q?DzFx@B6JwCUm^ZO6YKKRCm-|sa zwG1orwAR2#+S?(yZir0^LrjDX@TMOU>DI!UJT}wPsAB+KWXx32f9GgpoOj8XWxqR| go^Ke3jxNG+)-A8bvkc>rlya;pIUB`42(#S%0kx-F0RR91 literal 0 HcmV?d00001 diff --git a/backend-services/src/data_service/operations/__pycache__/datapool.cpython-311.pyc b/backend-services/src/data_service/operations/__pycache__/datapool.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2bb55576254d4e6069b777ee04b4fccf2c7b2a19 GIT binary patch literal 2392 zcmah~O>7%Q6rTObdTqx}+@`JDglbEnm76-2I3SP^2(?X%S_NnW6kn{(&N$h0f2^5x z+6GsODC(h?q6(=M5~3FZs339dp-4G%K%2@3Yb7KkF6CyFa_NaTv-V=Ap-g7qd-LYa zo0s>#dHyz+%ODu|mtU>3BMAM$7yY62gss~k+(8&&$w97El_W09j_fK`MaYVyx+B#Q zA*+t&rm87duj*nw;-uY7HREQhS+UlfQ8!o3ft(^atdkT@lT2O1na|W}zNgc18fQT_ z3c4|&%aIYV)m_GNe>lH8KW_I7NnOc;vEydzqRM zTO}_x0Z-UE>$ca zlZt0H1KVk`azL9bAh>M#Zlf8H%7STKA|5Wop%vRAtiq^O;a+P!O~r2zYH~m^q32kc zXWaI$u;tD$V+*7VKk&z;T8;dbV5sO~U3*?pn9Zwqcm zb3+K^co7JE48rpfIE)N|p#+iKaeo8}&JY@um;c47d`X;K2YNs80a%mzSi7dQl(n&d zSF|_qHe`M(0fq-|>f0gIQidZP^b0LT5*R)rfEqt*z%XkN%dXo5Z$t8&{RO;*Qi}4} zqcj$6fP-1D+a9j@9uWYIWE)csvq+0gO6njQZCnfdTD%h#$Q5W5wzrtTgK_5oP=oH{ zF2;Jd^zlm%fp!mk>;{k?dNP2XyR+@75c6jU4(dKY91WX5MJ$jZil_nekiYo8_=r+RPklXO4yHe@?oe zN19F^_s*EYU=(8tY6bGMBS@+bSQ(H9d)@zG1?nlU&WU=SCjqs|3W16`kYvNJ8_<4| znlhvAQ`lRySBPgc;T0Qo>bpj;M1;+P$w=J6=1NMW@)F1W=S7ITB*!J?GUK84>y_>o ziqV%r&8x*;1rk@PtD{}TJCnC3zqM02A2olxHJqp6+D z2zU-`@FbdTn%nK)$u7Q*H!{)D1Te+_{5=w33;aIS-*A20bjX{u43_+-gk^zt6-kmh z=ukL3JLrXQc>a!#gu}CgX2YFk2fY>UG&|^cI6S+WE*0+`=^|i1%?P$}QLyb~Z(5q> jhQPQXu#I`awv(bNossU&b`j^_U5oj~RLq}GMY8?@K^9SD literal 0 HcmV?d00001 diff --git a/backend-services/src/data_service/operations/__pycache__/dataset.cpython-311.pyc b/backend-services/src/data_service/operations/__pycache__/dataset.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3707d5cb48ed724c7d3b6432755b7a791c2f6786 GIT binary patch literal 2706 zcmc&#O>7%Q6rTNwy|H5_PD+xJMr>OeYD#R7P%0=OP?HKs8d_S2WQ45E&N$s4#c znSJk@x8J5x2?WFWGda;w0Gm zz}C-gDbfRR%$5e*0Jrs%Ow%?1wn3acg|eBy*pahBkb3*{=@T>ObW-*V#|DG)-r_RR zy>~EkE@-Anytgo>#C5Y`kUC0<=8Osc8c4NCkg9@+6zWoZ)(~P;ACtGHepW zNRyW}s#$Ijqr|IFTNil(L!tn?2!Ec=StLM8J>j8$U07~uAh(_bS&E`SmfPf>HaRL5 z`d-)q`DRPMAg-fp@hGyLuZvr-msC6I{!>Ug%PGl)l{3D zRdJZ59QR~nLGM|f&7y&WKISWy9miyvY-<(?l9;$UHFzC@mh)q`V zx`RpH)+(N1R@_OCR$PzZN!_u^6_4Z>HGPHHcoH63HFVN;6r%b5E5ae<@ zfFoC43)11~qy6b9?9c9zy9VSg{5H@(3L1L4J~&z%+;?lZ_R{pvQ@k&W3#3?(yH4qZO<`ARjhua?;7%UxzYIqb{B z_h550-+?)X5RSRKAUqj!omk+gXG* zqu*oIY!3Vg7C#jLwQV~^aR{wTohNNy7n+K|QG0-6GrYxsTDMGeqht`=iQReQO8|d1 zPT8dj5=}HQ1>xqFYlb0v`(Sy}QwwB2H z@?$664M*V@vOAVAxI-*KjX>TxyjIl#BW-efSNkuFoI*Fm^T&A|-zOe5$SQ$Knvh)8 zDXGwLqFTCY$)Vs{GFFMLR^aBUCF)qJcZTqgMQG_^ubR(Ffy^rVu;paMu#&9(xa_1+ zos_7z&;wv)RdT0*gcWKiXmIrE*cW48FI-=$O&q@c%AJYnYG$UEnemf5raTj7ly$fN zH=}ev90A(sv%ta}urozDU~)$e`uHtaT;mO$J_qiDEab6yc=fhPtLi}+bu1p>AWvf z)+H$Wzy*7{g%McUGhikDndxP5ySv4O+p#Xr+d03Oy!L_QdX&HY4HOoVUE~MKYnFp6 zCV7Lt2rB!Cx<`OEBta1BXs_Qn>uB8XoPVGRzjM~nwBK#k(d&M Datapool: + """ + Create a new datapool. + """ + new_datapool = Datapool( + creator_wallet_id=params.creator_wallet_id, name=params.name, description=params.description, length=params.length, datapool_hash=params.datapool_hash, created=params.created + ) + await engine.save(new_datapool) + return new_datapool + + +async def delete_datapool(engine: Engine, params: DeleteDatapool) -> None: + """ + Delete a specified datapool. + """ + # XXX: assumes `params.id` is a 24 character hex string + id_to_delete = ObjectId(params.delete_id) + existing_datapool = await engine.find_one(Datapool, Datapool.id == id_to_delete) + if existing_datapool is None: + raise HTTPException(404) + await engine.delete(existing_datapool) + + +async def datapools(engine: Engine, wallet_id: WalletAddress) -> DatapoolList: + """ + Retrieve a list of all datapools for a given user from the database. + """ + return await engine.find(Datapool, Datapool.wallet_id == wallet_id) diff --git a/backend-services/src/data_service/operations/dataschema.py b/backend-services/src/data_service/operations/dataschema.py new file mode 100644 index 0000000..524a04d --- /dev/null +++ b/backend-services/src/data_service/operations/dataschema.py @@ -0,0 +1,37 @@ +from fastapi import HTTPException +from odmantic import ObjectId + +from common.types import WalletAddress +from data_service.schema.actions import CreateDataschema, DeleteDataschema +from data_service.schema.entities import Dataschema, DataschemaList +from data_service.schema.types import Engine + + +async def create_dataschema(engine: Engine, params: CreateDataschema) -> Dataschema: + """ + Create a new dataschema. + """ + new_dataschema = Dataschema( + wallet_id=params.wallet_id, data_pool_id=params.data_pool_id, name=params.name, description=params.description, length=params.length, created=params.created + ) + await engine.save(new_dataschema) + return new_dataschema + + +async def delete_dataschema(engine: Engine, params: DeleteDataschema) -> None: + """ + Delete a specified dataschema. + """ + # XXX: assumes `params.id` is a 24 character hex string + id_to_delete = ObjectId(params.dataschema_id) + existing_dataschema = await engine.find_one(Dataschema, Dataschema.id == id_to_delete) + if existing_dataschema is None: + raise HTTPException(404) + await engine.delete(existing_dataschema) + + +async def find_by_pool(engine: Engine, data_schema_id: str) -> DataschemaList: + """ + Retrieve a list of all dataschemas for a given user from the database. + """ + return await engine.find(Dataschema, Dataschema.data_schema_id == data_schema_id) diff --git a/backend-services/src/data_service/operations/dataset.py b/backend-services/src/data_service/operations/dataset.py new file mode 100644 index 0000000..3d981fd --- /dev/null +++ b/backend-services/src/data_service/operations/dataset.py @@ -0,0 +1,44 @@ +from fastapi import HTTPException +from odmantic import ObjectId + +from common.types import WalletAddress +from data_service.schema.actions import CreateDataset, DeleteDataset +from data_service.schema.entities import Dataset, DatasetList +from data_service.schema.types import Engine + + +async def create_dataset(engine: Engine, params: CreateDataset) -> Dataset: + """ + Create a new dataset. + """ + new_dataset = Dataset( + wallet_id=params.wallet_id, data_pool_id=params.data_pool_id, name=params.name, description=params.description, length=params.length, created=params.created + ) + await engine.save(new_dataset) + return new_dataset + + +async def delete_dataset(engine: Engine, params: DeleteDataset) -> None: + """ + Delete a specified dataset. + """ + # XXX: assumes `params.id` is a 24 character hex string + id_to_delete = ObjectId(params.dataset_id) + existing_dataset = await engine.find_one(Dataset, Dataset.id == id_to_delete) + if existing_dataset is None: + raise HTTPException(404) + await engine.delete(existing_dataset) + + +async def datasets(engine: Engine, wallet_id: WalletAddress) -> DatasetList: + """ + Retrieve a list of all datasets for a given user from the database. + """ + return await engine.find(Dataset, Dataset.wallet_id == wallet_id) + + +async def find_by_pool(engine: Engine, data_pool_id: str) -> DatasetList: + """ + Retrieve a list of all datasets for a given user from the database. + """ + return await engine.find(Dataset, Dataset.data_pool_id == data_pool_id) diff --git a/backend-services/src/data_service/schema/__init__.py b/backend-services/src/data_service/schema/__init__.py new file mode 100644 index 0000000..58bc07d --- /dev/null +++ b/backend-services/src/data_service/schema/__init__.py @@ -0,0 +1,3 @@ +""" +Internals and abstractions for the data service. +""" diff --git a/backend-services/src/data_service/schema/__pycache__/__init__.cpython-311.pyc b/backend-services/src/data_service/schema/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cccd3fb655fa0fa27d7ed3830f91999b3c4a24ed GIT binary patch literal 280 zcmY*Uy-EZz5Kh)ZW#JycF6|Y20XsqLZEVEGCS)fg7jHK?G7~{x#77XHz<2NwY_04T zuDi+v*21s&=I0x}k9k`zTT$@w^9dKFe%Ij-a&GqZ7wT?cX8Wk%gw*kW+qY)YCE=o(|@ji%x=T5XIEo{d@Wo)4#&V|01It8`p4 W>rZr6XgZQoPE8{hllVtzQPf}K&{7Bh literal 0 HcmV?d00001 diff --git a/backend-services/src/data_service/schema/__pycache__/actions.cpython-311.pyc b/backend-services/src/data_service/schema/__pycache__/actions.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ec52f85875268a641b9182066d96124f58863beb GIT binary patch literal 3358 zcmd5;OKcNI7@mE2y?!Q6fbt0K76EB0C5E;_m5M6ysHzCXsv1!m=djxBOtE3@HM46< z(j1(ML#R09#sT%3D&o>()f4whl_P;ROP&&HcLP5|}Nj%UA}nQtEd zjQ{`J`6ZJ{5=bxq_|twFBjhivbQ9D?>iiC`2ZRzTIiw;LrHWjXC9KPiQc;VlC@W5^ zq7^lX$mB~x)w_hon6#=8@(7+V72|@_fQ$EWy5Mx+5`A1ka7o}&eOyv-Y2Y$_T#9C= z$=JXPTz*Ur5*ICxO}UggLE^UMl&R&rd`t>5*DS|j{sl@o^E_x!fnoNR)#BCNL+2}~ zJ|K(~B}$6&RXCHP!c-Qc@_AsG1|=mbsZl8=N^xK{QPQCl#}d`S!bFg{#2Ku4+48|e zf8kWpfCM$D7&cO6w`$ZZZdI7ixHlpAAo0C0+$_@|4JKP=&2=5Dsa5D0q$u-jUasNb zKyz62x?c+7Vmd|(Yl%QNP3&lzLDDoUF0DIQPMhYfy5(#!anq!(ZJHe2As8@Ct6Ft^ zVUP!%70>5^Qm*=31AdKk0LiPl{8bOk%-@)E?Gmf9n|T|KJzurze%Yye<36u@KBMEd zTdCE3mY=iio2*L5VbJZe&AhzF?Y!90R!iQ4c`8=kvT-xsL~Wkyu#f;;*qa4t?D(~1 zIi|M>f=&jHH`Niy>*`2r=wMUDysjQ>B{Pl5#^lmuD|eu&VqRAdw9*5OD~&5lS6Z1| zW2!N=1W#j%AMUQ!;}&QGrVa(z-z{Wt3@Wcm5Df5yiN&eHbgD8H0!95!quO0{6{ttu z4y3nMOwc&EiXLPxGjP_(RZe$Z1s%r#-)8&xil7*JhhjTkAl(i$&ip#B+H$lcA-E%S z_Rb2x1L8;a60#^!X%+fDiuy~$?*<0+UX*%wNadS?1r| z;2a$fVE_0VZWJ1YrNZ-AwlTB(!+Px4li0CVY_KhBvD~j}o51V0Vext#zC>BThC;O5 z-C2B%z^JwgeYe@r9yG;Wc@W7&==I`NVA|->$|62L@`)ED>)qE6S zrzDBsTsYf%EN>w?pW{8z%*-aqk`em=a~ea=6F5%@v(jsvz8Ns?M*thrZyPEI#_ zbBi2l_U5*ll!n@*A66zeuyu2rIyxYMX!is5gx1Y%>O}u^Vu_WRx1JMv?wV6aJNsc} Negj)K_n?HE{{wY*00{s9 literal 0 HcmV?d00001 diff --git a/backend-services/src/data_service/schema/__pycache__/entities.cpython-311.pyc b/backend-services/src/data_service/schema/__pycache__/entities.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4badd78ddd21b540e31c9f9ddd3e2daf7dc628da GIT binary patch literal 2686 zcmb_e&2Jk;6rc63z3Z>o&L>UNu%Hknhs2_XB2a}CR0)NUfYeq9b69P5rpc!JVP@BW zdvYWWIp)?LdInYe3;Y9IkbSfE6p0fzN69HC-kbG0iS4EZv6*>#^WMyxncw{0bABxr za|FKM|M=57Pzd=82g#T2D`$#C$aC_TP(me#xKd4$P)|82SFXuImmS4T*U~~)oQ$j1 zRH3IG&CS-b5=oKI3C;XWsLJGDWI}#}9)GnQ%d_0AWJqcSCb1&b?t?|F%EGD~OAoD@ z5WYP43L_Cq5V3S6Vp&8i4kAv#s?tcriilVSUu7iXB%ORnR;T{PQ?5!;_EEFWHXPdw zV36MSDRa>JnHjKTQ2fSp92Ra+%2|NZ6l#Xd8e9{U1cI}#Vep(VQj;jDr2uHDCNqVl zX$p_bGN8!=O&Mrup{d}_2u%Y`MU853*leUeFhe*|c=2&ghi}8v&G7l&37PxLprz--|L1^Y+61 zNVPbFyV9Lk*+?@CoM;$P&M;h`HXPIohVgyFbow6EFsN@C2G79Rqmp5mp67=q#tdMx z9E3cQZ7<|1_+ODTkmSOuK88~U)q`E%+GienTD9OAs-D>hZKn~eg}f2K8P+V{tv5ne z-8HSJ%%f|t=m*{h1R3bu|i-7S<_Tdl3bt!}Z>+HP$h zLT_#J`DC{!-+#F;?I0XanH8A(Hk6?XP$3OrGKD#HL7p=SS_Bv;EpeZ;6 z>bn0#H}$~w_8gY5Bjy9o!@iM zeS>=--U`&>C4MoGaY&3d9-{w{RhUb0R$Z(!KeY+J$BQD(=m4R?zQ z$&LOux|NfN1HOIqulR;&^$CYqL|Ovjn;9oS90GP3VsI39q2J87tH4fNLKkBgGY$id zXB>vVAt|w<57lv+hV;xtIm9cjKhN&Q#ajR3;a59)Y}23k91;>ifULvpOz`M~gp7k) z41ObC5wq+y={X0p6xDxQ`<&M8V1{0or*GHvko4@jqO=GG zETK)jySUGFLR@I~GKfPRU6^`sSS%KCeE4b4f?ldfpo4C^)?$mdcRlL)vIG#C0>-iX$$fSP& DWFB|9 literal 0 HcmV?d00001 diff --git a/backend-services/src/data_service/schema/__pycache__/types.cpython-311.pyc b/backend-services/src/data_service/schema/__pycache__/types.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..55ed99dce724bdd7615bb776e24c68ce34e665d2 GIT binary patch literal 391 zcmZWlu};G<5Ir|()F3J*Ht61=m=CCsIxuvB0lIVvu6-(|i5=MvQn!x$0iS^Q0{(%i zY$y{FQ@2XpI$=W@5U1z6_nz*2mY>?~J@E0edgTjWKZE#!v@TTTrwNPV0d}1rcz;@{M3tXQYUU+ zN;NfMW8KoCV9H5uVlPcIcn4X=l+unlsg=#LXV`cfwl{QS(O7yn(fk$_&M4OcsbZCr zd1ZUfRMw&Bab1*^Lpou6hD!AO(7ohnsWqGm=2*6KsP*?0jQR(mJt^ngR=?1q%JIzX t`-Q|GJM?KC5klVKX!#Ex&{_V)I&P47oxovdkvybJIQDq^&Yqa?|6eS|ZjJx| literal 0 HcmV?d00001 diff --git a/backend-services/src/data_service/schema/actions.py b/backend-services/src/data_service/schema/actions.py new file mode 100644 index 0000000..2183030 --- /dev/null +++ b/backend-services/src/data_service/schema/actions.py @@ -0,0 +1,74 @@ +from pydantic import BaseModel, validator + +from common.types import WalletAddress +from datetime import datetime + +class CreateDataset(BaseModel): + """ + Datset creation parameters. + """ + + wallet_id: WalletAddress + data_pool_id: str + name: str + description: str + length: int + created: datetime + + +class DeleteDataset(BaseModel): + """ + Dataset deletion parameters. + """ + + delete_id: str + + @validator("delete_id") + @classmethod + def valid_object_id_hex_representation(cls: type, v: str) -> str: + int(v, 16) + if len(v) != 24: + raise AssertionError( + f"expected a 24 character hexadecimal string but '{v}' has length {len(v)}" + ) + return v + +class CreateDatapool(BaseModel): + """ + Datpool creation parameters. + """ + + creator_wallet_id: WalletAddress + name: str + description: str + length: int + datapool_hash: str + created: datetime + + +class DeleteDatapool(BaseModel): + """ + Datapool deletion parameters. + """ + + delete_id: str + + @validator("delete_id") + @classmethod + def valid_object_id_hex_representation(cls: type, v: str) -> str: + int(v, 16) + if len(v) != 24: + raise AssertionError( + f"expected a 24 character hexadecimal string but '{v}' has length {len(v)}" + ) + return v + +class CreateDataschema(BaseModel): + """ + Schema creation parameters. + """ + + name: str + length: int + data_schema: str + created: datetime diff --git a/backend-services/src/data_service/schema/entities.py b/backend-services/src/data_service/schema/entities.py new file mode 100644 index 0000000..fed710b --- /dev/null +++ b/backend-services/src/data_service/schema/entities.py @@ -0,0 +1,65 @@ +from typing import TypeAlias + +from odmantic import Model +from pydantic import BaseModel + +from common.types import WalletAddress + +from datetime import datetime + +class Dataset(Model): + """ + An address on the ledger dataseted by the user. + """ + + wallet_id: WalletAddress + data_pool_id: str + name: str + description: str + length: int + created: datetime + + +DatasetList: TypeAlias = list[Dataset] + + +class DatasetDocument(BaseModel): + """ + Database representation of a single dataset. + """ + + wallet_id: WalletAddress + dataset: Dataset + +class Datapool(Model): + """ + An address on the ledger dataseted by the user. + """ + + creator_wallet_id: WalletAddress + name: str + description: str + length: int + datapool_hash: str + created: datetime + + +DatapoolList: TypeAlias = list[Datapool] + + +class DatapoolDocument(BaseModel): + """ + Database representation of a single datapool. + """ + + creator_wallet_id: WalletAddress + datapool: Datapool + +class Dataschema(Model): + """ + A JSON schema for a dataset of datapool. + """ + + name: str + data_schema: str + created: datetime diff --git a/backend-services/src/data_service/schema/types.py b/backend-services/src/data_service/schema/types.py new file mode 100644 index 0000000..919c327 --- /dev/null +++ b/backend-services/src/data_service/schema/types.py @@ -0,0 +1,8 @@ +from typing import TypeAlias + +from odmantic import AIOEngine + +""" +A database engine instance. +""" +Engine: TypeAlias = AIOEngine diff --git a/backend-services/src/web_asgi/__init__.py b/backend-services/src/web_asgi/__init__.py new file mode 100644 index 0000000..332be91 --- /dev/null +++ b/backend-services/src/web_asgi/__init__.py @@ -0,0 +1,4 @@ +""" +The web server and its endpoints that exposes the various services of Vault +backend. +""" diff --git a/backend-services/src/web_asgi/__pycache__/__init__.cpython-311.pyc b/backend-services/src/web_asgi/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bcf4adb42fb8512f4f821b29734d47c353b150bc GIT binary patch literal 306 zcmY*UJ5B>J5VeyCqLp$0I=3k{zCgqgX!wc(%WDs;$;MuJ?C`k=M?kp>N1&ynS}9#B z#wZj_@n+uq-pu=KRxz^e_lLP7|5eDJ@k6jHEpN=STW0w=n~z?vtBV%I6Ep%LZXgQn zt#Anic-sf(DN3zQ0-pPTPzZ>PjxJ>Uop6Sd;a*(n+$B*p+N@}DQJu~C=dn^Y7^Svs zSM>Kc@{&YQJ~qL$;9(_Aupqt8$#og)6f-8UwF&D!Cy<9_b-AqQNQ_3(sY>I6lS(=7 ml2VKQWj|f6gUubB#v>9c-{J|uFy@>OqcNWh>>tDlReu0{{#!Tz literal 0 HcmV?d00001 diff --git a/backend-services/src/web_asgi/__pycache__/main.cpython-311.pyc b/backend-services/src/web_asgi/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..953d68d2fdec41b3a6c9207738a259e09035626d GIT binary patch literal 4960 zcmcgv&2JmW6`v(nq{L5=lt_tEZ2CKrEYkY0Wy?-rK~fXjiDX-B8f*g)Ywnn$vrDqG zE4xx+Ky`w~0ea{yCj&wOyE5v7k2>Zr2$sbHCFW$HDA4v&3T`hs_023-Bu&XN+NRX( zo0&In-oD?PxAUHU9}M~s{HDMAF8_BJ{h3XipSLl1IUpkR4N{PV6hU#Rg65K3np<)U zZ0=S?txM|SV^Q^JUdhYHU23=1BlYmHNA+ob$ME)#k4-DPwSWZwYU`LYd$rh4M+pppfso@rKC0_4Qa#DFkkblZ)u05L)u~Ku$Gci zoEK1!Xh)@^0&*dI^a()ugM$l6$AIU>$L<_=SWg64hsXX&Ct$q?p8$!I4)0m;i3?=l zX~>)cnYTe=#No8-Clp|k1F8; zQhI+UD3OBjEc&Di?1abu2?%y(oLOtH#PA??-#O#(p7lL(!%leYpVE*0N*oW~7L~-8 z;w$z{fYwPzvb9$R@BnC?a(EqD2XPd%4uIBVht_G(de+(5+ABlKFlasJ@b=LfQ{u`n zXnm_gYxqD99Ku6y;DI5~dbmUD%z++A;p7i^pbtEd1g%Fpw4OiE14n<*1N{vT9P7|} z;XqrDW9HY_omL!dWqv);p> z&tz4_M(Q5EmC`Y}i%Ht|H+GIAF6#Y>tQ&LJuTYO}$i|vJBGAzM^39bGi;AM+dosbm ziO%WkrTmrU56ecG%&SFQGJxANcV&68R4A61NYH-AoT3n{>!7$>kqueLhE79yf@K5e z8VvRZ1%o|JP8SW%bD0Hu4-GDG0cRR&u2#xrm4=$jeBRq!*Ym4blSjI!*V*iE3_d98 z2JL1Oz9-;}IN!&G?7eQ8` zqkq*fDzll4TF%SrYFRgCrzg*x$&QHB{oZ1hir1G{fWE&tw?I7$iytgz7pX7`t3f!o z^1WP{6v4|njo4GLNP!b5%Bt>2XxLaSD|^#bEGwAk8$B5YgdGBy6@r7QluJ6!X=T7b z{q}+9@-U-4_jripiVF1*Y^;$|e(x@ZK!NOozJTZDB_P+30J+F$SvU6XWQ0CP?YHz7 zkhMN@e}ukq|5{u@Plcrs7wG{lG@zABg>nw_2zn}zQ^3@j($x3a%ugXs^~{}HWjK-& z{xrjk%#<4OJZ_LR-N4FtzN}T&44knHDd<{^%DGx zHLM#yj?c&_ycE2~$^^o)890lj4BJ^`9ELPjfv9r8I1Zb8pvpjg=wzk!-A0INC``DEjWoE z=A5t`r86%ya0QV6&?9yGy{d28@=crKfz3weF;RblnthL4@@HP<_Y_Ei3T7mKx#=F>lLh%ZpJ#y@0Uh) zNS7;^$VL%TVY-nXc|x-9SAM~;%Y_cLZL+xj-EiLEfmzT1OOIdzd5_YffZ;-H{e2RFC@pSlo_a&%t)>Qm1`2?0&QKA0> z0A1flM731S^F(v5`UCOX#HYG~4IZ~Ji$nW(M3Kqt-iRznNseyxUXnC-2G?wW7b zYDhNUti3=Vn+LZSXvA!9FT%-(pM8D*H}^LKweS%$d}Qmib@WO#eANnHWvqdR>otF( z796yKr|MnqUe_)H@=r!K19cw?gda{l{M-tUR{dj^f6Vlq-t^YoVaq*SM}ly=Ci=fx zdaz{1MyukOC61Zm*b7f^v+%3pm&HwY4Y~h>qJKouni#D`2W#iR12An|Z$>*qVSt#_|)CaS^>OSn;Y3BuIYID7BZ^J~0ol3h1) z-4q-thyqYD@L-@O_HPw-&RG|4)v7m&I~5N5XSGX*m{3EnlyuD4Ch)|Pyb ztcjsoEK%!?TfL)oFLDKTk;wD`srv-stZm%c=L<~L*(TZbw~5*M7{uW%^;?g1`6h$7 zVhJk@;`G)#Z0GdzPk7fP3}O}_+EOhL<6FPn`N(=FyAQzmk_W~wHdq#fc!i**Cr$#3J<+{gP^H*1d0G8MBs8@y|hcJpi@zRE9ze*^Ib B(kK7` literal 0 HcmV?d00001 diff --git a/backend-services/src/web_asgi/__pycache__/settings.cpython-311.pyc b/backend-services/src/web_asgi/__pycache__/settings.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f04282451c91bcc317b885c0e408df8ffc86e21b GIT binary patch literal 861 zcmZuvL2uJA6m}A~&C13OV-qkmc9_sAt;-*nCXf(tfE}1BpQA z-S!Vah=0PVy;VLTaoVkDoOa^bT@i@Ayu5th^YinUCx2dAY9lau{*B%b5c=WB+!|Nl zVjsX6Vu%F=DuXmA!!!&W4~wY8DGpGGo+1`~L=1EMDMIKgyfaH1tZ|4s&2vXPp=~`g zrs}D}#xJB8$j4fA0vjK4V{$Rj^lF#?%zIos1bT)zN&|+{um?KQh-2Ph;U288C~fi< zFzgtQ0W~~Y0MzsqEl?2K8;`1Le$a=V_9hr)ikxO9mtvDj@j4&WYR2@HB41{2Rw^$u zH6&8ygIqkZi`rxW2BegX+oj{IE(~FPBC?X(yMHM36r8&DL>mS52c5Q!i7z9>wu#$c z7aZ^+A@Ay}a1DU92w{>EqTCSdG9j4|(s*eavI{PY`%)G*g2oC1|AH DatasetList: + return await datasets(mongo_engine, wallet_id) + + +@app.post( + "/dataset/create", response_model=Dataset, status_code=status.HTTP_201_CREATED +) +async def post_dataset_create(request: CreateDataset) -> Dataset: + return await create_dataset(mongo_engine, request) + + +@app.delete( + "/dataset", + response_model=None, + status_code=status.HTTP_204_NO_CONTENT, +) +async def delete_dataset(request: DeleteDataset) -> None: + await data_delete_dataset(mongo_engine, request) + + +@app.get("/datapools", response_model=DatapoolList, status_code=status.HTTP_200_OK) +async def get_datapools(wallet_id: WalletAddress) -> DatapoolList: + return await datapools(mongo_engine, wallet_id) + + +@app.post( + "/datapool/create", response_model=Datapool, status_code=status.HTTP_201_CREATED +) +async def post_datapool_create(request: CreateDatapool) -> Datapool: + return await create_datapool(mongo_engine, request) + + +@app.delete( + "/datapool", + response_model=None, + status_code=status.HTTP_204_NO_CONTENT, +) +async def post_delete_datapool(request: DeleteDatapool) -> None: + await delete_datapool(mongo_engine, request) + + +@app.post( + "/dataschema/create", response_model=Dataschema, status_code=status.HTTP_201_CREATED +) +async def post_dataschema_create(request: CreateDataschema) -> Dataschema: + return await create_dataschema(mongo_engine, request) diff --git a/backend-services/src/web_asgi/settings.py b/backend-services/src/web_asgi/settings.py new file mode 100644 index 0000000..724737e --- /dev/null +++ b/backend-services/src/web_asgi/settings.py @@ -0,0 +1,14 @@ +from pydantic import HttpUrl, MongoDsn + +from common.settings import Settings + + +class AppSettings(Settings): + """ + Application configuration settings + """ + + primary_origin: HttpUrl + staging_mode: bool = False + vault_db_name: str + vault_db_connection_string: MongoDsn diff --git a/backend-services/tests/__init__.py b/backend-services/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend-services/tests/data_service/__init__.py b/backend-services/tests/data_service/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend-services/tests/data_service/operations/__init__.py b/backend-services/tests/data_service/operations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend-services/tests/data_service/operations/helpers.py b/backend-services/tests/data_service/operations/helpers.py new file mode 100644 index 0000000..3e09665 --- /dev/null +++ b/backend-services/tests/data_service/operations/helpers.py @@ -0,0 +1,5 @@ +from data_service.settings import MongoSettings + +mock_settings = MongoSettings( + vault_db_dataset_collection="dataset", +) diff --git a/backend-services/tests/data_service/operations/test_bookmark.py b/backend-services/tests/data_service/operations/test_bookmark.py new file mode 100644 index 0000000..ca48154 --- /dev/null +++ b/backend-services/tests/data_service/operations/test_bookmark.py @@ -0,0 +1,84 @@ +from unittest.mock import AsyncMock + +import pytest +from motor import motor_asyncio +from odmantic import AIOEngine, ObjectId +from pytest_mock import MockerFixture + +from common.types import WalletAddress +from data_service.operations.dataset import datasets, create_dataset, delete_dataset +from data_service.schema.actions import CreateDataset, DeleteDataset +from data_service.schema.entities import Dataset + + +@pytest.mark.asyncio +async def test_create_dataset_success(mocker: MockerFixture) -> None: + mocker.patch("motor.motor_asyncio.AsyncIOMotorClient") + test_create_dataset = CreateDataset( + wallet_id=WalletAddress("test_wallet_id"), + name="test_name", + address=WalletAddress("test_address"), + ) + + mock_save = AsyncMock(return_value=test_create_dataset) + mocker.patch.object(AIOEngine, "save", mock_save) + engine = AIOEngine(client=motor_asyncio.AsyncIOMotorClient()) + + returned_dataset = await create_dataset(engine, test_create_dataset) + mock_save.assert_awaited_once_with(returned_dataset) + + +@pytest.mark.asyncio +async def test_delete_dataset_success(mocker: MockerFixture) -> None: + hex_string_id = "a" * 24 + dataset_to_delete = Dataset.parse_obj( + { + "id": ObjectId(hex_string_id), + "wallet_id": "test_wallet_id", + "name": "test_name1", + "address": "test_address1", + } + ) + mocker.patch("motor.motor_asyncio.AsyncIOMotorClient") + + mock_find_one = AsyncMock(return_value=dataset_to_delete) + mock_delete = AsyncMock(return_value=None) + mocker.patch.object(AIOEngine, "find_one", mock_find_one) + mocker.patch.object(AIOEngine, "delete", mock_delete) + + engine = AIOEngine(client=motor_asyncio.AsyncIOMotorClient()) + + params = DeleteDataset(delete_id=hex_string_id) + + assert await delete_dataset(engine, params) is None + mock_find_one.assert_awaited_once_with( + Dataset, Dataset.id == ObjectId(params.delete_id) + ) + mock_delete.assert_awaited_once_with(dataset_to_delete) + + +@pytest.mark.asyncio +async def test_get_datasets_success(mocker: MockerFixture) -> None: + stored_docs = [ + { + "id": ObjectId(b"a" * 12), + "wallet_id": "test_wallet_id", + "name": "test_name1", + "address": "test_address1", + }, + { + "id": ObjectId(b"b" * 12), + "wallet_id": "test_wallet_id", + "name": "test_name2", + "address": "test_address2", + }, + ] + mock_find = AsyncMock(return_value=stored_docs) + mocker.patch("motor.motor_asyncio.AsyncIOMotorClient") + mocker.patch.object(AIOEngine, "find", mock_find) + engine = AIOEngine(client=motor_asyncio.AsyncIOMotorClient()) + + wallet_id = WalletAddress("test_wallet_id") + expected_datasets = [Dataset.parse_obj(doc) for doc in stored_docs] + assert await datasets(engine, wallet_id) == expected_datasets + mock_find.assert_awaited_once_with(Dataset, Dataset.wallet_id == wallet_id)