+static int tcrypt_load(struct crypt_device *cd, struct crypt_params_tcrypt *params)
+{
+ int r, tries = opt_tries, eperm = 0;
+
+ do {
+ /* TCRYPT header is encrypted, get passphrase now */
+ r = tools_get_key(_("Enter passphrase: "),
+ CONST_CAST(char**)¶ms->passphrase,
+ ¶ms->passphrase_size, 0, 0, NULL, opt_timeout,
+ _verify_passphrase(0), 0, cd);
+ if (r < 0)
+ continue;
+
+ if (opt_tcrypt_hidden)
+ params->flags |= CRYPT_TCRYPT_HIDDEN_HEADER;
+
+ if (opt_tcrypt_system)
+ params->flags |= CRYPT_TCRYPT_SYSTEM_HEADER;
+
+ if (opt_tcrypt_backup)
+ params->flags |= CRYPT_TCRYPT_BACKUP_HEADER;
+
+ r = crypt_load(cd, CRYPT_TCRYPT, params);
+
+ if (r == -EPERM) {
+ log_err(_("No device header detected with this passphrase.\n"));
+ eperm = 1;
+ }
+
+ if (r < 0) {
+ crypt_safe_free(CONST_CAST(char*)params->passphrase);
+ params->passphrase = NULL;
+ params->passphrase_size = 0;
+ }
+ check_signal(&r);
+ } while (r == -EPERM && (--tries > 0));
+
+ /* Report wrong passphrase if at least one try failed */
+ if (eperm && r == -EPIPE)
+ r = -EPERM;
+
+ return r;
+}
+