keyforkd: add warning when loading seed with less than 128 bits #39

Manually merged
ryan merged 1 commits from anton/require-min-entropy into main 2024-05-05 18:49:33 +00:00
1 changed files with 4 additions and 1 deletions
Showing only changes of commit bcfcc8711f - Show all commits

View File

@ -12,7 +12,7 @@ use keyfork_derive_path_data::guess_target;
// use keyfork_derive_util::request::{DerivationError, DerivationRequest, DerivationResponse}; // use keyfork_derive_util::request::{DerivationError, DerivationRequest, DerivationResponse};
use keyforkd_models::{DerivationError, Error, Request, Response}; use keyforkd_models::{DerivationError, Error, Request, Response};
use tower::Service; use tower::Service;
use tracing::info; use tracing::{info, warn};
// NOTE: All values implemented in Keyforkd must implement Clone with low overhead, either by // NOTE: All values implemented in Keyforkd must implement Clone with low overhead, either by
// using an Arc or by having a small signature. This is because Service<T> takes &mut self. // using an Arc or by having a small signature. This is because Service<T> takes &mut self.
@ -38,6 +38,9 @@ impl std::fmt::Debug for Keyforkd {
impl Keyforkd { impl Keyforkd {
/// Create a new instance of Keyfork from a given seed. /// Create a new instance of Keyfork from a given seed.
pub fn new(seed: Vec<u8>) -> Self { pub fn new(seed: Vec<u8>) -> Self {
if seed.len() < 16 {
warn!("Entropy size is lower than 128 bits: {} bits.", seed.len() * 8);
}
Self { Self {
seed: Arc::new(seed), seed: Arc::new(seed),
} }