Skip to contentSkip to conversation

crypto: brcm - explicitly cast cipher to hash type

RFC PATCH In review Stefan Agner 3 participants 5 messages Mar 24, 2018 – Mar 30, 2018 Crypto API

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 crypto: brcm - explicitly cast cipher to hash type

In the AES cases enum spu_cipher_type and enum hash_type have the same values, so the assignment is fine. Explicitly cast the enum type conversion.

This fixes two warnings when building with clang:
drivers/crypto/bcm/cipher.c:821:34: warning: implicit conversion from
enumeration type 'enum spu_cipher_type' to different enumeration type 'enum hash_type' [-Wenum-conversion]
hash_parms.type = cipher_parms.type;
~ ~~~~~~~~~~~~~^~~~
drivers/crypto/bcm/cipher.c:1412:26: warning: implicit conversion from
enumeration type 'enum spu_cipher_type' to different enumeration type 'enum hash_type' [-Wenum-conversion]
hash_parms.type = ctx->cipher_type;
~ ~~~~~^~~~~~~~~~~

---
I am not familar with the IP... I would be glad if somebody with better insight could have a look whether that patch makes sense.

 drivers/crypto/bcm/cipher.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/bcm/cipher.c +2 -2
index 2b75f95bbe1b..309c67c7012f 100644
@@ -818,7 +818,7 @@ static int handle_ahash_req(struct iproc_reqctx_s *rctx)
 
 	/* AES hashing keeps key size in type field, so need to copy it here */
 	if (hash_parms.alg == HASH_ALG_AES)
-		hash_parms.type = cipher_parms.type;
+		hash_parms.type = (enum hash_type)cipher_parms.type;
 	else
 		hash_parms.type = spu->spu_hash_type(rctx->total_sent);
 
@@ -1409,7 +1409,7 @@ static int handle_aead_req(struct iproc_reqctx_s *rctx)
 						rctx->iv_ctr_len);
 
 	if (ctx->auth.alg == HASH_ALG_AES)
-		hash_parms.type = ctx->cipher_type;
+		hash_parms.type = (enum hash_type)ctx->cipher_type;
 
 	/* General case AAD padding (CCM and RFC4543 special cases below) */
 	aead_parms.aad_pad_len = spu->spu_gcm_ccm_pad_len(ctx->cipher.mode,
Signature · 1 line
2.16.2
#1 lore raw

Hi Stefan,

The change looks to be fine. From the IP point of view its using the same values in case of AES cipher and hash types so explicit casting should be ok.

-Raveendra

Quoted 49 lines · Stefan Agner

In the AES cases enum spu_cipher_type and enum hash_type have the same values, so the assignment is fine. Explicitly cast the enum type conversion.

This fixes two warnings when building with clang:
drivers/crypto/bcm/cipher.c:821:34: warning: implicit conversion from
enumeration type 'enum spu_cipher_type' to different enumeration type 'enum hash_type' [-Wenum-conversion]
hash_parms.type = cipher_parms.type;
~ ~~~~~~~~~~~~~^~~~
drivers/crypto/bcm/cipher.c:1412:26: warning: implicit conversion from
enumeration type 'enum spu_cipher_type' to different enumeration type 'enum hash_type' [-Wenum-conversion]
hash_parms.type = ctx->cipher_type;
~ ~~~~~^~~~~~~~~~~

---
I am not familar with the IP... I would be glad if somebody with better insight could have a look whether that patch makes sense.

 drivers/crypto/bcm/cipher.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/bcm/cipher.c +2 -3
index 2b75f95bbe1b..309c67c7012f 100644
@@ -818,7 +818,7 @@ static int handle_ahash_req(struct iproc_reqctx_s *rctx)
 
        /* AES hashing keeps key size in type field, so need to copy it here */
        if (hash_parms.alg == HASH_ALG_AES)
-               hash_parms.type = cipher_parms.type;
+               hash_parms.type = (enum hash_type)cipher_parms.type;
        else
                hash_parms.type = spu->spu_hash_type(rctx->total_sent);
 
@@ -1409,7 +1409,7 @@ static int handle_aead_req(struct iproc_reqctx_s *rctx)
                                                rctx->iv_ctr_len);
 
        if (ctx->auth.alg == HASH_ALG_AES)
-               hash_parms.type = ctx->cipher_type;
+               hash_parms.type = (enum hash_type)ctx->cipher_type;
 
        /* General case AAD padding (CCM and RFC4543 special cases below) */
        aead_parms.aad_pad_len = spu->spu_gcm_ccm_pad_len(ctx->cipher.mode,
--

2.16.2

#2 lore raw
Quoted 5 lines · Raveendra Padasalagi

Hi Stefan,

The change looks to be fine. From the IP point of view its using the same values in case of AES cipher and hash types so explicit casting should be ok.

Can I take that as an Ack?

Herbert, given that Raveendra agrees to the change, do you want me to send a non-RFC version or can you merge the patch as is?

--
Stefan

Quoted 53 lines

-Raveendra

Quoted 49 lines · Stefan Agner

In the AES cases enum spu_cipher_type and enum hash_type have the same values, so the assignment is fine. Explicitly cast the enum type conversion.

This fixes two warnings when building with clang:
drivers/crypto/bcm/cipher.c:821:34: warning: implicit conversion from
enumeration type 'enum spu_cipher_type' to different enumeration type 'enum hash_type' [-Wenum-conversion]
hash_parms.type = cipher_parms.type;
~ ~~~~~~~~~~~~~^~~~
drivers/crypto/bcm/cipher.c:1412:26: warning: implicit conversion from
enumeration type 'enum spu_cipher_type' to different enumeration type 'enum hash_type' [-Wenum-conversion]
hash_parms.type = ctx->cipher_type;
~ ~~~~~^~~~~~~~~~~

---
I am not familar with the IP... I would be glad if somebody with better insight could have a look whether that patch makes sense.

 drivers/crypto/bcm/cipher.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/bcm/cipher.c +2 -3
index 2b75f95bbe1b..309c67c7012f 100644
@@ -818,7 +818,7 @@ static int handle_ahash_req(struct iproc_reqctx_s *rctx)
 
        /* AES hashing keeps key size in type field, so need to copy it here */
        if (hash_parms.alg == HASH_ALG_AES)
-               hash_parms.type = cipher_parms.type;
+               hash_parms.type = (enum hash_type)cipher_parms.type;
        else
                hash_parms.type = spu->spu_hash_type(rctx->total_sent);
 
@@ -1409,7 +1409,7 @@ static int handle_aead_req(struct iproc_reqctx_s *rctx)
                                                rctx->iv_ctr_len);
 
        if (ctx->auth.alg == HASH_ALG_AES)
-               hash_parms.type = ctx->cipher_type;
+               hash_parms.type = (enum hash_type)ctx->cipher_type;
 
        /* General case AAD padding (CCM and RFC4543 special cases below) */
        aead_parms.aad_pad_len = spu->spu_gcm_ccm_pad_len(ctx->cipher.mode,
--

2.16.2

maintainer
#3 lore raw
Quoted 3 lines · Stefan Agner

Herbert, given that Raveendra agrees to the change, do you want me to send a non-RFC version or can you merge the patch as is?

There is no need to resend it.

Thanks,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
maintainer
#4 lore raw
In reply to Stefan Agner
Quoted 16 lines · Stefan Agner

In the AES cases enum spu_cipher_type and enum hash_type have the same values, so the assignment is fine. Explicitly cast the enum type conversion.

This fixes two warnings when building with clang:
drivers/crypto/bcm/cipher.c:821:34: warning: implicit conversion from
enumeration type 'enum spu_cipher_type' to different enumeration type 'enum hash_type' [-Wenum-conversion]
hash_parms.type = cipher_parms.type;
~ ~~~~~~~~~~~~~^~~~
drivers/crypto/bcm/cipher.c:1412:26: warning: implicit conversion from
enumeration type 'enum spu_cipher_type' to different enumeration type 'enum hash_type' [-Wenum-conversion]
hash_parms.type = ctx->cipher_type;
~ ~~~~~^~~~~~~~~~~

Quoted 1 line

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt