summaryrefslogtreecommitdiff
path: root/drivers/crypto/caam/caamalg.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2016-12-01 00:01:59 +0300
committerHerbert Xu <herbert@gondor.apana.org.au>2016-12-01 16:06:40 +0300
commit9c0bc511e93cc7693f0147274edfb719f221b8c1 (patch)
tree0fb67880961ab47671dbaa64a9efc9b54f49ca9d /drivers/crypto/caam/caamalg.c
parent0be8a270b3f4af358549b8176c25be6972d86b35 (diff)
downloadlinux-9c0bc511e93cc7693f0147274edfb719f221b8c1.tar.xz
crypto: caam - pass key buffers with typesafe pointers
The 'key' field is defined as a 'u64' and used for two different pieces of information: either to store a pointer or a dma_addr_t. The former leads to a build error on 32-bit machines: drivers/crypto/caam/caamalg_desc.c: In function 'cnstr_shdsc_aead_null_encap': drivers/crypto/caam/caamalg_desc.c:67:27: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] drivers/crypto/caam/caamalg_desc.c: In function 'cnstr_shdsc_aead_null_decap': drivers/crypto/caam/caamalg_desc.c:143:27: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] Using a union to provide correct types gets rid of the warnings and as well as a couple of redundant casts. Fixes: db57656b0072 ("crypto: caam - group algorithm related params") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/caam/caamalg.c')
-rw-r--r--drivers/crypto/caam/caamalg.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c
index 37f0540d4694..662fe94cb2f8 100644
--- a/drivers/crypto/caam/caamalg.c
+++ b/drivers/crypto/caam/caamalg.c
@@ -162,10 +162,10 @@ static int aead_null_set_sh_desc(struct crypto_aead *aead)
*/
if (rem_bytes >= DESC_AEAD_NULL_ENC_LEN) {
ctx->adata.key_inline = true;
- ctx->adata.key = (uintptr_t)ctx->key;
+ ctx->adata.key_virt = ctx->key;
} else {
ctx->adata.key_inline = false;
- ctx->adata.key = ctx->key_dma;
+ ctx->adata.key_dma = ctx->key_dma;
}
/* aead_encrypt shared descriptor */
@@ -185,10 +185,10 @@ static int aead_null_set_sh_desc(struct crypto_aead *aead)
*/
if (rem_bytes >= DESC_AEAD_NULL_DEC_LEN) {
ctx->adata.key_inline = true;
- ctx->adata.key = (uintptr_t)ctx->key;
+ ctx->adata.key_virt = ctx->key;
} else {
ctx->adata.key_inline = false;
- ctx->adata.key = ctx->key_dma;
+ ctx->adata.key_dma = ctx->key_dma;
}
/* aead_decrypt shared descriptor */
@@ -262,14 +262,14 @@ static int aead_set_sh_desc(struct crypto_aead *aead)
return -EINVAL;
if (inl_mask & 1)
- ctx->adata.key = (uintptr_t)ctx->key;
+ ctx->adata.key_virt = ctx->key;
else
- ctx->adata.key = ctx->key_dma;
+ ctx->adata.key_dma = ctx->key_dma;
if (inl_mask & 2)
- ctx->cdata.key = (uintptr_t)(ctx->key + ctx->adata.keylen_pad);
+ ctx->cdata.key_virt = ctx->key + ctx->adata.keylen_pad;
else
- ctx->cdata.key = ctx->key_dma + ctx->adata.keylen_pad;
+ ctx->cdata.key_dma = ctx->key_dma + ctx->adata.keylen_pad;
ctx->adata.key_inline = !!(inl_mask & 1);
ctx->cdata.key_inline = !!(inl_mask & 2);
@@ -298,14 +298,14 @@ skip_enc:
return -EINVAL;
if (inl_mask & 1)
- ctx->adata.key = (uintptr_t)ctx->key;
+ ctx->adata.key_virt = ctx->key;
else
- ctx->adata.key = ctx->key_dma;
+ ctx->adata.key_dma = ctx->key_dma;
if (inl_mask & 2)
- ctx->cdata.key = (uintptr_t)(ctx->key + ctx->adata.keylen_pad);
+ ctx->cdata.key_virt = ctx->key + ctx->adata.keylen_pad;
else
- ctx->cdata.key = ctx->key_dma + ctx->adata.keylen_pad;
+ ctx->cdata.key_dma = ctx->key_dma + ctx->adata.keylen_pad;
ctx->adata.key_inline = !!(inl_mask & 1);
ctx->cdata.key_inline = !!(inl_mask & 2);
@@ -337,14 +337,14 @@ skip_enc:
return -EINVAL;
if (inl_mask & 1)
- ctx->adata.key = (uintptr_t)ctx->key;
+ ctx->adata.key_virt = ctx->key;
else
- ctx->adata.key = ctx->key_dma;
+ ctx->adata.key_dma = ctx->key_dma;
if (inl_mask & 2)
- ctx->cdata.key = (uintptr_t)(ctx->key + ctx->adata.keylen_pad);
+ ctx->cdata.key_virt = ctx->key + ctx->adata.keylen_pad;
else
- ctx->cdata.key = ctx->key_dma + ctx->adata.keylen_pad;
+ ctx->cdata.key_dma = ctx->key_dma + ctx->adata.keylen_pad;
ctx->adata.key_inline = !!(inl_mask & 1);
ctx->cdata.key_inline = !!(inl_mask & 2);
@@ -395,10 +395,10 @@ static int gcm_set_sh_desc(struct crypto_aead *aead)
*/
if (rem_bytes >= DESC_GCM_ENC_LEN) {
ctx->cdata.key_inline = true;
- ctx->cdata.key = (uintptr_t)ctx->key;
+ ctx->cdata.key_virt = ctx->key;
} else {
ctx->cdata.key_inline = false;
- ctx->cdata.key = ctx->key_dma;
+ ctx->cdata.key_dma = ctx->key_dma;
}
desc = ctx->sh_desc_enc;
@@ -417,10 +417,10 @@ static int gcm_set_sh_desc(struct crypto_aead *aead)
*/
if (rem_bytes >= DESC_GCM_DEC_LEN) {
ctx->cdata.key_inline = true;
- ctx->cdata.key = (uintptr_t)ctx->key;
+ ctx->cdata.key_virt = ctx->key;
} else {
ctx->cdata.key_inline = false;
- ctx->cdata.key = ctx->key_dma;
+ ctx->cdata.key_dma = ctx->key_dma;
}
desc = ctx->sh_desc_dec;
@@ -464,10 +464,10 @@ static int rfc4106_set_sh_desc(struct crypto_aead *aead)
*/
if (rem_bytes >= DESC_RFC4106_ENC_LEN) {
ctx->cdata.key_inline = true;
- ctx->cdata.key = (uintptr_t)ctx->key;
+ ctx->cdata.key_virt = ctx->key;
} else {
ctx->cdata.key_inline = false;
- ctx->cdata.key = ctx->key_dma;
+ ctx->cdata.key_dma = ctx->key_dma;
}
desc = ctx->sh_desc_enc;
@@ -486,10 +486,10 @@ static int rfc4106_set_sh_desc(struct crypto_aead *aead)
*/
if (rem_bytes >= DESC_RFC4106_DEC_LEN) {
ctx->cdata.key_inline = true;
- ctx->cdata.key = (uintptr_t)ctx->key;
+ ctx->cdata.key_virt = ctx->key;
} else {
ctx->cdata.key_inline = false;
- ctx->cdata.key = ctx->key_dma;
+ ctx->cdata.key_dma = ctx->key_dma;
}
desc = ctx->sh_desc_dec;
@@ -534,10 +534,10 @@ static int rfc4543_set_sh_desc(struct crypto_aead *aead)
*/
if (rem_bytes >= DESC_RFC4543_ENC_LEN) {
ctx->cdata.key_inline = true;
- ctx->cdata.key = (uintptr_t)ctx->key;
+ ctx->cdata.key_virt = ctx->key;
} else {
ctx->cdata.key_inline = false;
- ctx->cdata.key = ctx->key_dma;
+ ctx->cdata.key_dma = ctx->key_dma;
}
desc = ctx->sh_desc_enc;
@@ -556,10 +556,10 @@ static int rfc4543_set_sh_desc(struct crypto_aead *aead)
*/
if (rem_bytes >= DESC_RFC4543_DEC_LEN) {
ctx->cdata.key_inline = true;
- ctx->cdata.key = (uintptr_t)ctx->key;
+ ctx->cdata.key_virt = ctx->key;
} else {
ctx->cdata.key_inline = false;
- ctx->cdata.key = ctx->key_dma;
+ ctx->cdata.key_dma = ctx->key_dma;
}
desc = ctx->sh_desc_dec;
@@ -794,7 +794,7 @@ static int ablkcipher_setkey(struct crypto_ablkcipher *ablkcipher,
return -ENOMEM;
}
ctx->cdata.keylen = keylen;
- ctx->cdata.key = (uintptr_t)ctx->key;
+ ctx->cdata.key_virt = ctx->key;
ctx->cdata.key_inline = true;
/* ablkcipher_encrypt shared descriptor */
@@ -857,7 +857,7 @@ static int xts_ablkcipher_setkey(struct crypto_ablkcipher *ablkcipher,
return -ENOMEM;
}
ctx->cdata.keylen = keylen;
- ctx->cdata.key = (uintptr_t)ctx->key;
+ ctx->cdata.key_virt = ctx->key;
ctx->cdata.key_inline = true;
/* xts_ablkcipher_encrypt shared descriptor */