Skip to content

Commit 9588e9e

Browse files
authored
CI: initial configuration (#4)
Configures GitHub Actions to build the crate, run clippy, check rustdoc, and check rustfmt
1 parent e1f33ae commit 9588e9e

File tree

13 files changed

+171
-124
lines changed

13 files changed

+171
-124
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: rustls-rustcrypto
2+
3+
on:
4+
pull_request:
5+
paths-ignore:
6+
- README.md
7+
push:
8+
branches: master
9+
paths-ignore:
10+
- README.md
11+
12+
permissions:
13+
contents: read
14+
15+
env:
16+
CARGO_INCREMENTAL: 0
17+
RUSTFLAGS: "-Dwarnings"
18+
19+
jobs:
20+
build:
21+
strategy:
22+
matrix:
23+
toolchain:
24+
- stable
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
- uses: RustCrypto/actions/cargo-cache@master
29+
- uses: dtolnay/rust-toolchain@master
30+
with:
31+
toolchain: ${{ matrix.toolchain }}
32+
- run: cargo build
33+
34+
clippy:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v4
38+
- uses: dtolnay/rust-toolchain@master
39+
with:
40+
toolchain: 1.75.0
41+
components: clippy
42+
- run: cargo clippy --all --all-features -- -D warnings
43+
44+
45+
doc:
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v4
49+
- uses: dtolnay/rust-toolchain@master
50+
with:
51+
toolchain: stable
52+
- run: cargo doc --all-features
53+
54+
rustfmt:
55+
runs-on: ubuntu-latest
56+
steps:
57+
- uses: actions/checkout@v4
58+
- uses: dtolnay/rust-toolchain@master
59+
with:
60+
toolchain: stable
61+
components: rustfmt
62+
- run: cargo fmt --all -- --check
63+
64+
# TODO(tarcieri): run tests in CI
65+
# test:
66+
# strategy:
67+
# matrix:
68+
# toolchain:
69+
# - stable
70+
# runs-on: ubuntu-latest
71+
# steps:
72+
# - uses: actions/checkout@v4
73+
# - uses: RustCrypto/actions/cargo-cache@master
74+
# - uses: dtolnay/rust-toolchain@master
75+
# with:
76+
# toolchain: ${{ matrix.toolchain }}
77+
# - run: cargo test

.gitignore

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
1-
# Generated by Cargo
2-
# will have compiled files and executables
31
debug/
42
target/
5-
6-
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
7-
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
8-
Cargo.lock
9-
10-
# These are backup files generated by rustfmt
113
**/*.rs.bk
12-
13-
# MSVC Windows builds of rustc generate these, which store debugging information
144
*.pdb

.rustfmt.toml

Lines changed: 0 additions & 16 deletions
This file was deleted.

examples/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustls_rustcrypto::provider;
1616

1717
struct TestPki {
1818
server_cert_der: Vec<u8>,
19-
server_key_der: Vec<u8>,
19+
server_key_der: Vec<u8>,
2020
}
2121

2222
impl TestPki {

src/aead/chacha20.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ impl cipher::Tls12AeadAlgorithm for Chacha20Poly1305 {
5959

6060
fn key_block_shape(&self) -> cipher::KeyBlockShape {
6161
cipher::KeyBlockShape {
62-
enc_key_len: 32,
63-
fixed_iv_len: 12,
62+
enc_key_len: 32,
63+
fixed_iv_len: 12,
6464
explicit_nonce_len: 0,
6565
}
6666
}

src/kx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl crypto::SupportedKxGroup for X25519 {
2121

2222
pub struct X25519KeyExchange {
2323
priv_key: x25519_dalek::EphemeralSecret,
24-
pub_key: x25519_dalek::PublicKey,
24+
pub_key: x25519_dalek::PublicKey,
2525
}
2626

2727
impl crypto::ActiveKeyExchange for X25519KeyExchange {

src/lib.rs

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![deny(
22
clippy::all,
3-
clippy::pedantic,
3+
// TODO: clippy::pedantic,
44
clippy::alloc_instead_of_core,
55
clippy::std_instead_of_alloc,
66
clippy::std_instead_of_core
@@ -22,11 +22,11 @@ pub struct Provider;
2222

2323
pub fn provider() -> CryptoProvider {
2424
CryptoProvider {
25-
cipher_suites: ALL_CIPHER_SUITES.to_vec(),
26-
kx_groups: kx::ALL_KX_GROUPS.to_vec(),
25+
cipher_suites: ALL_CIPHER_SUITES.to_vec(),
26+
kx_groups: kx::ALL_KX_GROUPS.to_vec(),
2727
signature_verification_algorithms: verify::ALGORITHMS,
28-
secure_random: &Provider,
29-
key_provider: &Provider,
28+
secure_random: &Provider,
29+
key_provider: &Provider,
3030
}
3131
}
3232

@@ -69,46 +69,46 @@ const TLS12_RSA_SCHEMES: [SignatureScheme; 6] = [
6969
#[cfg(feature = "tls12")]
7070
pub const TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256: SupportedCipherSuite =
7171
SupportedCipherSuite::Tls12(&rustls::Tls12CipherSuite {
72-
common: CipherSuiteCommon {
73-
suite: CipherSuite::TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
74-
hash_provider: hash::SHA256,
72+
common: CipherSuiteCommon {
73+
suite: CipherSuite::TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
74+
hash_provider: hash::SHA256,
7575
confidentiality_limit: u64::MAX,
76-
integrity_limit: 1 << 36,
76+
integrity_limit: 1 << 36,
7777
},
78-
kx: rustls::crypto::KeyExchangeAlgorithm::ECDHE,
79-
sign: &TLS12_ECDSA_SCHEMES,
80-
aead_alg: &aead::gcm::Tls12Aes128Gcm,
78+
kx: rustls::crypto::KeyExchangeAlgorithm::ECDHE,
79+
sign: &TLS12_ECDSA_SCHEMES,
80+
aead_alg: &aead::gcm::Tls12Aes128Gcm,
8181
prf_provider: &rustls::crypto::tls12::PrfUsingHmac(hmac::SHA256),
8282
});
8383

8484
#[cfg(feature = "tls12")]
8585
pub const TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384: SupportedCipherSuite =
8686
SupportedCipherSuite::Tls12(&rustls::Tls12CipherSuite {
87-
common: CipherSuiteCommon {
88-
suite: CipherSuite::TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
89-
hash_provider: hash::SHA384,
87+
common: CipherSuiteCommon {
88+
suite: CipherSuite::TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
89+
hash_provider: hash::SHA384,
9090
confidentiality_limit: u64::MAX,
91-
integrity_limit: 1 << 36,
91+
integrity_limit: 1 << 36,
9292
},
93-
kx: rustls::crypto::KeyExchangeAlgorithm::ECDHE,
94-
sign: &TLS12_ECDSA_SCHEMES,
93+
kx: rustls::crypto::KeyExchangeAlgorithm::ECDHE,
94+
sign: &TLS12_ECDSA_SCHEMES,
9595
prf_provider: &rustls::crypto::tls12::PrfUsingHmac(hmac::SHA384),
96-
aead_alg: &aead::gcm::Tls12Aes256Gcm,
96+
aead_alg: &aead::gcm::Tls12Aes256Gcm,
9797
});
9898

9999
#[cfg(feature = "tls12")]
100100
pub const TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256: SupportedCipherSuite =
101101
SupportedCipherSuite::Tls12(&rustls::Tls12CipherSuite {
102-
common: CipherSuiteCommon {
103-
suite: CipherSuite::TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
104-
hash_provider: hash::SHA256,
102+
common: CipherSuiteCommon {
103+
suite: CipherSuite::TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
104+
hash_provider: hash::SHA256,
105105
confidentiality_limit: u64::MAX,
106-
integrity_limit: 1 << 36,
106+
integrity_limit: 1 << 36,
107107
},
108108
prf_provider: &rustls::crypto::tls12::PrfUsingHmac(hmac::SHA256),
109-
kx: rustls::crypto::KeyExchangeAlgorithm::ECDHE,
110-
sign: &TLS12_ECDSA_SCHEMES,
111-
aead_alg: &aead::chacha20::Chacha20Poly1305,
109+
kx: rustls::crypto::KeyExchangeAlgorithm::ECDHE,
110+
sign: &TLS12_ECDSA_SCHEMES,
111+
aead_alg: &aead::chacha20::Chacha20Poly1305,
112112
});
113113

114114
#[cfg(feature = "tls12")]
@@ -121,46 +121,46 @@ const TLS_ECDHE_ECDSA_SUITES: &[SupportedCipherSuite] = &[
121121
#[cfg(feature = "tls12")]
122122
pub const TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256: SupportedCipherSuite =
123123
SupportedCipherSuite::Tls12(&rustls::Tls12CipherSuite {
124-
common: CipherSuiteCommon {
125-
suite: CipherSuite::TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
126-
hash_provider: hash::SHA256,
124+
common: CipherSuiteCommon {
125+
suite: CipherSuite::TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
126+
hash_provider: hash::SHA256,
127127
confidentiality_limit: u64::MAX,
128-
integrity_limit: 1 << 36,
128+
integrity_limit: 1 << 36,
129129
},
130-
kx: rustls::crypto::KeyExchangeAlgorithm::ECDHE,
131-
sign: &TLS12_RSA_SCHEMES,
132-
aead_alg: &aead::gcm::Tls12Aes128Gcm,
130+
kx: rustls::crypto::KeyExchangeAlgorithm::ECDHE,
131+
sign: &TLS12_RSA_SCHEMES,
132+
aead_alg: &aead::gcm::Tls12Aes128Gcm,
133133
prf_provider: &rustls::crypto::tls12::PrfUsingHmac(hmac::SHA256),
134134
});
135135

136136
#[cfg(feature = "tls12")]
137137
pub const TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384: SupportedCipherSuite =
138138
SupportedCipherSuite::Tls12(&rustls::Tls12CipherSuite {
139-
common: CipherSuiteCommon {
140-
suite: CipherSuite::TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
141-
hash_provider: hash::SHA384,
139+
common: CipherSuiteCommon {
140+
suite: CipherSuite::TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
141+
hash_provider: hash::SHA384,
142142
confidentiality_limit: u64::MAX,
143-
integrity_limit: 1 << 36,
143+
integrity_limit: 1 << 36,
144144
},
145-
kx: rustls::crypto::KeyExchangeAlgorithm::ECDHE,
146-
sign: &TLS12_RSA_SCHEMES,
145+
kx: rustls::crypto::KeyExchangeAlgorithm::ECDHE,
146+
sign: &TLS12_RSA_SCHEMES,
147147
prf_provider: &rustls::crypto::tls12::PrfUsingHmac(hmac::SHA384),
148-
aead_alg: &aead::gcm::Tls12Aes256Gcm,
148+
aead_alg: &aead::gcm::Tls12Aes256Gcm,
149149
});
150150

151151
#[cfg(feature = "tls12")]
152152
pub const TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256: SupportedCipherSuite =
153153
SupportedCipherSuite::Tls12(&rustls::Tls12CipherSuite {
154-
common: CipherSuiteCommon {
155-
suite: CipherSuite::TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
156-
hash_provider: hash::SHA256,
154+
common: CipherSuiteCommon {
155+
suite: CipherSuite::TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
156+
hash_provider: hash::SHA256,
157157
confidentiality_limit: u64::MAX,
158-
integrity_limit: 1 << 36,
158+
integrity_limit: 1 << 36,
159159
},
160-
kx: rustls::crypto::KeyExchangeAlgorithm::ECDHE,
161-
sign: &TLS12_RSA_SCHEMES,
160+
kx: rustls::crypto::KeyExchangeAlgorithm::ECDHE,
161+
sign: &TLS12_RSA_SCHEMES,
162162
prf_provider: &rustls::crypto::tls12::PrfUsingHmac(hmac::SHA256),
163-
aead_alg: &aead::chacha20::Chacha20Poly1305,
163+
aead_alg: &aead::chacha20::Chacha20Poly1305,
164164
});
165165

166166
#[cfg(feature = "tls12")]
@@ -182,44 +182,44 @@ const TLS12_SUITES: &[SupportedCipherSuite] = &[];
182182

183183
pub const TLS13_AES_128_GCM_SHA256: SupportedCipherSuite =
184184
SupportedCipherSuite::Tls13(&Tls13CipherSuite {
185-
common: CipherSuiteCommon {
186-
suite: CipherSuite::TLS13_AES_128_GCM_SHA256,
187-
hash_provider: hash::SHA256,
185+
common: CipherSuiteCommon {
186+
suite: CipherSuite::TLS13_AES_128_GCM_SHA256,
187+
hash_provider: hash::SHA256,
188188
confidentiality_limit: u64::MAX,
189-
integrity_limit: 1 << 36,
189+
integrity_limit: 1 << 36,
190190
},
191191
hkdf_provider: &rustls::crypto::tls13::HkdfUsingHmac(hmac::SHA256),
192-
aead_alg: &aead::gcm::Tls13Aes128Gcm,
193-
quic: None,
192+
aead_alg: &aead::gcm::Tls13Aes128Gcm,
193+
quic: None,
194194
});
195195

196196
pub const TLS13_AES_256_GCM_SHA384: SupportedCipherSuite =
197197
SupportedCipherSuite::Tls13(&Tls13CipherSuite {
198-
common: CipherSuiteCommon {
199-
suite: CipherSuite::TLS13_AES_256_GCM_SHA384,
200-
hash_provider: hash::SHA384,
198+
common: CipherSuiteCommon {
199+
suite: CipherSuite::TLS13_AES_256_GCM_SHA384,
200+
hash_provider: hash::SHA384,
201201
confidentiality_limit: u64::MAX,
202-
integrity_limit: 1 << 36,
202+
integrity_limit: 1 << 36,
203203
},
204204
hkdf_provider: &rustls::crypto::tls13::HkdfUsingHmac(hmac::SHA384),
205-
aead_alg: &aead::gcm::Tls13Aes256Gcm,
206-
quic: None,
205+
aead_alg: &aead::gcm::Tls13Aes256Gcm,
206+
quic: None,
207207
});
208208

209209
const TLS13_AES_SUITES: &[SupportedCipherSuite] =
210210
&[TLS13_AES_128_GCM_SHA256, TLS13_AES_256_GCM_SHA384];
211211

212212
pub const TLS13_CHACHA20_POLY1305_SHA256: SupportedCipherSuite =
213213
SupportedCipherSuite::Tls13(&Tls13CipherSuite {
214-
common: CipherSuiteCommon {
215-
suite: CipherSuite::TLS13_CHACHA20_POLY1305_SHA256,
216-
hash_provider: hash::SHA256,
214+
common: CipherSuiteCommon {
215+
suite: CipherSuite::TLS13_CHACHA20_POLY1305_SHA256,
216+
hash_provider: hash::SHA256,
217217
confidentiality_limit: u64::MAX,
218-
integrity_limit: 1 << 36,
218+
integrity_limit: 1 << 36,
219219
},
220220
hkdf_provider: &rustls::crypto::tls13::HkdfUsingHmac(hmac::SHA256),
221-
aead_alg: &aead::chacha20::Chacha20Poly1305,
222-
quic: None,
221+
aead_alg: &aead::chacha20::Chacha20Poly1305,
222+
quic: None,
223223
});
224224

225225
const TLS13_SUITES: &[SupportedCipherSuite] = misc::const_concat_slices!(

src/quic.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ impl quic::HeaderProtectionKey for HeaderProtectionKey {
4747
}
4848

4949
pub struct PacketKey {
50-
#[allow(dead_code)]
5150
/// Computes unique nonces for each packet
52-
iv: Iv,
51+
iv: Iv,
52+
5353
/// The cipher suite used for this packet key
54-
suite: &'static Tls13CipherSuite,
54+
#[allow(dead_code)]
55+
suite: &'static Tls13CipherSuite,
56+
5557
crypto: chacha20poly1305::ChaCha20Poly1305,
5658
}
5759

@@ -76,7 +78,7 @@ impl quic::PacketKey for PacketKey {
7678

7779
let tag = self
7880
.crypto
79-
.encrypt_in_place_detached(&nonce.into(), &aad, payload)
81+
.encrypt_in_place_detached(&nonce.into(), aad, payload)
8082
.map_err(|_| rustls::Error::EncryptError)?;
8183
Ok(quic::Tag::from(tag.as_ref()))
8284
}
@@ -99,7 +101,7 @@ impl quic::PacketKey for PacketKey {
99101
let nonce = chacha20poly1305::Nonce::from(cipher::Nonce::new(&self.iv, packet_number).0);
100102

101103
self.crypto
102-
.decrypt_in_place(&nonce, &aad, &mut payload_)
104+
.decrypt_in_place(&nonce, aad, &mut payload_)
103105
.map_err(|_| rustls::Error::DecryptError)?;
104106

105107
// Unfortunately the lifetime bound on decrypt_in_place sucks

0 commit comments

Comments
 (0)