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