crypto.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. extern int ceph_crypto_key_clone(struct ceph_crypto_key *dst,
  20. const struct ceph_crypto_key *src);
  21. extern int ceph_crypto_key_encode(struct ceph_crypto_key *key,
  22. void **p, void *end);
  23. extern int ceph_crypto_key_decode(struct ceph_crypto_key *key,
  24. void **p, void *end);
  25. extern int ceph_crypto_key_unarmor(struct ceph_crypto_key *key, const char *in);
  26. /* crypto.c */
  27. extern int ceph_decrypt(struct ceph_crypto_key *secret,
  28. void *dst, size_t *dst_len,
  29. const void *src, size_t src_len);
  30. extern int ceph_encrypt(struct ceph_crypto_key *secret,
  31. void *dst, size_t *dst_len,
  32. const void *src, size_t src_len);
  33. extern 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. extern 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_crypt(const struct ceph_crypto_key *key, bool encrypt,
  42. void *buf, int buf_len, int in_len, int *pout_len);
  43. extern int ceph_crypto_init(void);
  44. extern void ceph_crypto_shutdown(void);
  45. /* armor.c */
  46. extern int ceph_armor(char *dst, const char *src, const char *end);
  47. extern int ceph_unarmor(char *dst, const char *src, const char *end);
  48. #endif