crypto.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. key->key = NULL;
  19. }
  20. }
  21. int ceph_crypto_key_clone(struct ceph_crypto_key *dst,
  22. const struct ceph_crypto_key *src);
  23. int ceph_crypto_key_encode(struct ceph_crypto_key *key, void **p, void *end);
  24. int ceph_crypto_key_decode(struct ceph_crypto_key *key, void **p, void *end);
  25. int ceph_crypto_key_unarmor(struct ceph_crypto_key *key, const char *in);
  26. /* crypto.c */
  27. int ceph_decrypt(struct ceph_crypto_key *secret,
  28. void *dst, size_t *dst_len,
  29. const void *src, size_t src_len);
  30. int ceph_encrypt(struct ceph_crypto_key *secret,
  31. void *dst, size_t *dst_len,
  32. const void *src, size_t src_len);
  33. int ceph_decrypt2(struct ceph_crypto_key *secret,
  34. void *dst1, size_t *dst1_len,
  35. void *dst2, size_t *dst2_len,
  36. const void *src, size_t src_len);
  37. int ceph_encrypt2(struct ceph_crypto_key *secret,
  38. void *dst, size_t *dst_len,
  39. const void *src1, size_t src1_len,
  40. const void *src2, size_t src2_len);
  41. int ceph_crypto_init(void);
  42. void ceph_crypto_shutdown(void);
  43. /* armor.c */
  44. int ceph_armor(char *dst, const char *src, const char *end);
  45. int ceph_unarmor(char *dst, const char *src, const char *end);
  46. #endif