Skip to content

Commit 5e27bde

Browse files
authored
[password] increase the number of argon2 iterations (#4556)
To get this test to pass on my Ryzen 7950X running Linux 6.5.6, I had to bump up the number of argon2 iterations all the way up from 13 to 23. See this comment thread for more benchmarks against gimlets etc. Fixes #4555.
1 parent 5afd8bc commit 5e27bde

File tree

8 files changed

+54
-35
lines changed

8 files changed

+54
-35
lines changed

nexus/db-queries/src/db/datastore/rack.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1101,10 +1101,10 @@ mod test {
11011101
DNS_ZONE
11021102
),
11031103
recovery_user_id: "test-user".parse().unwrap(),
1104-
// empty string password
1105-
recovery_user_password_hash: "$argon2id$v=19$m=98304,t=13,\
1106-
p=1$d2t2UHhOdWt3NkYyY1l3cA$pIvmXrcTk/\
1107-
nsUzWvBQIeuMJk96ijye/oIXHCj15xg+M"
1104+
// Generated via `cargo run --example argon2 -- --input ""`.
1105+
recovery_user_password_hash: "$argon2id$v=19$m=98304,t=23,\
1106+
p=1$E4DE+f6Yduuy0nSubo5qtg$57JDYGov3SZoEZnLyZZBHOACH95s\
1107+
8aOpG22zBoWZ2S4"
11081108
.parse()
11091109
.unwrap(),
11101110
dns_update: DnsVersionUpdateBuilder::new(

passwords/examples/argon2.rs

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ fn main() -> anyhow::Result<()> {
5757
println!(" 'm' cost: {} KiB", cli.m_cost);
5858
println!(" 'p' cost: {} (degree of parallelism)", cli.p_cost);
5959
println!(" 't' cost: {} (number of iterations)", cli.t_cost);
60+
println!("password hash: {}", password_hash);
6061
println!(
6162
"output size override: {}",
6263
OUTPUT_SIZE_OVERRIDE

passwords/src/lib.rs

+22-18
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use thiserror::Error;
3434
// output length.
3535
const ARGON2_ALGORITHM: argon2::Algorithm = argon2::Algorithm::Argon2id;
3636
pub const ARGON2_COST_M_KIB: u32 = 96 * 1024;
37-
pub const ARGON2_COST_T: u32 = 13;
37+
pub const ARGON2_COST_T: u32 = 23;
3838
pub const ARGON2_COST_P: u32 = 1;
3939

4040
// Maximum password length, intended to prevent denial of service attacks. See
@@ -589,62 +589,66 @@ mod test {
589589
parse_phc_hash("dummy").unwrap_err(),
590590
"password hash: password hash string missing field"
591591
);
592-
// This input was generated from argon2.online using the empty string as
593-
// input.
592+
// This input was generated via `cargo run --example argon2 -- --input ""`.
594593
let _ = parse_phc_hash(
595-
"$argon2id$v=19$m=98304,t=13,p=1$MDEyMzQ1Njc4OTAxMjM0NQ\
596-
$tFRlFMnzazQduuAkXOEi6k9g88nwBbUV8rJI0PjT8/I",
594+
"$argon2id$v=19$m=98304,t=23,\
595+
p=1$E4DE+f6Yduuy0nSubo5qtg$57JDYGov3SZoEZnLyZZBHOACH95s\
596+
8aOpG22zBoWZ2S4",
597597
)
598598
.unwrap();
599599

600600
// The following inputs were constructed by taking the valid hash above
601601
// and adjusting the string by hand.
602602
assert_eq!(
603603
parse_phc_hash(
604-
"$argon2i$v=19$m=98304,t=13,p=1$MDEyMzQ1Njc4OTAxMjM0NQ\
605-
$tFRlFMnzazQduuAkXOEi6k9g88nwBbUV8rJI0PjT8/I"
604+
"$argon2i$v=19$m=98304,t=23,\
605+
p=1$E4DE+f6Yduuy0nSubo5qtg$57JDYGov3SZoEZnLyZZBHOACH95s\
606+
8aOpG22zBoWZ2S4",
606607
)
607608
.unwrap_err(),
608609
"password hash: algorithm: expected argon2id, found argon2i"
609610
);
610611
assert_eq!(
611612
parse_phc_hash(
612-
"$argon2id$v=19$m=98304,t=13,p=1$\
613-
$tFRlFMnzazQduuAkXOEi6k9g88nwBbUV8rJI0PjT8/I"
613+
"$argon2id$v=19$m=98304,t=23,p=1$\
614+
$57JDYGov3SZoEZnLyZZBHOACH95s8aOpG22zBoWZ2S4",
614615
)
615616
.unwrap_err(),
616617
// sic
617618
"password hash: salt invalid: value to short",
618619
);
619620
assert_eq!(
620621
parse_phc_hash(
621-
"$argon2id$v=19$m=98304,t=13,p=1$MDEyMzQ1Njc\
622-
$tFRlFMnzazQduuAkXOEi6k9g88nwBbUV8rJI0PjT8/I"
622+
"$argon2id$v=19$m=98304,t=23,p=1$E4DE+f6Ydu$\
623+
57JDYGov3SZoEZnLyZZBHOACH95s8aOpG22zBoWZ2S4",
623624
)
624625
.unwrap_err(),
625626
"password hash: salt: expected at least 16 bytes",
626627
);
627628
assert_eq!(
628629
parse_phc_hash(
629-
"$argon2id$v=19$m=4096,t=13,p=1$MDEyMzQ1Njc4OTAxMjM0NQ\
630-
$tFRlFMnzazQduuAkXOEi6k9g88nwBbUV8rJI0PjT8/I"
630+
"$argon2id$v=19$m=4096,t=23,\
631+
p=1$E4DE+f6Yduuy0nSubo5qtg$57JDYGov3SZoEZnLyZZBHOACH95s\
632+
8aOpG22zBoWZ2S4",
631633
)
632634
.unwrap_err(),
633635
"password hash: parameter 'm': expected at least 98304 (KiB), \
634636
found 4096"
635637
);
636638
assert_eq!(
637639
parse_phc_hash(
638-
"$argon2id$v=19$m=98304,t=12,p=1$MDEyMzQ1Njc4OTAxMjM0NQ\
639-
$tFRlFMnzazQduuAkXOEi6k9g88nwBbUV8rJI0PjT8/I"
640+
"$argon2id$v=19$m=98304,t=22,\
641+
p=1$E4DE+f6Yduuy0nSubo5qtg$57JDYGov3SZoEZnLyZZBHOACH95s\
642+
8aOpG22zBoWZ2S4",
640643
)
641644
.unwrap_err(),
642-
"password hash: parameter 't': expected at least 13, found 12"
645+
"password hash: parameter 't': expected at least 23, found 22"
643646
);
644647
assert_eq!(
645648
parse_phc_hash(
646-
"$argon2id$v=19$m=98304,t=13,p=0$MDEyMzQ1Njc4OTAxMjM0NQ\
647-
$tFRlFMnzazQduuAkXOEi6k9g88nwBbUV8rJI0PjT8/I"
649+
"$argon2id$v=19$m=98304,t=23,\
650+
p=0$E4DE+f6Yduuy0nSubo5qtg$57JDYGov3SZoEZnLyZZBHOACH95s\
651+
8aOpG22zBoWZ2S4",
648652
)
649653
.unwrap_err(),
650654
// sic

sled-agent/src/rack_setup/plan/service.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,12 @@ mod tests {
12231223
recovery_silo: RecoverySiloConfig {
12241224
silo_name: "recovery".parse().unwrap(),
12251225
user_name: "recovery".parse().unwrap(),
1226-
user_password_hash: "$argon2id$v=19$m=98304,t=13,p=1$RUlWc0ZxaHo0WFdrN0N6ZQ$S8p52j85GPvMhR/ek3GL0el/oProgTwWpHJZ8lsQQoY".parse().unwrap(),
1226+
// Generated via `cargo run --example argon2`.
1227+
user_password_hash: "$argon2id$v=19$m=98304,t=23,\
1228+
p=1$Naz/hHpgS8GXQqT8Zm0Nog$ucAKOsMiq70xtAEaLCY\
1229+
unjEgDyjSnuXaKTfmMKpKQIA"
1230+
.parse()
1231+
.unwrap(),
12271232
},
12281233
rack_network_config: RackNetworkConfig {
12291234
rack_subnet: Ipv6Net::host_net(Ipv6Addr::LOCALHOST),

sled-agent/src/sim/server.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -514,10 +514,14 @@ pub async fn run_standalone_server(
514514
// individuals running this program who then want to log in as this
515515
// user. For more on what's supported, see the API docs for this
516516
// type and the specific constraints in the nexus-passwords crate.
517-
user_password_hash: "$argon2id$v=19$m=98304,t=13,p=1$\
518-
RUlWc0ZxaHo0WFdrN0N6ZQ$S8p52j85GPvMhR/ek3GL0el/oProgTwWpHJZ8lsQQoY"
519-
.parse()
520-
.unwrap(),
517+
//
518+
// The hash was generated via:
519+
// `cargo run --example argon2 -- --input oxide`.
520+
user_password_hash:
521+
"$argon2id$v=19$m=98304,t=23,p=1$Effh/p6M2ZKdnpJFeGqtGQ$\
522+
ZtUwcVODAvUAVK6EQ5FJMv+GMlUCo9PQQsy9cagL+EU"
523+
.parse()
524+
.unwrap(),
521525
};
522526

523527
let mut crucible_datasets = vec![];

sled-agent/types/src/rack_init.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,12 @@ mod tests {
486486
recovery_silo: RecoverySiloConfig {
487487
silo_name: "recovery".parse().unwrap(),
488488
user_name: "recovery".parse().unwrap(),
489-
user_password_hash: "$argon2id$v=19$m=98304,t=13,p=1$RUlWc0ZxaHo0WFdrN0N6ZQ$S8p52j85GPvMhR/ek3GL0el/oProgTwWpHJZ8lsQQoY".parse().unwrap(),
489+
// Generated via `cargo run --example argon2 -- --input oxide`.
490+
user_password_hash:
491+
"$argon2id$v=19$m=98304,t=23,p=1$Effh/p6M2ZKdnpJFeGqtGQ$\
492+
ZtUwcVODAvUAVK6EQ5FJMv+GMlUCo9PQQsy9cagL+EU"
493+
.parse()
494+
.unwrap(),
490495
},
491496
rack_network_config: RackNetworkConfig {
492497
rack_subnet: Ipv6Net::host_net(Ipv6Addr::LOCALHOST),
@@ -607,11 +612,11 @@ mod tests {
607612
user_name: "dummy".parse().unwrap(),
608613
// This is a hash for the password "oxide". It doesn't matter,
609614
// though; it's not used.
610-
user_password_hash: "$argon2id$v=19$m=98304,t=13,p=1$\
611-
RUlWc0ZxaHo0WFdrN0N6ZQ$S8p52j85GPvMhR/\
612-
ek3GL0el/oProgTwWpHJZ8lsQQoY"
613-
.parse()
614-
.unwrap(),
615+
user_password_hash:
616+
"$argon2id$v=19$m=98304,t=23,p=1$Effh/p6M2ZKdnpJFeGqtGQ$\
617+
ZtUwcVODAvUAVK6EQ5FJMv+GMlUCo9PQQsy9cagL+EU"
618+
.parse()
619+
.unwrap(),
615620
},
616621
rack_network_config: RackNetworkConfig {
617622
rack_subnet: Ipv6Net::new(

smf/sled-agent/gimlet-standalone/config-rss.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,4 @@ user_name = "recovery"
144144
# (2) the end-to-end tests, which use this password to log in to a
145145
# newly-initialized rack. For more on what's supported, see the API docs for
146146
# this type and the specific constraints in the omicron-passwords crate.
147-
user_password_hash = "$argon2id$v=19$m=98304,t=13,p=1$RUlWc0ZxaHo0WFdrN0N6ZQ$S8p52j85GPvMhR/ek3GL0el/oProgTwWpHJZ8lsQQoY"
147+
user_password_hash = "$argon2id$v=19$m=98304,t=23,p=1$Effh/p6M2ZKdnpJFeGqtGQ$ZtUwcVODAvUAVK6EQ5FJMv+GMlUCo9PQQsy9cagL+EU"

smf/sled-agent/non-gimlet/config-rss.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,4 @@ user_name = "recovery"
159159
# individuals running this program who then want to log in as this user. For
160160
# more on what's supported, see the API docs for this type and the specific
161161
# constraints in the omicron-passwords crate.
162-
user_password_hash = "$argon2id$v=19$m=98304,t=13,p=1$RUlWc0ZxaHo0WFdrN0N6ZQ$S8p52j85GPvMhR/ek3GL0el/oProgTwWpHJZ8lsQQoY"
162+
user_password_hash = "$argon2id$v=19$m=98304,t=23,p=1$Effh/p6M2ZKdnpJFeGqtGQ$ZtUwcVODAvUAVK6EQ5FJMv+GMlUCo9PQQsy9cagL+EU"

0 commit comments

Comments
 (0)