-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is the first building block to provide file level encryption on UBIFS. Signed-off-by: Richard Weinberger <richard@nod.at>
- Loading branch information
Richard Weinberger
committed
Dec 12, 2016
1 parent
6a5e98a
commit d475a50
Showing
9 changed files
with
178 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include "ubifs.h" | ||
|
||
static int ubifs_crypt_get_context(struct inode *inode, void *ctx, size_t len) | ||
{ | ||
return ubifs_xattr_get(inode, UBIFS_XATTR_NAME_ENCRYPTION_CONTEXT, | ||
ctx, len); | ||
} | ||
|
||
static int ubifs_crypt_set_context(struct inode *inode, const void *ctx, | ||
size_t len, void *fs_data) | ||
{ | ||
return ubifs_xattr_set(inode, UBIFS_XATTR_NAME_ENCRYPTION_CONTEXT, | ||
ctx, len, 0); | ||
} | ||
|
||
static bool ubifs_crypt_empty_dir(struct inode *inode) | ||
{ | ||
return ubifs_check_dir_empty(inode) == 0; | ||
} | ||
|
||
static unsigned int ubifs_crypt_max_namelen(struct inode *inode) | ||
{ | ||
if (S_ISLNK(inode->i_mode)) | ||
return UBIFS_MAX_INO_DATA; | ||
else | ||
return UBIFS_MAX_NLEN; | ||
} | ||
|
||
static int ubifs_key_prefix(struct inode *inode, u8 **key) | ||
{ | ||
static char prefix[] = "ubifs:"; | ||
|
||
*key = prefix; | ||
|
||
return sizeof(prefix) - 1; | ||
} | ||
|
||
struct fscrypt_operations ubifs_crypt_operations = { | ||
.flags = FS_CFLG_INPLACE_ENCRYPTION, | ||
.get_context = ubifs_crypt_get_context, | ||
.set_context = ubifs_crypt_set_context, | ||
.is_encrypted = ubifs_crypt_is_encrypted, | ||
.empty_dir = ubifs_crypt_empty_dir, | ||
.max_namelen = ubifs_crypt_max_namelen, | ||
.key_prefix = ubifs_key_prefix, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters