]> git.lizzy.rs Git - PAKEs.git/commitdiff
spake2: initial `no_std` support (#87)
authorTony Arcieri <bascule@gmail.com>
Sat, 22 Jan 2022 22:03:05 +0000 (15:03 -0700)
committerGitHub <noreply@github.com>
Sat, 22 Jan 2022 22:03:05 +0000 (15:03 -0700)
Still has a hard dependency on `alloc`, and with the current hard
dependency on `getrandom` also limited platform support

.github/workflows/spake2.yml
spake2/Cargo.toml
spake2/src/lib.rs
spake2/src/tests.rs

index e3b6c0c5a9beb27c93091fa763fc4fc060a1bdf4..6aaf07666e2212265c1c227f57affa650026a094 100644 (file)
@@ -17,6 +17,25 @@ env:
   RUSTFLAGS: "-Dwarnings"
 
 jobs:
+  build:
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        rust:
+          - 1.56.0 # MSRV
+          - stable
+        target:
+          - wasm32-unknown-unknown
+    steps:
+      - uses: actions/checkout@v1
+      - uses: actions-rs/toolchain@v1
+        with:
+          profile: minimal
+          toolchain: ${{ matrix.rust }}
+          target: ${{ matrix.target }}
+          override: true
+      - run: cargo build --target ${{ matrix.target }} --release
+
   test:
     runs-on: ubuntu-latest
     strategy:
index febbb6dedf33492d31396e6dc46f571381dc8e1d..0558737a8cc024295ab0332d5ecb391c584c897b 100644 (file)
@@ -15,7 +15,7 @@ edition = "2021"
 rust-version = "1.56"
 
 [dependencies]
-curve25519-dalek = "3"
+curve25519-dalek = { version = "3", default-features = false, features = ["u64_backend"] }
 rand_core = { version = "0.5", default-features = false, features = ["getrandom"] }
 sha2 = "0.10"
 hkdf = "0.12"
@@ -25,6 +25,10 @@ bencher = "0.1"
 hex = "0.4"
 num-bigint = "0.4"
 
+[features]
+default = []
+std = []
+
 [[bench]]
 name = "spake2"
 harness = false
index 1c87a5cdc0230ff5115325bf23a6c8db1239812e..61f7973ff21aefe51a8e37d6ff9833ff4489fa70 100644 (file)
@@ -1,7 +1,8 @@
-#![forbid(unsafe_code)]
-#![warn(rust_2018_idioms, unused_qualifications)]
+#![no_std]
 #![doc(html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo_small.png")]
 #![doc = include_str!("../README.md")]
+#![forbid(unsafe_code)]
+#![warn(rust_2018_idioms, unused_qualifications)]
 
 //! # Usage
 //!
 //! [6]: http://eprint.iacr.org/2003/038.pdf "Pretty-Simple Password-Authenticated Key-Exchange Under Standard Assumptions"
 //! [7]: https://moderncrypto.org/mail-archive/curves/2015/000419.html "PAKE questions"
 
+#[allow(unused_imports)]
+#[macro_use]
+extern crate alloc;
+
+#[cfg(feature = "std")]
+#[cfg_attr(test, macro_use)]
+extern crate std;
+
+use alloc::vec::Vec;
 use core::{fmt, ops::Deref, str};
 use curve25519_dalek::{
     constants::ED25519_BASEPOINT_POINT,
index 45999533113038c5cd69c4abe318e5f691d5174a..d063b86d2699d3c3e367191d2f4ba60c57b21157 100644 (file)
@@ -2,6 +2,9 @@
 //! spake2.test.test_compat.SPAKE2.test_asymmetric . The python test passes a
 //! deterministic RNG (used only for tests, of course) into the per-Group
 //! "random_scalar()" function, which results in some particular scalar.
+
+#![cfg(feature = "std")]
+
 use super::*;
 use curve25519_dalek::constants::ED25519_BASEPOINT_POINT;