xref: /openbmc/linux/net/ceph/crypto.h (revision cdd38c5f1ce4398ec58fec95904b75824daab7b5)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
23d14c5d2SYehuda Sadeh #ifndef _FS_CEPH_CRYPTO_H
33d14c5d2SYehuda Sadeh #define _FS_CEPH_CRYPTO_H
43d14c5d2SYehuda Sadeh 
53d14c5d2SYehuda Sadeh #include <linux/ceph/types.h>
63d14c5d2SYehuda Sadeh #include <linux/ceph/buffer.h>
73d14c5d2SYehuda Sadeh 
8*285ea34fSIlya Dryomov #define CEPH_KEY_LEN			16
9*285ea34fSIlya Dryomov #define CEPH_MAX_CON_SECRET_LEN		64
10*285ea34fSIlya Dryomov 
113d14c5d2SYehuda Sadeh /*
123d14c5d2SYehuda Sadeh  * cryptographic secret
133d14c5d2SYehuda Sadeh  */
143d14c5d2SYehuda Sadeh struct ceph_crypto_key {
153d14c5d2SYehuda Sadeh 	int type;
163d14c5d2SYehuda Sadeh 	struct ceph_timespec created;
173d14c5d2SYehuda Sadeh 	int len;
183d14c5d2SYehuda Sadeh 	void *key;
1969d6302bSKees Cook 	struct crypto_sync_skcipher *tfm;
203d14c5d2SYehuda Sadeh };
213d14c5d2SYehuda Sadeh 
22348662a1SJoe Perches int ceph_crypto_key_clone(struct ceph_crypto_key *dst,
238323c3aaSTommi Virtanen 			  const struct ceph_crypto_key *src);
24348662a1SJoe Perches int ceph_crypto_key_encode(struct ceph_crypto_key *key, void **p, void *end);
25348662a1SJoe Perches int ceph_crypto_key_decode(struct ceph_crypto_key *key, void **p, void *end);
26348662a1SJoe Perches int ceph_crypto_key_unarmor(struct ceph_crypto_key *key, const char *in);
276db2304aSIlya Dryomov void ceph_crypto_key_destroy(struct ceph_crypto_key *key);
283d14c5d2SYehuda Sadeh 
293d14c5d2SYehuda Sadeh /* crypto.c */
30a45f795cSIlya Dryomov int ceph_crypt(const struct ceph_crypto_key *key, bool encrypt,
31a45f795cSIlya Dryomov 	       void *buf, int buf_len, int in_len, int *pout_len);
32348662a1SJoe Perches int ceph_crypto_init(void);
33348662a1SJoe Perches void ceph_crypto_shutdown(void);
343d14c5d2SYehuda Sadeh 
353d14c5d2SYehuda Sadeh /* armor.c */
36348662a1SJoe Perches int ceph_armor(char *dst, const char *src, const char *end);
37348662a1SJoe Perches int ceph_unarmor(char *dst, const char *src, const char *end);
383d14c5d2SYehuda Sadeh 
393d14c5d2SYehuda Sadeh #endif
40