aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto/inside-secure/safexcel_hash.c
diff options
context:
space:
mode:
authorPascal van Leeuwen <pascalvanl@gmail.com>2019-08-30 03:40:54 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2019-09-05 00:37:01 -0400
commit062b64ca6db409fd6e102aed0fa59716b5cdfd78 (patch)
tree0de1abd004dae25cdab4444ca9557b0b392784f8 /drivers/crypto/inside-secure/safexcel_hash.c
parentc7da38a71cfbb5c0f20f84864a290b9450ad78e9 (diff)
crypto: inside-secure - Only enable algorithms advertised by the hardware
This patch probes the supported algorithms from the hardware and only registers the ones that the hardware actually supports. This is necessary because this is a generic driver supposed to run on a wide variety of engines, which may or may not implement certain algorithms. Signed-off-by: Pascal van Leeuwen <pvanleeuwen@verimatrix.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/inside-secure/safexcel_hash.c')
-rw-r--r--drivers/crypto/inside-secure/safexcel_hash.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/crypto/inside-secure/safexcel_hash.c b/drivers/crypto/inside-secure/safexcel_hash.c
index 626dd82e583f..e60838f2fa96 100644
--- a/drivers/crypto/inside-secure/safexcel_hash.c
+++ b/drivers/crypto/inside-secure/safexcel_hash.c
@@ -845,6 +845,7 @@ static void safexcel_ahash_cra_exit(struct crypto_tfm *tfm)
845 845
846struct safexcel_alg_template safexcel_alg_sha1 = { 846struct safexcel_alg_template safexcel_alg_sha1 = {
847 .type = SAFEXCEL_ALG_TYPE_AHASH, 847 .type = SAFEXCEL_ALG_TYPE_AHASH,
848 .algo_mask = SAFEXCEL_ALG_SHA1,
848 .alg.ahash = { 849 .alg.ahash = {
849 .init = safexcel_sha1_init, 850 .init = safexcel_sha1_init,
850 .update = safexcel_ahash_update, 851 .update = safexcel_ahash_update,
@@ -1085,6 +1086,7 @@ static int safexcel_hmac_sha1_setkey(struct crypto_ahash *tfm, const u8 *key,
1085 1086
1086struct safexcel_alg_template safexcel_alg_hmac_sha1 = { 1087struct safexcel_alg_template safexcel_alg_hmac_sha1 = {
1087 .type = SAFEXCEL_ALG_TYPE_AHASH, 1088 .type = SAFEXCEL_ALG_TYPE_AHASH,
1089 .algo_mask = SAFEXCEL_ALG_SHA1,
1088 .alg.ahash = { 1090 .alg.ahash = {
1089 .init = safexcel_hmac_sha1_init, 1091 .init = safexcel_hmac_sha1_init,
1090 .update = safexcel_ahash_update, 1092 .update = safexcel_ahash_update,
@@ -1140,6 +1142,7 @@ static int safexcel_sha256_digest(struct ahash_request *areq)
1140 1142
1141struct safexcel_alg_template safexcel_alg_sha256 = { 1143struct safexcel_alg_template safexcel_alg_sha256 = {
1142 .type = SAFEXCEL_ALG_TYPE_AHASH, 1144 .type = SAFEXCEL_ALG_TYPE_AHASH,
1145 .algo_mask = SAFEXCEL_ALG_SHA2_256,
1143 .alg.ahash = { 1146 .alg.ahash = {
1144 .init = safexcel_sha256_init, 1147 .init = safexcel_sha256_init,
1145 .update = safexcel_ahash_update, 1148 .update = safexcel_ahash_update,
@@ -1194,6 +1197,7 @@ static int safexcel_sha224_digest(struct ahash_request *areq)
1194 1197
1195struct safexcel_alg_template safexcel_alg_sha224 = { 1198struct safexcel_alg_template safexcel_alg_sha224 = {
1196 .type = SAFEXCEL_ALG_TYPE_AHASH, 1199 .type = SAFEXCEL_ALG_TYPE_AHASH,
1200 .algo_mask = SAFEXCEL_ALG_SHA2_256,
1197 .alg.ahash = { 1201 .alg.ahash = {
1198 .init = safexcel_sha224_init, 1202 .init = safexcel_sha224_init,
1199 .update = safexcel_ahash_update, 1203 .update = safexcel_ahash_update,
@@ -1262,6 +1266,7 @@ static int safexcel_hmac_sha224_digest(struct ahash_request *areq)
1262 1266
1263struct safexcel_alg_template safexcel_alg_hmac_sha224 = { 1267struct safexcel_alg_template safexcel_alg_hmac_sha224 = {
1264 .type = SAFEXCEL_ALG_TYPE_AHASH, 1268 .type = SAFEXCEL_ALG_TYPE_AHASH,
1269 .algo_mask = SAFEXCEL_ALG_SHA2_256,
1265 .alg.ahash = { 1270 .alg.ahash = {
1266 .init = safexcel_hmac_sha224_init, 1271 .init = safexcel_hmac_sha224_init,
1267 .update = safexcel_ahash_update, 1272 .update = safexcel_ahash_update,
@@ -1331,6 +1336,7 @@ static int safexcel_hmac_sha256_digest(struct ahash_request *areq)
1331 1336
1332struct safexcel_alg_template safexcel_alg_hmac_sha256 = { 1337struct safexcel_alg_template safexcel_alg_hmac_sha256 = {
1333 .type = SAFEXCEL_ALG_TYPE_AHASH, 1338 .type = SAFEXCEL_ALG_TYPE_AHASH,
1339 .algo_mask = SAFEXCEL_ALG_SHA2_256,
1334 .alg.ahash = { 1340 .alg.ahash = {
1335 .init = safexcel_hmac_sha256_init, 1341 .init = safexcel_hmac_sha256_init,
1336 .update = safexcel_ahash_update, 1342 .update = safexcel_ahash_update,
@@ -1386,6 +1392,7 @@ static int safexcel_sha512_digest(struct ahash_request *areq)
1386 1392
1387struct safexcel_alg_template safexcel_alg_sha512 = { 1393struct safexcel_alg_template safexcel_alg_sha512 = {
1388 .type = SAFEXCEL_ALG_TYPE_AHASH, 1394 .type = SAFEXCEL_ALG_TYPE_AHASH,
1395 .algo_mask = SAFEXCEL_ALG_SHA2_512,
1389 .alg.ahash = { 1396 .alg.ahash = {
1390 .init = safexcel_sha512_init, 1397 .init = safexcel_sha512_init,
1391 .update = safexcel_ahash_update, 1398 .update = safexcel_ahash_update,
@@ -1440,6 +1447,7 @@ static int safexcel_sha384_digest(struct ahash_request *areq)
1440 1447
1441struct safexcel_alg_template safexcel_alg_sha384 = { 1448struct safexcel_alg_template safexcel_alg_sha384 = {
1442 .type = SAFEXCEL_ALG_TYPE_AHASH, 1449 .type = SAFEXCEL_ALG_TYPE_AHASH,
1450 .algo_mask = SAFEXCEL_ALG_SHA2_512,
1443 .alg.ahash = { 1451 .alg.ahash = {
1444 .init = safexcel_sha384_init, 1452 .init = safexcel_sha384_init,
1445 .update = safexcel_ahash_update, 1453 .update = safexcel_ahash_update,
@@ -1508,6 +1516,7 @@ static int safexcel_hmac_sha512_digest(struct ahash_request *areq)
1508 1516
1509struct safexcel_alg_template safexcel_alg_hmac_sha512 = { 1517struct safexcel_alg_template safexcel_alg_hmac_sha512 = {
1510 .type = SAFEXCEL_ALG_TYPE_AHASH, 1518 .type = SAFEXCEL_ALG_TYPE_AHASH,
1519 .algo_mask = SAFEXCEL_ALG_SHA2_512,
1511 .alg.ahash = { 1520 .alg.ahash = {
1512 .init = safexcel_hmac_sha512_init, 1521 .init = safexcel_hmac_sha512_init,
1513 .update = safexcel_ahash_update, 1522 .update = safexcel_ahash_update,
@@ -1577,6 +1586,7 @@ static int safexcel_hmac_sha384_digest(struct ahash_request *areq)
1577 1586
1578struct safexcel_alg_template safexcel_alg_hmac_sha384 = { 1587struct safexcel_alg_template safexcel_alg_hmac_sha384 = {
1579 .type = SAFEXCEL_ALG_TYPE_AHASH, 1588 .type = SAFEXCEL_ALG_TYPE_AHASH,
1589 .algo_mask = SAFEXCEL_ALG_SHA2_512,
1580 .alg.ahash = { 1590 .alg.ahash = {
1581 .init = safexcel_hmac_sha384_init, 1591 .init = safexcel_hmac_sha384_init,
1582 .update = safexcel_ahash_update, 1592 .update = safexcel_ahash_update,
@@ -1632,6 +1642,7 @@ static int safexcel_md5_digest(struct ahash_request *areq)
1632 1642
1633struct safexcel_alg_template safexcel_alg_md5 = { 1643struct safexcel_alg_template safexcel_alg_md5 = {
1634 .type = SAFEXCEL_ALG_TYPE_AHASH, 1644 .type = SAFEXCEL_ALG_TYPE_AHASH,
1645 .algo_mask = SAFEXCEL_ALG_MD5,
1635 .alg.ahash = { 1646 .alg.ahash = {
1636 .init = safexcel_md5_init, 1647 .init = safexcel_md5_init,
1637 .update = safexcel_ahash_update, 1648 .update = safexcel_ahash_update,
@@ -1701,6 +1712,7 @@ static int safexcel_hmac_md5_digest(struct ahash_request *areq)
1701 1712
1702struct safexcel_alg_template safexcel_alg_hmac_md5 = { 1713struct safexcel_alg_template safexcel_alg_hmac_md5 = {
1703 .type = SAFEXCEL_ALG_TYPE_AHASH, 1714 .type = SAFEXCEL_ALG_TYPE_AHASH,
1715 .algo_mask = SAFEXCEL_ALG_MD5,
1704 .alg.ahash = { 1716 .alg.ahash = {
1705 .init = safexcel_hmac_md5_init, 1717 .init = safexcel_hmac_md5_init,
1706 .update = safexcel_ahash_update, 1718 .update = safexcel_ahash_update,