<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/drivers/crypto/qce, branch v5.8</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v5.8</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v5.8'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2020-03-12T12:00:13Z</updated>
<entry>
<title>crypto: qce - fix wrong config symbol reference</title>
<updated>2020-03-12T12:00:13Z</updated>
<author>
<name>Eneas U de Queiroz</name>
<email>cotequeiroz@gmail.com</email>
</author>
<published>2020-03-04T18:24:55Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d069b20403d7fe5585d38d2c04b2d429fc95f3e6'/>
<id>urn:sha1:d069b20403d7fe5585d38d2c04b2d429fc95f3e6</id>
<content type='text'>
The CONFIG_CRYPTO_DEV_QCE_SOFT_THRESHOLD symbol was renamed during
development, but the stringify reference in the parameter description
sneaked by unnoticed.

Signed-off-by: Eneas U de Queiroz &lt;cotequeiroz@gmail.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: qce - handle AES-XTS cases that qce fails</title>
<updated>2020-02-13T09:05:27Z</updated>
<author>
<name>Eneas U de Queiroz</name>
<email>cotequeiroz@gmail.com</email>
</author>
<published>2020-02-07T15:02:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7f19380b2cfd412dcef2facefb3f6c62788864d7'/>
<id>urn:sha1:7f19380b2cfd412dcef2facefb3f6c62788864d7</id>
<content type='text'>
QCE hangs when presented with an AES-XTS request whose length is larger
than QCE_SECTOR_SIZE (512-bytes), and is not a multiple of it.  Let the
fallback cipher handle them.

Signed-off-by: Eneas U de Queiroz &lt;cotequeiroz@gmail.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: qce - use AES fallback for small requests</title>
<updated>2020-02-13T09:05:27Z</updated>
<author>
<name>Eneas U de Queiroz</name>
<email>cotequeiroz@gmail.com</email>
</author>
<published>2020-02-07T15:02:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ce163ba0bf298f1707321ac025ef639f88e62801'/>
<id>urn:sha1:ce163ba0bf298f1707321ac025ef639f88e62801</id>
<content type='text'>
Process small blocks using the fallback cipher, as a workaround for an
observed failure (DMA-related, apparently) when computing the GCM ghash
key.  This brings a speed gain as well, since it avoids the latency of
using the hardware engine to process small blocks.

Using software for all 16-byte requests would be enough to make GCM
work, but to increase performance, a larger threshold would be better.
Measuring the performance of supported ciphers with openssl speed,
software matches hardware at around 768-1024 bytes.

Considering the 256-bit ciphers, software is 2-3 times faster than qce
at 256-bytes, 30% faster at 512, and about even at 768-bytes.  With
128-bit keys, the break-even point would be around 1024-bytes.

This adds the 'aes_sw_max_len' parameter, to set the largest request
length processed by the software fallback.  Its default is being set to
512 bytes, a little lower than the break-even point, to balance the cost
in CPU usage.

Signed-off-by: Eneas U de Queiroz &lt;cotequeiroz@gmail.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: qce - use cryptlen when adding extra sgl</title>
<updated>2020-02-13T09:05:26Z</updated>
<author>
<name>Eneas U de Queiroz</name>
<email>cotequeiroz@gmail.com</email>
</author>
<published>2020-02-07T15:02:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d6364b8128439a8c0e381f80c38667de9f15eef8'/>
<id>urn:sha1:d6364b8128439a8c0e381f80c38667de9f15eef8</id>
<content type='text'>
The qce crypto driver appends an extra entry to the dst sgl, to maintain
private state information.

When the gcm driver sends requests to the ctr skcipher, it passes the
authentication tag after the actual crypto payload, but it must not be
touched.

Commit 1336c2221bee ("crypto: qce - save a sg table slot for result
buf") limited the destination sgl to avoid overwriting the
authentication tag but it assumed the tag would be in a separate sgl
entry.

This is not always the case, so it is better to limit the length of the
destination buffer to req-&gt;cryptlen before appending the result buf.

Signed-off-by: Eneas U de Queiroz &lt;cotequeiroz@gmail.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: remove CRYPTO_TFM_RES_BAD_KEY_LEN</title>
<updated>2020-01-09T03:30:53Z</updated>
<author>
<name>Eric Biggers</name>
<email>ebiggers@google.com</email>
</author>
<published>2019-12-31T03:19:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=674f368a952c48ede71784935a799a5205b92b6c'/>
<id>urn:sha1:674f368a952c48ede71784935a799a5205b92b6c</id>
<content type='text'>
The CRYPTO_TFM_RES_BAD_KEY_LEN flag was apparently meant as a way to
make the -&gt;setkey() functions provide more information about errors.

However, no one actually checks for this flag, which makes it pointless.

Also, many algorithms fail to set this flag when given a bad length key.
Reviewing just the generic implementations, this is the case for
aes-fixed-time, cbcmac, echainiv, nhpoly1305, pcrypt, rfc3686, rfc4309,
rfc7539, rfc7539esp, salsa20, seqiv, and xcbc.  But there are probably
many more in arch/*/crypto/ and drivers/crypto/.

Some algorithms can even set this flag when the key is the correct
length.  For example, authenc and authencesn set it when the key payload
is malformed in any way (not just a bad length), the atmel-sha and ccree
drivers can set it if a memory allocation fails, and the chelsio driver
sets it for bad auth tag lengths, not just bad key lengths.

So even if someone actually wanted to start checking this flag (which
seems unlikely, since it's been unused for a long time), there would be
a lot of work needed to get it working correctly.  But it would probably
be much better to go back to the drawing board and just define different
return values, like -EINVAL if the key is invalid for the algorithm vs.
-EKEYREJECTED if the key was rejected by a policy like "no weak keys".
That would be much simpler, less error-prone, and easier to test.

So just remove this flag.

Signed-off-by: Eric Biggers &lt;ebiggers@google.com&gt;
Reviewed-by: Horia Geantă &lt;horia.geanta@nxp.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: qce - allow building only hashes/ciphers</title>
<updated>2019-12-27T10:18:04Z</updated>
<author>
<name>Eneas U de Queiroz</name>
<email>cotequeiroz@gmail.com</email>
</author>
<published>2019-12-20T19:02:18Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=59e056cda4beb5412e3653e6360c2eb0fa770baa'/>
<id>urn:sha1:59e056cda4beb5412e3653e6360c2eb0fa770baa</id>
<content type='text'>
Allow the user to choose whether to build support for all algorithms
(default), hashes-only, or skciphers-only.

The QCE engine does not appear to scale as well as the CPU to handle
multiple crypto requests.  While the ipq40xx chips have 4-core CPUs, the
QCE handles only 2 requests in parallel.

Ipsec throughput seems to improve when disabling either family of
algorithms, sharing the load with the CPU.  Enabling skciphers-only
appears to work best.

Signed-off-by: Eneas U de Queiroz &lt;cotequeiroz@gmail.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: qce - initialize fallback only for AES</title>
<updated>2019-12-27T10:18:04Z</updated>
<author>
<name>Eneas U de Queiroz</name>
<email>cotequeiroz@gmail.com</email>
</author>
<published>2019-12-20T19:02:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8ceda883205db6dfedb82e39f67feae3b50c95a1'/>
<id>urn:sha1:8ceda883205db6dfedb82e39f67feae3b50c95a1</id>
<content type='text'>
Adjust cra_flags to add CRYPTO_NEED_FALLBACK only for AES ciphers, where
AES-192 is not handled by the qce hardware, and don't allocate &amp; free
the fallback skcipher for other algorithms.

Signed-off-by: Eneas U de Queiroz &lt;cotequeiroz@gmail.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: qce - update the skcipher IV</title>
<updated>2019-12-27T10:18:04Z</updated>
<author>
<name>Eneas U de Queiroz</name>
<email>cotequeiroz@gmail.com</email>
</author>
<published>2019-12-20T19:02:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=3e806a12d10af2581aa26c37b58439286eab9782'/>
<id>urn:sha1:3e806a12d10af2581aa26c37b58439286eab9782</id>
<content type='text'>
Update the IV after the completion of each cipher operation.

Signed-off-by: Eneas U de Queiroz &lt;cotequeiroz@gmail.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: qce - save a sg table slot for result buf</title>
<updated>2019-12-27T10:18:04Z</updated>
<author>
<name>Eneas U de Queiroz</name>
<email>cotequeiroz@gmail.com</email>
</author>
<published>2019-12-20T19:02:15Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=3ee50c896d712dc2fc8f34c2cd1918d035e74045'/>
<id>urn:sha1:3ee50c896d712dc2fc8f34c2cd1918d035e74045</id>
<content type='text'>
When ctr-aes-qce is used for gcm-mode, an extra sg entry for the
authentication tag is present, causing trouble when the qce driver
prepares the dst-results sg table for dma.

It computes the number of entries needed with sg_nents_for_len, leaving
out the tag entry.  Then it creates a sg table with that number plus
one, used to store a result buffer.

When copying the sg table, there's no limit to the number of entries
copied, so the extra slot is filled with the authentication tag sg.
When the driver tries to add the result sg, the list is full, and it
returns EINVAL.

By limiting the number of sg entries copied to the dest table, the slot
for the result buffer is guaranteed to be unused.

Signed-off-by: Eneas U de Queiroz &lt;cotequeiroz@gmail.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: qce - fix xts-aes-qce key sizes</title>
<updated>2019-12-27T10:18:04Z</updated>
<author>
<name>Eneas U de Queiroz</name>
<email>cotequeiroz@gmail.com</email>
</author>
<published>2019-12-20T19:02:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7de4c2bd196f111e39cc60f6197654aff23ba2b4'/>
<id>urn:sha1:7de4c2bd196f111e39cc60f6197654aff23ba2b4</id>
<content type='text'>
XTS-mode uses two keys, so the keysizes should be doubled in
skcipher_def, and halved when checking if it is AES-128/192/256.

Signed-off-by: Eneas U de Queiroz &lt;cotequeiroz@gmail.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
</feed>
