From: Keerthy <j-keerthy@ti.com>
To: <herbert@gondor.apana.org.au>, <davem@davemloft.net>,
<robh+dt@kernel.org>
Cc: <linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<devicetree@vger.kernel.org>, <t-kristo@ti.com>,
<j-keerthy@ti.com>, <linux-crypto@vger.kernel.org>, <nm@ti.com>
Subject: [RESEND PATCH 08/10] crypto: sa2ul: Add hmac(sha256) HMAC algorithm support
Date: Fri, 28 Jun 2019 09:57:43 +0530 [thread overview]
Message-ID: <20190628042745.28455-9-j-keerthy@ti.com> (raw)
In-Reply-To: <20190628042745.28455-1-j-keerthy@ti.com>
HMAC hash-based message authentication code) is a specific type of
message authentication code (MAC) involving a cryptographic hash
function and a secret cryptographic key. It may be used to
simultaneously verify both the data integrity and the authentication
of a message, as with any MAC. Add hmac(sha256) HMAC algorithm support
and the message digest size is 32 bytes.
Signed-off-by: Keerthy <j-keerthy@ti.com>
---
drivers/crypto/sa2ul.c | 52 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/drivers/crypto/sa2ul.c b/drivers/crypto/sa2ul.c
index e3a1321f0666..74211cd21c62 100644
--- a/drivers/crypto/sa2ul.c
+++ b/drivers/crypto/sa2ul.c
@@ -1673,11 +1673,38 @@ static int sa_sham_sha1_setkey(struct crypto_ahash *tfm, const u8 *key,
return sa_sham_setkey(tfm, key, keylen, ad);
}
+static int sa_sham_sha256_setkey(struct crypto_ahash *tfm, const u8 *key,
+ unsigned int keylen)
+{
+ struct algo_data *ad = kzalloc(sizeof(*ad), GFP_KERNEL);
+
+ ad->enc_eng.eng_id = SA_ENG_ID_NONE;
+ ad->enc_eng.sc_size = SA_CTX_ENC_TYPE1_SZ;
+ ad->auth_eng.eng_id = SA_ENG_ID_AM1;
+ ad->auth_eng.sc_size = SA_CTX_AUTH_TYPE2_SZ;
+ ad->mci_enc = NULL;
+ ad->mci_dec = NULL;
+ ad->inv_key = false;
+ ad->keyed_mac = true;
+ ad->ealg_id = SA_EALG_ID_NONE;
+ ad->aalg_id = SA_AALG_ID_HMAC_SHA2_256;
+ ad->hash_size = SHA256_DIGEST_SIZE;
+ ad->auth_ctrl = 0x4;
+ ad->prep_iopad = sa_hmac_sha256_get_pad;
+
+ return sa_sham_setkey(tfm, key, keylen, ad);
+}
+
static int sa_sham_cra_sha1_init(struct crypto_tfm *tfm)
{
return sa_sham_cra_init_alg(tfm, "sha1");
}
+static int sa_sham_cra_sha256_init(struct crypto_tfm *tfm)
+{
+ return sa_sham_cra_init_alg(tfm, "sha256");
+}
+
static void sa_sham_cra_exit(struct crypto_tfm *tfm)
{
struct crypto_alg *alg = tfm->__crt_alg;
@@ -1839,6 +1866,31 @@ static struct ahash_alg algs_sha[] = {
.cra_exit = sa_sham_cra_exit,
}
},
+{
+ .init = sa_sham_init,
+ .update = sa_sham_update,
+ .final = sa_sham_final,
+ .finup = sa_sham_finup,
+ .digest = sa_sham_digest,
+ .setkey = sa_sham_sha256_setkey,
+ .halg.digestsize = SHA256_DIGEST_SIZE,
+ .halg.statesize = 128,
+ .halg.base = {
+ .cra_name = "hmac(sha256)",
+ .cra_driver_name = "sa-hmac-sha256",
+ .cra_priority = 400,
+ .cra_flags = CRYPTO_ALG_TYPE_AHASH |
+ CRYPTO_ALG_ASYNC |
+ CRYPTO_ALG_KERN_DRIVER_ONLY |
+ CRYPTO_ALG_NEED_FALLBACK,
+ .cra_blocksize = SHA256_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct sa_tfm_ctx),
+ .cra_alignmask = SA_ALIGN_MASK,
+ .cra_module = THIS_MODULE,
+ .cra_init = sa_sham_cra_sha256_init,
+ .cra_exit = sa_sham_cra_exit,
+ }
+},
};
/* Register the algorithms in crypto framework */
--
2.17.1
next prev parent reply other threads:[~2019-06-28 4:28 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-28 4:27 [RESEND PATCH 00/10] crypto: k3: Add sa2ul driver Keerthy
2019-06-28 4:27 ` [RESEND PATCH 01/10] dt-bindings: crypto: k3: Add sa2ul bindings documentation Keerthy
2019-07-22 18:29 ` Rob Herring
2019-07-23 4:11 ` Keerthy
2019-06-28 4:27 ` [RESEND PATCH 02/10] crypto: sa2ul: Add crypto driver Keerthy
2019-06-28 5:07 ` Eric Biggers
2019-06-28 5:24 ` Keerthy
2019-06-28 4:27 ` [RESEND PATCH 03/10] crypto: sa2ul: Add AES ECB Mode support Keerthy
2019-06-28 4:27 ` [RESEND PATCH 04/10] crypto: sa2ul: Add aead support for hmac(sha1)cbc(aes) algorithm Keerthy
2019-06-28 4:27 ` [RESEND PATCH 05/10] crypto: sha256_generic: Export the Transform function Keerthy
2019-06-28 5:09 ` Eric Biggers
2019-06-28 5:27 ` Keerthy
2019-06-28 4:27 ` [RESEND PATCH 06/10] crypto: sa2ul: Add hmac(sha256)cbc(aes) AEAD Algo support Keerthy
2019-06-28 5:12 ` Eric Biggers
2019-06-28 4:27 ` [RESEND PATCH 07/10] crypto: sa2ul: Add hmac(sha1) HMAC algorithm support Keerthy
2019-06-28 5:14 ` Eric Biggers
2019-06-28 5:32 ` Keerthy
2019-06-28 4:27 ` Keerthy [this message]
2019-06-28 4:27 ` [RESEND PATCH 09/10] sa2ul: Add 3DES ECB & CBC Mode support Keerthy
2019-06-28 4:27 ` [RESEND PATCH 10/10] arm64: dts: k3-am6: Add crypto accelarator node Keerthy
2019-06-28 4:53 ` [RESEND PATCH 00/10] crypto: k3: Add sa2ul driver Eric Biggers
2019-06-28 5:14 ` keerthy
2019-06-28 5:25 ` Eric Biggers
2019-06-28 5:31 ` Keerthy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190628042745.28455-9-j-keerthy@ti.com \
--to=j-keerthy@ti.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nm@ti.com \
--cc=robh+dt@kernel.org \
--cc=t-kristo@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).