Page MenuHomePhabricator

D5879.id19971.diff
No OneTemporary

D5879.id19971.diff

diff --git a/keyserver/addons/opaque-ke-node/.gitignore b/keyserver/addons/opaque-ke-node/.gitignore
deleted file mode 100644
--- a/keyserver/addons/opaque-ke-node/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-target
-index.node
-**/node_modules
-**/.DS_Store
-npm-debug.log*
diff --git a/keyserver/addons/opaque-ke-node/Cargo.lock b/keyserver/addons/opaque-ke-node/Cargo.lock
deleted file mode 100644
--- a/keyserver/addons/opaque-ke-node/Cargo.lock
+++ /dev/null
@@ -1,511 +0,0 @@
-# This file is automatically @generated by Cargo.
-# It is not intended for manual editing.
-version = 3
-
-[[package]]
-name = "argon2"
-version = "0.3.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "25df3c03f1040d0069fcd3907e24e36d59f9b6fa07ba49be0eb25a794f036ba7"
-dependencies = [
- "base64ct",
- "blake2",
- "password-hash",
-]
-
-[[package]]
-name = "base64ct"
-version = "1.0.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8a32fd6af2b5827bce66c29053ba0e7c42b9dcab01835835058558c10851a46b"
-
-[[package]]
-name = "blake2"
-version = "0.10.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b12e5fd123190ce1c2e559308a94c9bacad77907d4c6005d9e58fe1a0689e55e"
-dependencies = [
- "digest 0.10.6",
-]
-
-[[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.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e"
-dependencies = [
- "generic-array",
-]
-
-[[package]]
-name = "byteorder"
-version = "1.4.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
-
-[[package]]
-name = "cfg-if"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
-
-[[package]]
-name = "constant_time_eq"
-version = "0.1.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
-
-[[package]]
-name = "cpufeatures"
-version = "0.2.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320"
-dependencies = [
- "libc",
-]
-
-[[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 = "crypto-mac"
-version = "0.11.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714"
-dependencies = [
- "generic-array",
- "subtle",
-]
-
-[[package]]
-name = "curve25519-dalek"
-version = "3.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "90f9d052967f590a76e62eb387bd0bbb1b000182c3cefe5364db6b7211651bc0"
-dependencies = [
- "byteorder",
- "digest 0.9.0",
- "rand_core 0.5.1",
- "subtle",
- "zeroize",
-]
-
-[[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.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f"
-dependencies = [
- "block-buffer 0.10.3",
- "crypto-common",
- "subtle",
-]
-
-[[package]]
-name = "displaydoc"
-version = "0.2.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3bf95dc3f046b9da4f2d51833c0d3547d8564ef6910f5c1ed130306a75b92886"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
-
-[[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.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
-dependencies = [
- "cfg-if",
- "libc",
- "wasi 0.9.0+wasi-snapshot-preview1",
-]
-
-[[package]]
-name = "getrandom"
-version = "0.2.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
-dependencies = [
- "cfg-if",
- "libc",
- "wasi 0.11.0+wasi-snapshot-preview1",
-]
-
-[[package]]
-name = "hkdf"
-version = "0.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "01706d578d5c281058480e673ae4086a9f4710d8df1ad80a5b03e39ece5f886b"
-dependencies = [
- "digest 0.9.0",
- "hmac",
-]
-
-[[package]]
-name = "hmac"
-version = "0.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b"
-dependencies = [
- "crypto-mac",
- "digest 0.9.0",
-]
-
-[[package]]
-name = "libc"
-version = "0.2.137"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89"
-
-[[package]]
-name = "libloading"
-version = "0.6.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883"
-dependencies = [
- "cfg-if",
- "winapi",
-]
-
-[[package]]
-name = "neon"
-version = "0.10.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "28e15415261d880aed48122e917a45e87bb82cf0260bb6db48bbab44b7464373"
-dependencies = [
- "neon-build",
- "neon-macros",
- "neon-runtime",
- "semver",
- "smallvec",
-]
-
-[[package]]
-name = "neon-build"
-version = "0.10.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8bac98a702e71804af3dacfde41edde4a16076a7bbe889ae61e56e18c5b1c811"
-
-[[package]]
-name = "neon-macros"
-version = "0.10.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b7288eac8b54af7913c60e0eb0e2a7683020dffa342ab3fd15e28f035ba897cf"
-dependencies = [
- "quote",
- "syn",
- "syn-mid",
-]
-
-[[package]]
-name = "neon-runtime"
-version = "0.10.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4676720fa8bb32c64c3d9f49c47a47289239ec46b4bdb66d0913cc512cb0daca"
-dependencies = [
- "cfg-if",
- "libloading",
- "smallvec",
-]
-
-[[package]]
-name = "opaque-debug"
-version = "0.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
-
-[[package]]
-name = "opaque-ke"
-version = "1.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f25e5f1be61b7a94f388368a24739318fe4edd2b841d20d7077a422a5391e22f"
-dependencies = [
- "constant_time_eq",
- "curve25519-dalek",
- "digest 0.9.0",
- "displaydoc",
- "generic-array",
- "hkdf",
- "hmac",
- "rand",
- "subtle",
- "zeroize",
-]
-
-[[package]]
-name = "opaque-ke-node"
-version = "0.1.0"
-dependencies = [
- "argon2",
- "curve25519-dalek",
- "digest 0.9.0",
- "neon",
- "opaque-ke",
- "rand",
- "sha2",
-]
-
-[[package]]
-name = "password-hash"
-version = "0.3.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d791538a6dcc1e7cb7fe6f6b58aca40e7f79403c45b2bc274008b5e647af1d8"
-dependencies = [
- "base64ct",
- "rand_core 0.6.4",
- "subtle",
-]
-
-[[package]]
-name = "ppv-lite86"
-version = "0.2.17"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
-
-[[package]]
-name = "proc-macro2"
-version = "1.0.47"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"
-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.8.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
-dependencies = [
- "libc",
- "rand_chacha",
- "rand_core 0.6.4",
-]
-
-[[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 0.6.4",
-]
-
-[[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]]
-name = "rand_core"
-version = "0.6.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
-dependencies = [
- "getrandom 0.2.8",
-]
-
-[[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-parser"
-version = "0.7.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
-
-[[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",
- "cpufeatures",
- "digest 0.9.0",
- "opaque-debug",
-]
-
-[[package]]
-name = "smallvec"
-version = "1.10.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
-
-[[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.103"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d"
-dependencies = [
- "proc-macro2",
- "quote",
- "unicode-ident",
-]
-
-[[package]]
-name = "syn-mid"
-version = "0.5.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "baa8e7560a164edb1621a55d18a0c59abf49d360f47aa7b821061dd7eea7fac9"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
-
-[[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 = "typenum"
-version = "1.15.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
-
-[[package]]
-name = "unicode-ident"
-version = "1.0.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3"
-
-[[package]]
-name = "unicode-xid"
-version = "0.2.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
-
-[[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.9.0+wasi-snapshot-preview1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
-
-[[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 = "zeroize"
-version = "1.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd"
-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/keyserver/addons/opaque-ke-node/Cargo.toml b/keyserver/addons/opaque-ke-node/Cargo.toml
deleted file mode 100644
--- a/keyserver/addons/opaque-ke-node/Cargo.toml
+++ /dev/null
@@ -1,25 +0,0 @@
-[package]
-name = "opaque-ke-node"
-version = "0.1.0"
-description = "Exposes the opaque-ke Rust library to Node"
-license = "BSD-3-Clause"
-edition = "2021"
-exclude = ["index.node"]
-
-[lib]
-crate-type = ["cdylib"]
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-argon2 = "0.3"
-opaque-ke = "1.2"
-curve25519-dalek = "3.2"
-rand = "0.8"
-sha2 = "0.9"
-digest = "0.9"
-
-[dependencies.neon]
-version = "0.10"
-default-features = false
-features = ["napi-6"]
diff --git a/keyserver/addons/opaque-ke-node/README.md b/keyserver/addons/opaque-ke-node/README.md
deleted file mode 100644
--- a/keyserver/addons/opaque-ke-node/README.md
+++ /dev/null
@@ -1,121 +0,0 @@
-# opaque-ke-node
-
-**opaque-ke-node:** Exposes the opaque-ke Rust library to Node
-
-This project was bootstrapped by [create-neon](https://yarn.pm/create-neon).
-
-## Installing opaque-ke-node
-
-Installing opaque-ke-node requires a [supported version of Node and Rust](https://github.com/neon-bindings/neon#platform-support).
-
-You can install the project with yarn. In the project directory, run:
-
-```sh
-$ yarn install
-```
-
-This fully installs the project, including installing any dependencies and running the build.
-
-## Building opaque-ke-node
-
-If you have already installed the project and only want to run the build, run:
-
-```sh
-$ yarn build
-```
-
-This command uses the [cargo-cp-artifact](https://github.com/neon-bindings/cargo-cp-artifact) utility to run the Rust build and copy the built library into `./index.node`.
-
-## Exploring opaque-ke-node
-
-After building opaque-ke-node, you can explore its exports at the Node REPL:
-
-```sh
-$ yarn install
-$ node
-> require('.').hello()
-"hello node"
-```
-
-## Available Scripts
-
-In the project directory, you can run:
-
-### `yarn install`
-
-Installs the project, including running `yarn build`.
-
-### `yarn build`
-
-Builds the Node addon (`index.node`) from source.
-
-Additional [`cargo build`](https://doc.rust-lang.org/cargo/commands/cargo-build.html) arguments may be passed to `yarn build` and `yarn build-*` commands. For example, to enable a [cargo feature](https://doc.rust-lang.org/cargo/reference/features.html):
-
-```
-yarn build --feature=beetle
-```
-
-#### `yarn build-debug`
-
-Alias for `yarn build`.
-
-#### `yarn build-release`
-
-Same as [`yarn build`](#yarn-build) but, builds the module with the [`release`](https://doc.rust-lang.org/cargo/reference/profiles.html#release) profile. Release builds will compile slower, but run faster.
-
-### `yarn test`
-
-Runs the unit tests by calling `cargo test`. You can learn more about [adding tests to your Rust code](https://doc.rust-lang.org/book/ch11-01-writing-tests.html) from the [Rust book](https://doc.rust-lang.org/book/).
-
-## Project Layout
-
-The directory structure of this project is:
-
-```
-opaque-ke-node/
-├── Cargo.toml
-├── README.md
-├── index.node
-├── package.json
-├── src/
-| └── lib.rs
-└── target/
-```
-
-### Cargo.toml
-
-The Cargo [manifest file](https://doc.rust-lang.org/cargo/reference/manifest.html), which informs the `cargo` command.
-
-### README.md
-
-This file.
-
-### index.node
-
-The Node addon—i.e., a binary Node module—generated by building the project. This is the main module for this package, as dictated by the `"main"` key in `package.json`.
-
-Under the hood, a [Node addon](https://nodejs.org/api/addons.html) is a [dynamically-linked shared object](<https://en.wikipedia.org/wiki/Library_(computing)#Shared_libraries>). The `"build"` script produces this file by copying it from within the `target/` directory, which is where the Rust build produces the shared object.
-
-### package.json
-
-The yarn [manifest file](https://classic.yarnpkg.com/lang/en/docs/package-json/), which informs the `yarn` command.
-
-### src/
-
-The directory tree containing the Rust source code for the project.
-
-### src/lib.rs
-
-The Rust library's main module.
-
-### target/
-
-Binary artifacts generated by the Rust build.
-
-## Learn More
-
-To learn more about Neon, see the [Neon documentation](https://neon-bindings.com).
-
-To learn more about Rust, see the [Rust documentation](https://www.rust-lang.org).
-
-To learn more about Node, see the [Node documentation](https://nodejs.org).
diff --git a/keyserver/addons/opaque-ke-node/package.json b/keyserver/addons/opaque-ke-node/package.json
deleted file mode 100644
--- a/keyserver/addons/opaque-ke-node/package.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "name": "opaque-ke-node",
- "version": "0.1.0",
- "description": "Exposes the opaque-ke Rust library to Node",
- "main": "index.node",
- "scripts": {
- "build": "cargo-cp-artifact -nc index.node -- cargo build --message-format=json-render-diagnostics",
- "build-debug": "yarn build",
- "build-release": "(yarn build --release || true)",
- "install": "yarn build-release",
- "test": "cargo test"
- },
- "author": "",
- "license": "BSD-3-Clause",
- "devDependencies": {
- "cargo-cp-artifact": "^0.1"
- }
-}
diff --git a/keyserver/addons/opaque-ke-node/src/lib.rs b/keyserver/addons/opaque-ke-node/src/lib.rs
deleted file mode 100644
--- a/keyserver/addons/opaque-ke-node/src/lib.rs
+++ /dev/null
@@ -1,260 +0,0 @@
-use argon2::Argon2;
-use digest::generic_array::GenericArray;
-use digest::Digest;
-use neon::prelude::*;
-use neon::types::buffer::TypedArray;
-use opaque_ke::ciphersuite::CipherSuite;
-use opaque_ke::errors::InternalPakeError;
-use opaque_ke::hash::Hash;
-use opaque_ke::slow_hash::SlowHash;
-use opaque_ke::{
- ClientLogin, ClientLoginFinishParameters, ClientLoginStartParameters,
- ClientRegistration, ClientRegistrationFinishParameters,
- CredentialFinalization, CredentialRequest, CredentialResponse,
- RegistrationRequest, RegistrationResponse, RegistrationUpload,
-};
-use rand::rngs::OsRng;
-
-struct Cipher;
-
-impl CipherSuite for Cipher {
- type Group = curve25519_dalek::ristretto::RistrettoPoint;
- type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH;
- type Hash = sha2::Sha512;
- type SlowHash = ArgonWrapper;
-}
-
-struct ArgonWrapper(Argon2<'static>);
-
-impl<D: Hash> SlowHash<D> for ArgonWrapper {
- fn hash(
- input: GenericArray<u8, <D as Digest>::OutputSize>,
- ) -> Result<Vec<u8>, InternalPakeError> {
- let params = Argon2::default();
- let mut output = vec![0u8; <D as Digest>::output_size()];
- params
- .hash_password_into(&input, &[0; argon2::MIN_SALT_LEN], &mut output)
- .map_err(|_| InternalPakeError::SlowHashError)?;
- Ok(output)
- }
-}
-
-struct ClientRegistrationStartResult {
- message: RegistrationRequest<Cipher>,
- state: ClientRegistration<Cipher>,
-}
-
-impl Finalize for ClientRegistrationStartResult {}
-
-struct ClientRegistrationFinishResult {
- message: RegistrationUpload<Cipher>,
-}
-
-impl Finalize for ClientRegistrationFinishResult {}
-
-struct ClientLoginStartResult {
- message: CredentialRequest<Cipher>,
- state: ClientLogin<Cipher>,
-}
-
-impl Finalize for ClientLoginStartResult {}
-
-struct ClientLoginFinishResult {
- message: CredentialFinalization<Cipher>,
- session_key: Vec<u8>,
-}
-
-impl Finalize for ClientLoginFinishResult {}
-
-fn client_register_start(
- mut cx: FunctionContext,
-) -> JsResult<JsBox<ClientRegistrationStartResult>> {
- let password = cx.argument::<JsString>(0)?;
- let mut client_rng = OsRng;
- let client_registration_start_result = ClientRegistration::<Cipher>::start(
- &mut client_rng,
- password.value(&mut cx).as_bytes(),
- )
- .or_else(|err| cx.throw_error(err.to_string()))?;
- Ok(cx.boxed(ClientRegistrationStartResult {
- message: client_registration_start_result.message,
- state: client_registration_start_result.state,
- }))
-}
-
-fn get_registration_start_message_array(
- mut cx: FunctionContext,
-) -> JsResult<JsArrayBuffer> {
- let client_registration_start_result =
- cx.argument::<JsBox<ClientRegistrationStartResult>>(0)?;
- Ok(JsArrayBuffer::external(
- &mut cx,
- client_registration_start_result.message.serialize(),
- ))
-}
-
-fn get_registration_start_state_array(
- mut cx: FunctionContext,
-) -> JsResult<JsArrayBuffer> {
- let client_registration_start_result =
- cx.argument::<JsBox<ClientRegistrationStartResult>>(0)?;
- Ok(JsArrayBuffer::external(
- &mut cx,
- client_registration_start_result.state.serialize(),
- ))
-}
-
-fn client_register_finish(
- mut cx: FunctionContext,
-) -> JsResult<JsBox<ClientRegistrationFinishResult>> {
- let client_register_state = cx.argument::<JsTypedArray<u8>>(0)?;
- let server_message = cx.argument::<JsTypedArray<u8>>(1)?;
- let client_registration = ClientRegistration::<Cipher>::deserialize(
- client_register_state.as_slice(&cx),
- )
- .or_else(|err| cx.throw_error(err.to_string()))?;
- let registration_response =
- RegistrationResponse::<Cipher>::deserialize(server_message.as_slice(&cx))
- .or_else(|err| cx.throw_error(err.to_string()))?;
-
- let mut client_rng = OsRng;
- let client_registration_finish_result = ClientRegistrationFinishResult {
- message: client_registration
- .finish(
- &mut client_rng,
- registration_response,
- ClientRegistrationFinishParameters::Default,
- )
- .or_else(|err| cx.throw_error(err.to_string()))?
- .message,
- };
- Ok(cx.boxed(client_registration_finish_result))
-}
-
-fn get_registration_finish_message_array(
- mut cx: FunctionContext,
-) -> JsResult<JsArrayBuffer> {
- let client_registration_finish_result =
- cx.argument::<JsBox<ClientRegistrationFinishResult>>(0)?;
- Ok(JsArrayBuffer::external(
- &mut cx,
- client_registration_finish_result.message.serialize(),
- ))
-}
-
-fn client_login_start(
- mut cx: FunctionContext,
-) -> JsResult<JsBox<ClientLoginStartResult>> {
- let password = cx.argument::<JsString>(0)?;
- let mut client_rng = OsRng;
- let client_login = ClientLogin::<Cipher>::start(
- &mut client_rng,
- password.value(&mut cx).as_bytes(),
- ClientLoginStartParameters::default(),
- )
- .or_else(|err| cx.throw_error(err.to_string()))?;
- Ok(cx.boxed(ClientLoginStartResult {
- message: client_login.message,
- state: client_login.state,
- }))
-}
-
-fn get_login_start_message_array(
- mut cx: FunctionContext,
-) -> JsResult<JsArrayBuffer> {
- let client_login_start_result =
- cx.argument::<JsBox<ClientLoginStartResult>>(0)?;
- let login_start_message_vec =
- client_login_start_result
- .message
- .serialize()
- .or_else(|err| cx.throw_error(err.to_string()))?;
- Ok(JsArrayBuffer::external(&mut cx, login_start_message_vec))
-}
-
-fn get_login_start_state_array(
- mut cx: FunctionContext,
-) -> JsResult<JsArrayBuffer> {
- let client_login_start_result =
- cx.argument::<JsBox<ClientLoginStartResult>>(0)?;
- let login_start_message_vec = client_login_start_result
- .state
- .serialize()
- .or_else(|err| cx.throw_error(err.to_string()))?;
- Ok(JsArrayBuffer::external(&mut cx, login_start_message_vec))
-}
-
-fn client_login_finish(
- mut cx: FunctionContext,
-) -> JsResult<JsBox<ClientLoginFinishResult>> {
- let client_login_state = cx.argument::<JsTypedArray<u8>>(0)?;
- let server_message = cx.argument::<JsTypedArray<u8>>(1)?;
- let client_login =
- ClientLogin::<Cipher>::deserialize(client_login_state.as_slice(&cx))
- .or_else(|err| cx.throw_error(err.to_string()))?;
- let credential_response =
- CredentialResponse::<Cipher>::deserialize(server_message.as_slice(&cx))
- .or_else(|err| cx.throw_error(err.to_string()))?;
- let client_login_finish = client_login
- .finish(credential_response, ClientLoginFinishParameters::default())
- .or_else(|err| cx.throw_error(err.to_string()))?;
- Ok(cx.boxed(ClientLoginFinishResult {
- message: client_login_finish.message,
- session_key: client_login_finish.session_key,
- }))
-}
-
-fn get_login_finish_message_array(
- mut cx: FunctionContext,
-) -> JsResult<JsArrayBuffer> {
- let client_login_finish_result =
- cx.argument::<JsBox<ClientLoginFinishResult>>(0)?;
- let login_finish_message_vec = client_login_finish_result
- .message
- .serialize()
- .or_else(|err| cx.throw_error(err.to_string()))?;
- Ok(JsArrayBuffer::external(&mut cx, login_finish_message_vec))
-}
-
-fn get_login_finish_session_array(
- mut cx: FunctionContext,
-) -> JsResult<JsArrayBuffer> {
- let client_login_finish_result =
- cx.argument::<JsBox<ClientLoginFinishResult>>(0)?;
- let login_finish_session_vec = client_login_finish_result.session_key.clone();
- Ok(JsArrayBuffer::external(&mut cx, login_finish_session_vec))
-}
-
-#[neon::main]
-fn main(mut cx: ModuleContext) -> NeonResult<()> {
- cx.export_function("clientRegisterStart", client_register_start)?;
- cx.export_function(
- "getRegistrationStartMessageArray",
- get_registration_start_message_array,
- )?;
- cx.export_function(
- "getRegistrationStartStateArray",
- get_registration_start_state_array,
- )?;
- cx.export_function("clientRegisterFinish", client_register_finish)?;
- cx.export_function(
- "getRegistrationFinishMessageArray",
- get_registration_finish_message_array,
- )?;
- cx.export_function("clientLoginStart", client_login_start)?;
- cx.export_function(
- "getLoginStartMessageArray",
- get_login_start_message_array,
- )?;
- cx.export_function("getLoginStartStateArray", get_login_start_state_array)?;
- cx.export_function("clientLoginFinish", client_login_finish)?;
- cx.export_function(
- "getLoginFinishMessageArray",
- get_login_finish_message_array,
- )?;
- cx.export_function(
- "getLoginFinishSessionArray",
- get_login_finish_session_array,
- )?;
- Ok(())
-}

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 16, 11:31 PM (20 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2502752
Default Alt Text
D5879.id19971.diff (27 KB)

Event Timeline