aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/esp.h
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2008-01-28 22:35:05 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-31 22:27:02 -0500
commit38320c70d282be1997a5204c7c7fe14c3aa6bfaa (patch)
treeaa86d8c3e26a3cc6d283a31b21116a35c7659f8f /include/net/esp.h
parentbf164cc054d568fa7889ffab41d3b091f5758c75 (diff)
[IPSEC]: Use crypto_aead and authenc in ESP
This patch converts ESP to use the crypto_aead interface and in particular the authenc algorithm. This lays the foundations for future support of combined mode algorithms. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/esp.h')
-rw-r--r--include/net/esp.h54
1 files changed, 8 insertions, 46 deletions
diff --git a/include/net/esp.h b/include/net/esp.h
index c05f529bff28..d58451331dbd 100644
--- a/include/net/esp.h
+++ b/include/net/esp.h
@@ -1,58 +1,20 @@
1#ifndef _NET_ESP_H 1#ifndef _NET_ESP_H
2#define _NET_ESP_H 2#define _NET_ESP_H
3 3
4#include <linux/crypto.h> 4#include <linux/skbuff.h>
5#include <net/xfrm.h>
6#include <linux/scatterlist.h>
7 5
8#define ESP_NUM_FAST_SG 4 6struct crypto_aead;
9 7
10struct esp_data 8struct esp_data {
11{ 9 /* 0..255 */
12 struct scatterlist sgbuf[ESP_NUM_FAST_SG]; 10 int padlen;
13 11
14 /* Confidentiality */ 12 /* Confidentiality & Integrity */
15 struct { 13 struct crypto_aead *aead;
16 int padlen; /* 0..255 */
17 /* ivlen is offset from enc_data, where encrypted data start.
18 * It is logically different of crypto_tfm_alg_ivsize(tfm).
19 * We assume that it is either zero (no ivec), or
20 * >= crypto_tfm_alg_ivsize(tfm). */
21 int ivlen;
22 int ivinitted;
23 u8 *ivec; /* ivec buffer */
24 struct crypto_blkcipher *tfm; /* crypto handle */
25 } conf;
26
27 /* Integrity. It is active when icv_full_len != 0 */
28 struct {
29 u8 *work_icv;
30 int icv_full_len;
31 int icv_trunc_len;
32 struct crypto_hash *tfm;
33 } auth;
34}; 14};
35 15
36extern void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len); 16extern void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len);
37 17
38static inline int esp_mac_digest(struct esp_data *esp, struct sk_buff *skb,
39 int offset, int len)
40{
41 struct hash_desc desc;
42 int err;
43
44 desc.tfm = esp->auth.tfm;
45 desc.flags = 0;
46
47 err = crypto_hash_init(&desc);
48 if (unlikely(err))
49 return err;
50 err = skb_icv_walk(skb, &desc, offset, len, crypto_hash_update);
51 if (unlikely(err))
52 return err;
53 return crypto_hash_final(&desc, esp->auth.work_icv);
54}
55
56struct ip_esp_hdr; 18struct ip_esp_hdr;
57 19
58static inline struct ip_esp_hdr *ip_esp_hdr(const struct sk_buff *skb) 20static inline struct ip_esp_hdr *ip_esp_hdr(const struct sk_buff *skb)