Skip to content

Commit d33a6a3

Browse files
committed
crypto: aspeed - Remove non-standard sha512 algorithms
Algorithms must never be added to a driver unless there is a generic implementation. These truncated versions of sha512 slipped through. Remove them as they are useless. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 304506f commit d33a6a3

1 file changed

Lines changed: 0 additions & 212 deletions

File tree

drivers/crypto/aspeed/aspeed-hace-hash.c

Lines changed: 0 additions & 212 deletions
Original file line numberDiff line numberDiff line change
@@ -59,28 +59,6 @@ static const __be64 sha512_iv[8] = {
5959
cpu_to_be64(SHA512_H6), cpu_to_be64(SHA512_H7)
6060
};
6161

62-
static const __be32 sha512_224_iv[16] = {
63-
cpu_to_be32(0xC8373D8CUL), cpu_to_be32(0xA24D5419UL),
64-
cpu_to_be32(0x6699E173UL), cpu_to_be32(0xD6D4DC89UL),
65-
cpu_to_be32(0xAEB7FA1DUL), cpu_to_be32(0x829CFF32UL),
66-
cpu_to_be32(0x14D59D67UL), cpu_to_be32(0xCF9F2F58UL),
67-
cpu_to_be32(0x692B6D0FUL), cpu_to_be32(0xA84DD47BUL),
68-
cpu_to_be32(0x736FE377UL), cpu_to_be32(0x4289C404UL),
69-
cpu_to_be32(0xA8859D3FUL), cpu_to_be32(0xC8361D6AUL),
70-
cpu_to_be32(0xADE61211UL), cpu_to_be32(0xA192D691UL)
71-
};
72-
73-
static const __be32 sha512_256_iv[16] = {
74-
cpu_to_be32(0x94213122UL), cpu_to_be32(0x2CF72BFCUL),
75-
cpu_to_be32(0xA35F559FUL), cpu_to_be32(0xC2644CC8UL),
76-
cpu_to_be32(0x6BB89323UL), cpu_to_be32(0x51B1536FUL),
77-
cpu_to_be32(0x19773896UL), cpu_to_be32(0xBDEA4059UL),
78-
cpu_to_be32(0xE23E2896UL), cpu_to_be32(0xE3FF8EA8UL),
79-
cpu_to_be32(0x251E5EBEUL), cpu_to_be32(0x92398653UL),
80-
cpu_to_be32(0xFC99012BUL), cpu_to_be32(0xAAB8852CUL),
81-
cpu_to_be32(0xDC2DB70EUL), cpu_to_be32(0xA22CC581UL)
82-
};
83-
8462
/* The purpose of this padding is to ensure that the padded message is a
8563
* multiple of 512 bits (SHA1/SHA224/SHA256) or 1024 bits (SHA384/SHA512).
8664
* The bit "1" is appended at the end of the message followed by
@@ -765,62 +743,6 @@ static int aspeed_sham_init(struct ahash_request *req)
765743
return 0;
766744
}
767745

768-
static int aspeed_sha512s_init(struct ahash_request *req)
769-
{
770-
struct aspeed_sham_reqctx *rctx = ahash_request_ctx(req);
771-
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
772-
struct aspeed_sham_ctx *tctx = crypto_ahash_ctx(tfm);
773-
struct aspeed_hace_dev *hace_dev = tctx->hace_dev;
774-
struct aspeed_sha_hmac_ctx *bctx = tctx->base;
775-
776-
AHASH_DBG(hace_dev, "digest size: %d\n", crypto_ahash_digestsize(tfm));
777-
778-
rctx->cmd = HASH_CMD_ACC_MODE;
779-
rctx->flags = 0;
780-
781-
switch (crypto_ahash_digestsize(tfm)) {
782-
case SHA224_DIGEST_SIZE:
783-
rctx->cmd |= HASH_CMD_SHA512_SER | HASH_CMD_SHA512_224 |
784-
HASH_CMD_SHA_SWAP;
785-
rctx->flags |= SHA_FLAGS_SHA512_224;
786-
rctx->digsize = SHA224_DIGEST_SIZE;
787-
rctx->block_size = SHA512_BLOCK_SIZE;
788-
rctx->sha_iv = sha512_224_iv;
789-
rctx->ivsize = 64;
790-
memcpy(rctx->digest, sha512_224_iv, rctx->ivsize);
791-
break;
792-
case SHA256_DIGEST_SIZE:
793-
rctx->cmd |= HASH_CMD_SHA512_SER | HASH_CMD_SHA512_256 |
794-
HASH_CMD_SHA_SWAP;
795-
rctx->flags |= SHA_FLAGS_SHA512_256;
796-
rctx->digsize = SHA256_DIGEST_SIZE;
797-
rctx->block_size = SHA512_BLOCK_SIZE;
798-
rctx->sha_iv = sha512_256_iv;
799-
rctx->ivsize = 64;
800-
memcpy(rctx->digest, sha512_256_iv, rctx->ivsize);
801-
break;
802-
default:
803-
dev_warn(tctx->hace_dev->dev, "digest size %d not support\n",
804-
crypto_ahash_digestsize(tfm));
805-
return -EINVAL;
806-
}
807-
808-
rctx->bufcnt = 0;
809-
rctx->total = 0;
810-
rctx->digcnt[0] = 0;
811-
rctx->digcnt[1] = 0;
812-
813-
/* HMAC init */
814-
if (tctx->flags & SHA_FLAGS_HMAC) {
815-
rctx->digcnt[0] = rctx->block_size;
816-
rctx->bufcnt = rctx->block_size;
817-
memcpy(rctx->buffer, bctx->ipad, rctx->block_size);
818-
rctx->flags |= SHA_FLAGS_HMAC;
819-
}
820-
821-
return 0;
822-
}
823-
824746
static int aspeed_sham_digest(struct ahash_request *req)
825747
{
826748
return aspeed_sham_init(req) ? : aspeed_sham_finup(req);
@@ -1195,70 +1117,6 @@ static struct aspeed_hace_alg aspeed_ahash_algs_g6[] = {
11951117
.do_one_request = aspeed_ahash_do_one,
11961118
},
11971119
},
1198-
{
1199-
.alg.ahash.base = {
1200-
.init = aspeed_sha512s_init,
1201-
.update = aspeed_sham_update,
1202-
.final = aspeed_sham_final,
1203-
.finup = aspeed_sham_finup,
1204-
.digest = aspeed_sham_digest,
1205-
.export = aspeed_sham_export,
1206-
.import = aspeed_sham_import,
1207-
.halg = {
1208-
.digestsize = SHA224_DIGEST_SIZE,
1209-
.statesize = sizeof(struct aspeed_sham_reqctx),
1210-
.base = {
1211-
.cra_name = "sha512_224",
1212-
.cra_driver_name = "aspeed-sha512_224",
1213-
.cra_priority = 300,
1214-
.cra_flags = CRYPTO_ALG_TYPE_AHASH |
1215-
CRYPTO_ALG_ASYNC |
1216-
CRYPTO_ALG_KERN_DRIVER_ONLY,
1217-
.cra_blocksize = SHA512_BLOCK_SIZE,
1218-
.cra_ctxsize = sizeof(struct aspeed_sham_ctx),
1219-
.cra_alignmask = 0,
1220-
.cra_module = THIS_MODULE,
1221-
.cra_init = aspeed_sham_cra_init,
1222-
.cra_exit = aspeed_sham_cra_exit,
1223-
}
1224-
}
1225-
},
1226-
.alg.ahash.op = {
1227-
.do_one_request = aspeed_ahash_do_one,
1228-
},
1229-
},
1230-
{
1231-
.alg.ahash.base = {
1232-
.init = aspeed_sha512s_init,
1233-
.update = aspeed_sham_update,
1234-
.final = aspeed_sham_final,
1235-
.finup = aspeed_sham_finup,
1236-
.digest = aspeed_sham_digest,
1237-
.export = aspeed_sham_export,
1238-
.import = aspeed_sham_import,
1239-
.halg = {
1240-
.digestsize = SHA256_DIGEST_SIZE,
1241-
.statesize = sizeof(struct aspeed_sham_reqctx),
1242-
.base = {
1243-
.cra_name = "sha512_256",
1244-
.cra_driver_name = "aspeed-sha512_256",
1245-
.cra_priority = 300,
1246-
.cra_flags = CRYPTO_ALG_TYPE_AHASH |
1247-
CRYPTO_ALG_ASYNC |
1248-
CRYPTO_ALG_KERN_DRIVER_ONLY,
1249-
.cra_blocksize = SHA512_BLOCK_SIZE,
1250-
.cra_ctxsize = sizeof(struct aspeed_sham_ctx),
1251-
.cra_alignmask = 0,
1252-
.cra_module = THIS_MODULE,
1253-
.cra_init = aspeed_sham_cra_init,
1254-
.cra_exit = aspeed_sham_cra_exit,
1255-
}
1256-
}
1257-
},
1258-
.alg.ahash.op = {
1259-
.do_one_request = aspeed_ahash_do_one,
1260-
},
1261-
},
12621120
{
12631121
.alg_base = "sha384",
12641122
.alg.ahash.base = {
@@ -1329,76 +1187,6 @@ static struct aspeed_hace_alg aspeed_ahash_algs_g6[] = {
13291187
.do_one_request = aspeed_ahash_do_one,
13301188
},
13311189
},
1332-
{
1333-
.alg_base = "sha512_224",
1334-
.alg.ahash.base = {
1335-
.init = aspeed_sha512s_init,
1336-
.update = aspeed_sham_update,
1337-
.final = aspeed_sham_final,
1338-
.finup = aspeed_sham_finup,
1339-
.digest = aspeed_sham_digest,
1340-
.setkey = aspeed_sham_setkey,
1341-
.export = aspeed_sham_export,
1342-
.import = aspeed_sham_import,
1343-
.halg = {
1344-
.digestsize = SHA224_DIGEST_SIZE,
1345-
.statesize = sizeof(struct aspeed_sham_reqctx),
1346-
.base = {
1347-
.cra_name = "hmac(sha512_224)",
1348-
.cra_driver_name = "aspeed-hmac-sha512_224",
1349-
.cra_priority = 300,
1350-
.cra_flags = CRYPTO_ALG_TYPE_AHASH |
1351-
CRYPTO_ALG_ASYNC |
1352-
CRYPTO_ALG_KERN_DRIVER_ONLY,
1353-
.cra_blocksize = SHA512_BLOCK_SIZE,
1354-
.cra_ctxsize = sizeof(struct aspeed_sham_ctx) +
1355-
sizeof(struct aspeed_sha_hmac_ctx),
1356-
.cra_alignmask = 0,
1357-
.cra_module = THIS_MODULE,
1358-
.cra_init = aspeed_sham_cra_init,
1359-
.cra_exit = aspeed_sham_cra_exit,
1360-
}
1361-
}
1362-
},
1363-
.alg.ahash.op = {
1364-
.do_one_request = aspeed_ahash_do_one,
1365-
},
1366-
},
1367-
{
1368-
.alg_base = "sha512_256",
1369-
.alg.ahash.base = {
1370-
.init = aspeed_sha512s_init,
1371-
.update = aspeed_sham_update,
1372-
.final = aspeed_sham_final,
1373-
.finup = aspeed_sham_finup,
1374-
.digest = aspeed_sham_digest,
1375-
.setkey = aspeed_sham_setkey,
1376-
.export = aspeed_sham_export,
1377-
.import = aspeed_sham_import,
1378-
.halg = {
1379-
.digestsize = SHA256_DIGEST_SIZE,
1380-
.statesize = sizeof(struct aspeed_sham_reqctx),
1381-
.base = {
1382-
.cra_name = "hmac(sha512_256)",
1383-
.cra_driver_name = "aspeed-hmac-sha512_256",
1384-
.cra_priority = 300,
1385-
.cra_flags = CRYPTO_ALG_TYPE_AHASH |
1386-
CRYPTO_ALG_ASYNC |
1387-
CRYPTO_ALG_KERN_DRIVER_ONLY,
1388-
.cra_blocksize = SHA512_BLOCK_SIZE,
1389-
.cra_ctxsize = sizeof(struct aspeed_sham_ctx) +
1390-
sizeof(struct aspeed_sha_hmac_ctx),
1391-
.cra_alignmask = 0,
1392-
.cra_module = THIS_MODULE,
1393-
.cra_init = aspeed_sham_cra_init,
1394-
.cra_exit = aspeed_sham_cra_exit,
1395-
}
1396-
}
1397-
},
1398-
.alg.ahash.op = {
1399-
.do_one_request = aspeed_ahash_do_one,
1400-
},
1401-
},
14021190
};
14031191

14041192
void aspeed_unregister_hace_hash_algs(struct aspeed_hace_dev *hace_dev)

0 commit comments

Comments
 (0)