5 #include <asm/scatterlist.h>
7 #define ESP_NUM_FAST_SG 4
11 struct scatterlist sgbuf[ESP_NUM_FAST_SG];
16 int key_len; /* Key length */
17 u8 *ivec; /* ivec buffer */
18 /* ivlen is offset from enc_data, where encrypted data start.
19 * It is logically different of crypto_tfm_alg_ivsize(tfm).
20 * We assume that it is either zero (no ivec), or
21 * >= crypto_tfm_alg_ivsize(tfm). */
23 int padlen; /* 0..255 */
24 struct crypto_tfm *tfm; /* crypto handle */
27 /* Integrity. It is active when icv_full_len != 0 */
30 int key_len; /* Length of the key */
34 void (*icv)(struct esp_data*,
36 int offset, int len, u8 *icv);
37 struct crypto_tfm *tfm;
41 extern int skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len);
42 extern int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer);
43 extern void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len);
46 esp_hmac_digest(struct esp_data *esp, struct sk_buff *skb, int offset,
47 int len, u8 *auth_data)
49 struct crypto_tfm *tfm = esp->auth.tfm;
50 char *icv = esp->auth.work_icv;
52 memset(auth_data, 0, esp->auth.icv_trunc_len);
53 crypto_hmac_init(tfm, esp->auth.key, &esp->auth.key_len);
54 skb_icv_walk(skb, tfm, offset, len, crypto_hmac_update);
55 crypto_hmac_final(tfm, esp->auth.key, &esp->auth.key_len, icv);
56 memcpy(auth_data, icv, esp->auth.icv_trunc_len);