Re: [PATCH v3 1/2] mac80211: fils_aead: Use crypto api CMAC shash rather than bare cipher

2 messages, 2 authors, 2017-02-08 · open the first message on its own page

Re: [PATCH v3 1/2] mac80211: fils_aead: Use crypto api CMAC shash rather than bare cipher

From: Ard Biesheuvel <hidden>
Date: 2017-02-08 07:45:51

On 8 February 2017 at 07:00, Johannes Berg [off-list ref] wrote:
This looks strange to me:
quoted
+static int aes_s2v(struct crypto_shash *tfm,
                 size_t num_elem, const u8 *addr[], size_t len[],
u8 *v)
 {
-     u8 d[AES_BLOCK_SIZE], tmp[AES_BLOCK_SIZE];
+     u8 d[AES_BLOCK_SIZE], tmp[AES_BLOCK_SIZE] = {};
+     SHASH_DESC_ON_STACK(desc, tfm);
desc declared
quoted
+     crypto_shash_digest(desc, tmp, AES_BLOCK_SIZE, d);
used here
Each digest() call combines a init()/update()/final() sequence
quoted
+     crypto_shash_init(desc);
but initialized now?
... for the 6th time, or so. The final vector may require two
update()s, so we cannot use digest() here. But we can use finup() for
the last one, which combines update() and final().

Hence,

init()/finup()

or

init()/update()/finup()

depending on the length of the last vector.

Re: [PATCH v3 1/2] mac80211: fils_aead: Use crypto api CMAC shash rather than bare cipher

From: Johannes Berg <johannes@sipsolutions.net>
Date: 2017-02-08 07:47:30

On Wed, 2017-02-08 at 07:45 +0000, Ard Biesheuvel wrote:
On 8 February 2017 at 07:00, Johannes Berg <johannes@sipsolutions.net
quoted
wrote:
This looks strange to me:
quoted
+static int aes_s2v(struct crypto_shash *tfm,
                 size_t num_elem, const u8 *addr[], size_t len[],
u8 *v)
 {
-     u8 d[AES_BLOCK_SIZE], tmp[AES_BLOCK_SIZE];
+     u8 d[AES_BLOCK_SIZE], tmp[AES_BLOCK_SIZE] = {};
+     SHASH_DESC_ON_STACK(desc, tfm);
desc declared
quoted
+     crypto_shash_digest(desc, tmp, AES_BLOCK_SIZE, d);
used here
Each digest() call combines a init()/update()/final() sequence
quoted
quoted
+     crypto_shash_init(desc);
but initialized now?
... for the 6th time, or so. The final vector may require two
update()s, so we cannot use digest() here. But we can use finup() for
the last one, which combines update() and final().

Hence,

init()/finup()

or

init()/update()/finup()

depending on the length of the last vector.
Great, thanks for the explanation :)

johannes
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help