ah.h 894 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef _NET_AH_H
  2. #define _NET_AH_H
  3. #include <linux/crypto.h>
  4. #include <net/xfrm.h>
  5. /* This is the maximum truncated ICV length that we know of. */
  6. #define MAX_AH_AUTH_LEN 12
  7. struct ah_data
  8. {
  9. u8 *work_icv;
  10. int icv_full_len;
  11. int icv_trunc_len;
  12. struct crypto_hash *tfm;
  13. };
  14. static inline int ah_mac_digest(struct ah_data *ahp, struct sk_buff *skb,
  15. u8 *auth_data)
  16. {
  17. struct hash_desc desc;
  18. int err;
  19. desc.tfm = ahp->tfm;
  20. desc.flags = 0;
  21. memset(auth_data, 0, ahp->icv_trunc_len);
  22. err = crypto_hash_init(&desc);
  23. if (unlikely(err))
  24. goto out;
  25. err = skb_icv_walk(skb, &desc, 0, skb->len, crypto_hash_update);
  26. if (unlikely(err))
  27. goto out;
  28. err = crypto_hash_final(&desc, ahp->work_icv);
  29. out:
  30. return err;
  31. }
  32. struct ip_auth_hdr;
  33. static inline struct ip_auth_hdr *ip_auth_hdr(const struct sk_buff *skb)
  34. {
  35. return (struct ip_auth_hdr *)skb_transport_header(skb);
  36. }
  37. #endif