diff options
author | Horia Geanta <horia.geanta@freescale.com> | 2012-09-04 12:18:00 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2012-09-06 16:17:07 -0400 |
commit | 891104ed008e8646c7860fe5bc70b0aac55dcc6c (patch) | |
tree | be2fddc35835ad644d8cb098a588358cd793957b /drivers | |
parent | c2b3711d11d08a34493dec45769d2e96141f8647 (diff) |
crypto: caam - add IPsec ESN support
Support for ESNs (extended sequence numbers).
Tested with strongswan by connecting back-to-back P1010RDB with P2020RDB.
Signed-off-by: Horia Geanta <horia.geanta@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/crypto/caam/caamalg.c | 27 | ||||
-rw-r--r-- | drivers/crypto/caam/compat.h | 1 |
2 files changed, 26 insertions, 2 deletions
diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c index cf268b14ae9a..b2a0a0726a54 100644 --- a/drivers/crypto/caam/caamalg.c +++ b/drivers/crypto/caam/caamalg.c | |||
@@ -1650,7 +1650,11 @@ struct caam_alg_template { | |||
1650 | }; | 1650 | }; |
1651 | 1651 | ||
1652 | static struct caam_alg_template driver_algs[] = { | 1652 | static struct caam_alg_template driver_algs[] = { |
1653 | /* single-pass ipsec_esp descriptor */ | 1653 | /* |
1654 | * single-pass ipsec_esp descriptor | ||
1655 | * authencesn(*,*) is also registered, although not present | ||
1656 | * explicitly here. | ||
1657 | */ | ||
1654 | { | 1658 | { |
1655 | .name = "authenc(hmac(md5),cbc(aes))", | 1659 | .name = "authenc(hmac(md5),cbc(aes))", |
1656 | .driver_name = "authenc-hmac-md5-cbc-aes-caam", | 1660 | .driver_name = "authenc-hmac-md5-cbc-aes-caam", |
@@ -2213,7 +2217,9 @@ static int __init caam_algapi_init(void) | |||
2213 | for (i = 0; i < ARRAY_SIZE(driver_algs); i++) { | 2217 | for (i = 0; i < ARRAY_SIZE(driver_algs); i++) { |
2214 | /* TODO: check if h/w supports alg */ | 2218 | /* TODO: check if h/w supports alg */ |
2215 | struct caam_crypto_alg *t_alg; | 2219 | struct caam_crypto_alg *t_alg; |
2220 | bool done = false; | ||
2216 | 2221 | ||
2222 | authencesn: | ||
2217 | t_alg = caam_alg_alloc(ctrldev, &driver_algs[i]); | 2223 | t_alg = caam_alg_alloc(ctrldev, &driver_algs[i]); |
2218 | if (IS_ERR(t_alg)) { | 2224 | if (IS_ERR(t_alg)) { |
2219 | err = PTR_ERR(t_alg); | 2225 | err = PTR_ERR(t_alg); |
@@ -2227,8 +2233,25 @@ static int __init caam_algapi_init(void) | |||
2227 | dev_warn(ctrldev, "%s alg registration failed\n", | 2233 | dev_warn(ctrldev, "%s alg registration failed\n", |
2228 | t_alg->crypto_alg.cra_driver_name); | 2234 | t_alg->crypto_alg.cra_driver_name); |
2229 | kfree(t_alg); | 2235 | kfree(t_alg); |
2230 | } else | 2236 | } else { |
2231 | list_add_tail(&t_alg->entry, &priv->alg_list); | 2237 | list_add_tail(&t_alg->entry, &priv->alg_list); |
2238 | if (driver_algs[i].type == CRYPTO_ALG_TYPE_AEAD && | ||
2239 | !memcmp(driver_algs[i].name, "authenc", 7) && | ||
2240 | !done) { | ||
2241 | char *name; | ||
2242 | |||
2243 | name = driver_algs[i].name; | ||
2244 | memmove(name + 10, name + 7, strlen(name) - 7); | ||
2245 | memcpy(name + 7, "esn", 3); | ||
2246 | |||
2247 | name = driver_algs[i].driver_name; | ||
2248 | memmove(name + 10, name + 7, strlen(name) - 7); | ||
2249 | memcpy(name + 7, "esn", 3); | ||
2250 | |||
2251 | done = true; | ||
2252 | goto authencesn; | ||
2253 | } | ||
2254 | } | ||
2232 | } | 2255 | } |
2233 | if (!list_empty(&priv->alg_list)) | 2256 | if (!list_empty(&priv->alg_list)) |
2234 | dev_info(ctrldev, "%s algorithms registered in /proc/crypto\n", | 2257 | dev_info(ctrldev, "%s algorithms registered in /proc/crypto\n", |
diff --git a/drivers/crypto/caam/compat.h b/drivers/crypto/caam/compat.h index 762aeff626ac..cf15e7813801 100644 --- a/drivers/crypto/caam/compat.h +++ b/drivers/crypto/caam/compat.h | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/types.h> | 23 | #include <linux/types.h> |
24 | #include <linux/debugfs.h> | 24 | #include <linux/debugfs.h> |
25 | #include <linux/circ_buf.h> | 25 | #include <linux/circ_buf.h> |
26 | #include <linux/string.h> | ||
26 | #include <net/xfrm.h> | 27 | #include <net/xfrm.h> |
27 | 28 | ||
28 | #include <crypto/algapi.h> | 29 | #include <crypto/algapi.h> |