Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): bump ring from 0.17.9 to 0.17.13 #79

Merged
merged 2 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions boringtun/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ hmac = "0.12"
jni = { version = "0.19.0", optional = true }
socket2 = { version = "0.5.8", features = ["all"], optional = true }
thiserror = { version = "1", optional = true }
constant_time_eq = "0.4.2"

[target.'cfg(unix)'.dependencies]
nix = { version = "0.29", default-features = false, features = [
Expand Down
8 changes: 5 additions & 3 deletions boringtun/src/noise/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use aead::{Aead, Payload};
use blake2::digest::{FixedOutput, KeyInit};
use blake2::{Blake2s256, Blake2sMac, Digest};
use chacha20poly1305::XChaCha20Poly1305;
use constant_time_eq::constant_time_eq;
use rand::rngs::OsRng;
use ring::aead::{Aad, LessSafeKey, Nonce, UnboundKey, CHACHA20_POLY1305};
use std::convert::TryInto;
Expand Down Expand Up @@ -525,11 +526,12 @@ impl Handshake {
&hash,
)?;

ring::constant_time::verify_slices_are_equal(
if !constant_time_eq(
self.params.peer_static_public.as_bytes(),
&peer_static_public_decrypted,
)
.map_err(|_| WireGuardError::WrongKey)?;
) {
return Err(WireGuardError::WrongKey);
}

// initiator.hash = HASH(initiator.hash || msg.encrypted_static)
hash = b2s_hash(&hash, packet.encrypted_static);
Expand Down
9 changes: 5 additions & 4 deletions boringtun/src/noise/rate_limiter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use std::time::Instant;
use aead::generic_array::GenericArray;
use aead::{AeadInPlace, KeyInit};
use chacha20poly1305::{Key, XChaCha20Poly1305};
use constant_time_eq::constant_time_eq;
use parking_lot::Mutex;
use rand::{rngs::OsRng, RngCore};
use ring::constant_time::verify_slices_are_equal;

const COOKIE_REFRESH: u64 = 128; // Use 128 and not 120 so the compiler can optimize out the division
const COOKIE_SIZE: usize = 16;
Expand Down Expand Up @@ -200,8 +200,9 @@ impl RateLimiter {
let (mac1, mac2) = macs.split_at(16);

let computed_mac1 = b2s_keyed_mac_16(&self.mac1_key, msg);
verify_slices_are_equal(&computed_mac1[..16], mac1)
.map_err(|_| TunnResult::Err(WireGuardError::InvalidMac))?;
if !constant_time_eq(&computed_mac1[..16], mac1) {
return Err(TunnResult::Err(WireGuardError::InvalidMac));
}

if self.is_under_load() {
let addr = match src_addr {
Expand All @@ -213,7 +214,7 @@ impl RateLimiter {
let cookie = self.current_cookie(addr, now);
let computed_mac2 = b2s_keyed_mac_16_2(&cookie, msg, mac1);

if verify_slices_are_equal(&computed_mac2[..16], mac2).is_err() {
if !constant_time_eq(&computed_mac2[..16], mac2) {
let cookie_packet = self
.format_cookie_reply(sender_idx, cookie, mac1, dst)
.map_err(TunnResult::Err)?;
Expand Down
Loading