Commit c51831be authored by Gilad Ben-Yossef's avatar Gilad Ben-Yossef Committed by Greg Kroah-Hartman

staging: ccree: register setkey for none hash macs

The original ccree driver was registering a useless setkey
method even for non-MAC hash transformations. Somewhere
around v4.9 a check was added that failed hash operations
if a setkey method was registered but was not called,
so during the initial upstream port code was added to
only register the setkey method for MAC type hash transform.

Unfortunately, the ccree driver also registers non-hash based
MAC transforms and the code had a logic error that stopped
it registering a setkey callback even for those, thus rendering
them useless.

This commit fixes the logic mistake, thus correctly registering
a setkey method only for MAC transformations, leaving it out
for non-MAC ones, whether they are hash based on not.

Fixes: 50cfbbb7 ("staging: ccree: add ahash support").
Signed-off-by: default avatarGilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 454527d0
...@@ -1877,8 +1877,8 @@ static int ssi_ahash_setkey(struct crypto_ahash *ahash, ...@@ -1877,8 +1877,8 @@ static int ssi_ahash_setkey(struct crypto_ahash *ahash,
struct ssi_hash_template { struct ssi_hash_template {
char name[CRYPTO_MAX_ALG_NAME]; char name[CRYPTO_MAX_ALG_NAME];
char driver_name[CRYPTO_MAX_ALG_NAME]; char driver_name[CRYPTO_MAX_ALG_NAME];
char hmac_name[CRYPTO_MAX_ALG_NAME]; char mac_name[CRYPTO_MAX_ALG_NAME];
char hmac_driver_name[CRYPTO_MAX_ALG_NAME]; char mac_driver_name[CRYPTO_MAX_ALG_NAME];
unsigned int blocksize; unsigned int blocksize;
bool synchronize; bool synchronize;
struct ahash_alg template_ahash; struct ahash_alg template_ahash;
...@@ -1897,8 +1897,8 @@ static struct ssi_hash_template driver_hash[] = { ...@@ -1897,8 +1897,8 @@ static struct ssi_hash_template driver_hash[] = {
{ {
.name = "sha1", .name = "sha1",
.driver_name = "sha1-dx", .driver_name = "sha1-dx",
.hmac_name = "hmac(sha1)", .mac_name = "hmac(sha1)",
.hmac_driver_name = "hmac-sha1-dx", .mac_driver_name = "hmac-sha1-dx",
.blocksize = SHA1_BLOCK_SIZE, .blocksize = SHA1_BLOCK_SIZE,
.synchronize = false, .synchronize = false,
.template_ahash = { .template_ahash = {
...@@ -1922,8 +1922,8 @@ static struct ssi_hash_template driver_hash[] = { ...@@ -1922,8 +1922,8 @@ static struct ssi_hash_template driver_hash[] = {
{ {
.name = "sha256", .name = "sha256",
.driver_name = "sha256-dx", .driver_name = "sha256-dx",
.hmac_name = "hmac(sha256)", .mac_name = "hmac(sha256)",
.hmac_driver_name = "hmac-sha256-dx", .mac_driver_name = "hmac-sha256-dx",
.blocksize = SHA256_BLOCK_SIZE, .blocksize = SHA256_BLOCK_SIZE,
.template_ahash = { .template_ahash = {
.init = ssi_ahash_init, .init = ssi_ahash_init,
...@@ -1946,8 +1946,8 @@ static struct ssi_hash_template driver_hash[] = { ...@@ -1946,8 +1946,8 @@ static struct ssi_hash_template driver_hash[] = {
{ {
.name = "sha224", .name = "sha224",
.driver_name = "sha224-dx", .driver_name = "sha224-dx",
.hmac_name = "hmac(sha224)", .mac_name = "hmac(sha224)",
.hmac_driver_name = "hmac-sha224-dx", .mac_driver_name = "hmac-sha224-dx",
.blocksize = SHA224_BLOCK_SIZE, .blocksize = SHA224_BLOCK_SIZE,
.template_ahash = { .template_ahash = {
.init = ssi_ahash_init, .init = ssi_ahash_init,
...@@ -1971,8 +1971,8 @@ static struct ssi_hash_template driver_hash[] = { ...@@ -1971,8 +1971,8 @@ static struct ssi_hash_template driver_hash[] = {
{ {
.name = "sha384", .name = "sha384",
.driver_name = "sha384-dx", .driver_name = "sha384-dx",
.hmac_name = "hmac(sha384)", .mac_name = "hmac(sha384)",
.hmac_driver_name = "hmac-sha384-dx", .mac_driver_name = "hmac-sha384-dx",
.blocksize = SHA384_BLOCK_SIZE, .blocksize = SHA384_BLOCK_SIZE,
.template_ahash = { .template_ahash = {
.init = ssi_ahash_init, .init = ssi_ahash_init,
...@@ -1995,8 +1995,8 @@ static struct ssi_hash_template driver_hash[] = { ...@@ -1995,8 +1995,8 @@ static struct ssi_hash_template driver_hash[] = {
{ {
.name = "sha512", .name = "sha512",
.driver_name = "sha512-dx", .driver_name = "sha512-dx",
.hmac_name = "hmac(sha512)", .mac_name = "hmac(sha512)",
.hmac_driver_name = "hmac-sha512-dx", .mac_driver_name = "hmac-sha512-dx",
.blocksize = SHA512_BLOCK_SIZE, .blocksize = SHA512_BLOCK_SIZE,
.template_ahash = { .template_ahash = {
.init = ssi_ahash_init, .init = ssi_ahash_init,
...@@ -2020,8 +2020,8 @@ static struct ssi_hash_template driver_hash[] = { ...@@ -2020,8 +2020,8 @@ static struct ssi_hash_template driver_hash[] = {
{ {
.name = "md5", .name = "md5",
.driver_name = "md5-dx", .driver_name = "md5-dx",
.hmac_name = "hmac(md5)", .mac_name = "hmac(md5)",
.hmac_driver_name = "hmac-md5-dx", .mac_driver_name = "hmac-md5-dx",
.blocksize = MD5_HMAC_BLOCK_SIZE, .blocksize = MD5_HMAC_BLOCK_SIZE,
.template_ahash = { .template_ahash = {
.init = ssi_ahash_init, .init = ssi_ahash_init,
...@@ -2042,8 +2042,8 @@ static struct ssi_hash_template driver_hash[] = { ...@@ -2042,8 +2042,8 @@ static struct ssi_hash_template driver_hash[] = {
.inter_digestsize = MD5_DIGEST_SIZE, .inter_digestsize = MD5_DIGEST_SIZE,
}, },
{ {
.name = "xcbc(aes)", .mac_name = "xcbc(aes)",
.driver_name = "xcbc-aes-dx", .mac_driver_name = "xcbc-aes-dx",
.blocksize = AES_BLOCK_SIZE, .blocksize = AES_BLOCK_SIZE,
.template_ahash = { .template_ahash = {
.init = ssi_ahash_init, .init = ssi_ahash_init,
...@@ -2065,8 +2065,8 @@ static struct ssi_hash_template driver_hash[] = { ...@@ -2065,8 +2065,8 @@ static struct ssi_hash_template driver_hash[] = {
}, },
#if SSI_CC_HAS_CMAC #if SSI_CC_HAS_CMAC
{ {
.name = "cmac(aes)", .mac_name = "cmac(aes)",
.driver_name = "cmac-aes-dx", .mac_driver_name = "cmac-aes-dx",
.blocksize = AES_BLOCK_SIZE, .blocksize = AES_BLOCK_SIZE,
.template_ahash = { .template_ahash = {
.init = ssi_ahash_init, .init = ssi_ahash_init,
...@@ -2109,9 +2109,9 @@ ssi_hash_create_alg(struct ssi_hash_template *template, bool keyed) ...@@ -2109,9 +2109,9 @@ ssi_hash_create_alg(struct ssi_hash_template *template, bool keyed)
if (keyed) { if (keyed) {
snprintf(alg->cra_name, CRYPTO_MAX_ALG_NAME, "%s", snprintf(alg->cra_name, CRYPTO_MAX_ALG_NAME, "%s",
template->hmac_name); template->mac_name);
snprintf(alg->cra_driver_name, CRYPTO_MAX_ALG_NAME, "%s", snprintf(alg->cra_driver_name, CRYPTO_MAX_ALG_NAME, "%s",
template->hmac_driver_name); template->mac_driver_name);
} else { } else {
halg->setkey = NULL; halg->setkey = NULL;
snprintf(alg->cra_name, CRYPTO_MAX_ALG_NAME, "%s", snprintf(alg->cra_name, CRYPTO_MAX_ALG_NAME, "%s",
...@@ -2300,11 +2300,9 @@ int ssi_hash_alloc(struct ssi_drvdata *drvdata) ...@@ -2300,11 +2300,9 @@ int ssi_hash_alloc(struct ssi_drvdata *drvdata)
/* ahash registration */ /* ahash registration */
for (alg = 0; alg < ARRAY_SIZE(driver_hash); alg++) { for (alg = 0; alg < ARRAY_SIZE(driver_hash); alg++) {
struct ssi_hash_alg *t_alg; struct ssi_hash_alg *t_alg;
int hw_mode = driver_hash[alg].hw_mode;
/* register hmac version */ /* register hmac version */
if ((((struct ssi_hash_template *)&driver_hash[alg])->hw_mode != DRV_CIPHER_XCBC_MAC) &&
(((struct ssi_hash_template *)&driver_hash[alg])->hw_mode != DRV_CIPHER_CMAC)) {
t_alg = ssi_hash_create_alg(&driver_hash[alg], true); t_alg = ssi_hash_create_alg(&driver_hash[alg], true);
if (IS_ERR(t_alg)) { if (IS_ERR(t_alg)) {
rc = PTR_ERR(t_alg); rc = PTR_ERR(t_alg);
...@@ -2324,7 +2322,10 @@ int ssi_hash_alloc(struct ssi_drvdata *drvdata) ...@@ -2324,7 +2322,10 @@ int ssi_hash_alloc(struct ssi_drvdata *drvdata)
list_add_tail(&t_alg->entry, list_add_tail(&t_alg->entry,
&hash_handle->hash_list); &hash_handle->hash_list);
} }
}
if ((hw_mode == DRV_CIPHER_XCBC_MAC) ||
(hw_mode == DRV_CIPHER_CMAC))
continue;
/* register hash version */ /* register hash version */
t_alg = ssi_hash_create_alg(&driver_hash[alg], false); t_alg = ssi_hash_create_alg(&driver_hash[alg], false);
......
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