aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/esp.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/esp.h')
-rw-r--r--include/net/esp.h28
1 files changed, 16 insertions, 12 deletions
diff --git a/include/net/esp.h b/include/net/esp.h
index af2ff18700c7..064366d66eea 100644
--- a/include/net/esp.h
+++ b/include/net/esp.h
@@ -35,7 +35,7 @@ struct esp_data
35 void (*icv)(struct esp_data*, 35 void (*icv)(struct esp_data*,
36 struct sk_buff *skb, 36 struct sk_buff *skb,
37 int offset, int len, u8 *icv); 37 int offset, int len, u8 *icv);
38 struct crypto_tfm *tfm; 38 struct crypto_hash *tfm;
39 } auth; 39 } auth;
40}; 40};
41 41
@@ -43,18 +43,22 @@ extern int skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset,
43extern int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer); 43extern int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer);
44extern void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len); 44extern void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len);
45 45
46static inline void 46static inline int esp_mac_digest(struct esp_data *esp, struct sk_buff *skb,
47esp_hmac_digest(struct esp_data *esp, struct sk_buff *skb, int offset, 47 int offset, int len)
48 int len, u8 *auth_data)
49{ 48{
50 struct crypto_tfm *tfm = esp->auth.tfm; 49 struct hash_desc desc;
51 char *icv = esp->auth.work_icv; 50 int err;
52 51
53 memset(auth_data, 0, esp->auth.icv_trunc_len); 52 desc.tfm = esp->auth.tfm;
54 crypto_hmac_init(tfm, esp->auth.key, &esp->auth.key_len); 53 desc.flags = 0;
55 skb_icv_walk(skb, tfm, offset, len, crypto_hmac_update); 54
56 crypto_hmac_final(tfm, esp->auth.key, &esp->auth.key_len, icv); 55 err = crypto_hash_init(&desc);
57 memcpy(auth_data, icv, esp->auth.icv_trunc_len); 56 if (unlikely(err))
57 return err;
58 err = skb_icv_walk(skb, &desc, offset, len, crypto_hash_update);
59 if (unlikely(err))
60 return err;
61 return crypto_hash_final(&desc, esp->auth.work_icv);
58} 62}
59 63
60#endif 64#endif