Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugeny committed Sep 20, 2024
1 parent 6811f1d commit d48619c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 20 deletions.
3 changes: 2 additions & 1 deletion cryptovec/src/cryptovec.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::platform::{self, memcpy, memset, mlock, munlock};
use std::ops::{Deref, DerefMut, Index, IndexMut, Range, RangeFrom, RangeFull, RangeTo};

use crate::platform::{self, memcpy, memset, mlock, munlock};

/// A buffer which zeroes its memory on `.clear()`, `.resize()`, and
/// reallocations, to avoid copying secrets around.
#[derive(Debug)]
Expand Down
6 changes: 2 additions & 4 deletions cryptovec/src/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ mod unix;
mod wasm;

// Re-export functions based on the platform
#[cfg(windows)]
pub use windows::{memcpy, memset, mlock, munlock};

#[cfg(not(windows))]
#[cfg(not(target_arch = "wasm32"))]
pub use unix::{memcpy, memset, mlock, munlock};

#[cfg(target_arch = "wasm32")]
pub use wasm::{memcpy, memset, mlock, munlock};
#[cfg(windows)]
pub use windows::{memcpy, memset, mlock, munlock};

#[cfg(test)]
mod tests {
Expand Down
6 changes: 3 additions & 3 deletions cryptovec/src/platform/windows.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use winapi::shared::{basetsd::SIZE_T, minwindef::LPVOID};
use winapi::um::memoryapi::{VirtualLock, VirtualUnlock};

use libc::c_void;
use winapi::shared::basetsd::SIZE_T;
use winapi::shared::minwindef::LPVOID;
use winapi::um::memoryapi::{VirtualLock, VirtualUnlock};

/// Unlock memory on drop for Windows.
pub fn munlock(ptr: *const u8, len: usize) {
Expand Down
5 changes: 3 additions & 2 deletions russh-keys/src/known_hosts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ use std::fs::{File, OpenOptions};
use std::io::{BufRead, BufReader, Read, Seek, SeekFrom, Write};
use std::path::{Path, PathBuf};

use crate::{key, Error, PublicKeyBase64};
use data_encoding::BASE64_MIME;
use hmac::{Hmac, Mac};
use log::debug;
use sha1::Sha1;

use crate::{key, Error, PublicKeyBase64};

/// Check whether the host is known, from its standard location.
pub fn check_known_hosts(host: &str, port: u16, pubkey: &key::PublicKey) -> Result<bool, Error> {
check_known_hosts_path(host, port, pubkey, known_hosts_path()?)
Expand Down Expand Up @@ -188,10 +189,10 @@ pub fn write_public_key_base64<W: Write>(

#[cfg(test)]
mod test {
use crate::parse_public_key_base64;
use std::fs::File;

use super::*;
use crate::parse_public_key_base64;

#[test]
fn test_check_known_hosts() {
Expand Down
8 changes: 3 additions & 5 deletions russh-util/src/runtime.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use std::{
future::Future,
pin::Pin,
task::{Context, Poll},
};
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};

#[derive(Debug)]
pub struct JoinError;
Expand Down
6 changes: 1 addition & 5 deletions russh/src/client/kex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,7 @@ impl KexInit {
write_buffer: &mut SSHBuffer,
) -> Result<(), crate::Error> {
self.exchange.client_kex_init.clear();
negotiation::write_kex(
&config.preferred,
&mut self.exchange.client_kex_init,
None,
)?;
negotiation::write_kex(&config.preferred, &mut self.exchange.client_kex_init, None)?;
self.sent = true;
cipher.write(&self.exchange.client_kex_init, write_buffer);
Ok(())
Expand Down

0 comments on commit d48619c

Please sign in to comment.