Commit 9c0bc511 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Herbert Xu

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: db57656b ("crypto: caam - group algorithm related params")
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 0be8a270
...@@ -162,10 +162,10 @@ static int aead_null_set_sh_desc(struct crypto_aead *aead) ...@@ -162,10 +162,10 @@ static int aead_null_set_sh_desc(struct crypto_aead *aead)
*/ */
if (rem_bytes >= DESC_AEAD_NULL_ENC_LEN) { if (rem_bytes >= DESC_AEAD_NULL_ENC_LEN) {
ctx->adata.key_inline = true; ctx->adata.key_inline = true;
ctx->adata.key = (uintptr_t)ctx->key; ctx->adata.key_virt = ctx->key;
} else { } else {
ctx->adata.key_inline = false; ctx->adata.key_inline = false;
ctx->adata.key = ctx->key_dma; ctx->adata.key_dma = ctx->key_dma;
} }
/* aead_encrypt shared descriptor */ /* aead_encrypt shared descriptor */
...@@ -185,10 +185,10 @@ static int aead_null_set_sh_desc(struct crypto_aead *aead) ...@@ -185,10 +185,10 @@ static int aead_null_set_sh_desc(struct crypto_aead *aead)
*/ */
if (rem_bytes >= DESC_AEAD_NULL_DEC_LEN) { if (rem_bytes >= DESC_AEAD_NULL_DEC_LEN) {
ctx->adata.key_inline = true; ctx->adata.key_inline = true;
ctx->adata.key = (uintptr_t)ctx->key; ctx->adata.key_virt = ctx->key;
} else { } else {
ctx->adata.key_inline = false; ctx->adata.key_inline = false;
ctx->adata.key = ctx->key_dma; ctx->adata.key_dma = ctx->key_dma;
} }
/* aead_decrypt shared descriptor */ /* aead_decrypt shared descriptor */
...@@ -262,14 +262,14 @@ static int aead_set_sh_desc(struct crypto_aead *aead) ...@@ -262,14 +262,14 @@ static int aead_set_sh_desc(struct crypto_aead *aead)
return -EINVAL; return -EINVAL;
if (inl_mask & 1) if (inl_mask & 1)
ctx->adata.key = (uintptr_t)ctx->key; ctx->adata.key_virt = ctx->key;
else else
ctx->adata.key = ctx->key_dma; ctx->adata.key_dma = ctx->key_dma;
if (inl_mask & 2) 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 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->adata.key_inline = !!(inl_mask & 1);
ctx->cdata.key_inline = !!(inl_mask & 2); ctx->cdata.key_inline = !!(inl_mask & 2);
...@@ -298,14 +298,14 @@ static int aead_set_sh_desc(struct crypto_aead *aead) ...@@ -298,14 +298,14 @@ static int aead_set_sh_desc(struct crypto_aead *aead)
return -EINVAL; return -EINVAL;
if (inl_mask & 1) if (inl_mask & 1)
ctx->adata.key = (uintptr_t)ctx->key; ctx->adata.key_virt = ctx->key;
else else
ctx->adata.key = ctx->key_dma; ctx->adata.key_dma = ctx->key_dma;
if (inl_mask & 2) 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 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->adata.key_inline = !!(inl_mask & 1);
ctx->cdata.key_inline = !!(inl_mask & 2); ctx->cdata.key_inline = !!(inl_mask & 2);
...@@ -337,14 +337,14 @@ static int aead_set_sh_desc(struct crypto_aead *aead) ...@@ -337,14 +337,14 @@ static int aead_set_sh_desc(struct crypto_aead *aead)
return -EINVAL; return -EINVAL;
if (inl_mask & 1) if (inl_mask & 1)
ctx->adata.key = (uintptr_t)ctx->key; ctx->adata.key_virt = ctx->key;
else else
ctx->adata.key = ctx->key_dma; ctx->adata.key_dma = ctx->key_dma;
if (inl_mask & 2) 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 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->adata.key_inline = !!(inl_mask & 1);
ctx->cdata.key_inline = !!(inl_mask & 2); ctx->cdata.key_inline = !!(inl_mask & 2);
...@@ -395,10 +395,10 @@ static int gcm_set_sh_desc(struct crypto_aead *aead) ...@@ -395,10 +395,10 @@ static int gcm_set_sh_desc(struct crypto_aead *aead)
*/ */
if (rem_bytes >= DESC_GCM_ENC_LEN) { if (rem_bytes >= DESC_GCM_ENC_LEN) {
ctx->cdata.key_inline = true; ctx->cdata.key_inline = true;
ctx->cdata.key = (uintptr_t)ctx->key; ctx->cdata.key_virt = ctx->key;
} else { } else {
ctx->cdata.key_inline = false; ctx->cdata.key_inline = false;
ctx->cdata.key = ctx->key_dma; ctx->cdata.key_dma = ctx->key_dma;
} }
desc = ctx->sh_desc_enc; desc = ctx->sh_desc_enc;
...@@ -417,10 +417,10 @@ static int gcm_set_sh_desc(struct crypto_aead *aead) ...@@ -417,10 +417,10 @@ static int gcm_set_sh_desc(struct crypto_aead *aead)
*/ */
if (rem_bytes >= DESC_GCM_DEC_LEN) { if (rem_bytes >= DESC_GCM_DEC_LEN) {
ctx->cdata.key_inline = true; ctx->cdata.key_inline = true;
ctx->cdata.key = (uintptr_t)ctx->key; ctx->cdata.key_virt = ctx->key;
} else { } else {
ctx->cdata.key_inline = false; ctx->cdata.key_inline = false;
ctx->cdata.key = ctx->key_dma; ctx->cdata.key_dma = ctx->key_dma;
} }
desc = ctx->sh_desc_dec; desc = ctx->sh_desc_dec;
...@@ -464,10 +464,10 @@ static int rfc4106_set_sh_desc(struct crypto_aead *aead) ...@@ -464,10 +464,10 @@ static int rfc4106_set_sh_desc(struct crypto_aead *aead)
*/ */
if (rem_bytes >= DESC_RFC4106_ENC_LEN) { if (rem_bytes >= DESC_RFC4106_ENC_LEN) {
ctx->cdata.key_inline = true; ctx->cdata.key_inline = true;
ctx->cdata.key = (uintptr_t)ctx->key; ctx->cdata.key_virt = ctx->key;
} else { } else {
ctx->cdata.key_inline = false; ctx->cdata.key_inline = false;
ctx->cdata.key = ctx->key_dma; ctx->cdata.key_dma = ctx->key_dma;
} }
desc = ctx->sh_desc_enc; desc = ctx->sh_desc_enc;
...@@ -486,10 +486,10 @@ static int rfc4106_set_sh_desc(struct crypto_aead *aead) ...@@ -486,10 +486,10 @@ static int rfc4106_set_sh_desc(struct crypto_aead *aead)
*/ */
if (rem_bytes >= DESC_RFC4106_DEC_LEN) { if (rem_bytes >= DESC_RFC4106_DEC_LEN) {
ctx->cdata.key_inline = true; ctx->cdata.key_inline = true;
ctx->cdata.key = (uintptr_t)ctx->key; ctx->cdata.key_virt = ctx->key;
} else { } else {
ctx->cdata.key_inline = false; ctx->cdata.key_inline = false;
ctx->cdata.key = ctx->key_dma; ctx->cdata.key_dma = ctx->key_dma;
} }
desc = ctx->sh_desc_dec; desc = ctx->sh_desc_dec;
...@@ -534,10 +534,10 @@ static int rfc4543_set_sh_desc(struct crypto_aead *aead) ...@@ -534,10 +534,10 @@ static int rfc4543_set_sh_desc(struct crypto_aead *aead)
*/ */
if (rem_bytes >= DESC_RFC4543_ENC_LEN) { if (rem_bytes >= DESC_RFC4543_ENC_LEN) {
ctx->cdata.key_inline = true; ctx->cdata.key_inline = true;
ctx->cdata.key = (uintptr_t)ctx->key; ctx->cdata.key_virt = ctx->key;
} else { } else {
ctx->cdata.key_inline = false; ctx->cdata.key_inline = false;
ctx->cdata.key = ctx->key_dma; ctx->cdata.key_dma = ctx->key_dma;
} }
desc = ctx->sh_desc_enc; desc = ctx->sh_desc_enc;
...@@ -556,10 +556,10 @@ static int rfc4543_set_sh_desc(struct crypto_aead *aead) ...@@ -556,10 +556,10 @@ static int rfc4543_set_sh_desc(struct crypto_aead *aead)
*/ */
if (rem_bytes >= DESC_RFC4543_DEC_LEN) { if (rem_bytes >= DESC_RFC4543_DEC_LEN) {
ctx->cdata.key_inline = true; ctx->cdata.key_inline = true;
ctx->cdata.key = (uintptr_t)ctx->key; ctx->cdata.key_virt = ctx->key;
} else { } else {
ctx->cdata.key_inline = false; ctx->cdata.key_inline = false;
ctx->cdata.key = ctx->key_dma; ctx->cdata.key_dma = ctx->key_dma;
} }
desc = ctx->sh_desc_dec; desc = ctx->sh_desc_dec;
...@@ -794,7 +794,7 @@ static int ablkcipher_setkey(struct crypto_ablkcipher *ablkcipher, ...@@ -794,7 +794,7 @@ static int ablkcipher_setkey(struct crypto_ablkcipher *ablkcipher,
return -ENOMEM; return -ENOMEM;
} }
ctx->cdata.keylen = keylen; ctx->cdata.keylen = keylen;
ctx->cdata.key = (uintptr_t)ctx->key; ctx->cdata.key_virt = ctx->key;
ctx->cdata.key_inline = true; ctx->cdata.key_inline = true;
/* ablkcipher_encrypt shared descriptor */ /* ablkcipher_encrypt shared descriptor */
...@@ -857,7 +857,7 @@ static int xts_ablkcipher_setkey(struct crypto_ablkcipher *ablkcipher, ...@@ -857,7 +857,7 @@ static int xts_ablkcipher_setkey(struct crypto_ablkcipher *ablkcipher,
return -ENOMEM; return -ENOMEM;
} }
ctx->cdata.keylen = keylen; ctx->cdata.keylen = keylen;
ctx->cdata.key = (uintptr_t)ctx->key; ctx->cdata.key_virt = ctx->key;
ctx->cdata.key_inline = true; ctx->cdata.key_inline = true;
/* xts_ablkcipher_encrypt shared descriptor */ /* xts_ablkcipher_encrypt shared descriptor */
......
...@@ -64,11 +64,11 @@ void cnstr_shdsc_aead_null_encap(u32 * const desc, struct alginfo *adata, ...@@ -64,11 +64,11 @@ void cnstr_shdsc_aead_null_encap(u32 * const desc, struct alginfo *adata,
key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL |
JUMP_COND_SHRD); JUMP_COND_SHRD);
if (adata->key_inline) if (adata->key_inline)
append_key_as_imm(desc, (void *)adata->key, adata->keylen_pad, append_key_as_imm(desc, adata->key_virt, adata->keylen_pad,
adata->keylen, CLASS_2 | KEY_DEST_MDHA_SPLIT | adata->keylen, CLASS_2 | KEY_DEST_MDHA_SPLIT |
KEY_ENC); KEY_ENC);
else else
append_key(desc, adata->key, adata->keylen, CLASS_2 | append_key(desc, adata->key_dma, adata->keylen, CLASS_2 |
KEY_DEST_MDHA_SPLIT | KEY_ENC); KEY_DEST_MDHA_SPLIT | KEY_ENC);
set_jump_tgt_here(desc, key_jump_cmd); set_jump_tgt_here(desc, key_jump_cmd);
...@@ -140,11 +140,11 @@ void cnstr_shdsc_aead_null_decap(u32 * const desc, struct alginfo *adata, ...@@ -140,11 +140,11 @@ void cnstr_shdsc_aead_null_decap(u32 * const desc, struct alginfo *adata,
key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL |
JUMP_COND_SHRD); JUMP_COND_SHRD);
if (adata->key_inline) if (adata->key_inline)
append_key_as_imm(desc, (void *)adata->key, adata->keylen_pad, append_key_as_imm(desc, adata->key_virt, adata->keylen_pad,
adata->keylen, CLASS_2 | adata->keylen, CLASS_2 |
KEY_DEST_MDHA_SPLIT | KEY_ENC); KEY_DEST_MDHA_SPLIT | KEY_ENC);
else else
append_key(desc, adata->key, adata->keylen, CLASS_2 | append_key(desc, adata->key_dma, adata->keylen, CLASS_2 |
KEY_DEST_MDHA_SPLIT | KEY_ENC); KEY_DEST_MDHA_SPLIT | KEY_ENC);
set_jump_tgt_here(desc, key_jump_cmd); set_jump_tgt_here(desc, key_jump_cmd);
...@@ -225,18 +225,18 @@ static void init_sh_desc_key_aead(u32 * const desc, ...@@ -225,18 +225,18 @@ static void init_sh_desc_key_aead(u32 * const desc,
enckeylen -= CTR_RFC3686_NONCE_SIZE; enckeylen -= CTR_RFC3686_NONCE_SIZE;
if (adata->key_inline) if (adata->key_inline)
append_key_as_imm(desc, (void *)adata->key, adata->keylen_pad, append_key_as_imm(desc, adata->key_virt, adata->keylen_pad,
adata->keylen, CLASS_2 | adata->keylen, CLASS_2 |
KEY_DEST_MDHA_SPLIT | KEY_ENC); KEY_DEST_MDHA_SPLIT | KEY_ENC);
else else
append_key(desc, adata->key, adata->keylen, CLASS_2 | append_key(desc, adata->key_dma, adata->keylen, CLASS_2 |
KEY_DEST_MDHA_SPLIT | KEY_ENC); KEY_DEST_MDHA_SPLIT | KEY_ENC);
if (cdata->key_inline) if (cdata->key_inline)
append_key_as_imm(desc, (void *)cdata->key, enckeylen, append_key_as_imm(desc, cdata->key_virt, enckeylen,
enckeylen, CLASS_1 | KEY_DEST_CLASS_REG); enckeylen, CLASS_1 | KEY_DEST_CLASS_REG);
else else
append_key(desc, cdata->key, enckeylen, CLASS_1 | append_key(desc, cdata->key_dma, enckeylen, CLASS_1 |
KEY_DEST_CLASS_REG); KEY_DEST_CLASS_REG);
/* Load Counter into CONTEXT1 reg */ /* Load Counter into CONTEXT1 reg */
...@@ -536,10 +536,10 @@ void cnstr_shdsc_gcm_encap(u32 * const desc, struct alginfo *cdata, ...@@ -536,10 +536,10 @@ void cnstr_shdsc_gcm_encap(u32 * const desc, struct alginfo *cdata,
key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL |
JUMP_COND_SHRD | JUMP_COND_SELF); JUMP_COND_SHRD | JUMP_COND_SELF);
if (cdata->key_inline) if (cdata->key_inline)
append_key_as_imm(desc, (void *)cdata->key, cdata->keylen, append_key_as_imm(desc, cdata->key_virt, cdata->keylen,
cdata->keylen, CLASS_1 | KEY_DEST_CLASS_REG); cdata->keylen, CLASS_1 | KEY_DEST_CLASS_REG);
else else
append_key(desc, cdata->key, cdata->keylen, CLASS_1 | append_key(desc, cdata->key_dma, cdata->keylen, CLASS_1 |
KEY_DEST_CLASS_REG); KEY_DEST_CLASS_REG);
set_jump_tgt_here(desc, key_jump_cmd); set_jump_tgt_here(desc, key_jump_cmd);
...@@ -626,10 +626,10 @@ void cnstr_shdsc_gcm_decap(u32 * const desc, struct alginfo *cdata, ...@@ -626,10 +626,10 @@ void cnstr_shdsc_gcm_decap(u32 * const desc, struct alginfo *cdata,
JUMP_TEST_ALL | JUMP_COND_SHRD | JUMP_TEST_ALL | JUMP_COND_SHRD |
JUMP_COND_SELF); JUMP_COND_SELF);
if (cdata->key_inline) if (cdata->key_inline)
append_key_as_imm(desc, (void *)cdata->key, cdata->keylen, append_key_as_imm(desc, cdata->key_virt, cdata->keylen,
cdata->keylen, CLASS_1 | KEY_DEST_CLASS_REG); cdata->keylen, CLASS_1 | KEY_DEST_CLASS_REG);
else else
append_key(desc, cdata->key, cdata->keylen, CLASS_1 | append_key(desc, cdata->key_dma, cdata->keylen, CLASS_1 |
KEY_DEST_CLASS_REG); KEY_DEST_CLASS_REG);
set_jump_tgt_here(desc, key_jump_cmd); set_jump_tgt_here(desc, key_jump_cmd);
...@@ -702,10 +702,10 @@ void cnstr_shdsc_rfc4106_encap(u32 * const desc, struct alginfo *cdata, ...@@ -702,10 +702,10 @@ void cnstr_shdsc_rfc4106_encap(u32 * const desc, struct alginfo *cdata,
key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL |
JUMP_COND_SHRD); JUMP_COND_SHRD);
if (cdata->key_inline) if (cdata->key_inline)
append_key_as_imm(desc, (void *)cdata->key, cdata->keylen, append_key_as_imm(desc, cdata->key_virt, cdata->keylen,
cdata->keylen, CLASS_1 | KEY_DEST_CLASS_REG); cdata->keylen, CLASS_1 | KEY_DEST_CLASS_REG);
else else
append_key(desc, cdata->key, cdata->keylen, CLASS_1 | append_key(desc, cdata->key_dma, cdata->keylen, CLASS_1 |
KEY_DEST_CLASS_REG); KEY_DEST_CLASS_REG);
set_jump_tgt_here(desc, key_jump_cmd); set_jump_tgt_here(desc, key_jump_cmd);
...@@ -773,11 +773,11 @@ void cnstr_shdsc_rfc4106_decap(u32 * const desc, struct alginfo *cdata, ...@@ -773,11 +773,11 @@ void cnstr_shdsc_rfc4106_decap(u32 * const desc, struct alginfo *cdata,
key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL |
JUMP_COND_SHRD); JUMP_COND_SHRD);
if (cdata->key_inline) if (cdata->key_inline)
append_key_as_imm(desc, (void *)cdata->key, cdata->keylen, append_key_as_imm(desc, cdata->key_virt, cdata->keylen,
cdata->keylen, CLASS_1 | cdata->keylen, CLASS_1 |
KEY_DEST_CLASS_REG); KEY_DEST_CLASS_REG);
else else
append_key(desc, cdata->key, cdata->keylen, CLASS_1 | append_key(desc, cdata->key_dma, cdata->keylen, CLASS_1 |
KEY_DEST_CLASS_REG); KEY_DEST_CLASS_REG);
set_jump_tgt_here(desc, key_jump_cmd); set_jump_tgt_here(desc, key_jump_cmd);
...@@ -845,10 +845,10 @@ void cnstr_shdsc_rfc4543_encap(u32 * const desc, struct alginfo *cdata, ...@@ -845,10 +845,10 @@ void cnstr_shdsc_rfc4543_encap(u32 * const desc, struct alginfo *cdata,
key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL |
JUMP_COND_SHRD); JUMP_COND_SHRD);
if (cdata->key_inline) if (cdata->key_inline)
append_key_as_imm(desc, (void *)cdata->key, cdata->keylen, append_key_as_imm(desc, cdata->key_virt, cdata->keylen,
cdata->keylen, CLASS_1 | KEY_DEST_CLASS_REG); cdata->keylen, CLASS_1 | KEY_DEST_CLASS_REG);
else else
append_key(desc, cdata->key, cdata->keylen, CLASS_1 | append_key(desc, cdata->key_dma, cdata->keylen, CLASS_1 |
KEY_DEST_CLASS_REG); KEY_DEST_CLASS_REG);
set_jump_tgt_here(desc, key_jump_cmd); set_jump_tgt_here(desc, key_jump_cmd);
...@@ -915,10 +915,10 @@ void cnstr_shdsc_rfc4543_decap(u32 * const desc, struct alginfo *cdata, ...@@ -915,10 +915,10 @@ void cnstr_shdsc_rfc4543_decap(u32 * const desc, struct alginfo *cdata,
key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL |
JUMP_COND_SHRD); JUMP_COND_SHRD);
if (cdata->key_inline) if (cdata->key_inline)
append_key_as_imm(desc, (void *)cdata->key, cdata->keylen, append_key_as_imm(desc, cdata->key_virt, cdata->keylen,
cdata->keylen, CLASS_1 | KEY_DEST_CLASS_REG); cdata->keylen, CLASS_1 | KEY_DEST_CLASS_REG);
else else
append_key(desc, cdata->key, cdata->keylen, CLASS_1 | append_key(desc, cdata->key_dma, cdata->keylen, CLASS_1 |
KEY_DEST_CLASS_REG); KEY_DEST_CLASS_REG);
set_jump_tgt_here(desc, key_jump_cmd); set_jump_tgt_here(desc, key_jump_cmd);
...@@ -1006,12 +1006,12 @@ void cnstr_shdsc_ablkcipher_encap(u32 * const desc, struct alginfo *cdata, ...@@ -1006,12 +1006,12 @@ void cnstr_shdsc_ablkcipher_encap(u32 * const desc, struct alginfo *cdata,
JUMP_COND_SHRD); JUMP_COND_SHRD);
/* Load class1 key only */ /* Load class1 key only */
append_key_as_imm(desc, (void *)cdata->key, cdata->keylen, append_key_as_imm(desc, cdata->key_virt, cdata->keylen,
cdata->keylen, CLASS_1 | KEY_DEST_CLASS_REG); cdata->keylen, CLASS_1 | KEY_DEST_CLASS_REG);
/* Load nonce into CONTEXT1 reg */ /* Load nonce into CONTEXT1 reg */
if (is_rfc3686) { if (is_rfc3686) {
u8 *nonce = (u8 *)cdata->key + cdata->keylen; u8 *nonce = cdata->key_virt + cdata->keylen;
append_load_as_imm(desc, nonce, CTR_RFC3686_NONCE_SIZE, append_load_as_imm(desc, nonce, CTR_RFC3686_NONCE_SIZE,
LDST_CLASS_IND_CCB | LDST_CLASS_IND_CCB |
...@@ -1071,12 +1071,12 @@ void cnstr_shdsc_ablkcipher_decap(u32 * const desc, struct alginfo *cdata, ...@@ -1071,12 +1071,12 @@ void cnstr_shdsc_ablkcipher_decap(u32 * const desc, struct alginfo *cdata,
JUMP_COND_SHRD); JUMP_COND_SHRD);
/* Load class1 key only */ /* Load class1 key only */
append_key_as_imm(desc, (void *)cdata->key, cdata->keylen, append_key_as_imm(desc, cdata->key_virt, cdata->keylen,
cdata->keylen, CLASS_1 | KEY_DEST_CLASS_REG); cdata->keylen, CLASS_1 | KEY_DEST_CLASS_REG);
/* Load nonce into CONTEXT1 reg */ /* Load nonce into CONTEXT1 reg */
if (is_rfc3686) { if (is_rfc3686) {
u8 *nonce = (u8 *)cdata->key + cdata->keylen; u8 *nonce = cdata->key_virt + cdata->keylen;
append_load_as_imm(desc, nonce, CTR_RFC3686_NONCE_SIZE, append_load_as_imm(desc, nonce, CTR_RFC3686_NONCE_SIZE,
LDST_CLASS_IND_CCB | LDST_CLASS_IND_CCB |
...@@ -1140,12 +1140,12 @@ void cnstr_shdsc_ablkcipher_givencap(u32 * const desc, struct alginfo *cdata, ...@@ -1140,12 +1140,12 @@ void cnstr_shdsc_ablkcipher_givencap(u32 * const desc, struct alginfo *cdata,
JUMP_COND_SHRD); JUMP_COND_SHRD);
/* Load class1 key only */ /* Load class1 key only */
append_key_as_imm(desc, (void *)cdata->key, cdata->keylen, append_key_as_imm(desc, cdata->key_virt, cdata->keylen,
cdata->keylen, CLASS_1 | KEY_DEST_CLASS_REG); cdata->keylen, CLASS_1 | KEY_DEST_CLASS_REG);
/* Load Nonce into CONTEXT1 reg */ /* Load Nonce into CONTEXT1 reg */
if (is_rfc3686) { if (is_rfc3686) {
u8 *nonce = (u8 *)cdata->key + cdata->keylen; u8 *nonce = cdata->key_virt + cdata->keylen;
append_load_as_imm(desc, nonce, CTR_RFC3686_NONCE_SIZE, append_load_as_imm(desc, nonce, CTR_RFC3686_NONCE_SIZE,
LDST_CLASS_IND_CCB | LDST_CLASS_IND_CCB |
...@@ -1216,7 +1216,7 @@ void cnstr_shdsc_xts_ablkcipher_encap(u32 * const desc, struct alginfo *cdata) ...@@ -1216,7 +1216,7 @@ void cnstr_shdsc_xts_ablkcipher_encap(u32 * const desc, struct alginfo *cdata)
JUMP_COND_SHRD); JUMP_COND_SHRD);
/* Load class1 keys only */ /* Load class1 keys only */
append_key_as_imm(desc, (void *)cdata->key, cdata->keylen, append_key_as_imm(desc, cdata->key_virt, cdata->keylen,
cdata->keylen, CLASS_1 | KEY_DEST_CLASS_REG); cdata->keylen, CLASS_1 | KEY_DEST_CLASS_REG);
/* Load sector size with index 40 bytes (0x28) */ /* Load sector size with index 40 bytes (0x28) */
...@@ -1268,7 +1268,7 @@ void cnstr_shdsc_xts_ablkcipher_decap(u32 * const desc, struct alginfo *cdata) ...@@ -1268,7 +1268,7 @@ void cnstr_shdsc_xts_ablkcipher_decap(u32 * const desc, struct alginfo *cdata)
JUMP_COND_SHRD); JUMP_COND_SHRD);
/* Load class1 key only */ /* Load class1 key only */
append_key_as_imm(desc, (void *)cdata->key, cdata->keylen, append_key_as_imm(desc, cdata->key_virt, cdata->keylen,
cdata->keylen, CLASS_1 | KEY_DEST_CLASS_REG); cdata->keylen, CLASS_1 | KEY_DEST_CLASS_REG);
/* Load sector size with index 40 bytes (0x28) */ /* Load sector size with index 40 bytes (0x28) */
......
...@@ -446,7 +446,10 @@ struct alginfo { ...@@ -446,7 +446,10 @@ struct alginfo {
u32 algtype; u32 algtype;
unsigned int keylen; unsigned int keylen;
unsigned int keylen_pad; unsigned int keylen_pad;
u64 key; union {
dma_addr_t key_dma;
void *key_virt;
};
bool key_inline; bool key_inline;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment