Skip to content

Commit 89c02e1

Browse files
authored
Merge pull request project-chip#49 from nevi-me/crypto/rustcrypto
RustCrypto backed crypto
2 parents 9412ab6 + b339f9f commit 89c02e1

File tree

10 files changed

+799
-11
lines changed

10 files changed

+799
-11
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Test-Linux-RustCrypto
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
build_and_test:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Build
20+
run: cd matter; cargo build --verbose --no-default-features --features crypto_rustcrypto
21+
- name: Run tests
22+
run: cd matter; cargo test --verbose --no-default-features --features crypto_rustcrypto -- --test-threads=1

matter/Cargo.toml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ default = ["crypto_mbedtls"]
1919
crypto_openssl = ["openssl", "foreign-types", "hmac", "sha2"]
2020
crypto_mbedtls = ["mbedtls"]
2121
crypto_esp_mbedtls = ["esp-idf-sys"]
22+
crypto_rustcrypto = ["sha2", "hmac", "pbkdf2", "hkdf", "aes", "ccm", "p256", "elliptic-curve", "crypto-bigint", "x509-cert"]
2223

2324
[dependencies]
2425
boxslab = { path = "../boxslab" }
@@ -34,11 +35,6 @@ log = { version = "0.4.17", features = ["max_level_debug", "release_max_level_de
3435
env_logger = "0.10.0"
3536
rand = "0.8.5"
3637
esp-idf-sys = { version = "0.32", features = ["binstart"], optional = true }
37-
openssl = { git = "https://github.com/sfackler/rust-openssl", optional = true }
38-
foreign-types = { version = "0.3.2", optional = true }
39-
sha2 = { version = "0.9.9", optional = true }
40-
hmac = { version = "0.11.0", optional = true }
41-
mbedtls = { git = "https://github.com/fortanix/rust-mbedtls", optional = true }
4238
subtle = "2.4.1"
4339
colored = "2.0.0"
4440
smol = "1.3.0"
@@ -47,6 +43,22 @@ safemem = "0.3.3"
4743
chrono = { version = "0.4.23", default-features = false, features = ["clock", "std"] }
4844
async-channel = "1.8"
4945

46+
# crypto
47+
openssl = { git = "https://github.com/sfackler/rust-openssl", optional = true }
48+
foreign-types = { version = "0.3.2", optional = true }
49+
mbedtls = { git = "https://github.com/fortanix/rust-mbedtls", optional = true }
50+
sha2 = { version = "0.10", default-features = false, optional = true }
51+
hmac = { version = "0.12", optional = true }
52+
pbkdf2 = { version = "0.12", optional = true }
53+
hkdf = { version = "0.12", optional = true }
54+
aes = { version = "0.8", optional = true }
55+
ccm = { version = "0.5", default-features = false, features = ["alloc"], optional = true }
56+
p256 = { version = "0.13.0", default-features = false, features = ["arithmetic", "ecdh", "ecdsa"], optional = true }
57+
elliptic-curve = { version = "0.13.2", optional = true }
58+
crypto-bigint = { version = "0.4", default-features = false, optional = true }
59+
# Note: requires std
60+
x509-cert = { version = "0.2.0", default-features = false, features = ["pem", "std"], optional = true }
61+
5062
# to compute the check digit
5163
verhoeff = "1"
5264

matter/src/crypto/crypto_openssl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use openssl::x509::{X509NameBuilder, X509ReqBuilder, X509};
3939
// We directly use the hmac crate here, there was a self-referential structure
4040
// problem while using OpenSSL's Signer
4141
// TODO: Use proper OpenSSL method for this
42-
use hmac::{Hmac, Mac, NewMac};
42+
use hmac::{Hmac, Mac};
4343
pub struct HmacSha256 {
4444
ctx: Hmac<sha2::Sha256>,
4545
}

0 commit comments

Comments
 (0)