Eric Biggers
3558721d95
UPSTREAM: crypto: ofb - fix handling partial blocks and make thread-safe
...
Fix multiple bugs in the OFB implementation:
1. It stored the per-request state 'cnt' in the tfm context, which can be
used by multiple threads concurrently (e.g. via AF_ALG).
2. It didn't support messages not a multiple of the block cipher size,
despite being a stream cipher.
3. It didn't set cra_blocksize to 1 to indicate it is a stream cipher.
To fix these, set the 'chunksize' property to the cipher block size to
guarantee that when walking through the scatterlist, a partial block can
only occur at the end. Then change the implementation to XOR a block at
a time at first, then XOR the partial block at the end if needed. This
is the same way CTR and CFB are implemented. As a bonus, this also
improves performance in most cases over the current approach.
Fixes: e497c51896b3 ("crypto: ofb - add output feedback mode")
Cc: <stable@vger.kernel.org > # v4.20+
Cc: Gilad Ben-Yossef <gilad@benyossef.com >
Signed-off-by: Eric Biggers <ebiggers@google.com >
Reviewed-by: Gilad Ben-Yossef <gilad@benyossef.com >
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au >
(cherry picked from commit b3e3e2db7de4a1ffe8845876c3520b866cd48de1)
Change-Id: I5b9174ef596f72cb295d931217d6132f8c9ec820
Signed-off-by: Lin Jinhan <troy.lin@rock-chips.com >
2022-02-14 17:11:49 +08:00
..
2019-07-26 09:14:13 +02:00
2018-06-18 20:17:38 +05:30
2016-10-25 11:08:33 +08:00
2018-08-03 18:06:04 +08:00
2017-04-21 20:30:50 +08:00
2020-10-25 11:47:54 +01:00
2019-03-23 20:09:54 +01:00
2019-03-23 20:09:54 +01:00
2019-03-23 20:09:54 +01:00
2019-03-23 20:09:54 +01:00
2018-11-13 11:08:46 -08:00
2018-12-05 09:48:14 -08:00
2019-02-12 19:46:58 +01:00
2020-12-30 11:25:48 +01:00
2019-03-23 20:09:54 +01:00
2017-01-13 00:24:39 +08:00
2020-02-11 04:34:05 -08:00
2020-09-24 17:59:50 +08:00
2020-10-29 09:54:59 +01:00
2020-07-09 09:37:10 +02:00
2018-05-26 09:16:44 +02:00
2020-10-29 09:55:01 +01:00
2015-04-22 09:30:18 +08:00
2014-11-24 22:43:57 +08:00
2021-05-22 10:59:14 +02:00
2014-11-24 22:43:57 +08:00
2019-01-22 21:40:32 +01:00
2019-01-22 21:40:31 +01:00
2021-10-20 10:11:13 -07:00
2021-10-20 10:10:54 -07:00
2018-08-03 18:06:04 +08:00
2011-09-22 21:25:25 +10:00
2015-01-13 22:29:11 +11:00
2017-11-29 17:33:25 +11:00
2017-11-29 17:33:25 +11:00
2017-11-29 17:33:25 +11:00
2013-08-14 20:42:03 +10:00
2018-12-13 09:16:21 +01:00
2019-05-22 07:37:43 +02:00
2019-03-23 20:09:40 +01:00
2019-07-26 10:31:53 +02:00
2020-11-16 09:22:35 +01:00
2018-04-21 00:58:34 +08:00
2017-02-11 17:52:28 +08:00
2016-10-21 11:03:42 +08:00
2018-05-27 00:12:09 +08:00
2018-05-27 00:12:08 +08:00
2013-09-12 15:31:34 +10:00
2019-05-22 07:37:37 +02:00
2019-07-10 09:53:41 +02:00
2018-02-15 23:26:50 +08:00
2018-07-09 00:30:24 +08:00
2019-12-13 08:52:48 +01:00
2014-03-21 21:54:28 +08:00
2018-04-21 00:58:34 +08:00
2018-04-21 00:58:34 +08:00
2020-10-24 22:42:43 +02:00
2017-04-24 18:11:08 +08:00
2022-02-09 10:16:15 +08:00
2018-08-03 18:06:06 +08:00
2018-07-20 13:51:21 +08:00
2018-08-03 18:05:48 +08:00
2014-11-26 20:06:30 +08:00
2018-07-20 13:51:22 +08:00
2019-12-13 08:52:48 +01:00
2018-04-21 00:58:29 +08:00
2021-03-04 09:39:41 +01:00
2021-01-12 20:10:20 +01:00
2017-12-22 19:52:45 +11:00
2014-11-24 22:43:57 +08:00
2015-04-23 14:18:09 +08:00
2019-05-22 07:37:37 +02:00
2017-12-22 19:52:40 +11:00
2019-07-26 09:14:19 +02:00
2015-12-20 15:27:12 +02:00
2017-11-29 13:39:15 +11:00
2020-02-11 04:34:05 -08:00
2016-11-17 23:34:52 +08:00
2015-06-25 23:18:33 +08:00
2022-02-14 17:11:37 +08:00
2017-11-29 17:33:26 +11:00
2014-11-24 22:43:57 +08:00
2017-01-13 00:24:39 +08:00
2020-05-20 08:18:46 +02:00
2017-04-10 19:17:27 +08:00
2017-04-10 19:17:27 +08:00
2017-05-08 17:15:13 -07:00
2022-02-14 17:11:37 +08:00
2018-02-15 23:26:45 +08:00
2018-07-09 00:30:24 +08:00
2018-07-09 00:30:24 +08:00
2013-12-09 20:09:12 +08:00
2014-11-24 22:43:57 +08:00
2019-03-23 20:09:54 +01:00
2019-03-23 20:09:54 +01:00
2020-10-25 11:47:54 +01:00
2022-02-14 17:11:49 +08:00
2021-04-03 14:09:44 +00:00
2019-03-23 20:09:55 +01:00
2021-11-26 11:36:11 +01:00
2020-10-25 11:47:54 +01:00
2018-05-16 07:23:35 +02:00
2017-11-02 11:10:55 +01:00
2018-07-09 00:30:24 +08:00
2018-07-09 00:30:24 +08:00
2018-07-27 19:28:36 +08:00
2018-07-27 19:28:36 +08:00
2017-07-28 17:56:00 +08:00
2018-04-07 19:04:02 +09:00
2019-11-20 18:47:44 +01:00
2018-04-21 00:58:37 +08:00
2016-07-05 23:05:26 +08:00
2015-10-14 22:23:16 +08:00
2019-05-22 07:37:36 +02:00
2018-08-03 18:06:03 +08:00
2018-01-06 09:18:00 -07:00
2014-11-24 22:43:57 +08:00
2017-12-22 19:52:45 +11:00
2019-07-26 09:14:13 +02:00
2018-07-09 00:30:24 +08:00
2018-08-03 17:55:12 +08:00
2018-07-09 00:30:24 +08:00
2018-07-09 00:30:24 +08:00
2021-07-20 16:15:44 +02:00
2018-12-01 09:37:32 +01:00
2020-03-12 10:46:18 -07:00
2019-01-22 21:40:31 +01:00
2018-05-05 14:52:51 +08:00
2021-03-07 12:45:27 +01:00
2015-07-17 21:20:20 +08:00
2015-01-13 22:29:11 +11:00
2021-10-20 10:10:26 -07:00
2022-02-14 17:11:49 +08:00
2020-01-27 14:50:13 +01:00
2017-11-29 17:33:25 +11:00
2017-11-29 17:33:25 +11:00
2018-07-01 21:00:44 +08:00
2018-07-09 00:30:24 +08:00
2017-11-29 17:33:25 +11:00
2017-11-15 18:21:04 -08:00
2020-05-20 08:18:46 +02:00
2018-04-21 00:58:30 +08:00