Properly initialise crypto backend in header backup/restore commands. (fixes issue #49)

git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@190 36d66b0a-2a48-0410-832c-cd162a569da5
This commit is contained in:
Milan Broz
2010-02-25 16:00:12 +00:00
parent ba7e7f94bf
commit 37708b7cad
3 changed files with 15 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
2010-02-25 Milan Broz <mbroz@redhat.com> 2010-02-25 Milan Broz <mbroz@redhat.com>
* Do not verify unlocking passphrase in luksAddKey command. * Do not verify unlocking passphrase in luksAddKey command.
* Properly initialise crypto backend in header backup/restore commands.
2010-01-17 Milan Broz <mbroz@redhat.com> 2010-01-17 Milan Broz <mbroz@redhat.com>
* If gcrypt compiled with capabilities, document workaround for cryptsetup (see lib/gcrypt.c). * If gcrypt compiled with capabilities, document workaround for cryptsetup (see lib/gcrypt.c).

View File

@@ -23,8 +23,10 @@ int init_crypto(void)
* and it locks its memory space anyway. * and it locks its memory space anyway.
*/ */
#if 0 #if 0
log_dbg("Initializing crypto backend (secure memory disabled).");
gcry_control (GCRYCTL_DISABLE_SECMEM); gcry_control (GCRYCTL_DISABLE_SECMEM);
#else #else
log_dbg("Initializing crypto backend (using secure memory).");
gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN); gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN);
gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0); gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0);
gcry_control (GCRYCTL_RESUME_SECMEM_WARN); gcry_control (GCRYCTL_RESUME_SECMEM_WARN);

View File

@@ -1213,6 +1213,12 @@ int crypt_header_backup(struct crypt_device *cd,
if ((requested_type && !isLUKS(requested_type)) || !backup_file) if ((requested_type && !isLUKS(requested_type)) || !backup_file)
return -EINVAL; return -EINVAL;
/* Some hash functions need initialized gcrypt library */
if (init_crypto()) {
log_err(cd, _("Cannot initialize crypto backend.\n"));
return -ENOSYS;
}
log_dbg("Requested header backup of device %s (%s) to " log_dbg("Requested header backup of device %s (%s) to "
"file %s.", cd->device, requested_type, backup_file); "file %s.", cd->device, requested_type, backup_file);
@@ -1226,6 +1232,12 @@ int crypt_header_restore(struct crypt_device *cd,
if (requested_type && !isLUKS(requested_type)) if (requested_type && !isLUKS(requested_type))
return -EINVAL; return -EINVAL;
/* Some hash functions need initialized gcrypt library */
if (init_crypto()) {
log_err(cd, _("Cannot initialize crypto backend.\n"));
return -ENOSYS;
}
log_dbg("Requested header restore to device %s (%s) from " log_dbg("Requested header restore to device %s (%s) from "
"file %s.", cd->device, requested_type, backup_file); "file %s.", cd->device, requested_type, backup_file);