blob: 13bd526349fa1b63b71f84fb4ab1076fc1d2a7f2 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Sage Weil8b6e4f22010-02-02 16:07:07 -08002#ifndef _FS_CEPH_CRYPTO_H
3#define _FS_CEPH_CRYPTO_H
4
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -07005#include <linux/ceph/types.h>
6#include <linux/ceph/buffer.h>
Sage Weil8b6e4f22010-02-02 16:07:07 -08007
Ilya Dryomov285ea34f2020-10-26 16:47:20 +01008#define CEPH_KEY_LEN 16
9#define CEPH_MAX_CON_SECRET_LEN 64
10
Sage Weil8b6e4f22010-02-02 16:07:07 -080011/*
12 * cryptographic secret
13 */
14struct ceph_crypto_key {
15 int type;
16 struct ceph_timespec created;
17 int len;
18 void *key;
Kees Cook69d6302b2018-09-18 19:10:45 -070019 struct crypto_sync_skcipher *tfm;
Sage Weil8b6e4f22010-02-02 16:07:07 -080020};
21
Joe Perches348662a2013-10-18 13:48:22 -070022int ceph_crypto_key_clone(struct ceph_crypto_key *dst,
23 const struct ceph_crypto_key *src);
24int ceph_crypto_key_encode(struct ceph_crypto_key *key, void **p, void *end);
25int ceph_crypto_key_decode(struct ceph_crypto_key *key, void **p, void *end);
26int ceph_crypto_key_unarmor(struct ceph_crypto_key *key, const char *in);
Ilya Dryomov6db23042016-12-02 16:35:08 +010027void ceph_crypto_key_destroy(struct ceph_crypto_key *key);
Sage Weil8b6e4f22010-02-02 16:07:07 -080028
29/* crypto.c */
Ilya Dryomova45f7952016-12-02 16:35:07 +010030int ceph_crypt(const struct ceph_crypto_key *key, bool encrypt,
31 void *buf, int buf_len, int in_len, int *pout_len);
Joe Perches348662a2013-10-18 13:48:22 -070032int ceph_crypto_init(void);
33void ceph_crypto_shutdown(void);
Sage Weil8b6e4f22010-02-02 16:07:07 -080034
35/* armor.c */
Joe Perches348662a2013-10-18 13:48:22 -070036int ceph_armor(char *dst, const char *src, const char *end);
37int ceph_unarmor(char *dst, const char *src, const char *end);
Sage Weil8b6e4f22010-02-02 16:07:07 -080038
39#endif