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

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

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

From: Johannes Berg <hidden>
Date: 2017-02-06 08:47:52

 {
 	u8 d[AES_BLOCK_SIZE], tmp[AES_BLOCK_SIZE];
+	struct shash_desc *desc;
+	u8 buf[sizeof(*desc) + crypto_shash_descsize(tfm)]
CRYPTO_MINALIGN_ATTR;
 	size_t i;
-	const u8 *data[2];
-	size_t data_len[2], data_elems;
+
+	desc = (struct shash_desc *)buf;
+	desc->tfm = tfm;

+	crypto_shash_digest(desc, (u8[AES_BLOCK_SIZE]){},
AES_BLOCK_SIZE, d);
That's an interesting expression in there. Can we name it into a real
variable? :)

I'm also slightly worried about stack usage now - do we know none of
this goes into an sg list eventually?

johannes

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

From: Ard Biesheuvel <hidden>
Date: 2017-02-06 09:08:46

On 6 February 2017 at 08:47, Johannes Berg [off-list ref] wrote:
quoted
 {
      u8 d[AES_BLOCK_SIZE], tmp[AES_BLOCK_SIZE];
+     struct shash_desc *desc;
+     u8 buf[sizeof(*desc) + crypto_shash_descsize(tfm)]
CRYPTO_MINALIGN_ATTR;
I realised we have a more idiomatic SHASH_DESC_ON_STACK for this.
quoted
      size_t i;
-     const u8 *data[2];
-     size_t data_len[2], data_elems;
+
+     desc = (struct shash_desc *)buf;
+     desc->tfm = tfm;

+     crypto_shash_digest(desc, (u8[AES_BLOCK_SIZE]){},
AES_BLOCK_SIZE, d);
That's an interesting expression in there. Can we name it into a real
variable? :)
Sure, if you prefer.
I'm also slightly worried about stack usage now - do we know none of
this goes into an sg list eventually?
Shashes do not usually use scatterlists: the shash API does not use
them, but uses u8[] arrays and lengths everywhere, and shashes are
explicitly synchronous, which means they are unsuitable for being
exposed on top of a high latency peripheral that uses DMA.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help