+2009-09-15 Milan Broz <mbroz@redhat.com>
+ * Initialize crypto library before LUKS header load.
+
2009-09-10 Milan Broz <mbroz@redhat.com>
* Clean up Makefiles and configure script.
* Version 1.1.0-test0.
#define MAX_DIGESTS 64
#define GCRYPT_REQ_VERSION "1.1.42"
+int init_crypto(void)
+{
+ if (!gcry_control (GCRYCTL_INITIALIZATION_FINISHED_P)) {
+ //if (!gcry_check_version (GCRYPT_VERSION))
+ // return -ENOSYS;
+ gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN);
+ gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0);
+ gcry_control (GCRYCTL_RESUME_SECMEM_WARN);
+ gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
+ }
+
+ return 0;
+}
+
static int gcrypt_hash(void *data, int size, char *key,
int sizep, const char *passphrase)
{
char *safe_strdup(const char *s);
void set_debug_level(int level);
+int init_crypto(void);
struct hash_backend *get_hash_backend(const char *name);
void put_hash_backend(struct hash_backend *backend);
int hash(const char *backend_name, const char *hash_name,
if (requested_type && !isPLAIN(requested_type) && !isLUKS(requested_type))
return -EINVAL;
+ /* Some hash functions need initialized gcrypt library */
+ if (init_crypto()) {
+ log_err(cd, _("Cannot initialize crypto backend.\n"));
+ return -ENOSYS;
+ }
+
r = LUKS_read_phdr(cd->device, &hdr, 0, cd);
if (!r) {
static volatile uint64_t __PBKDF2_global_j = 0;
static volatile uint64_t __PBKDF2_performance = 0;
-static int init_crypto(void)
-{
- if (!gcry_control (GCRYCTL_INITIALIZATION_FINISHED_P)) {
- //if (!gcry_check_version (GCRYPT_VERSION))
- // return -ENOSYS;
- gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN);
- gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0);
- gcry_control (GCRYCTL_RESUME_SECMEM_WARN);
- gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
- }
-
- return 0;
-}
+int init_crypto(void);
/*
* 5.2 PBKDF2