blob: 2e9cab09f37ba65c9c5961c12e10d2aded02413f [file] [log] [blame]
Sage Weil8b6e4f22010-02-02 16:07:07 -08001#ifndef _FS_CEPH_CRYPTO_H
2#define _FS_CEPH_CRYPTO_H
3
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -07004#include <linux/ceph/types.h>
5#include <linux/ceph/buffer.h>
Sage Weil8b6e4f22010-02-02 16:07:07 -08006
7/*
8 * cryptographic secret
9 */
10struct ceph_crypto_key {
11 int type;
12 struct ceph_timespec created;
13 int len;
14 void *key;
15};
16
17static inline void ceph_crypto_key_destroy(struct ceph_crypto_key *key)
18{
Ilya Dryomovcbf99a12015-10-26 11:03:46 +010019 if (key) {
Sylvain Munautf0666b12012-08-02 09:12:59 -070020 kfree(key->key);
Ilya Dryomovcbf99a12015-10-26 11:03:46 +010021 key->key = NULL;
22 }
Sage Weil8b6e4f22010-02-02 16:07:07 -080023}
24
Joe Perches348662a2013-10-18 13:48:22 -070025int ceph_crypto_key_clone(struct ceph_crypto_key *dst,
26 const struct ceph_crypto_key *src);
27int ceph_crypto_key_encode(struct ceph_crypto_key *key, void **p, void *end);
28int ceph_crypto_key_decode(struct ceph_crypto_key *key, void **p, void *end);
29int ceph_crypto_key_unarmor(struct ceph_crypto_key *key, const char *in);
Sage Weil8b6e4f22010-02-02 16:07:07 -080030
31/* crypto.c */
Joe Perches348662a2013-10-18 13:48:22 -070032int ceph_decrypt(struct ceph_crypto_key *secret,
33 void *dst, size_t *dst_len,
34 const void *src, size_t src_len);
35int ceph_encrypt(struct ceph_crypto_key *secret,
36 void *dst, size_t *dst_len,
37 const void *src, size_t src_len);
38int ceph_decrypt2(struct ceph_crypto_key *secret,
39 void *dst1, size_t *dst1_len,
40 void *dst2, size_t *dst2_len,
41 const void *src, size_t src_len);
42int ceph_encrypt2(struct ceph_crypto_key *secret,
43 void *dst, size_t *dst_len,
44 const void *src1, size_t src1_len,
45 const void *src2, size_t src2_len);
46int ceph_crypto_init(void);
47void ceph_crypto_shutdown(void);
Sage Weil8b6e4f22010-02-02 16:07:07 -080048
49/* armor.c */
Joe Perches348662a2013-10-18 13:48:22 -070050int ceph_armor(char *dst, const char *src, const char *end);
51int ceph_unarmor(char *dst, const char *src, const char *end);
Sage Weil8b6e4f22010-02-02 16:07:07 -080052
53#endif