xref: /OK3568_Linux_fs/kernel/net/ceph/crypto.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef _FS_CEPH_CRYPTO_H
3*4882a593Smuzhiyun #define _FS_CEPH_CRYPTO_H
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #include <linux/ceph/types.h>
6*4882a593Smuzhiyun #include <linux/ceph/buffer.h>
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun /*
9*4882a593Smuzhiyun  * cryptographic secret
10*4882a593Smuzhiyun  */
11*4882a593Smuzhiyun struct ceph_crypto_key {
12*4882a593Smuzhiyun 	int type;
13*4882a593Smuzhiyun 	struct ceph_timespec created;
14*4882a593Smuzhiyun 	int len;
15*4882a593Smuzhiyun 	void *key;
16*4882a593Smuzhiyun 	struct crypto_sync_skcipher *tfm;
17*4882a593Smuzhiyun };
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun int ceph_crypto_key_clone(struct ceph_crypto_key *dst,
20*4882a593Smuzhiyun 			  const struct ceph_crypto_key *src);
21*4882a593Smuzhiyun int ceph_crypto_key_encode(struct ceph_crypto_key *key, void **p, void *end);
22*4882a593Smuzhiyun int ceph_crypto_key_decode(struct ceph_crypto_key *key, void **p, void *end);
23*4882a593Smuzhiyun int ceph_crypto_key_unarmor(struct ceph_crypto_key *key, const char *in);
24*4882a593Smuzhiyun void ceph_crypto_key_destroy(struct ceph_crypto_key *key);
25*4882a593Smuzhiyun 
26*4882a593Smuzhiyun /* crypto.c */
27*4882a593Smuzhiyun int ceph_crypt(const struct ceph_crypto_key *key, bool encrypt,
28*4882a593Smuzhiyun 	       void *buf, int buf_len, int in_len, int *pout_len);
29*4882a593Smuzhiyun int ceph_crypto_init(void);
30*4882a593Smuzhiyun void ceph_crypto_shutdown(void);
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun /* armor.c */
33*4882a593Smuzhiyun int ceph_armor(char *dst, const char *src, const char *end);
34*4882a593Smuzhiyun int ceph_unarmor(char *dst, const char *src, const char *end);
35*4882a593Smuzhiyun 
36*4882a593Smuzhiyun #endif
37