From bc26ebee2b836e87a877b2622ad850af4385403b Mon Sep 17 00:00:00 2001 From: Joel Sing Date: Thu, 8 Sep 2016 19:08:15 +0000 Subject: When changing the passphrase, keep the previous number of rounds, unless specified otherwise. Part of a diff from halex@ --- sbin/bioctl/bioctl.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'sbin/bioctl') diff --git a/sbin/bioctl/bioctl.c b/sbin/bioctl/bioctl.c index 7fc057d0ac6..8a6fe987382 100644 --- a/sbin/bioctl/bioctl.c +++ b/sbin/bioctl/bioctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bioctl.c,v 1.133 2016/09/08 18:41:04 jsing Exp $ */ +/* $OpenBSD: bioctl.c,v 1.134 2016/09/08 19:08:14 jsing Exp $ */ /* * Copyright (c) 2004, 2005 Marco Peereboom @@ -87,7 +87,7 @@ int devh = -1; int human; int verbose; u_int32_t cflags = 0; -int rflag = 8192; +int rflag = 0; char *password; void *bio_cookie; @@ -965,7 +965,7 @@ bio_kdf_generate(struct sr_crypto_kdfinfo *kdfinfo) kdfinfo->pbkdf2.len = sizeof(kdfinfo->pbkdf2); kdfinfo->pbkdf2.type = SR_CRYPTOKDFT_PBKDF2; - kdfinfo->pbkdf2.rounds = rflag; + kdfinfo->pbkdf2.rounds = rflag ? rflag : 8192; kdfinfo->flags = SR_CRYPTOKDF_KEY | SR_CRYPTOKDF_HINT; kdfinfo->len = sizeof(*kdfinfo); @@ -1105,6 +1105,10 @@ bio_changepass(char *dev) /* Current passphrase. */ bio_kdf_derive(&kdfinfo1, &kdfhint, "Old passphrase: ", 0); + /* Keep the previous number of rounds, unless specified. */ + if (!rflag) + rflag = kdfhint.rounds; + /* New passphrase. */ bio_kdf_generate(&kdfinfo2); -- cgit v1.2.3