crypto.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef _FS_CEPH_CRYPTO_H
  2. #define _FS_CEPH_CRYPTO_H
  3. #include <linux/ceph/types.h>
  4. #include <linux/ceph/buffer.h>
  5. /*
  6. * cryptographic secret
  7. */
  8. struct ceph_crypto_key {
  9. int type;
  10. struct ceph_timespec created;
  11. int len;
  12. void *key;
  13. };
  14. static inline void ceph_crypto_key_destroy(struct ceph_crypto_key *key)
  15. {
  16. if (key)
  17. kfree(key->key);
  18. }
  19. int ceph_crypto_key_clone(struct ceph_crypto_key *dst,
  20. const struct ceph_crypto_key *src);
  21. int ceph_crypto_key_encode(struct ceph_crypto_key *key, void **p, void *end);
  22. int ceph_crypto_key_decode(struct ceph_crypto_key *key, void **p, void *end);
  23. int ceph_crypto_key_unarmor(struct ceph_crypto_key *key, const char *in);
  24. /* crypto.c */
  25. int ceph_decrypt(struct ceph_crypto_key *secret,
  26. void *dst, size_t *dst_len,
  27. const void *src, size_t src_len);
  28. int ceph_encrypt(struct ceph_crypto_key *secret,
  29. void *dst, size_t *dst_len,
  30. const void *src, size_t src_len);
  31. int ceph_decrypt2(struct ceph_crypto_key *secret,
  32. void *dst1, size_t *dst1_len,
  33. void *dst2, size_t *dst2_len,
  34. const void *src, size_t src_len);
  35. int ceph_encrypt2(struct ceph_crypto_key *secret,
  36. void *dst, size_t *dst_len,
  37. const void *src1, size_t src1_len,
  38. const void *src2, size_t src2_len);
  39. int ceph_crypto_init(void);
  40. void ceph_crypto_shutdown(void);
  41. /* armor.c */
  42. int ceph_armor(char *dst, const char *src, const char *end);
  43. int ceph_unarmor(char *dst, const char *src, const char *end);
  44. #endif