blob: bb45c7d43739a9eb35410b7b16753b7b1c1d3bd1 [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
8/*
9 * cryptographic secret
10 */
11struct ceph_crypto_key {
12 int type;
13 struct ceph_timespec created;
14 int len;
15 void *key;
Ilya Dryomov7af3ea12016-12-02 16:35:08 +010016 struct crypto_skcipher *tfm;
Sage Weil8b6e4f22010-02-02 16:07:07 -080017};
18
Joe Perches348662a2013-10-18 13:48:22 -070019int ceph_crypto_key_clone(struct ceph_crypto_key *dst,
20 const struct ceph_crypto_key *src);
21int ceph_crypto_key_encode(struct ceph_crypto_key *key, void **p, void *end);
22int ceph_crypto_key_decode(struct ceph_crypto_key *key, void **p, void *end);
23int ceph_crypto_key_unarmor(struct ceph_crypto_key *key, const char *in);
Ilya Dryomov6db23042016-12-02 16:35:08 +010024void ceph_crypto_key_destroy(struct ceph_crypto_key *key);
Sage Weil8b6e4f22010-02-02 16:07:07 -080025
26/* crypto.c */
Ilya Dryomova45f7952016-12-02 16:35:07 +010027int ceph_crypt(const struct ceph_crypto_key *key, bool encrypt,
28 void *buf, int buf_len, int in_len, int *pout_len);
Joe Perches348662a2013-10-18 13:48:22 -070029int ceph_crypto_init(void);
30void ceph_crypto_shutdown(void);
Sage Weil8b6e4f22010-02-02 16:07:07 -080031
32/* armor.c */
Joe Perches348662a2013-10-18 13:48:22 -070033int ceph_armor(char *dst, const char *src, const char *end);
34int ceph_unarmor(char *dst, const char *src, const char *end);
Sage Weil8b6e4f22010-02-02 16:07:07 -080035
36#endif