All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Willi <martin@strongswan.org>
To: Herbert Xu <herbert@gondor.apana.org.au>,
	Steffen Klassert <steffen.klassert@secunet.com>,
	linux-crypto@vger.kernel.org
Subject: [PATCH 7/9] crypto: chacha20poly1305 - Add an IPsec variant for RFC7539 AEAD
Date: Mon,  1 Jun 2015 13:44:02 +0200	[thread overview]
Message-ID: <1433159044-30753-8-git-send-email-martin@strongswan.org> (raw)
In-Reply-To: <1433159044-30753-1-git-send-email-martin@strongswan.org>

draft-ietf-ipsecme-chacha20-poly1305 defines the use of ChaCha20/Poly1305 in
ESP. It uses additional four byte key material as a salt, which is then used
with an 8 byte IV to form the ChaCha20 nonce as defined in the RFC7539.

Signed-off-by: Martin Willi <martin@strongswan.org>
---
 crypto/chacha20poly1305.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/crypto/chacha20poly1305.c b/crypto/chacha20poly1305.c
index 6171cf1..05fbc59 100644
--- a/crypto/chacha20poly1305.c
+++ b/crypto/chacha20poly1305.c
@@ -627,6 +627,11 @@ static struct crypto_instance *rfc7539_alloc(struct rtattr **tb)
 	return chachapoly_alloc(tb, "rfc7539", 12);
 }
 
+static struct crypto_instance *rfc7539esp_alloc(struct rtattr **tb)
+{
+	return chachapoly_alloc(tb, "rfc7539esp", 8);
+}
+
 static void chachapoly_free(struct crypto_instance *inst)
 {
 	struct chachapoly_instance_ctx *ctx = crypto_instance_ctx(inst);
@@ -643,13 +648,31 @@ static struct crypto_template rfc7539_tmpl = {
 	.module = THIS_MODULE,
 };
 
+static struct crypto_template rfc7539esp_tmpl = {
+	.name = "rfc7539esp",
+	.alloc = rfc7539esp_alloc,
+	.free = chachapoly_free,
+	.module = THIS_MODULE,
+};
+
 static int __init chacha20poly1305_module_init(void)
 {
-	return crypto_register_template(&rfc7539_tmpl);
+	int err;
+
+	err = crypto_register_template(&rfc7539_tmpl);
+	if (err)
+		return err;
+
+	err = crypto_register_template(&rfc7539esp_tmpl);
+	if (err)
+		crypto_unregister_template(&rfc7539_tmpl);
+
+	return err;
 }
 
 static void __exit chacha20poly1305_module_exit(void)
 {
+	crypto_unregister_template(&rfc7539esp_tmpl);
 	crypto_unregister_template(&rfc7539_tmpl);
 }
 
@@ -661,3 +684,4 @@ MODULE_AUTHOR("Martin Willi <martin@strongswan.org>");
 MODULE_DESCRIPTION("ChaCha20-Poly1305 AEAD");
 MODULE_ALIAS_CRYPTO("chacha20poly1305");
 MODULE_ALIAS_CRYPTO("rfc7539");
+MODULE_ALIAS_CRYPTO("rfc7539esp");
-- 
1.9.1

  parent reply	other threads:[~2015-06-01 12:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-01 11:43 [PATCH 0/9] crypto: Add ChaCha20-Poly1305 AEAD support for IPsec Martin Willi
2015-06-01 11:43 ` [PATCH 1/9] crypto: Add a generic ChaCha20 stream cipher implementation Martin Willi
2015-06-01 11:43 ` [PATCH 2/9] crypto: testmgr - Add ChaCha20 test vectors from RFC7539 Martin Willi
2015-06-01 11:43 ` [PATCH 3/9] crypto: Add a generic Poly1305 authenticator implementation Martin Willi
2015-06-04  9:59   ` Herbert Xu
2015-06-04 19:42     ` Martin Willi
2015-06-01 11:43 ` [PATCH 4/9] crypto: testmgr - Add Poly1305 test vectors from RFC7539 Martin Willi
2015-06-01 11:44 ` [PATCH 5/9] crypto: Add a ChaCha20-Poly1305 AEAD construction, RFC7539 Martin Willi
2015-06-01 11:44 ` [PATCH 6/9] crypto: testmgr - Add ChaCha20-Poly1305 test vectors from RFC7539 Martin Willi
2015-06-01 11:44 ` Martin Willi [this message]
2015-06-01 11:44 ` [PATCH 8/9] crypto: testmgr - Add draft-ietf-ipsecme-chacha20-poly1305 test vector Martin Willi
2015-06-01 11:44 ` [PATCH 9/9] xfrm: Define ChaCha20-Poly1305 AEAD XFRM algo for IPsec users Martin Willi
2015-06-03  2:44 ` [PATCH 0/9] crypto: Add ChaCha20-Poly1305 AEAD support for IPsec Herbert Xu
2015-06-03  7:53   ` Steffen Klassert
2015-06-04  8:13 ` Herbert Xu

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=1433159044-30753-8-git-send-email-martin@strongswan.org \
    --to=martin@strongswan.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=steffen.klassert@secunet.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.