#include <linux/uaccess.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/parser.h>
#include <linux/string.h>
#include <linux/err.h>
#include <keys/user-type.h>
#include <keys/trusted-type.h>
#include <keys/encrypted-type.h>
#include <linux/key-type.h>
#include <linux/random.h>
#include <linux/rcupdate.h>
#include <linux/scatterlist.h>
#include <linux/ctype.h>
#include <crypto/aes.h>
#include <crypto/hash.h>
#include <crypto/sha2.h>
#include <crypto/skcipher.h>
#include <crypto/utils.h>
#include "encrypted.h"
#include "ecryptfs_format.h"
static const char KEY_TRUSTED_PREFIX[] = …;
static const char KEY_USER_PREFIX[] = …;
static const char hash_alg[] = …;
static const char hmac_alg[] = …;
static const char blkcipher_alg[] = …;
static const char key_format_default[] = …;
static const char key_format_ecryptfs[] = …;
static const char key_format_enc32[] = …;
static unsigned int ivsize;
static int blksize;
#define KEY_TRUSTED_PREFIX_LEN …
#define KEY_USER_PREFIX_LEN …
#define KEY_ECRYPTFS_DESC_LEN …
#define HASH_SIZE …
#define MAX_DATA_SIZE …
#define MIN_DATA_SIZE …
#define KEY_ENC32_PAYLOAD_LEN …
static struct crypto_shash *hash_tfm;
enum { … };
enum { … };
static const match_table_t key_format_tokens = …;
static const match_table_t key_tokens = …;
static bool user_decrypted_data = … IS_ENABLED(…);
module_param(user_decrypted_data, bool, 0);
MODULE_PARM_DESC(…) …;
static int aes_get_sizes(void)
{ … }
static int valid_ecryptfs_desc(const char *ecryptfs_desc)
{ … }
static int valid_master_desc(const char *new_desc, const char *orig_desc)
{ … }
static int datablob_parse(char *datablob, const char **format,
char **master_desc, char **decrypted_datalen,
char **hex_encoded_iv, char **decrypted_data)
{ … }
static char *datablob_format(struct encrypted_key_payload *epayload,
size_t asciiblob_len)
{ … }
static struct key *request_user_key(const char *master_desc, const u8 **master_key,
size_t *master_keylen)
{ … }
static int calc_hmac(u8 *digest, const u8 *key, unsigned int keylen,
const u8 *buf, unsigned int buflen)
{ … }
enum derived_key_type { … };
static int get_derived_key(u8 *derived_key, enum derived_key_type key_type,
const u8 *master_key, size_t master_keylen)
{ … }
static struct skcipher_request *init_skcipher_req(const u8 *key,
unsigned int key_len)
{ … }
static struct key *request_master_key(struct encrypted_key_payload *epayload,
const u8 **master_key, size_t *master_keylen)
{ … }
static int derived_key_encrypt(struct encrypted_key_payload *epayload,
const u8 *derived_key,
unsigned int derived_keylen)
{ … }
static int datablob_hmac_append(struct encrypted_key_payload *epayload,
const u8 *master_key, size_t master_keylen)
{ … }
static int datablob_hmac_verify(struct encrypted_key_payload *epayload,
const u8 *format, const u8 *master_key,
size_t master_keylen)
{ … }
static int derived_key_decrypt(struct encrypted_key_payload *epayload,
const u8 *derived_key,
unsigned int derived_keylen)
{ … }
static struct encrypted_key_payload *encrypted_key_alloc(struct key *key,
const char *format,
const char *master_desc,
const char *datalen,
const char *decrypted_data)
{ … }
static int encrypted_key_decrypt(struct encrypted_key_payload *epayload,
const char *format, const char *hex_encoded_iv)
{ … }
static void __ekey_init(struct encrypted_key_payload *epayload,
const char *format, const char *master_desc,
const char *datalen)
{ … }
static int encrypted_init(struct encrypted_key_payload *epayload,
const char *key_desc, const char *format,
const char *master_desc, const char *datalen,
const char *hex_encoded_iv, const char *decrypted_data)
{ … }
static int encrypted_instantiate(struct key *key,
struct key_preparsed_payload *prep)
{ … }
static void encrypted_rcu_free(struct rcu_head *rcu)
{ … }
static int encrypted_update(struct key *key, struct key_preparsed_payload *prep)
{ … }
static long encrypted_read(const struct key *key, char *buffer,
size_t buflen)
{ … }
static void encrypted_destroy(struct key *key)
{ … }
struct key_type key_type_encrypted = …;
EXPORT_SYMBOL_GPL(…);
static int __init init_encrypted(void)
{ … }
static void __exit cleanup_encrypted(void)
{ … }
late_initcall(init_encrypted);
module_exit(cleanup_encrypted);
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;