Skip to content

Commit

Permalink
Spelling (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoref authored and kornelski committed Apr 7, 2019
1 parent d6b26a2 commit b040eb4
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 47 deletions.
6 changes: 3 additions & 3 deletions src/crypto/x25519/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ pub struct X25519SecretKey {

#[repr(C)]
#[derive(Debug)]
/// An ephemeral X25519 key. Ideally should only be used once, but because WG uses the same ephemral
/// key twice, it is essentialy identical to a secret key
/// An ephemeral X25519 key. Ideally should only be used once, but because WG uses the same ephemeral
/// key twice, it is essentially identical to a secret key
pub struct X25519EphemeralKey {
internal: X25519SecretKey,
}
Expand Down Expand Up @@ -82,7 +82,7 @@ impl X25519SecretKey {
}
}

/// Derive a shared key from a secret key of one peer and a pulic key of another
/// Derive a shared key from a secret key of one peer and a public key of another
pub fn shared_key(&self, peer_public: &X25519PublicKey) -> Result<[u8; 32], WireGuardError> {
let shared_key = x25519_shared_key(&peer_public.internal[..], &self.internal[..]);

Expand Down
2 changes: 1 addition & 1 deletion src/device/allowed_ips.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ macro_rules! build_node {
let dir = if next_bit { &mut right } else { &mut left };
$insert(dir, key << (shared_bits + 1), bits - shared_bits - 1, data);
}
// The node is unchaged
// The node is unchanged
*node = Some($name::Node {
cur_key,
cur_bits,
Expand Down
10 changes: 5 additions & 5 deletions src/device/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::sync::atomic::Ordering;
const SOCK_DIR: &str = "/var/run/wireguard/";

fn create_sock_dir() {
create_dir(SOCK_DIR).is_ok(); // Create the directory if not existant
create_dir(SOCK_DIR).is_ok(); // Create the directory if it does not exist

if let Ok((saved_uid, saved_gid)) = get_saved_ids() {
unsafe {
Expand All @@ -33,7 +33,7 @@ fn create_sock_dir() {
}

impl Device {
/// Register the api handler for this Device. The api handler recieves stream connections on a Unix socket
/// Register the api handler for this Device. The api handler receives stream connections on a Unix socket
/// with a known path: /var/run/wireguard/{tun_name}.sock.
pub fn register_api_handler(&mut self) -> Result<(), Error> {
let path = format!("{}/{}.sock", SOCK_DIR, self.iface.name()?);
Expand Down Expand Up @@ -69,7 +69,7 @@ impl Device {
// The protocol requires to return an error code as the response, or zero on success
writeln!(writer, "errno={}\n", status).ok();
}
Action::Continue // Inidicates the worker thread should continue as normal
Action::Continue // Indicates the worker thread should continue as normal
}),
)?;

Expand All @@ -85,15 +85,15 @@ impl Device {
// file was deleted by stating it.
// The problem is that on linux inotify can be used quite beautifully to detect
// deletion, and kqueue EVFILT_VNODE can be used for the same purpose, but that
// will require introducing new events, for no measureable benefit.
// will require introducing new events, for no measurable benefit.
// TODO: Could this be an issue if we restart the service too quickly?
let path = std::path::Path::new(&path);
if !path.exists() {
d.trigger_exit();
return Action::Exit;
}

// Preriodically read the mtu of the interface in case it changes
// Periodically read the mtu of the interface in case it changes
if let Ok(mtu) = d.iface.mtu() {
d.mtu.store(mtu, Ordering::Relaxed);
}
Expand Down
8 changes: 4 additions & 4 deletions src/device/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ impl<H: Sync + Send> EventPoll<H> {
/// event overrides all previous events. In case the same trigger is used with multiple polls,
/// each event will be triggered independently.
/// The event will keep triggering until a Read operation is no longer possible on the trigger.
/// When triggered, one of the threads waiting on the poll will recieve the handler via an
/// appropriate EventGuard. It is guranteed that only a single thread can have a reference to
/// When triggered, one of the threads waiting on the poll will receive the handler via an
/// appropriate EventGuard. It is guaranteed that only a single thread can have a reference to
/// the handler at any given time.
pub fn new_event(&self, trigger: RawFd, handler: H) -> Result<EventRef, Error> {
// Create an event descriptor
Expand Down Expand Up @@ -193,7 +193,7 @@ impl<H: Sync + Send> EventPoll<H> {

/// Wait until one of the registered events becomes triggered. Once an event
/// is triggered, a single caller thread gets the handler for that event.
/// In case a notifier is triggered, all waiting threads will recieve the same
/// In case a notifier is triggered, all waiting threads will receive the same
/// handler.
pub fn wait<'a>(&'a self) -> WaitResult<'a, H> {
let mut event = epoll_event { events: 0, u64: 0 };
Expand Down Expand Up @@ -302,7 +302,7 @@ impl<H: Sync + Send> EventPoll<H> {
}

impl<H> EventPoll<H> {
/// Disable and remove the event and assosiated handler, using the fd that was used
/// Disable and remove the event and associated handler, using the fd that was used
/// to register it.
/// This function is only safe to call when the event loop is not running, otherwise the
/// memory of the handler may get freed while in use.
Expand Down
4 changes: 2 additions & 2 deletions src/device/integration_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: BSD-3-Clause

// This module contains some integration tests for boringtun
// Those tests require docker and sudo priviliges to run
// Those tests require docker and sudo privileges to run
#[cfg(test)]
mod tests {
use crate::crypto::x25519::*;
Expand Down Expand Up @@ -163,7 +163,7 @@ mod tests {
"net.ipv6.conf.default.disable_ipv6=0",
"-p", // Open port for the endpoint
&format!("{0}:{0}/udp", self.endpoint.port()),
"-v", // Map the generated wiregurad config file
"-v", // Map the generated wireguard config file
&format!("{}:/wireguard/wg.conf", peer_config_file),
"-v", // Map the nginx config file
&format!("{}:/etc/nginx/conf.d/default.conf", nginx_config_file),
Expand Down
10 changes: 5 additions & 5 deletions src/device/kqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ enum EventKind {

// A single event
struct Event<H> {
event: kevent, // The kqueue event desctiption
event: kevent, // The kqueue event description
handler: H, // The associated data
kind: EventKind,
}
Expand Down Expand Up @@ -90,8 +90,8 @@ impl<H: Send + Sync> EventPoll<H> {
/// event overrides all previous events. In case the same trigger is used with multiple polls,
/// each event will be triggered independently.
/// The event will keep triggering until a Read operation is no longer possible on the trigger.
/// When triggered, one of the threads waiting on the poll will recieve the handler via an
/// appropriate EventGuard. It is guranteed that only a single thread can have a reference to
/// When triggered, one of the threads waiting on the poll will receive the handler via an
/// appropriate EventGuard. It is guaranteed that only a single thread can have a reference to
/// the handler at any given time.
pub fn new_event(&self, trigger: RawFd, handler: H) -> Result<EventRef, Error> {
// Create an event descriptor
Expand Down Expand Up @@ -174,7 +174,7 @@ impl<H: Send + Sync> EventPoll<H> {

/// Wait until one of the registered events becomes triggered. Once an event
/// is triggered, a single caller thread gets the handler for that event.
/// In case a notifier is triggered, all waiting threads will recieve the same
/// In case a notifier is triggered, all waiting threads will receive the same
/// handler.
pub fn wait(&'_ self) -> WaitResult<'_, H> {
let mut event = kevent {
Expand Down Expand Up @@ -244,7 +244,7 @@ impl<H: Send + Sync> EventPoll<H> {
}

if ev.kind == EventKind::Signal {
// Mask the signal if succesfully added to kqueue
// Mask the signal if successfully added to kqueue
unsafe { signal(trigger, SIG_IGN) };
}

Expand Down
2 changes: 1 addition & 1 deletion src/device/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ impl Device {

fn remove_peer(&mut self, pub_key: &X25519PublicKey) {
if let Some(peer) = self.peers.remove(pub_key) {
// Found a peer to remove, now perge all references to is:
// Found a peer to remove, now purge all references to it:
peer.shutdown_endpoint(); // close open udp socket and free the closure
self.peers_by_idx.remove(&peer.index()); // peers_by_idx
self.peers_by_ip
Expand Down
4 changes: 2 additions & 2 deletions src/device/udp_unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use libc::*;
use std::net::{SocketAddr, SocketAddrV4, SocketAddrV6};
use std::os::unix::io::{AsRawFd, RawFd};

/// Recieves and sends UDP packets over the network
/// Receives and sends UDP packets over the network
#[derive(Debug)]
pub struct UDPSocket {
fd: RawFd,
Expand Down Expand Up @@ -354,7 +354,7 @@ impl UDPSocket {
}
}

/// Sends a message on a connected UDP socket. Returns number of bytes succesfully sent.
/// Sends a message on a connected UDP socket. Returns number of bytes successfully sent.
pub fn write(&self, src: &[u8]) -> usize {
UDPSocket::write_fd(self.fd, src)
}
Expand Down
8 changes: 4 additions & 4 deletions src/ffi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub enum result_type {
WIREGUARD_DONE = 0,
/// Write dst buffer to network. Size indicates the number of bytes to write.
WRITE_TO_NETWORK = 1,
/// Some error occured, no operation is required. Size indicates error code.
/// Some error occurred, no operation is required. Size indicates error code.
WIREGUARD_ERROR = 2,
/// Write dst buffer to the interface as an ipv4 packet. Size indicates the number of bytes to write.
WRITE_TO_TUNNEL_IPV4 = 4,
Expand Down Expand Up @@ -253,7 +253,7 @@ pub unsafe extern "C" fn wireguard_read(
wireguard_result::from(tunnel.network_to_tunnel(src, dst))
}

/// This is a state keeping function, that need to be called preriodically.
/// This is a state keeping function, that need to be called periodically.
/// Recommended interval: 100ms.
#[no_mangle]
pub unsafe extern "C" fn wireguard_tick(
Expand Down Expand Up @@ -281,7 +281,7 @@ pub unsafe extern "C" fn wireguard_force_handshake(
}

/// Returns stats from the tunnel:
/// Time of last handshake in seconds (or -1 if no handshake occured)
/// Time of last handshake in seconds (or -1 if no handshake occurred)
/// Number of data bytes encapsulated
/// Number of data bytes decapsulated
#[no_mangle]
Expand All @@ -296,7 +296,7 @@ pub unsafe extern "C" fn wireguard_stats(tunnel: *mut Tunn) -> stats {
}
}

/// Performs an iternal benchmark, and returns its result as a C-string.
/// Performs an internal benchmark, and returns its result as a C-string.
#[no_mangle]
pub extern "C" fn benchmark(name: i32, idx: u32) -> *const c_char {
if let Some(s) = do_benchmark(name != 0, idx as usize) {
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ fn main() {
}
};

if !matches.is_present("disable-drop-priviliges") {
if !matches.is_present("disable-drop-privileges") {
drop_privileges().ok();
}

Expand Down
10 changes: 5 additions & 5 deletions src/noise/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ pub struct Handshake {
next_index: u32, // Index of the next session
state: HandshakeState, // Current handshake state
cookie: Option<[u8; 16]>, // An optional expirable cookie
last_handshake_timestamp: Tai64N, // The timestamp of the last handshake we recieved
last_handshake_timestamp: Tai64N, // The timestamp of the last handshake we received
stamper: TimeStamper, // TODO: make TimeStamper a singleton
}

Expand Down Expand Up @@ -229,8 +229,8 @@ pub fn parse_handshake_anon(
[0x01]
);
// temp = HMAC(initiator.chaining_key, DH(initiator.ephemeral_private, responder.static_public))
let epehemeral_shared = static_private.shared_key(&peer_ephemeral_public)?;
let temp = HMAC!(chaining_key, &epehemeral_shared[..]);
let ephemeral_shared = static_private.shared_key(&peer_ephemeral_public)?;
let temp = HMAC!(chaining_key, &ephemeral_shared[..]);
// initiator.chaining_key = HMAC(temp, 0x1)
chaining_key = HMAC!(temp, [0x01]);
// key = HMAC(temp, initiator.chaining_key || 0x2)
Expand Down Expand Up @@ -400,8 +400,8 @@ impl Handshake {
// initiator.chaining_key = HMAC(temp, 0x1)
chaining_key = HMAC!(HMAC!(chaining_key, dst[EPH_OFF..EPH_OFF + EPH_SZ]), [0x01]);
// temp = HMAC(initiator.chaining_key, DH(initiator.ephemeral_private, responder.static_public))
let epehemeral_shared = ephemeral_private.shared_key(&self.params.peer_static_public)?;
let temp = HMAC!(chaining_key, epehemeral_shared);
let ephemeral_shared = ephemeral_private.shared_key(&self.params.peer_static_public)?;
let temp = HMAC!(chaining_key, ephemeral_shared);
// initiator.chaining_key = HMAC(temp, 0x1)
chaining_key = HMAC!(temp, [0x01]);
// key = HMAC(temp, initiator.chaining_key || 0x2)
Expand Down
2 changes: 1 addition & 1 deletion src/noise/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ impl Tunn {
if src.len() < session::IDX_OFF + session::IDX_SZ {
return TunnResult::Err(WireGuardError::InvalidPacket);
}
// Extract the reciever index
// Extract the receiver index
let idx = u32::from_le_bytes(make_array(&src[session::IDX_OFF..])) as usize;

// Get the (possibly) right session
Expand Down
4 changes: 2 additions & 2 deletions src/noise/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl ReceivingKeyCounterValidator {
((self.bitmap[word] >> bit) & 1) == 1
}

// Returns true if the counter was not yet recieved, and is not too far back
// Returns true if the counter was not yet received, and is not too far back
#[inline(always)]
fn will_accept(&self, counter: u64) -> bool {
if counter >= self.next {
Expand Down Expand Up @@ -295,7 +295,7 @@ impl Session {
&mut dst[..src.len() - DATA_OFF],
)
.map_err(|_| WireGuardError::InvalidAeadTag)?;
// After decryption is done, check counter again, and mark as recieved
// After decryption is done, check counter again, and mark as received
self.receiving_counter_mark(receiving_key_counter)?;
Ok(packet)
}
Expand Down
8 changes: 4 additions & 4 deletions src/noise/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ mod tests {
packet.extend_from_slice(&ipv4_header);
packet.extend_from_slice(&icmp_header);
packet.extend_from_slice(&data);
// Compute the checkusm of the icmp header + payload
// Compute the checksum of the icmp header + payload
let icmp_checksum = ipv4_checksum(&packet[20..]);
write_u16_be(icmp_checksum, &mut packet[20 + 2..]);
socket.send(&packet).unwrap();
Expand Down Expand Up @@ -338,7 +338,7 @@ mod tests {

#[test]
fn wireguard_handshake() {
// Test the connection is succesfully established and some packets are passed around
// Test the connection is successfully established and some packets are passed around
{
let (peer_iface_socket_sender, client_iface_socket_sender, close) =
wireguard_test_pair();
Expand Down Expand Up @@ -437,7 +437,7 @@ mod tests {
#[test]
#[ignore]
fn wireguard_interop() {
// Test the connection with wireguard-go is succesfully established
// Test the connection with wireguard-go is successfully established
// and we are getting ping from server
let c_key_pair = key_pair();
let itr = 1000;
Expand Down Expand Up @@ -477,7 +477,7 @@ mod tests {
#[test]
#[ignore]
fn wireguard_receiver() {
// Test the connection with wireguard-go is succesfully established
// Test the connection with wireguard-go is successfully established
// when go is the initiator
let c_key_pair = key_pair();
let itr = 1000;
Expand Down
14 changes: 7 additions & 7 deletions src/noise/timers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
/*
static MAX_TIMER_HANDSHAKES: u32 = 90 / 5;
static COOKIE_REFRESH_TIME: Duration = Duration::from_secs(120);
static HANDSHAKE_INITATION_RATE: Duration = Duration::from_millis(50);
static HANDSHAKE_INITIATION_RATE: Duration = Duration::from_millis(50);
*/

// Some constants, represent time in seconds
Expand All @@ -28,11 +28,11 @@ pub enum TimerName {
TimeCurrent, // Current time, updated each call to `update_timers`
TimeSessionEstablished, // Time when last handshake was completed
TimeLastHandshakeStarted, // Time the last attempt for a new handshake began
TimeLastPacketReceived, // Time we last recieved and authenticated a packet
TimeLastPacketReceived, // Time we last received and authenticated a packet
TimeLastPacketSent, // Time we last send a packet
TimeLastDataPacketReceived, // Time we last recieved and authenticated a DATA packet
TimeLastDataPacketReceived, // Time we last received and authenticated a DATA packet
TimeLastDataPacketSent, // Time we last send a DATA packet
TimeCookieReceived, // Time we last recieved a cookie
TimeCookieReceived, // Time we last received a cookie
TimePersistentKeepalive, // Time we last sent persistent keepalive
Top,
}
Expand All @@ -50,8 +50,8 @@ pub struct Timers {
is_initiator: AtomicBool, // Is the owner of the timer the initiator or the responder for the last handshake?
time_started: Instant, // Start time of the tunnel
timers: [Timer; TimerName::Top as usize],
want_keepalive: AtomicBool, // Did we recieve data without sending anything back?
want_handshake: AtomicBool, // Did we send data withoug hearing back?
want_keepalive: AtomicBool, // Did we receive data without sending anything back?
want_handshake: AtomicBool, // Did we send data without hearing back?
persistent_keepalive: AtomicUsize,
}

Expand Down Expand Up @@ -234,7 +234,7 @@ impl Tunn {
{
self.log(
Verbosity::Debug,
"HANDSHAKE(REJECT_AFTER_TIME - KEEPALIVE_TIMEOUT - REKEY_TIMEOUT (on recieve))",
"HANDSHAKE(REJECT_AFTER_TIME - KEEPALIVE_TIMEOUT - REKEY_TIMEOUT (on receive))",
);
hanshake_initiation_required = true;
}
Expand Down

0 comments on commit b040eb4

Please sign in to comment.