Skip to content

Commit 82fd074

Browse files
logist322rainliu
authored andcommitted
Fix lint
1 parent 3f1b868 commit 82fd074

File tree

5 files changed

+14
-57
lines changed

5 files changed

+14
-57
lines changed

srtp/benches/srtp_bench.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use util::Marshal;
44
use webrtc_srtp::{context::Context, protection_profile::ProtectionProfile};
55

66
const RAW_RTCP: Bytes = Bytes::from_static(&[
7-
0x81, 0xc8, 0x00, 0x0b, 0xca, 0xfe, 0xba, 0xbe, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab,
8-
0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab,
7+
0x81, 0xc8, 0x00, 0x0b, 0xca, 0xfe, 0xba, 0xbe, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab,
8+
0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab,
99
]);
1010

1111
fn benchmark_encrypt_rtp_aes_128_cm_hmac_sha1(c: &mut Criterion) {
@@ -121,8 +121,7 @@ fn benchmark_encrypt_rtcp_aes_128_cm_hmac_sha1(c: &mut Criterion) {
121121

122122
c.bench_function("Benchmark RTCP encrypt", |b| {
123123
b.iter(|| {
124-
ctx.encrypt_rtcp(&RAW_RTCP)
125-
.unwrap();
124+
ctx.encrypt_rtcp(&RAW_RTCP).unwrap();
126125
});
127126
});
128127
}

srtp/src/cipher/cipher_aead_aes_gcm.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ impl Cipher for CipherAeadAesGcm {
3434
) -> Result<Bytes> {
3535
// Grow the given buffer to fit the output.
3636
let header_len = header.marshal_size();
37-
let mut writer =
38-
BytesMut::with_capacity(payload.len() + self.auth_tag_len());
37+
let mut writer = BytesMut::with_capacity(payload.len() + self.auth_tag_len());
3938

4039
// Copy header unencrypted.
4140
writer.extend_from_slice(&payload[..header_len]);

srtp/src/cipher/cipher_aes_cm_hmac_sha1/ctrcipher.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl Cipher for CtrCipher {
104104

105105
// See if the auth tag actually matches.
106106
// We use a constant time comparison to prevent timing attacks.
107-
if actual_tag.ct_eq(&expected_tag).unwrap_u8() != 1 {
107+
if actual_tag.ct_eq(expected_tag).unwrap_u8() != 1 {
108108
return Err(Error::RtpFailedToVerifyAuthTag);
109109
}
110110

@@ -147,9 +147,7 @@ impl Cipher for CtrCipher {
147147
let nonce = GenericArray::from_slice(&counter);
148148
let mut stream = Aes128Ctr::new(key, nonce);
149149

150-
stream.apply_keystream(
151-
&mut writer[HEADER_LENGTH + SSRC_LENGTH..],
152-
);
150+
stream.apply_keystream(&mut writer[HEADER_LENGTH + SSRC_LENGTH..]);
153151

154152
// Add SRTCP index and set Encryption bit
155153
writer.put_u32(srtcp_index as u32 | (1u32 << 31));
@@ -197,7 +195,7 @@ impl Cipher for CtrCipher {
197195

198196
// See if the auth tag actually matches.
199197
// We use a constant time comparison to prevent timing attacks.
200-
if actual_tag.ct_eq(&expected_tag).unwrap_u8() != 1 {
198+
if actual_tag.ct_eq(expected_tag).unwrap_u8() != 1 {
201199
return Err(Error::RtcpFailedToVerifyAuthTag);
202200
}
203201

@@ -213,9 +211,7 @@ impl Cipher for CtrCipher {
213211
let mut stream = Aes128Ctr::new(key, nonce);
214212

215213
stream.seek(0);
216-
stream.apply_keystream(
217-
&mut writer[HEADER_LENGTH + SSRC_LENGTH..],
218-
);
214+
stream.apply_keystream(&mut writer[HEADER_LENGTH + SSRC_LENGTH..]);
219215

220216
Ok(Bytes::from(writer))
221217
}

srtp/src/context/srtp.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@ impl Context {
4848
payload: &[u8],
4949
header: &rtp::header::Header,
5050
) -> Result<Bytes> {
51-
let roc = self.get_srtp_ssrc_state(header.ssrc).next_rollover_count(header.sequence_number);
51+
let roc = self
52+
.get_srtp_ssrc_state(header.ssrc)
53+
.next_rollover_count(header.sequence_number);
5254

53-
let dst = self
54-
.cipher
55-
.encrypt_rtp(&payload, header, roc)?;
55+
let dst = self.cipher.encrypt_rtp(payload, header, roc)?;
5656

57-
self.get_srtp_ssrc_state(header.ssrc).update_rollover_count(header.sequence_number);
57+
self.get_srtp_ssrc_state(header.ssrc)
58+
.update_rollover_count(header.sequence_number);
5859

5960
Ok(dst)
6061
}

srtp/src/main.rs

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

0 commit comments

Comments
 (0)