Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3fc3d715 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "pfk: add changes for clear key support"

parents da69d8be 686016dc
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@
#include <linux/ion_kernel.h>
#include <linux/compat.h>
#include "compat_qseecom.h"
#include <linux/pfk.h>

#define QSEECOM_DEV			"qseecom"
#define QSEOS_VERSION_14		0x14
@@ -7741,6 +7742,19 @@ static inline long qseecom_ioctl(struct file *file,
		qcom_ice_set_fde_flag(ice_data.flag);
		break;
	}
	case QSEECOM_IOCTL_FBE_CLEAR_KEY: {
		struct qseecom_ice_key_data_t key_data;

		ret = copy_from_user(&key_data, argp, sizeof(key_data));
		if (ret) {
			pr_err("copy from user failed\n");
			return -EFAULT;
		}
		pfk_fbe_clear_key((const unsigned char *) key_data.key,
				key_data.key_len, (const unsigned char *)
				key_data.salt, key_data.salt_len);
		break;
	}
	default:
		pr_err("Invalid IOCTL: 0x%x\n", cmd);
		return -EINVAL;
+8 −0
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ int pfk_load_key_start(const struct bio *bio,
				bool *is_pfe, bool async);
int pfk_load_key_end(const struct bio *bio, bool *is_pfe);
int pfk_remove_key(const unsigned char *key, size_t key_size);
int pfk_fbe_clear_key(const unsigned char *key, size_t key_size,
		const unsigned char *salt, size_t salt_size);
bool pfk_allow_merge_bio(const struct bio *bio1, const struct bio *bio2);
void pfk_clear_on_reset(void);

@@ -63,6 +65,12 @@ static inline bool pfk_allow_merge_bio(const struct bio *bio1,
	return true;
}

static inline int pfk_fbe_clear_key(const unsigned char *key, size_t key_size,
			const unsigned char *salt, size_t salt_size)
{
	return -ENODEV;
}

static inline void pfk_clear_on_reset(void)
{}

+13 −0
Original line number Diff line number Diff line
@@ -12,6 +12,9 @@
#define QSEECOM_TA_ION_ALLOCATE_DELAY           50
#define QSEECOM_TA_ION_ALLOCATE_MAX_ATTEMP      20

#define ICE_KEY_SIZE 32
#define ICE_SALT_SIZE 32

/*
 * struct qseecom_register_listener_req -
 *      for register listener ioctl request
@@ -281,6 +284,13 @@ struct qseecom_ce_info_req {
	struct qseecom_ce_pipe_entry ce_pipe_entry[MAX_CE_PIPE_PAIR_PER_UNIT];
};

struct qseecom_ice_key_data_t {
	uint8_t key[ICE_KEY_SIZE];
	uint32_t key_len;
	uint8_t salt[ICE_SALT_SIZE];
	uint32_t salt_len;
};

#define SG_ENTRY_SZ		sizeof(struct qseecom_sg_entry)
#define SG_ENTRY_SZ_64BIT	sizeof(struct qseecom_sg_entry_64bit)

@@ -392,4 +402,7 @@ struct file;
#define QSEECOM_IOCTL_SET_ICE_INFO \
	_IOWR(QSEECOM_IOC_MAGIC, 43, struct qseecom_ice_data_t)

#define QSEECOM_IOCTL_FBE_CLEAR_KEY \
	_IOWR(QSEECOM_IOC_MAGIC, 44, struct qseecom_ice_key_data_t)

#endif /* _UAPI_QSEECOM_H_ */
+14 −0
Original line number Diff line number Diff line
@@ -533,6 +533,20 @@ bool pfk_allow_merge_bio(const struct bio *bio1, const struct bio *bio2)
		 !crypto_memneq(key1->raw, key2->raw, sizeof(key1->raw)));
}

int pfk_fbe_clear_key(const unsigned char *key, size_t key_size,
		const unsigned char *salt, size_t salt_size)
{
	int ret = -EINVAL;

	if (!key || !salt)
		return ret;

	ret = pfk_kc_remove_key_with_salt(key, key_size, salt, salt_size);
	if (ret)
		pr_err("Clear key error: ret value %d\n", ret);
	return ret;
}

/**
 * Flush key table on storage core reset. During core reset key configuration
 * is lost in ICE. We need to flash the cache, so that the keys will be