Support Argon2 for user passwords
cover Support Argon2 for user passwords
This patch series introduces the password_argon2 GRUB command and the corresponding grub-mkpasswd-argon2 user-space utility to allow setting user passwords with Argon2 hashes.
Gary Lin (3):
password_argon2: Support Argon2 for user passwords
util: Introduce grub-mkpasswd-argon2
docs: Document password_argon2 and grub-mkpasswd-argon2
Makefile.util.def | 18 ++ docs/grub.texi | 86 ++++++++-- grub-core/Makefile.core.def | 5 + grub-core/commands/password_argon2.c | 247 +++++++++++++++++++++++++++ util/grub-mkpasswd-argon2.c | 231 +++++++++++++++++++++++++ 5 files changed, 574 insertions(+), 13 deletions(-) create mode 100644 grub-core/commands/password_argon2.c create mode 100644 util/grub-mkpasswd-argon2.c
Signature · 7 lines
2.51.0 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH 1/3 password_argon2: Support Argon2 for user passwords
This commit introduces a new command, password_argon2, which allows verifying a user-provided password against a stored Argon2 hash.
--- grub-core/Makefile.core.def | 5 + grub-core/commands/password_argon2.c | 247 +++++++++++++++++++++++++++ 2 files changed, 252 insertions(+) create mode 100644 grub-core/commands/password_argon2.c
grub-core/Makefile.core.def +5 -0
@@ -1087,6 +1087,11 @@ module = { common = commands/password.c; }; +module = { + name = password_argon2; + common = commands/password_argon2.c; +}; + module = { name = password_pbkdf2; common = commands/password_pbkdf2.c;
grub-core/commands/password_argon2.c new file +247 -0
247 lines not on this page · raw message
Signature · 7 lines
2.51.0 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH 2/3 util: Introduce grub-mkpasswd-argon2
In reply to Gary Lin via Grub-develThis commit adds grub-mkpasswd-argon2, a new user-space utility used to generate Argon2 password hashes compatible with the password_argon2 command.
The utility generates a random salt and computes the hash based on the user's input password. It allows customizing the Argon2 parameters via command-line arguments.
The default parameters are configured as follows:
- Iterations (-i): 5
- Memory (-m): 131072 KiB
- Parallelism (-p): 1
- Salt length (-s): 16 bytes
- Hash length (-l): 32 bytes
--- Makefile.util.def | 18 +++ util/grub-mkpasswd-argon2.c | 231 ++++++++++++++++++++++++++++++++++++ 2 files changed, 249 insertions(+) create mode 100644 util/grub-mkpasswd-argon2.c
Makefile.util.def +18 -0
@@ -293,6 +293,24 @@ program = { ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; +program = { + name = grub-mkpasswd-argon2; + mansection = 1; + + common = util/grub-mkpasswd-argon2.c; + common = grub-core/kern/emu/argp_common.c; + common = grub-core/osdep/random.c; + common = grub-core/osdep/init.c; + + /* Link libgrubkern.a twice to resolve a circular dependency with libgrubgcry.a */ + ldadd = libgrubmods.a; + ldadd = libgrubkern.a; + ldadd = libgrubgcry.a; + ldadd = libgrubkern.a; + ldadd = grub-core/lib/gnulib/libgnu.a; + ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; +}; + program = { name = grub-mkpasswd-pbkdf2; mansection = 1;
util/grub-mkpasswd-argon2.c new file +231 -0
231 lines not on this page · raw message
Signature · 7 lines
2.51.0 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH 3/3 docs: Document password_argon2 and grub-mkpasswd-argon2
In reply to Gary Lin via Grub-devel--- docs/grub.texi | 86 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 73 insertions(+), 13 deletions(-)
docs/grub.texi +73 -13
@@ -35,6 +35,7 @@ Invariant Sections. * GRUB: (grub). The GRand Unified Bootloader * grub-install: (grub)Invoking grub-install. Install GRUB on your drive * grub-mkconfig: (grub)Invoking grub-mkconfig. Generate GRUB configuration +* grub-mkpasswd-argon2: (grub)Invoking grub-mkpasswd-argon2. * grub-mkpasswd-pbkdf2: (grub)Invoking grub-mkpasswd-pbkdf2. * grub-mkrelpath: (grub)Invoking grub-mkrelpath. * grub-mkrescue: (grub)Invoking grub-mkrescue. Make a GRUB rescue image
@@ -4250,6 +4251,7 @@ Modules can be loaded via the @command{insmod} (@pxref{insmod}) command. * part_sunpc_module:: * parttool_module:: * password_module:: +* password_argon2_module:: * password_pbkdf2_module:: * pata_module:: * pbkdf2_module::
@@ -5655,8 +5657,13 @@ for more information. @section password This module provides support for the @command{password} command. Please note that this uses the password in plain text, if security is a concern consider -using @ref{password_pbkdf2_module} instead. @xref{password} for more -information. +using @ref{password_argon2_module} or @ref{password_pbkdf2_module} instead. +@xref{password} for more information. + +@node password_argon2_module +@section password_argon2 +This module provides support for the @command{password_argon2} command. +@xref{password_argon2} for more information. @node password_pbkdf2_module @section password_pbkdf2
@@ -6717,7 +6724,8 @@ you forget a command, you can run the command @command{help} * normal_exit:: Exit from normal mode * parttool:: Modify partition table entries * password:: Set a clear-text password -* password_pbkdf2:: Set a hashed password +* password_argon2:: Set a Argon2 hashed password +* password_pbkdf2:: Set a PBKDF2 hashed password * plainmount:: Open device encrypted in plain mode * play:: Play a tune * probe:: Retrieve device info
@@ -7975,12 +7983,23 @@ Define a user named @var{user} with password @var{clear-password}. @end deffn +@node password_argon2 +@subsection password_argon2 + +@deffn Command password_argon2 user hashed-password +Define a user named @var{user} with password hash @var{hashed-password}. +Use @command{grub-mkpasswd-argon2} (@pxref{Invoking grub-mkpasswd-argon2}) +to generate password hashes. @xref{Security}. +@end deffn + + @node password_pbkdf2 @subsection password_pbkdf2 @deffn Command password_pbkdf2 user hashed-password Define a user named @var{user} with password hash @var{hashed-password}. -Use @command{grub-mkpasswd-pbkdf2} (@pxref{Invoking grub-mkpasswd-pbkdf2}) +Use @command{grub-mkpasswd-argon2} (@pxref{Invoking grub-mkpasswd-argon2}) +or @command{grub-mkpasswd-pbkdf2} (@pxref{Invoking grub-mkpasswd-pbkdf2}) to generate password hashes. @xref{Security}. @end deffn
@@ -9237,12 +9256,17 @@ However, in some environments, such as kiosks, it may be appropriate to lock down the boot loader to require authentication before performing certain operations. -The @samp{password} (@pxref{password}) and @samp{password_pbkdf2} +The @samp{password} (@pxref{password}), @samp{password_argon2} +(@pxref{password_argon2}) and @samp{password_pbkdf2} (@pxref{password_pbkdf2}) commands can be used to define users, each of which has an associated password. @samp{password} sets the password in -plain text, requiring @file{grub.cfg} to be secure; @samp{password_pbkdf2} -sets the password hashed using the Password-Based Key Derivation Function -(RFC 2898), requiring the use of @command{grub-mkpasswd-pbkdf2} +plain text, requiring @file{grub.cfg} to be secure; @samp{password_argon2} +sets the password hashed using the Argon2 key derivation function (RFC 9106), +requiring the use of @command{grub-mkpasswd-argon2} +(@pxref{Invoking grub-mkpasswd-argon2}) to generate password hashes. +@samp{password_pbkdf2} sets the password hashed using the Password-Based Key +Derivation Function (RFC 2898), requiring the use of @command{grub-mkpasswd-argon2} +(@pxref{Invoking grub-mkpasswd-argon2}) or @command{grub-mkpasswd-pbkdf2} (@pxref{Invoking grub-mkpasswd-pbkdf2}) to generate password hashes. In order to enable authentication support, the @samp{superusers} environment
@@ -9293,8 +9317,8 @@ menuentry "May be run by user1 or a superuser" --users user1 @{ The @command{grub-mkconfig} program does not yet have built-in support for generating configuration files with authentication. You can use @file{/etc/grub.d/40_custom} to add simple superuser authentication, by -adding @kbd{set superusers=} and @kbd{password} or @kbd{password_pbkdf2} -commands. +adding @kbd{set superusers=} and @kbd{password}, @kbd{password_argon2} +or @kbd{password_pbkdf2} commands. @node Using GPG-style digital signatures @section Using GPG-style digital signatures in GRUB
@@ -10648,8 +10672,10 @@ bootability on other machines. @menu * Invoking grub-install:: How to use the GRUB installer * Invoking grub-mkconfig:: Generate a GRUB configuration file +* Invoking grub-mkpasswd-argon2:: + Generate GRUB password hashes (Argon2) * Invoking grub-mkpasswd-pbkdf2:: - Generate GRUB password hashes + Generate GRUB password hashes (PBKDF2) * Invoking grub-mkrelpath:: Make system path relative to its root * Invoking grub-mkrescue:: Make a GRUB rescue image * Invoking grub-mount:: Mount a file system using GRUB
@@ -10750,12 +10776,46 @@ Send the generated configuration file to @var{file}. The default is to send it to standard output. @end table +@node Invoking grub-mkpasswd-argon2 +@section Invoking grub-mkpasswd-argon2 + +The program @command{grub-mkpasswd-pbkdf2} generates password hashes (Argon2) +for GRUB (@pxref{Security}). + +@example +grub-mkpasswd-argon2 +@end example + +@command{grub-mkpasswd-argon2} accepts the following options: + +@table @option +@item -i @var{number} +@itemx --iterations=@var{number} +Number of iterations to perform. Defaults to 5. + +@item -m @var{number} +@itemx --memory=@var{number} +Amount of memory (in kibibytes) to use. Defaults to 131072. + +@item -p @var{number} +@itemx --parallelism=@var{number} +Degree of parallelism (i.e. number of threads). Defaults to 1. + +@item -l @var{number} +@itemx --buflen=@var{number} +Length of the generated hash. Defaults to 32. + +@item -s @var{number} +@itemx --salt=@var{number} +Length of the salt. Defaults to 16. +@end table + @node Invoking grub-mkpasswd-pbkdf2 @section Invoking grub-mkpasswd-pbkdf2 -The program @command{grub-mkpasswd-pbkdf2} generates password hashes for -GRUB (@pxref{Security}). +The program @command{grub-mkpasswd-pbkdf2} generates password hashes (PBKDF) +for GRUB (@pxref{Security}). @example grub-mkpasswd-pbkdf2
Signature · 7 lines
2.51.0 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel