ah.h 766 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 *key;
  10. int key_len;
  11. u8 *work_icv;
  12. int icv_full_len;
  13. int icv_trunc_len;
  14. struct crypto_hash *tfm;
  15. };
  16. static inline int ah_mac_digest(struct ah_data *ahp, struct sk_buff *skb,
  17. u8 *auth_data)
  18. {
  19. struct hash_desc desc;
  20. int err;
  21. desc.tfm = ahp->tfm;
  22. desc.flags = 0;
  23. memset(auth_data, 0, ahp->icv_trunc_len);
  24. err = crypto_hash_init(&desc);
  25. if (unlikely(err))
  26. goto out;
  27. err = skb_icv_walk(skb, &desc, 0, skb->len, crypto_hash_update);
  28. if (unlikely(err))
  29. goto out;
  30. err = crypto_hash_final(&desc, ahp->work_icv);
  31. out:
  32. return err;
  33. }
  34. #endif