aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto
diff options
context:
space:
mode:
authorHoria Geanta <horia.geanta@freescale.com>2012-08-08 11:46:45 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2012-08-28 11:56:30 -0400
commite763eb699be723fb41af818118068c6b3afdaf8d (patch)
treea15372752e0f498db491dd8b64e39ee295c22aed /drivers/crypto
parent79fd31d355f7e315025a330adc2183fb5ae8f22d (diff)
crypto: talitos - add IPsec ESN support
Support for ESNs (extended sequence numbers). Tested with strongswan on a P2020RDB back-to-back setup. Extracted from /etc/ipsec.conf: esp=aes-sha1-esn-modp4096! Signed-off-by: Horia Geanta <horia.geanta@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
-rw-r--r--drivers/crypto/talitos.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
index bea25e291a5a..da1112765a44 100644
--- a/drivers/crypto/talitos.c
+++ b/drivers/crypto/talitos.c
@@ -38,6 +38,7 @@
38#include <linux/spinlock.h> 38#include <linux/spinlock.h>
39#include <linux/rtnetlink.h> 39#include <linux/rtnetlink.h>
40#include <linux/slab.h> 40#include <linux/slab.h>
41#include <linux/string.h>
41 42
42#include <crypto/algapi.h> 43#include <crypto/algapi.h>
43#include <crypto/aes.h> 44#include <crypto/aes.h>
@@ -1974,7 +1975,11 @@ struct talitos_alg_template {
1974}; 1975};
1975 1976
1976static struct talitos_alg_template driver_algs[] = { 1977static struct talitos_alg_template driver_algs[] = {
1977 /* AEAD algorithms. These use a single-pass ipsec_esp descriptor */ 1978 /*
1979 * AEAD algorithms. These use a single-pass ipsec_esp descriptor.
1980 * authencesn(*,*) is also registered, although not present
1981 * explicitly here.
1982 */
1978 { .type = CRYPTO_ALG_TYPE_AEAD, 1983 { .type = CRYPTO_ALG_TYPE_AEAD,
1979 .alg.crypto = { 1984 .alg.crypto = {
1980 .cra_name = "authenc(hmac(sha1),cbc(aes))", 1985 .cra_name = "authenc(hmac(sha1),cbc(aes))",
@@ -2816,7 +2821,9 @@ static int talitos_probe(struct platform_device *ofdev)
2816 if (hw_supports(dev, driver_algs[i].desc_hdr_template)) { 2821 if (hw_supports(dev, driver_algs[i].desc_hdr_template)) {
2817 struct talitos_crypto_alg *t_alg; 2822 struct talitos_crypto_alg *t_alg;
2818 char *name = NULL; 2823 char *name = NULL;
2824 bool authenc = false;
2819 2825
2826authencesn:
2820 t_alg = talitos_alg_alloc(dev, &driver_algs[i]); 2827 t_alg = talitos_alg_alloc(dev, &driver_algs[i]);
2821 if (IS_ERR(t_alg)) { 2828 if (IS_ERR(t_alg)) {
2822 err = PTR_ERR(t_alg); 2829 err = PTR_ERR(t_alg);
@@ -2831,6 +2838,8 @@ static int talitos_probe(struct platform_device *ofdev)
2831 err = crypto_register_alg( 2838 err = crypto_register_alg(
2832 &t_alg->algt.alg.crypto); 2839 &t_alg->algt.alg.crypto);
2833 name = t_alg->algt.alg.crypto.cra_driver_name; 2840 name = t_alg->algt.alg.crypto.cra_driver_name;
2841 authenc = authenc ? !authenc :
2842 !(bool)memcmp(name, "authenc", 7);
2834 break; 2843 break;
2835 case CRYPTO_ALG_TYPE_AHASH: 2844 case CRYPTO_ALG_TYPE_AHASH:
2836 err = crypto_register_ahash( 2845 err = crypto_register_ahash(
@@ -2843,8 +2852,25 @@ static int talitos_probe(struct platform_device *ofdev)
2843 dev_err(dev, "%s alg registration failed\n", 2852 dev_err(dev, "%s alg registration failed\n",
2844 name); 2853 name);
2845 kfree(t_alg); 2854 kfree(t_alg);
2846 } else 2855 } else {
2847 list_add_tail(&t_alg->entry, &priv->alg_list); 2856 list_add_tail(&t_alg->entry, &priv->alg_list);
2857 if (authenc) {
2858 struct crypto_alg *alg =
2859 &driver_algs[i].alg.crypto;
2860
2861 name = alg->cra_name;
2862 memmove(name + 10, name + 7,
2863 strlen(name) - 7);
2864 memcpy(name + 7, "esn", 3);
2865
2866 name = alg->cra_driver_name;
2867 memmove(name + 10, name + 7,
2868 strlen(name) - 7);
2869 memcpy(name + 7, "esn", 3);
2870
2871 goto authencesn;
2872 }
2873 }
2848 } 2874 }
2849 } 2875 }
2850 if (!list_empty(&priv->alg_list)) 2876 if (!list_empty(&priv->alg_list))