Skip to content

Commit 498b86f

Browse files
Merge pull request #9542 from holtrop-wolfssl/rust-wolfssl-wolfcrypt-crate
Create wolfssl-wolfcrypt Rust crate
2 parents b23f59f + 9020373 commit 498b86f

40 files changed

+572
-548
lines changed

wrapper/rust/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
.PHONY: all
22
all:
3-
+$(MAKE) -C wolfssl
3+
+$(MAKE) -C wolfssl-wolfcrypt
44

55
.PHONY: test
66
test:
7-
+$(MAKE) -C wolfssl test
7+
+$(MAKE) -C wolfssl-wolfcrypt test
88

99
.PHONY: clean
1010
clean:
11-
+$(MAKE) -C wolfssl clean
11+
+$(MAKE) -C wolfssl-wolfcrypt clean

wrapper/rust/README.md

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# wolfSSL Rust Wrapper
22

3-
## Building the wolfssl Rust Wrapper
3+
The wolfSSL Rust wrapper currently consists of a single Rust crate named
4+
`wolfssl-wolfcrypt`.
5+
The `wolfssl-wolfcrypt` crate is a Rust wrapper for the wolfCrypt cryptographic
6+
algorithms portion of the wolfSSL C library.
7+
8+
## Locally building and testing the wolfSSL Rust Wrapper
49

510
First, configure and build wolfssl C library.
611

@@ -17,32 +22,5 @@ Run tests with:
1722
| Repository Directory | Description |
1823
| --- | --- |
1924
| `/wrapper/rust` | Top level container for all Rust wrapper functionality. |
20-
| `/wrapper/rust/wolfssl` | Top level for the `wolfssl` library crate. |
21-
| `/wrapper/rust/wolfssl/src` | Source directory for `wolfssl` crate top-level modules. |
22-
| `/wrapper/rust/wolfssl/src/wolfcrypt` | Source directory for submodules of `wolfssl::wolfcrypt` module. |
23-
24-
## API Coverage
25-
26-
The wolfSSL Rust wrapper provides a wrapper API for the following C library
27-
functionality:
28-
29-
* AES
30-
* CBC, CCM, CFB, CTR, EAX, ECB, GCM, OFB, XTS
31-
* CMAC
32-
* DH
33-
* ECC
34-
* Ed448
35-
* Ed25519
36-
* HKDF
37-
* HMAC
38-
* PBKDF2
39-
* PKCS #12 PBKDF
40-
* PRF
41-
* RSA
42-
* RNG
43-
* SHA
44-
* SHA-1, SHA-224, SHA-256, SHA-384, SHA-512, SHA3-224, SHA3-256, SHA3-384,
45-
SHA3-512, SHAKE128, SHAKE256
46-
* SRTP/SRTCP KDF
47-
* SSH KDF
48-
* TLSv1.3 HKDF
25+
| `/wrapper/rust/wolfssl-wolfcrypt` | Top level for the `wolfssl-wolfcrypt` library crate. |
26+
| `/wrapper/rust/wolfssl-wolfcrypt/src` | Source directory for `wolfssl-wolfcrypt` crate top-level modules. |

wrapper/rust/include.am

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,38 @@
44

55
EXTRA_DIST += wrapper/rust/Makefile
66
EXTRA_DIST += wrapper/rust/README.md
7-
EXTRA_DIST += wrapper/rust/wolfssl/Cargo.lock
8-
EXTRA_DIST += wrapper/rust/wolfssl/Cargo.toml
9-
EXTRA_DIST += wrapper/rust/wolfssl/Makefile
10-
EXTRA_DIST += wrapper/rust/wolfssl/build.rs
11-
EXTRA_DIST += wrapper/rust/wolfssl/headers.h
12-
EXTRA_DIST += wrapper/rust/wolfssl/src/lib.rs
13-
EXTRA_DIST += wrapper/rust/wolfssl/src/wolfcrypt.rs
14-
EXTRA_DIST += wrapper/rust/wolfssl/src/wolfcrypt/aes.rs
15-
EXTRA_DIST += wrapper/rust/wolfssl/src/wolfcrypt/cmac.rs
16-
EXTRA_DIST += wrapper/rust/wolfssl/src/wolfcrypt/dh.rs
17-
EXTRA_DIST += wrapper/rust/wolfssl/src/wolfcrypt/ecc.rs
18-
EXTRA_DIST += wrapper/rust/wolfssl/src/wolfcrypt/ed25519.rs
19-
EXTRA_DIST += wrapper/rust/wolfssl/src/wolfcrypt/ed448.rs
20-
EXTRA_DIST += wrapper/rust/wolfssl/src/wolfcrypt/hkdf.rs
21-
EXTRA_DIST += wrapper/rust/wolfssl/src/wolfcrypt/hmac.rs
22-
EXTRA_DIST += wrapper/rust/wolfssl/src/wolfcrypt/kdf.rs
23-
EXTRA_DIST += wrapper/rust/wolfssl/src/wolfcrypt/prf.rs
24-
EXTRA_DIST += wrapper/rust/wolfssl/src/wolfcrypt/random.rs
25-
EXTRA_DIST += wrapper/rust/wolfssl/src/wolfcrypt/rsa.rs
26-
EXTRA_DIST += wrapper/rust/wolfssl/src/wolfcrypt/sha.rs
27-
EXTRA_DIST += wrapper/rust/wolfssl/tests/test_aes.rs
28-
EXTRA_DIST += wrapper/rust/wolfssl/tests/test_cmac.rs
29-
EXTRA_DIST += wrapper/rust/wolfssl/tests/test_dh.rs
30-
EXTRA_DIST += wrapper/rust/wolfssl/tests/test_ecc.rs
31-
EXTRA_DIST += wrapper/rust/wolfssl/tests/test_ed25519.rs
32-
EXTRA_DIST += wrapper/rust/wolfssl/tests/test_ed448.rs
33-
EXTRA_DIST += wrapper/rust/wolfssl/tests/test_hkdf.rs
34-
EXTRA_DIST += wrapper/rust/wolfssl/tests/test_hmac.rs
35-
EXTRA_DIST += wrapper/rust/wolfssl/tests/test_kdf.rs
36-
EXTRA_DIST += wrapper/rust/wolfssl/tests/test_prf.rs
37-
EXTRA_DIST += wrapper/rust/wolfssl/tests/test_random.rs
38-
EXTRA_DIST += wrapper/rust/wolfssl/tests/test_rsa.rs
39-
EXTRA_DIST += wrapper/rust/wolfssl/tests/test_sha.rs
7+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/Cargo.lock
8+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/Cargo.toml
9+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/Makefile
10+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/README.md
11+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/build.rs
12+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/headers.h
13+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/src/aes.rs
14+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/src/cmac.rs
15+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/src/dh.rs
16+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/src/ecc.rs
17+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/src/ed25519.rs
18+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/src/ed448.rs
19+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/src/hkdf.rs
20+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/src/hmac.rs
21+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/src/kdf.rs
22+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/src/lib.rs
23+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/src/prf.rs
24+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/src/random.rs
25+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/src/rsa.rs
26+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/src/sha.rs
27+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/src/sys.rs
28+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/tests/test_aes.rs
29+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/tests/test_cmac.rs
30+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/tests/test_dh.rs
31+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/tests/test_ecc.rs
32+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/tests/test_ed25519.rs
33+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/tests/test_ed448.rs
34+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/tests/test_hkdf.rs
35+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/tests/test_hmac.rs
36+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/tests/test_kdf.rs
37+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/tests/test_prf.rs
38+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/tests/test_random.rs
39+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/tests/test_rsa.rs
40+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/tests/test_sha.rs
41+
EXTRA_DIST += wrapper/rust/wolfssl-wolfcrypt/tests/test_wolfcrypt.rs
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# wolfssl-wolfcrypt Change Log
2+
3+
## v1.0.0
4+
5+
- Bump version to 1.0 after testing
6+
7+
## v0.1.1
8+
9+
- Only set link-search and link-arg for local repo build
10+
11+
## v0.1.0
12+
13+
- Initial test version
Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
[package]
2-
name = "wolfssl"
3-
version = "0.1.0"
2+
name = "wolfssl-wolfcrypt"
3+
version = "1.0.0"
44
edition = "2024"
5-
description = "Rust wrapper for wolfssl C library"
5+
description = "Rust wrapper for wolfssl C library cryptographic functionality"
66
license = "GPL-3.0"
77
repository = "https://github.com/wolfSSL/wolfssl"
88
documentation = "https://github.com/wolfSSL/wolfssl/tree/master/wrapper/rust"
99
keywords = ["wolfssl", "fips", "security", "encryption", "cryptography"]
1010
categories = ["cryptography", "security", "api-bindings"]
11+
readme = "README.md"
1112

1213
[features]
1314
std = []
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# wolfssl-wolfcrypt crate
2+
3+
The `wolfssl-wolfcrypt` crate is a Rust wrapper for the wolfCrypt cryptographic
4+
algorithms portion of the wolfSSL C library.
5+
6+
## Installation
7+
8+
The `wolfssl` C library must be installed to be used by the Rust crate.
9+
10+
The `wolfssl-wolfcrypt` crate can be used by including it as a dependency in
11+
your project's `Cargo.toml` file.
12+
13+
For example:
14+
15+
```
16+
[dependencies]
17+
wolfssl-wolfcrypt = "1.0"
18+
```
19+
20+
## API Coverage
21+
22+
This crate provides a wrapper API for the following wolfCrypt C library
23+
functionality:
24+
25+
* AES
26+
* CBC, CCM, CFB, CTR, EAX, ECB, GCM, OFB, XTS
27+
* CMAC
28+
* DH
29+
* ECC
30+
* Ed448
31+
* Ed25519
32+
* HKDF
33+
* HMAC
34+
* PBKDF2
35+
* PKCS #12 PBKDF
36+
* PRF
37+
* RSA
38+
* RNG
39+
* SHA
40+
* SHA-1, SHA-224, SHA-256, SHA-384, SHA-512, SHA3-224, SHA3-256, SHA3-384,
41+
SHA3-512, SHAKE128, SHAKE256
42+
* SRTP/SRTCP KDF
43+
* SSH KDF
44+
* TLSv1.3 HKDF
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use regex::Regex;
44
use std::env;
55
use std::fs;
66
use std::io::{self, Read, Result};
7-
use std::path::PathBuf;
7+
use std::path::{Path,PathBuf};
88

99
/// Perform crate build.
1010
fn main() {
@@ -69,12 +69,19 @@ fn generate_bindings() -> Result<()> {
6969
/// Returns `Ok(())` if successful, or an error if any step fails.
7070
fn setup_wolfssl_link() -> Result<()> {
7171
println!("cargo:rustc-link-lib=wolfssl");
72-
println!("cargo:rustc-link-search={}", wolfssl_lib_dir()?);
73-
println!("cargo:rustc-link-arg=-Wl,-rpath,{}", wolfssl_lib_dir()?);
7472

7573
// TODO: do we need this if only a static library is built?
7674
// println!("cargo:rustc-link-lib=static=wolfssl");
7775

76+
let build_in_repo = Path::new(&wolfssl_lib_dir()?).exists();
77+
if build_in_repo {
78+
// When the crate is built in the wolfssl repository, link with the
79+
// locally build wolfssl library to allow testing any local changes
80+
// and running unit tests even if library is not installed.
81+
println!("cargo:rustc-link-search={}", wolfssl_lib_dir()?);
82+
println!("cargo:rustc-link-arg=-Wl,-rpath,{}", wolfssl_lib_dir()?);
83+
}
84+
7885
Ok(())
7986
}
8087

0 commit comments

Comments
 (0)