aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2015-06-01 07:44:02 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2015-06-04 03:04:53 -0400
commit4db4ad26096c4c1e579f9a957ca7752fe02bf7b4 (patch)
treec2673dc8798f506e26771fc857f0dea1c3d50ff2 /crypto
parentaf2b76b53a0668ff85b34cb108fefa85d72bb9c6 (diff)
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')
-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)
627 return chachapoly_alloc(tb, "rfc7539", 12); 627 return chachapoly_alloc(tb, "rfc7539", 12);
628} 628}
629 629
630static struct crypto_instance *rfc7539esp_alloc(struct rtattr **tb)
631{
632 return chachapoly_alloc(tb, "rfc7539esp", 8);
633}
634
630static void chachapoly_free(struct crypto_instance *inst) 635static void chachapoly_free(struct crypto_instance *inst)
631{ 636{
632 struct chachapoly_instance_ctx *ctx = crypto_instance_ctx(inst); 637 struct chachapoly_instance_ctx *ctx = crypto_instance_ctx(inst);
@@ -643,13 +648,31 @@ static struct crypto_template rfc7539_tmpl = {
643 .module = THIS_MODULE, 648 .module = THIS_MODULE,
644}; 649};
645 650
651static struct crypto_template rfc7539esp_tmpl = {
652 .name = "rfc7539esp",
653 .alloc = rfc7539esp_alloc,
654 .free = chachapoly_free,
655 .module = THIS_MODULE,
656};
657
646static int __init chacha20poly1305_module_init(void) 658static int __init chacha20poly1305_module_init(void)
647{ 659{
648 return crypto_register_template(&rfc7539_tmpl); 660 int err;
661
662 err = crypto_register_template(&rfc7539_tmpl);
663 if (err)
664 return err;
665
666 err = crypto_register_template(&rfc7539esp_tmpl);
667 if (err)
668 crypto_unregister_template(&rfc7539_tmpl);
669
670 return err;
649} 671}
650 672
651static void __exit chacha20poly1305_module_exit(void) 673static void __exit chacha20poly1305_module_exit(void)
652{ 674{
675 crypto_unregister_template(&rfc7539esp_tmpl);
653 crypto_unregister_template(&rfc7539_tmpl); 676 crypto_unregister_template(&rfc7539_tmpl);
654} 677}
655 678
@@ -661,3 +684,4 @@ MODULE_AUTHOR("Martin Willi <martin@strongswan.org>");
661MODULE_DESCRIPTION("ChaCha20-Poly1305 AEAD"); 684MODULE_DESCRIPTION("ChaCha20-Poly1305 AEAD");
662MODULE_ALIAS_CRYPTO("chacha20poly1305"); 685MODULE_ALIAS_CRYPTO("chacha20poly1305");
663MODULE_ALIAS_CRYPTO("rfc7539"); 686MODULE_ALIAS_CRYPTO("rfc7539");
687MODULE_ALIAS_CRYPTO("rfc7539esp");