[dm-crypt] Block size and tweak value

jonetsu jonetsu at teksavvy.com
Fri Jun 10 19:12:59 CEST 2016


From: "Arno Wagner" <arno at wagner.name>
Date: 06/10/16 12:04

Hi,

> the block size is always 512 bytes for cryptsetup. The
> tweak is, I think, the block-number as counted from the
> offset.
>
> You can read the key and offset as described in FAQ Item 6.10.


I've looked at sections 6.10/11/12 but could not come up with a clear definition.  crypsetup loopaes.c has:

int LOOPAES_parse_keyfile(struct crypt_device *cd,
              struct volume_key **vk,
              const char *hash,
              unsigned int *keys_count,
              char *buffer,
              size_t buffer_len)
{
[ ... ]

    return hash_keys(cd, vk, hash, keys, key_index,
             crypt_get_volume_key_size(cd), key_len);
}

hash_keys(...) has:

  hash_name = hash_override ?: get_hash(key_len_output);
    tweak = get_tweak(keys_count);

While get_tweaks(keys_count) is:

static unsigned char get_tweak(unsigned int keys_count)
{
    switch (keys_count) {
        case 64: return 0x55;
        case 65: return 0xF4;
        default: break;
    }
    return 0x00;
}

It seems that the tweak value can only be either 0x66 or 0xF4, or 0 ... does that makes sense ?

Thanks.






More information about the dm-crypt mailing list