mirror of
https://github.com/rosenpass/rosenpass.git
synced 2026-07-28 14:26:59 -07:00
run formatters
This commit is contained in:
@@ -105,10 +105,12 @@ unsafe impl Allocator for MallocAllocator {
|
||||
// Ensure the right alignment is used
|
||||
let off = (mem.as_ptr() as *const u8).align_offset(layout.align());
|
||||
if off != 0 {
|
||||
log::error!("Allocation {layout:?} was requested but malloc-based memsec returned allocation \
|
||||
log::error!(
|
||||
"Allocation {layout:?} was requested but malloc-based memsec returned allocation \
|
||||
with offset {off} from the requested alignment. Malloc always allocates values \
|
||||
at the end of a memory page for security reasons, custom alignments are not supported. \
|
||||
You could try allocating an oversized value.");
|
||||
You could try allocating an oversized value."
|
||||
);
|
||||
unsafe { memsec::free(mem) };
|
||||
return Err(AllocError);
|
||||
};
|
||||
|
||||
@@ -99,17 +99,21 @@ unsafe impl Allocator for MemfdSecAllocator {
|
||||
|
||||
// Unwrap the option
|
||||
let Some(mem) = mem else {
|
||||
log::error!("Allocation {layout:?} was requested but memfd-based memsec returned a null pointer");
|
||||
log::error!(
|
||||
"Allocation {layout:?} was requested but memfd-based memsec returned a null pointer"
|
||||
);
|
||||
return Err(AllocError);
|
||||
};
|
||||
|
||||
// Ensure the right alignment is used
|
||||
let off = (mem.as_ptr() as *const u8).align_offset(layout.align());
|
||||
if off != 0 {
|
||||
log::error!("Allocation {layout:?} was requested but memfd-based memsec returned allocation \
|
||||
log::error!(
|
||||
"Allocation {layout:?} was requested but memfd-based memsec returned allocation \
|
||||
with offset {off} from the requested alignment. Memfd always allocates values \
|
||||
at the end of a memory page for security reasons, custom alignments are not supported. \
|
||||
You could try allocating an oversized value.");
|
||||
You could try allocating an oversized value."
|
||||
);
|
||||
unsafe { memsec::free_memfd_secret(mem) };
|
||||
return Err(AllocError);
|
||||
};
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use crate::debug::debug_crypto_array;
|
||||
use anyhow::Context;
|
||||
use rand::{Fill as Randomize, Rng};
|
||||
use rosenpass_to::{ops::copy_slice, To};
|
||||
use rosenpass_to::{To, ops::copy_slice};
|
||||
use rosenpass_util::b64::{b64_decode, b64_encode};
|
||||
use rosenpass_util::file::{
|
||||
fopen_r, fopen_w, LoadValue, LoadValueB64, ReadExactToEnd, ReadSliceToEnd, StoreValue,
|
||||
StoreValueB64, StoreValueB64Writer, Visibility,
|
||||
LoadValue, LoadValueB64, ReadExactToEnd, ReadSliceToEnd, StoreValue, StoreValueB64,
|
||||
StoreValueB64Writer, Visibility, fopen_r, fopen_w,
|
||||
};
|
||||
use rosenpass_util::functional::mutating;
|
||||
use std::borrow::{Borrow, BorrowMut};
|
||||
@@ -390,8 +390,8 @@ mod tests {
|
||||
use rosenpass_util::{
|
||||
b64::b64_encode,
|
||||
file::{
|
||||
fopen_w, LoadValue, LoadValueB64, StoreValue, StoreValueB64, StoreValueB64Writer,
|
||||
Visibility,
|
||||
LoadValue, LoadValueB64, StoreValue, StoreValueB64, StoreValueB64Writer,
|
||||
Visibility, fopen_w,
|
||||
},
|
||||
};
|
||||
use std::{fs, ops::Deref, os::unix::fs::PermissionsExt};
|
||||
|
||||
@@ -10,15 +10,15 @@ use zeroize::{Zeroize, ZeroizeOnDrop};
|
||||
|
||||
use rosenpass_util::b64::{b64_decode, b64_encode};
|
||||
use rosenpass_util::file::{
|
||||
fopen_r, LoadValue, LoadValueB64, ReadExactToEnd, ReadSliceToEnd, StoreValueB64,
|
||||
StoreValueB64Writer,
|
||||
LoadValue, LoadValueB64, ReadExactToEnd, ReadSliceToEnd, StoreValueB64, StoreValueB64Writer,
|
||||
fopen_r,
|
||||
};
|
||||
use rosenpass_util::functional::mutating;
|
||||
|
||||
use crate::alloc::{secret_box, SecretBox, SecretVec};
|
||||
use crate::alloc::{SecretBox, SecretVec, secret_box};
|
||||
use crate::file::StoreSecret;
|
||||
|
||||
use rosenpass_util::file::{fopen_w, Visibility};
|
||||
use rosenpass_util::file::{Visibility, fopen_w};
|
||||
use std::io::Write;
|
||||
// This might become a problem in library usage; it's effectively a memory
|
||||
// leak which probably isn't a problem right now because most memory will
|
||||
|
||||
@@ -101,7 +101,7 @@ impl<'de, const N: usize> Deserialize<'de> for PublicBox<N> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::secret_policy_use_only_malloc_secrets;
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
use serde::{Serialize, de::DeserializeOwned};
|
||||
use serde_json;
|
||||
|
||||
// Generic helper: serialize to JSON, then deserialize back.
|
||||
|
||||
Reference in New Issue
Block a user