diff mbox series

[3/4] crypto: ccree - fix some reported cipher block sizes

Message ID 20200129143757.680-4-gilad@benyossef.com (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series crypto: ccree - fixes | expand

Commit Message

Gilad Ben-Yossef Jan. 29, 2020, 2:37 p.m. UTC
OFB and CTR modes block sizes were wrongfully reported as
the underlying block sizes. Fix it to 1 bytes as they
turn the block ciphers into stream ciphers.

Also document why our XTS differes from the generic
implementation.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
---
 drivers/crypto/ccree/cc_cipher.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Geert Uytterhoeven Jan. 29, 2020, 2:57 p.m. UTC | #1
Hi Gilad,

On Wed, Jan 29, 2020 at 3:38 PM Gilad Ben-Yossef <gilad@benyossef.com> wrote:
> OFB and CTR modes block sizes were wrongfully reported as
> the underlying block sizes. Fix it to 1 bytes as they
> turn the block ciphers into stream ciphers.
>
> Also document why our XTS differes from the generic
> implementation.
>
> Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
> ---
>  drivers/crypto/ccree/cc_cipher.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c
> index c08dee04941b..73457548ee92 100644
> --- a/drivers/crypto/ccree/cc_cipher.c
> +++ b/drivers/crypto/ccree/cc_cipher.c
> @@ -1236,6 +1236,10 @@ static const struct cc_alg_template skcipher_algs[] = {
>                 .sec_func = true,
>         },
>         {
> +               /* See https://www.mail-archive.com/linux-crypto@vger.kernel.org/msg40576.html

You may want to refer to
https://lore.kernel.org/linux-crypto/20190910012134.GA24413@gondor.apana.org.au/
instead, as mail-archive is maintained externally.


> +                * for the reason why this differs from the generic
> +                * implementation.
> +                */
>                 .name = "xts(aes)",
>                 .driver_name = "xts-aes-ccree",
>                 .blocksize = 1,
> @@ -1431,7 +1435,7 @@ static const struct cc_alg_template skcipher_algs[] = {
>         {
>                 .name = "ofb(aes)",
>                 .driver_name = "ofb-aes-ccree",
> -               .blocksize = AES_BLOCK_SIZE,
> +               .blocksize = 1,
>                 .template_skcipher = {
>                         .setkey = cc_cipher_setkey,
>                         .encrypt = cc_cipher_encrypt,
> @@ -1584,7 +1588,7 @@ static const struct cc_alg_template skcipher_algs[] = {
>         {
>                 .name = "ctr(sm4)",
>                 .driver_name = "ctr-sm4-ccree",
> -               .blocksize = SM4_BLOCK_SIZE,
> +               .blocksize = 1,
>                 .template_skcipher = {
>                         .setkey = cc_cipher_setkey,
>                         .encrypt = cc_cipher_encrypt,
> --
> 2.25.0
>


--
Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
diff mbox series

Patch

diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c
index c08dee04941b..73457548ee92 100644
--- a/drivers/crypto/ccree/cc_cipher.c
+++ b/drivers/crypto/ccree/cc_cipher.c
@@ -1236,6 +1236,10 @@  static const struct cc_alg_template skcipher_algs[] = {
 		.sec_func = true,
 	},
 	{
+		/* See https://www.mail-archive.com/linux-crypto@vger.kernel.org/msg40576.html
+		 * for the reason why this differs from the generic
+		 * implementation.
+		 */
 		.name = "xts(aes)",
 		.driver_name = "xts-aes-ccree",
 		.blocksize = 1,
@@ -1431,7 +1435,7 @@  static const struct cc_alg_template skcipher_algs[] = {
 	{
 		.name = "ofb(aes)",
 		.driver_name = "ofb-aes-ccree",
-		.blocksize = AES_BLOCK_SIZE,
+		.blocksize = 1,
 		.template_skcipher = {
 			.setkey = cc_cipher_setkey,
 			.encrypt = cc_cipher_encrypt,
@@ -1584,7 +1588,7 @@  static const struct cc_alg_template skcipher_algs[] = {
 	{
 		.name = "ctr(sm4)",
 		.driver_name = "ctr-sm4-ccree",
-		.blocksize = SM4_BLOCK_SIZE,
+		.blocksize = 1,
 		.template_skcipher = {
 			.setkey = cc_cipher_setkey,
 			.encrypt = cc_cipher_encrypt,