summaryrefslogtreecommitdiffstats
path: root/crypto/chacha20poly1305.c
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2015-06-01 13:44:02 +0200
committerHerbert Xu <herbert@gondor.apana.org.au>2015-06-04 15:04:53 +0800
commit4db4ad26096c4c1e579f9a957ca7752fe02bf7b4 (patch)
treec2673dc8798f506e26771fc857f0dea1c3d50ff2 /crypto/chacha20poly1305.c
parentaf2b76b53a0668ff85b34cb108fefa85d72bb9c6 (diff)
downloadlinux-4db4ad26096c4c1e579f9a957ca7752fe02bf7b4.tar.gz
linux-4db4ad26096c4c1e579f9a957ca7752fe02bf7b4.tar.bz2
linux-4db4ad26096c4c1e579f9a957ca7752fe02bf7b4.zip
crypto: chacha20poly1305 - Add an IPsec variant for RFC7539 AEAD
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> Acked-by: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/chacha20poly1305.c')
-rw-r--r--crypto/chacha20poly1305.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/crypto/chacha20poly1305.c b/crypto/chacha20poly1305.c
index 6171cf14c5f5..05fbc59297e5 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");