Skip to content

Commit 05b7812

Browse files
herbertxgregkh
authored andcommitted
crypto: crypto4xx - Remove ahash-related code
commit 97855e7 upstream. The hash implementation in crypto4xx has been disabled since 2009. As nobody has tried to fix this remove all the dead code. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent b2dbc71 commit 05b7812

3 files changed

Lines changed: 1 addition & 155 deletions

File tree

drivers/crypto/amcc/crypto4xx_alg.c

Lines changed: 0 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
#include <linux/interrupt.h>
1313
#include <linux/spinlock_types.h>
1414
#include <linux/scatterlist.h>
15-
#include <linux/crypto.h>
16-
#include <linux/hash.h>
17-
#include <crypto/internal/hash.h>
1815
#include <linux/dma-mapping.h>
1916
#include <crypto/algapi.h>
2017
#include <crypto/aead.h>
@@ -616,106 +613,3 @@ int crypto4xx_decrypt_aes_gcm(struct aead_request *req)
616613
{
617614
return crypto4xx_crypt_aes_gcm(req, true);
618615
}
619-
620-
/*
621-
* HASH SHA1 Functions
622-
*/
623-
static int crypto4xx_hash_alg_init(struct crypto_tfm *tfm,
624-
unsigned int sa_len,
625-
unsigned char ha,
626-
unsigned char hm)
627-
{
628-
struct crypto_alg *alg = tfm->__crt_alg;
629-
struct crypto4xx_alg *my_alg;
630-
struct crypto4xx_ctx *ctx = crypto_tfm_ctx(tfm);
631-
struct dynamic_sa_hash160 *sa;
632-
int rc;
633-
634-
my_alg = container_of(__crypto_ahash_alg(alg), struct crypto4xx_alg,
635-
alg.u.hash);
636-
ctx->dev = my_alg->dev;
637-
638-
/* Create SA */
639-
if (ctx->sa_in || ctx->sa_out)
640-
crypto4xx_free_sa(ctx);
641-
642-
rc = crypto4xx_alloc_sa(ctx, sa_len);
643-
if (rc)
644-
return rc;
645-
646-
crypto_ahash_set_reqsize(__crypto_ahash_cast(tfm),
647-
sizeof(struct crypto4xx_ctx));
648-
sa = (struct dynamic_sa_hash160 *)ctx->sa_in;
649-
set_dynamic_sa_command_0(&sa->ctrl, SA_SAVE_HASH, SA_NOT_SAVE_IV,
650-
SA_NOT_LOAD_HASH, SA_LOAD_IV_FROM_SA,
651-
SA_NO_HEADER_PROC, ha, SA_CIPHER_ALG_NULL,
652-
SA_PAD_TYPE_ZERO, SA_OP_GROUP_BASIC,
653-
SA_OPCODE_HASH, DIR_INBOUND);
654-
set_dynamic_sa_command_1(&sa->ctrl, 0, SA_HASH_MODE_HASH,
655-
CRYPTO_FEEDBACK_MODE_NO_FB, SA_EXTENDED_SN_OFF,
656-
SA_SEQ_MASK_OFF, SA_MC_ENABLE,
657-
SA_NOT_COPY_PAD, SA_NOT_COPY_PAYLOAD,
658-
SA_NOT_COPY_HDR);
659-
/* Need to zero hash digest in SA */
660-
memset(sa->inner_digest, 0, sizeof(sa->inner_digest));
661-
memset(sa->outer_digest, 0, sizeof(sa->outer_digest));
662-
663-
return 0;
664-
}
665-
666-
int crypto4xx_hash_init(struct ahash_request *req)
667-
{
668-
struct crypto4xx_ctx *ctx = crypto_tfm_ctx(req->base.tfm);
669-
int ds;
670-
struct dynamic_sa_ctl *sa;
671-
672-
sa = ctx->sa_in;
673-
ds = crypto_ahash_digestsize(
674-
__crypto_ahash_cast(req->base.tfm));
675-
sa->sa_command_0.bf.digest_len = ds >> 2;
676-
sa->sa_command_0.bf.load_hash_state = SA_LOAD_HASH_FROM_SA;
677-
678-
return 0;
679-
}
680-
681-
int crypto4xx_hash_update(struct ahash_request *req)
682-
{
683-
struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
684-
struct crypto4xx_ctx *ctx = crypto_tfm_ctx(req->base.tfm);
685-
struct scatterlist dst;
686-
unsigned int ds = crypto_ahash_digestsize(ahash);
687-
688-
sg_init_one(&dst, req->result, ds);
689-
690-
return crypto4xx_build_pd(&req->base, ctx, req->src, &dst,
691-
req->nbytes, NULL, 0, ctx->sa_in,
692-
ctx->sa_len, 0, NULL);
693-
}
694-
695-
int crypto4xx_hash_final(struct ahash_request *req)
696-
{
697-
return 0;
698-
}
699-
700-
int crypto4xx_hash_digest(struct ahash_request *req)
701-
{
702-
struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
703-
struct crypto4xx_ctx *ctx = crypto_tfm_ctx(req->base.tfm);
704-
struct scatterlist dst;
705-
unsigned int ds = crypto_ahash_digestsize(ahash);
706-
707-
sg_init_one(&dst, req->result, ds);
708-
709-
return crypto4xx_build_pd(&req->base, ctx, req->src, &dst,
710-
req->nbytes, NULL, 0, ctx->sa_in,
711-
ctx->sa_len, 0, NULL);
712-
}
713-
714-
/*
715-
* SHA1 Algorithm
716-
*/
717-
int crypto4xx_sha1_alg_init(struct crypto_tfm *tfm)
718-
{
719-
return crypto4xx_hash_alg_init(tfm, SA_HASH160_LEN, SA_HASH_ALG_SHA1,
720-
SA_HASH_MODE_HASH);
721-
}

drivers/crypto/amcc/crypto4xx_core.c

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -485,18 +485,6 @@ static void crypto4xx_copy_pkt_to_dst(struct crypto4xx_device *dev,
485485
}
486486
}
487487

488-
static void crypto4xx_copy_digest_to_dst(void *dst,
489-
struct pd_uinfo *pd_uinfo,
490-
struct crypto4xx_ctx *ctx)
491-
{
492-
struct dynamic_sa_ctl *sa = (struct dynamic_sa_ctl *) ctx->sa_in;
493-
494-
if (sa->sa_command_0.bf.hash_alg == SA_HASH_ALG_SHA1) {
495-
memcpy(dst, pd_uinfo->sr_va->save_digest,
496-
SA_HASH_ALG_SHA1_DIGEST_SIZE);
497-
}
498-
}
499-
500488
static void crypto4xx_ret_sg_desc(struct crypto4xx_device *dev,
501489
struct pd_uinfo *pd_uinfo)
502490
{
@@ -549,23 +537,6 @@ static void crypto4xx_cipher_done(struct crypto4xx_device *dev,
549537
skcipher_request_complete(req, 0);
550538
}
551539

552-
static void crypto4xx_ahash_done(struct crypto4xx_device *dev,
553-
struct pd_uinfo *pd_uinfo)
554-
{
555-
struct crypto4xx_ctx *ctx;
556-
struct ahash_request *ahash_req;
557-
558-
ahash_req = ahash_request_cast(pd_uinfo->async_req);
559-
ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(ahash_req));
560-
561-
crypto4xx_copy_digest_to_dst(ahash_req->result, pd_uinfo, ctx);
562-
crypto4xx_ret_sg_desc(dev, pd_uinfo);
563-
564-
if (pd_uinfo->state & PD_ENTRY_BUSY)
565-
ahash_request_complete(ahash_req, -EINPROGRESS);
566-
ahash_request_complete(ahash_req, 0);
567-
}
568-
569540
static void crypto4xx_aead_done(struct crypto4xx_device *dev,
570541
struct pd_uinfo *pd_uinfo,
571542
struct ce_pd *pd)
@@ -642,9 +613,6 @@ static void crypto4xx_pd_done(struct crypto4xx_device *dev, u32 idx)
642613
case CRYPTO_ALG_TYPE_AEAD:
643614
crypto4xx_aead_done(dev, pd_uinfo, pd);
644615
break;
645-
case CRYPTO_ALG_TYPE_AHASH:
646-
crypto4xx_ahash_done(dev, pd_uinfo);
647-
break;
648616
}
649617
}
650618

@@ -915,8 +883,7 @@ int crypto4xx_build_pd(struct crypto_async_request *req,
915883
}
916884

917885
pd->pd_ctl.w = PD_CTL_HOST_READY |
918-
((crypto_tfm_alg_type(req->tfm) == CRYPTO_ALG_TYPE_AHASH) ||
919-
(crypto_tfm_alg_type(req->tfm) == CRYPTO_ALG_TYPE_AEAD) ?
886+
((crypto_tfm_alg_type(req->tfm) == CRYPTO_ALG_TYPE_AEAD) ?
920887
PD_CTL_HASH_FINAL : 0);
921888
pd->pd_ctl_len.w = 0x00400000 | (assoclen + datalen);
922889
pd_uinfo->state = PD_ENTRY_INUSE | (is_busy ? PD_ENTRY_BUSY : 0);
@@ -1022,10 +989,6 @@ static int crypto4xx_register_alg(struct crypto4xx_device *sec_dev,
1022989
rc = crypto_register_aead(&alg->alg.u.aead);
1023990
break;
1024991

1025-
case CRYPTO_ALG_TYPE_AHASH:
1026-
rc = crypto_register_ahash(&alg->alg.u.hash);
1027-
break;
1028-
1029992
case CRYPTO_ALG_TYPE_RNG:
1030993
rc = crypto_register_rng(&alg->alg.u.rng);
1031994
break;
@@ -1051,10 +1014,6 @@ static void crypto4xx_unregister_alg(struct crypto4xx_device *sec_dev)
10511014
list_for_each_entry_safe(alg, tmp, &sec_dev->alg_list, entry) {
10521015
list_del(&alg->entry);
10531016
switch (alg->alg.type) {
1054-
case CRYPTO_ALG_TYPE_AHASH:
1055-
crypto_unregister_ahash(&alg->alg.u.hash);
1056-
break;
1057-
10581017
case CRYPTO_ALG_TYPE_AEAD:
10591018
crypto_unregister_aead(&alg->alg.u.aead);
10601019
break;

drivers/crypto/amcc/crypto4xx_core.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <linux/ratelimit.h>
1717
#include <linux/mutex.h>
1818
#include <linux/scatterlist.h>
19-
#include <crypto/internal/hash.h>
2019
#include <crypto/internal/aead.h>
2120
#include <crypto/internal/rng.h>
2221
#include <crypto/internal/skcipher.h>
@@ -135,7 +134,6 @@ struct crypto4xx_alg_common {
135134
u32 type;
136135
union {
137136
struct skcipher_alg cipher;
138-
struct ahash_alg hash;
139137
struct aead_alg aead;
140138
struct rng_alg rng;
141139
} u;
@@ -182,11 +180,6 @@ int crypto4xx_encrypt_noiv_block(struct skcipher_request *req);
182180
int crypto4xx_decrypt_noiv_block(struct skcipher_request *req);
183181
int crypto4xx_rfc3686_encrypt(struct skcipher_request *req);
184182
int crypto4xx_rfc3686_decrypt(struct skcipher_request *req);
185-
int crypto4xx_sha1_alg_init(struct crypto_tfm *tfm);
186-
int crypto4xx_hash_digest(struct ahash_request *req);
187-
int crypto4xx_hash_final(struct ahash_request *req);
188-
int crypto4xx_hash_update(struct ahash_request *req);
189-
int crypto4xx_hash_init(struct ahash_request *req);
190183

191184
/*
192185
* Note: Only use this function to copy items that is word aligned.

0 commit comments

Comments
 (0)