+2010-01-10 Milan Broz <mbroz@redhat.com>
+ * Fix initialisation of gcrypt duting luksFormat.
+ * Convert hash name to lower case in header (fix sha1 backward comatible header)
+
2009-12-30 Milan Broz <mbroz@redhat.com>
* Fix key slot iteration count calculation (small -i value was the same as default).
* The slot and key digest iteration minimun is now 1000.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
#include "luks.h"
#include "af.h"
return r;
}
+static void _to_lower(char *str)
+{
+ for(; *str; str++)
+ if (isupper(*str))
+ *str = tolower(*str);
+}
+
+static void LUKS_fix_header_compatible(struct luks_phdr *header)
+{
+ /* Old cryptsetup expects "sha1", gcrypt allows case insensistive names,
+ * so always convert hash to lower case in header */
+ _to_lower(header->hashSpec);
+}
+
int LUKS_read_phdr_backup(const char *backup_file,
const char *device,
struct luks_phdr *hdr,
if(read(devfd, hdr, sizeof(struct luks_phdr)) < sizeof(struct luks_phdr))
r = -EIO;
- else
+ else {
+ LUKS_fix_header_compatible(hdr);
r = _check_and_convert_hdr(backup_file, hdr, require_luks_device, ctx);
+ }
close(devfd);
return r;
header->keyBytes=mk->keyLength;
+ LUKS_fix_header_compatible(header);
+
log_dbg("Generating LUKS header version %d using hash %s, %s, %s, MK %d bytes",
header->version, header->hashSpec ,header->cipherName, header->cipherMode,
header->keyBytes);