ah.h 793 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef _NET_AH_H
  2. #define _NET_AH_H
  3. #include <net/xfrm.h>
  4. /* This is the maximum truncated ICV length that we know of. */
  5. #define MAX_AH_AUTH_LEN 12
  6. struct ah_data
  7. {
  8. u8 *key;
  9. int key_len;
  10. u8 *work_icv;
  11. int icv_full_len;
  12. int icv_trunc_len;
  13. void (*icv)(struct ah_data*,
  14. struct sk_buff *skb, u8 *icv);
  15. struct crypto_tfm *tfm;
  16. };
  17. static inline void
  18. ah_hmac_digest(struct ah_data *ahp, struct sk_buff *skb, u8 *auth_data)
  19. {
  20. struct crypto_tfm *tfm = ahp->tfm;
  21. memset(auth_data, 0, ahp->icv_trunc_len);
  22. crypto_hmac_init(tfm, ahp->key, &ahp->key_len);
  23. skb_icv_walk(skb, tfm, 0, skb->len, crypto_hmac_update);
  24. crypto_hmac_final(tfm, ahp->key, &ahp->key_len, ahp->work_icv);
  25. memcpy(auth_data, ahp->work_icv, ahp->icv_trunc_len);
  26. }
  27. #endif