]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
dm crypt: properly handle extra key string in initialization
authorMilan Broz <gmazyland@gmail.com>
Mon, 28 Oct 2013 22:21:03 +0000 (23:21 +0100)
committerMike Snitzer <snitzer@redhat.com>
Sat, 9 Nov 2013 23:20:20 +0000 (18:20 -0500)
commitda31a0787a2ac92dd219ce0d33322160b66d6a01
tree01f47fbf8855b25ea85a7504dbb32569f712f293
parent2c2263c93f70c6abdce90ad96a854760532aa52f
dm crypt: properly handle extra key string in initialization

Some encryption modes use extra keys (e.g. loopAES has IV seed) which
are not used in block cipher initialization but are part of key string
in table constructor.

This patch adds an additional field which describes the length of the
extra key(s) and substracts it before real key encryption setting.

The key_size always includes the size, in bytes, of the key provided
in mapping table.

The key_parts describes how many parts (usually keys) are contained in
the whole key buffer.  And key_extra_size contains size in bytes of
additional keys part (this number of bytes must be subtracted because it
is processed by the IV generator).

| K1 | K2 | .... | K64 |      Kiv       |
|----------- key_size ----------------- |
|                      |-key_extra_size-|
|     [64 keys]        |  [1 key]       | => key_parts = 65

Example where key string contains main key K, whitening key
Kw and IV seed Kiv:

|     K       |   Kiv   |       Kw      |
|--------------- key_size --------------|
|             |-----key_extra_size------|
|  [1 key]    | [1 key] |     [1 key]   | => key_parts = 3

Because key_extra_size is calculated during IV mode setting, key
initialization is moved after this step.

For now, this change has no effect to supported modes (thanks to ilog2
rounding) but it is required by the following patch.

Also, fix a sparse warning in crypt_iv_lmk_one().

Signed-off-by: Milan Broz <gmazyland@gmail.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-crypt.c