crypto.h (3fd945a79e147ee10f84213976889b29049c3519) crypto.h (457117f077c6749d1e28469eae91fb69c9806768)
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Ceph fscrypt functionality
4 */
5
6#ifndef _CEPH_CRYPTO_H
7#define _CEPH_CRYPTO_H
8
9#include <crypto/sha2.h>
10#include <linux/fscrypt.h>
11
12struct ceph_fs_client;
13struct ceph_acl_sec_ctx;
14struct ceph_mds_request;
15
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Ceph fscrypt functionality
4 */
5
6#ifndef _CEPH_CRYPTO_H
7#define _CEPH_CRYPTO_H
8
9#include <crypto/sha2.h>
10#include <linux/fscrypt.h>
11
12struct ceph_fs_client;
13struct ceph_acl_sec_ctx;
14struct ceph_mds_request;
15
16struct ceph_fname {
17 struct inode *dir;
18 char *name; // b64 encoded, possibly hashed
19 unsigned char *ctext; // binary crypttext (if any)
20 u32 name_len; // length of name buffer
21 u32 ctext_len; // length of crypttext
22};
23
16struct ceph_fscrypt_auth {
17 __le32 cfa_version;
18 __le32 cfa_blob_len;
19 u8 cfa_blob[FSCRYPT_SET_CONTEXT_MAX_SIZE];
20} __packed;
21
22#define CEPH_FSCRYPT_AUTH_VERSION 1
23static inline u32 ceph_fscrypt_auth_len(struct ceph_fscrypt_auth *fa)

--- 42 unchanged lines hidden (view full) ---

66
67int ceph_fscrypt_prepare_context(struct inode *dir, struct inode *inode,
68 struct ceph_acl_sec_ctx *as);
69void ceph_fscrypt_as_ctx_to_req(struct ceph_mds_request *req,
70 struct ceph_acl_sec_ctx *as);
71int ceph_encode_encrypted_fname(const struct inode *parent,
72 struct dentry *dentry, char *buf);
73
24struct ceph_fscrypt_auth {
25 __le32 cfa_version;
26 __le32 cfa_blob_len;
27 u8 cfa_blob[FSCRYPT_SET_CONTEXT_MAX_SIZE];
28} __packed;
29
30#define CEPH_FSCRYPT_AUTH_VERSION 1
31static inline u32 ceph_fscrypt_auth_len(struct ceph_fscrypt_auth *fa)

--- 42 unchanged lines hidden (view full) ---

74
75int ceph_fscrypt_prepare_context(struct inode *dir, struct inode *inode,
76 struct ceph_acl_sec_ctx *as);
77void ceph_fscrypt_as_ctx_to_req(struct ceph_mds_request *req,
78 struct ceph_acl_sec_ctx *as);
79int ceph_encode_encrypted_fname(const struct inode *parent,
80 struct dentry *dentry, char *buf);
81
82static inline int ceph_fname_alloc_buffer(struct inode *parent,
83 struct fscrypt_str *fname)
84{
85 if (!IS_ENCRYPTED(parent))
86 return 0;
87 return fscrypt_fname_alloc_buffer(NAME_MAX, fname);
88}
89
90static inline void ceph_fname_free_buffer(struct inode *parent,
91 struct fscrypt_str *fname)
92{
93 if (IS_ENCRYPTED(parent))
94 fscrypt_fname_free_buffer(fname);
95}
96
97int ceph_fname_to_usr(const struct ceph_fname *fname, struct fscrypt_str *tname,
98 struct fscrypt_str *oname, bool *is_nokey);
99
74#else /* CONFIG_FS_ENCRYPTION */
75
76static inline void ceph_fscrypt_set_ops(struct super_block *sb)
77{
78}
79
80static inline void ceph_fscrypt_free_dummy_policy(struct ceph_fs_client *fsc)
81{

--- 13 unchanged lines hidden (view full) ---

95{
96}
97
98static inline int ceph_encode_encrypted_fname(const struct inode *parent,
99 struct dentry *dentry, char *buf)
100{
101 return -EOPNOTSUPP;
102}
100#else /* CONFIG_FS_ENCRYPTION */
101
102static inline void ceph_fscrypt_set_ops(struct super_block *sb)
103{
104}
105
106static inline void ceph_fscrypt_free_dummy_policy(struct ceph_fs_client *fsc)
107{

--- 13 unchanged lines hidden (view full) ---

121{
122}
123
124static inline int ceph_encode_encrypted_fname(const struct inode *parent,
125 struct dentry *dentry, char *buf)
126{
127 return -EOPNOTSUPP;
128}
129
130static inline int ceph_fname_alloc_buffer(struct inode *parent,
131 struct fscrypt_str *fname)
132{
133 return 0;
134}
135
136static inline void ceph_fname_free_buffer(struct inode *parent,
137 struct fscrypt_str *fname)
138{
139}
140
141static inline int ceph_fname_to_usr(const struct ceph_fname *fname,
142 struct fscrypt_str *tname,
143 struct fscrypt_str *oname, bool *is_nokey)
144{
145 oname->name = fname->name;
146 oname->len = fname->name_len;
147 return 0;
148}
103#endif /* CONFIG_FS_ENCRYPTION */
104
105#endif
149#endif /* CONFIG_FS_ENCRYPTION */
150
151#endif