Commit d15dd89b authored by Milan Broz's avatar Milan Broz

Get rid of confusing LUKS_PHDR_SIZE macro.

parent 961682aa
...@@ -53,7 +53,7 @@ static uint64_t LUKS_device_sectors(size_t keyLen) ...@@ -53,7 +53,7 @@ static uint64_t LUKS_device_sectors(size_t keyLen)
int i; int i;
keyslot_sectors = div_round_up(keyLen * LUKS_STRIPES, SECTOR_SIZE); keyslot_sectors = div_round_up(keyLen * LUKS_STRIPES, SECTOR_SIZE);
sector = round_up_modulo(LUKS_PHDR_SIZE, LUKS_ALIGN_KEYSLOTS / SECTOR_SIZE); sector = LUKS_ALIGN_KEYSLOTS / SECTOR_SIZE;
for (i = 0; i < LUKS_NUMKEYS; i++) { for (i = 0; i < LUKS_NUMKEYS; i++) {
sector = round_up_modulo(sector, LUKS_ALIGN_KEYSLOTS / SECTOR_SIZE); sector = round_up_modulo(sector, LUKS_ALIGN_KEYSLOTS / SECTOR_SIZE);
...@@ -505,6 +505,9 @@ int LUKS_read_phdr(struct luks_phdr *hdr, ...@@ -505,6 +505,9 @@ int LUKS_read_phdr(struct luks_phdr *hdr,
ssize_t hdr_size = sizeof(struct luks_phdr); ssize_t hdr_size = sizeof(struct luks_phdr);
int devfd = 0, r = 0; int devfd = 0, r = 0;
/* LUKS header starts at offset 0, first keyslot on LUKS_ALIGN_KEYSLOTS */
assert(sizeof(struct luks_phdr) <= LUKS_ALIGN_KEYSLOTS);
if (repair && !require_luks_device) if (repair && !require_luks_device)
return -EINVAL; return -EINVAL;
...@@ -678,7 +681,7 @@ int LUKS_generate_phdr(struct luks_phdr *header, ...@@ -678,7 +681,7 @@ int LUKS_generate_phdr(struct luks_phdr *header,
return r; return r;
} }
currentSector = round_up_modulo(LUKS_PHDR_SIZE, LUKS_ALIGN_KEYSLOTS / SECTOR_SIZE); currentSector = LUKS_ALIGN_KEYSLOTS / SECTOR_SIZE;
for(i = 0; i < LUKS_NUMKEYS; ++i) { for(i = 0; i < LUKS_NUMKEYS; ++i) {
header->keyblock[i].active = LUKS_KEY_DISABLED; header->keyblock[i].active = LUKS_KEY_DISABLED;
header->keyblock[i].keyMaterialOffset = currentSector; header->keyblock[i].keyMaterialOffset = currentSector;
......
...@@ -51,8 +51,6 @@ ...@@ -51,8 +51,6 @@
#define LUKS_MAGIC {'L','U','K','S', 0xba, 0xbe}; #define LUKS_MAGIC {'L','U','K','S', 0xba, 0xbe};
#define LUKS_MAGIC_L 6 #define LUKS_MAGIC_L 6
#define LUKS_PHDR_SIZE (sizeof(struct luks_phdr)/SECTOR_SIZE+1)
/* Actually we need only 37, but we don't want struct autoaligning to kick in */ /* Actually we need only 37, but we don't want struct autoaligning to kick in */
#define UUID_STRING_L 40 #define UUID_STRING_L 40
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment