···56565757 ykinfo -v 1>/dev/null 2>&1
5858 if [ $? != 0 ]; then
5959- echo -n "Waiting $secs seconds for Yubikey to appear..."
5959+ echo -n "Waiting $secs seconds for YubiKey to appear..."
6060 local success=false
6161 for try in $(seq $secs); do
6262 echo -n .
···118118 # Cryptsetup locking directory
119119 mkdir -p /run/cryptsetup
120120121121- # For Yubikey salt storage
121121+ # For YubiKey salt storage
122122 mkdir -p /crypt-storage
123123124124 ${optionalString luks.gpgSupport ''
···218218 }
219219220220 ${optionalString (luks.yubikeySupport && (yubikey != null)) ''
221221- # Yubikey
221221+ # YubiKey
222222 rbtohex() {
223223 ( od -An -vtx1 | tr -d ' \n' )
224224 }
···244244 local new_k_luks
245245246246 mount -t ${yubikey.storage.fsType} ${yubikey.storage.device} /crypt-storage || \
247247- die "Failed to mount Yubikey salt storage device"
247247+ die "Failed to mount YubiKey salt storage device"
248248249249 salt="$(cat /crypt-storage${yubikey.storage.path} | sed -n 1p | tr -d '\n')"
250250 iterations="$(cat /crypt-storage${yubikey.storage.path} | sed -n 2p | tr -d '\n')"
···254254 for try in $(seq 3); do
255255 ${optionalString yubikey.twoFactor ''
256256 echo -n "Enter two-factor passphrase: "
257257- read -r k_user
258258- echo
257257+ k_user=
258258+ while true; do
259259+ if [ -e /crypt-ramfs/passphrase ]; then
260260+ echo "reused"
261261+ k_user=$(cat /crypt-ramfs/passphrase)
262262+ break
263263+ else
264264+ # Try reading it from /dev/console with a timeout
265265+ IFS= read -t 1 -r k_user
266266+ if [ -n "$k_user" ]; then
267267+ ${if luks.reusePassphrases then ''
268268+ # Remember it for the next device
269269+ echo -n "$k_user" > /crypt-ramfs/passphrase
270270+ '' else ''
271271+ # Don't save it to ramfs. We are very paranoid
272272+ ''}
273273+ echo
274274+ break
275275+ fi
276276+ fi
277277+ done
259278 ''}
260279261280 if [ ! -z "$k_user" ]; then
···268287269288 if [ $? == 0 ]; then
270289 opened=true
290290+ ${if luks.reusePassphrases then ''
291291+ # We don't rm here because we might reuse it for the next device
292292+ '' else ''
293293+ rm -f /crypt-ramfs/passphrase
294294+ ''}
271295 break
272296 else
273297 opened=false
···317341 if wait_yubikey ${toString yubikey.gracePeriod}; then
318342 do_open_yubikey
319343 else
320320- echo "No yubikey found, falling back to non-yubikey open procedure"
344344+ echo "No YubiKey found, falling back to non-YubiKey open procedure"
321345 open_normally
322346 fi
323347 }
···665689 yubikey = mkOption {
666690 default = null;
667691 description = ''
668668- The options to use for this LUKS device in Yubikey-PBA.
669669- If null (the default), Yubikey-PBA will be disabled for this device.
692692+ The options to use for this LUKS device in YubiKey-PBA.
693693+ If null (the default), YubiKey-PBA will be disabled for this device.
670694 '';
671695672696 type = with types; nullOr (submodule {
···674698 twoFactor = mkOption {
675699 default = true;
676700 type = types.bool;
677677- description = "Whether to use a passphrase and a Yubikey (true), or only a Yubikey (false).";
701701+ description = "Whether to use a passphrase and a YubiKey (true), or only a YubiKey (false).";
678702 };
679703680704 slot = mkOption {
681705 default = 2;
682706 type = types.int;
683683- description = "Which slot on the Yubikey to challenge.";
707707+ description = "Which slot on the YubiKey to challenge.";
684708 };
685709686710 saltLength = mkOption {
···704728 gracePeriod = mkOption {
705729 default = 10;
706730 type = types.int;
707707- description = "Time in seconds to wait for the Yubikey.";
731731+ description = "Time in seconds to wait for the YubiKey.";
708732 };
709733710734 /* TODO: Add to the documentation of the current module:
···779803 default = false;
780804 type = types.bool;
781805 description = ''
782782- Enables support for authenticating with a Yubikey on LUKS devices.
806806+ Enables support for authenticating with a YubiKey on LUKS devices.
783807 See the NixOS wiki for information on how to properly setup a LUKS device
784784- and a Yubikey to work with this feature.
808808+ and a YubiKey to work with this feature.
785809 '';
786810 };
787811···799823800824 assertions =
801825 [ { assertion = !(luks.gpgSupport && luks.yubikeySupport);
802802- message = "Yubikey and GPG Card may not be used at the same time.";
826826+ message = "YubiKey and GPG Card may not be used at the same time.";
803827 }
804828805829 { assertion = !(luks.gpgSupport && luks.fido2Support);
···807831 }
808832809833 { assertion = !(luks.fido2Support && luks.yubikeySupport);
810810- message = "FIDO2 and Yubikey may not be used at the same time.";
834834+ message = "FIDO2 and YubiKey may not be used at the same time.";
811835 }
812836 ];
813837