diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2006-08-20 00:24:50 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2006-09-20 21:46:18 -0400 |
commit | 07d4ee583e21830ec5604d31f65cdc60a6eca19e (patch) | |
tree | 32962ef0dd13d0d1f66b143ca5d03a88d8b9f772 /include/net/esp.h | |
parent | e9d41164e2fdd897fe4520c2079ea0000f6e0ec3 (diff) |
[IPSEC]: Use HMAC template and hash interface
This patch converts IPsec to use the new HMAC template. The names of
existing simple digest algorithms may still be used to refer to their
HMAC composites.
The same structure can be used by other MACs such as AES-XCBC-MAC.
This patch also switches from the digest interface to hash.
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.h | 28 |
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, | |||
43 | extern int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer); | 43 | extern int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer); |
44 | extern void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len); | 44 | extern void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len); |
45 | 45 | ||
46 | static inline void | 46 | static inline int esp_mac_digest(struct esp_data *esp, struct sk_buff *skb, |
47 | esp_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 |