Skip to content

Commit dd699de

Browse files
TobTheRockTobias Waurick
authored and
Tobias Waurick
committed
feat: crypto library feature handling
Making ring the default feature. `openssl` and `ring` are now mutually exclusive. The `wasm-bindgen` feature is not needed, we can activate the needed `ring` feature by setting it target dependent.
1 parent 1091c9e commit dd699de

File tree

4 files changed

+38
-14
lines changed

4 files changed

+38
-14
lines changed

Cargo.toml

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
[package]
2-
name = "sframe"
3-
version = "0.2.0"
42
edition = "2021"
53
license = "MIT/Apache-2.0"
4+
name = "sframe"
5+
version = "0.2.0"
66

77
authors = [
88
"Tobias Waurick <[email protected]>",
99
"Hendrik Sollich <[email protected]>",
1010
"Richard Haehne <[email protected]>",
1111
]
12+
1213
description = "pure rust implementation of SFrame draft-ietf-sframe-enc-01"
1314
repository = "https://github.com/goto-opensource/sframe-rs"
1415
documentation = "https://docs.rs/sframe/"
@@ -26,29 +27,30 @@ thiserror = "1.0"
2627
version = "0.16"
2728
optional = true
2829

30+
[target.'cfg(target_arch = "wasm32")'.dependencies]
31+
ring = { version = "0.16", features = ["wasm32_c"], optional = true }
32+
2933
[dependencies.openssl]
3034
version = "0.10"
35+
features = ["vendored"]
3136
optional = true
3237

3338
[dev-dependencies]
34-
criterion = { version= "0.4", features=["html_reports"] }
39+
criterion = { version = "0.4", features = ["html_reports"] }
3540
hex = "0.4"
41+
lazy_static = "1.4.0"
42+
phf = { version = "0.11", features = ["macros"] }
3643
pretty_assertions = "1.3"
3744
rand = "0.8"
38-
serde_json = "1.0"
3945
serde = { version = "1.0", features = ["derive"] }
40-
lazy_static = "1.4.0"
46+
serde_json = "1.0"
4147
strum_macros = "0.24"
42-
phf = { version = "0.11", features = ["macros"] }
43-
4448

4549
[features]
46-
# default = ["ring"]
47-
default = ["openssl"]
50+
default = ["ring"]
4851
openssl = ["dep:openssl"]
4952
ring = ["dep:ring"]
50-
wasm-bindgen = ["ring", "ring/wasm32_c"]
5153

5254
[[bench]]
5355
name = "bench_main"
54-
harness = false
56+
harness = false

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ There is an alternative implementation under [goto-opensource/secure-frame-ts](h
1717
* ratcheting is not implemented
1818
* keyIds are used as senderIds
1919

20+
## Supported crypto libraries
21+
Currently two crypto libraries are supported:
22+
- [ring](https://crates.io/crates/ring)
23+
- is enabled per default with the feature `ring`
24+
- supports compilation to Wasm32
25+
- [openssl](https://crates.io/crates/openssl)
26+
- is enabled with the feature `openssl`
27+
- To build e.g. use `cargo build --features openssl --no-default-features`
28+
- uses rust bindings to OpenSSL.
29+
- Per default the OpenSSL library is locally compiled and then statically linked. The build process requires a C compiler, `perl` (and `perl-core`), and `make`. For further options see the [openssl crate documentation](https://docs.rs/openssl/0.10.55/openssl/).
30+
- Compilation to Wasm32 is [not yet supported](https://github.com/sfackler/rust-openssl/issues/1016)
31+
2032

2133
## License
2234
Licensed under either of Apache License, Version 2.0 or MIT license at your option.

src/crypto/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ pub mod key_expansion;
77
pub mod secret;
88

99
cfg_if::cfg_if! {
10-
if #[cfg(all(feature = "openssl", feature = "wasm-bindgen"))]{
11-
// TODO issue a warning
12-
// compile_error!{"Cannot use openssl with wasm-bindgen. Falling back to ring."};
10+
if #[cfg(all(not(feature = "openssl"), feature = "ring"))]{
1311
mod ring;
1412
}
1513
else if #[cfg(all(feature = "openssl", not(feature = "ring")))] {
1614
mod openssl;
1715
} else {
16+
// fallback to ring
1817
mod ring;
1918
}
2019
}

src/lib.rs

+11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44
//! This library is an implementation of [draft-ietf-sframe-enc-latest](https://sframe-wg.github.io/sframe/draft-ietf-sframe-enc.html).
55
//!
66
//! It is in it's current form a subset of the specification (e.g. Aes-CTR is not implemented).
7+
//!
8+
//! # Optional features
9+
//!
10+
//! Using optional features `sframe` allows to configure different crypto libraries.
11+
//! Be aware that those features are mutually exlusive, if multiple `sframe` falls back to using `ring`.
12+
//!
13+
//! - **`ring`** *(enabled by default)* — Uses the [ring](https://crates.io/crates/ring) library which allows compilation to Wasm32.
14+
//! - **`openssl`** — Uses the [rust-openssl](https://crates.io/crates/openssl) crate, which provides bindings to OpenSSL.
15+
//! Per default the OpenSSL library is locally compiled and then statically linked. The build process requires a C compiler,
16+
//! `perl` (and `perl-core`), and `make`. For further options see the [openssl crate documentation](https://docs.rs/openssl/0.10.55/openssl/).
17+
//! Compilation to Wasm32 is not yet supported.
718
819
#![deny(clippy::missing_panics_doc)]
920
#![deny(

0 commit comments

Comments
 (0)