Skip to content

Commit 971108c

Browse files
larperaxisherbertx
authored andcommitted
crypto: axis - remove sha384 support for artpec7
The hardware implementation of SHA384 was not correct and it cannot be used in any situation. Signed-off-by: Lars Persson <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 6e88098 commit 971108c

File tree

1 file changed

+2
-105
lines changed

1 file changed

+2
-105
lines changed

drivers/crypto/axis/artpec6_crypto.c

Lines changed: 2 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@
135135
#define regk_crypto_ext 0x00000001
136136
#define regk_crypto_hmac_sha1 0x00000007
137137
#define regk_crypto_hmac_sha256 0x00000009
138-
#define regk_crypto_hmac_sha384 0x0000000b
139138
#define regk_crypto_hmac_sha512 0x0000000d
140139
#define regk_crypto_init 0x00000000
141140
#define regk_crypto_key_128 0x00000000
@@ -144,7 +143,6 @@
144143
#define regk_crypto_null 0x00000000
145144
#define regk_crypto_sha1 0x00000006
146145
#define regk_crypto_sha256 0x00000008
147-
#define regk_crypto_sha384 0x0000000a
148146
#define regk_crypto_sha512 0x0000000c
149147

150148
/* DMA descriptor structures */
@@ -190,7 +188,6 @@ struct pdma_stat_descr {
190188
/* Hash modes (including HMAC variants) */
191189
#define ARTPEC6_CRYPTO_HASH_SHA1 1
192190
#define ARTPEC6_CRYPTO_HASH_SHA256 2
193-
#define ARTPEC6_CRYPTO_HASH_SHA384 3
194191
#define ARTPEC6_CRYPTO_HASH_SHA512 4
195192

196193
/* Crypto modes */
@@ -1315,8 +1312,7 @@ static int artpec6_crypto_prepare_hash(struct ahash_request *areq)
13151312
struct artpec6_hashalg_context *ctx = crypto_tfm_ctx(areq->base.tfm);
13161313
struct artpec6_hash_request_context *req_ctx = ahash_request_ctx(areq);
13171314
size_t digestsize = crypto_ahash_digestsize(crypto_ahash_reqtfm(areq));
1318-
size_t contextsize = digestsize == SHA384_DIGEST_SIZE ?
1319-
SHA512_DIGEST_SIZE : digestsize;
1315+
size_t contextsize = digestsize;
13201316
size_t blocksize = crypto_tfm_alg_blocksize(
13211317
crypto_ahash_tfm(crypto_ahash_reqtfm(areq)));
13221318
struct artpec6_crypto_req_common *common = &req_ctx->common;
@@ -1456,7 +1452,6 @@ static int artpec6_crypto_prepare_hash(struct ahash_request *areq)
14561452

14571453
/* Finalize */
14581454
if (req_ctx->hash_flags & HASH_FLAG_FINALIZE) {
1459-
bool needtrim = contextsize != digestsize;
14601455
size_t hash_pad_len;
14611456
u64 digest_bits;
14621457
u32 oper;
@@ -1502,19 +1497,10 @@ static int artpec6_crypto_prepare_hash(struct ahash_request *areq)
15021497
/* Descriptor for the final result */
15031498
error = artpec6_crypto_setup_in_descr(common, areq->result,
15041499
digestsize,
1505-
!needtrim);
1500+
true);
15061501
if (error)
15071502
return error;
15081503

1509-
if (needtrim) {
1510-
/* Discard the extra context bytes for SHA-384 */
1511-
error = artpec6_crypto_setup_in_descr(common,
1512-
req_ctx->partial_buffer,
1513-
digestsize - contextsize, true);
1514-
if (error)
1515-
return error;
1516-
}
1517-
15181504
} else { /* This is not the final operation for this request */
15191505
if (!run_hw)
15201506
return ARTPEC6_CRYPTO_PREPARE_HASH_NO_START;
@@ -2266,9 +2252,6 @@ artpec6_crypto_init_hash(struct ahash_request *req, u8 type, int hmac)
22662252
case ARTPEC6_CRYPTO_HASH_SHA256:
22672253
oper = hmac ? regk_crypto_hmac_sha256 : regk_crypto_sha256;
22682254
break;
2269-
case ARTPEC6_CRYPTO_HASH_SHA384:
2270-
oper = hmac ? regk_crypto_hmac_sha384 : regk_crypto_sha384;
2271-
break;
22722255
case ARTPEC6_CRYPTO_HASH_SHA512:
22732256
oper = hmac ? regk_crypto_hmac_sha512 : regk_crypto_sha512;
22742257
break;
@@ -2368,22 +2351,6 @@ static int artpec6_crypto_sha256_digest(struct ahash_request *req)
23682351
return artpec6_crypto_prepare_submit_hash(req);
23692352
}
23702353

2371-
static int __maybe_unused artpec6_crypto_sha384_init(struct ahash_request *req)
2372-
{
2373-
return artpec6_crypto_init_hash(req, ARTPEC6_CRYPTO_HASH_SHA384, 0);
2374-
}
2375-
2376-
static int __maybe_unused
2377-
artpec6_crypto_sha384_digest(struct ahash_request *req)
2378-
{
2379-
struct artpec6_hash_request_context *req_ctx = ahash_request_ctx(req);
2380-
2381-
artpec6_crypto_init_hash(req, ARTPEC6_CRYPTO_HASH_SHA384, 0);
2382-
req_ctx->hash_flags |= HASH_FLAG_UPDATE | HASH_FLAG_FINALIZE;
2383-
2384-
return artpec6_crypto_prepare_submit_hash(req);
2385-
}
2386-
23872354
static int artpec6_crypto_sha512_init(struct ahash_request *req)
23882355
{
23892356
return artpec6_crypto_init_hash(req, ARTPEC6_CRYPTO_HASH_SHA512, 0);
@@ -2404,12 +2371,6 @@ static int artpec6_crypto_hmac_sha256_init(struct ahash_request *req)
24042371
return artpec6_crypto_init_hash(req, ARTPEC6_CRYPTO_HASH_SHA256, 1);
24052372
}
24062373

2407-
static int __maybe_unused
2408-
artpec6_crypto_hmac_sha384_init(struct ahash_request *req)
2409-
{
2410-
return artpec6_crypto_init_hash(req, ARTPEC6_CRYPTO_HASH_SHA384, 1);
2411-
}
2412-
24132374
static int artpec6_crypto_hmac_sha512_init(struct ahash_request *req)
24142375
{
24152376
return artpec6_crypto_init_hash(req, ARTPEC6_CRYPTO_HASH_SHA512, 1);
@@ -2425,17 +2386,6 @@ static int artpec6_crypto_hmac_sha256_digest(struct ahash_request *req)
24252386
return artpec6_crypto_prepare_submit_hash(req);
24262387
}
24272388

2428-
static int __maybe_unused
2429-
artpec6_crypto_hmac_sha384_digest(struct ahash_request *req)
2430-
{
2431-
struct artpec6_hash_request_context *req_ctx = ahash_request_ctx(req);
2432-
2433-
artpec6_crypto_init_hash(req, ARTPEC6_CRYPTO_HASH_SHA384, 1);
2434-
req_ctx->hash_flags |= HASH_FLAG_UPDATE | HASH_FLAG_FINALIZE;
2435-
2436-
return artpec6_crypto_prepare_submit_hash(req);
2437-
}
2438-
24392389
static int artpec6_crypto_hmac_sha512_digest(struct ahash_request *req)
24402390
{
24412391
struct artpec6_hash_request_context *req_ctx = ahash_request_ctx(req);
@@ -2480,12 +2430,6 @@ static int artpec6_crypto_ahash_init_hmac_sha256(struct crypto_tfm *tfm)
24802430
return artpec6_crypto_ahash_init_common(tfm, "sha256");
24812431
}
24822432

2483-
static int __maybe_unused
2484-
artpec6_crypto_ahash_init_hmac_sha384(struct crypto_tfm *tfm)
2485-
{
2486-
return artpec6_crypto_ahash_init_common(tfm, "sha384");
2487-
}
2488-
24892433
static int artpec6_crypto_ahash_init_hmac_sha512(struct crypto_tfm *tfm)
24902434
{
24912435
return artpec6_crypto_ahash_init_common(tfm, "sha512");
@@ -2762,53 +2706,6 @@ static struct ahash_alg hash_algos[] = {
27622706
};
27632707

27642708
static struct ahash_alg artpec7_hash_algos[] = {
2765-
/* SHA-384 */
2766-
{
2767-
.init = artpec6_crypto_sha384_init,
2768-
.update = artpec6_crypto_hash_update,
2769-
.final = artpec6_crypto_hash_final,
2770-
.digest = artpec6_crypto_sha384_digest,
2771-
.import = artpec6_crypto_hash_import,
2772-
.export = artpec6_crypto_hash_export,
2773-
.halg.digestsize = SHA384_DIGEST_SIZE,
2774-
.halg.statesize = sizeof(struct artpec6_hash_export_state),
2775-
.halg.base = {
2776-
.cra_name = "sha384",
2777-
.cra_driver_name = "artpec-sha384",
2778-
.cra_priority = 300,
2779-
.cra_flags = CRYPTO_ALG_ASYNC,
2780-
.cra_blocksize = SHA384_BLOCK_SIZE,
2781-
.cra_ctxsize = sizeof(struct artpec6_hashalg_context),
2782-
.cra_alignmask = 3,
2783-
.cra_module = THIS_MODULE,
2784-
.cra_init = artpec6_crypto_ahash_init,
2785-
.cra_exit = artpec6_crypto_ahash_exit,
2786-
}
2787-
},
2788-
/* HMAC SHA-384 */
2789-
{
2790-
.init = artpec6_crypto_hmac_sha384_init,
2791-
.update = artpec6_crypto_hash_update,
2792-
.final = artpec6_crypto_hash_final,
2793-
.digest = artpec6_crypto_hmac_sha384_digest,
2794-
.import = artpec6_crypto_hash_import,
2795-
.export = artpec6_crypto_hash_export,
2796-
.setkey = artpec6_crypto_hash_set_key,
2797-
.halg.digestsize = SHA384_DIGEST_SIZE,
2798-
.halg.statesize = sizeof(struct artpec6_hash_export_state),
2799-
.halg.base = {
2800-
.cra_name = "hmac(sha384)",
2801-
.cra_driver_name = "artpec-hmac-sha384",
2802-
.cra_priority = 300,
2803-
.cra_flags = CRYPTO_ALG_ASYNC,
2804-
.cra_blocksize = SHA384_BLOCK_SIZE,
2805-
.cra_ctxsize = sizeof(struct artpec6_hashalg_context),
2806-
.cra_alignmask = 3,
2807-
.cra_module = THIS_MODULE,
2808-
.cra_init = artpec6_crypto_ahash_init_hmac_sha384,
2809-
.cra_exit = artpec6_crypto_ahash_exit,
2810-
}
2811-
},
28122709
/* SHA-512 */
28132710
{
28142711
.init = artpec6_crypto_sha512_init,

0 commit comments

Comments
 (0)