integrity.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (C) 2009-2010 IBM Corporation
  3. *
  4. * Authors:
  5. * Mimi Zohar <zohar@us.ibm.com>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation, version 2 of the
  10. * License.
  11. *
  12. */
  13. #include <linux/types.h>
  14. #include <linux/integrity.h>
  15. #include <crypto/sha.h>
  16. /* iint cache flags */
  17. #define IMA_MEASURED 0x01
  18. enum evm_ima_xattr_type {
  19. IMA_XATTR_DIGEST = 0x01,
  20. EVM_XATTR_HMAC,
  21. EVM_IMA_XATTR_DIGSIG,
  22. };
  23. struct evm_ima_xattr_data {
  24. u8 type;
  25. u8 digest[SHA1_DIGEST_SIZE];
  26. } __attribute__((packed));
  27. /* integrity data associated with an inode */
  28. struct integrity_iint_cache {
  29. struct rb_node rb_node; /* rooted in integrity_iint_tree */
  30. struct inode *inode; /* back pointer to inode in question */
  31. u64 version; /* track inode changes */
  32. unsigned char flags;
  33. u8 digest[SHA1_DIGEST_SIZE];
  34. struct mutex mutex; /* protects: version, flags, digest */
  35. enum integrity_status evm_status;
  36. };
  37. /* rbtree tree calls to lookup, insert, delete
  38. * integrity data associated with an inode.
  39. */
  40. struct integrity_iint_cache *integrity_iint_insert(struct inode *inode);
  41. struct integrity_iint_cache *integrity_iint_find(struct inode *inode);
  42. #define INTEGRITY_KEYRING_EVM 0
  43. #define INTEGRITY_KEYRING_MODULE 1
  44. #define INTEGRITY_KEYRING_IMA 2
  45. #define INTEGRITY_KEYRING_MAX 3
  46. #ifdef CONFIG_INTEGRITY_SIGNATURE
  47. int integrity_digsig_verify(const unsigned int id, const char *sig, int siglen,
  48. const char *digest, int digestlen);
  49. #else
  50. static inline int integrity_digsig_verify(const unsigned int id,
  51. const char *sig, int siglen,
  52. const char *digest, int digestlen)
  53. {
  54. return -EOPNOTSUPP;
  55. }
  56. #endif /* CONFIG_INTEGRITY_SIGNATURE */
  57. /* set during initialization */
  58. extern int iint_initialized;