Change-Id: I22a6d0697548927e5a396f1cd311eda649461eba
+tz_padding_type to_tz_padding_type(hal_security_keys_padding_algorithm_e padding)
+{
+ switch (padding) {
+ case HAL_SECURITY_KEYS_PADDING_ALGORITHM_NONE: return PADDING_NONE;
+ case HAL_SECURITY_KEYS_PADDING_ALGORITHM_PKCS7: return PADDING_PKCS7;
+ case HAL_SECURITY_KEYS_PADDING_ALGORITHM_ISO9797_M2: return PADDING_ISO9797_M2;
+ default:
+ throw std::invalid_argument("Requested padding algorithm is not supported");
+ }
+}
+
tz_prf to_tz_prf(hal_security_keys_kdf_prf_type_e prf)
{
switch (prf) {
tz_prf to_tz_prf(hal_security_keys_kdf_prf_type_e prf)
{
switch (prf) {
int security_keys_encrypt_data(const hal_security_keys_context_s context,
const hal_security_keys_algo_type_e algo,
const hal_security_keys_hash_algorithm_e hash,
int security_keys_encrypt_data(const hal_security_keys_context_s context,
const hal_security_keys_algo_type_e algo,
const hal_security_keys_hash_algorithm_e hash,
+ const hal_security_keys_padding_algorithm_e padding,
const hal_security_keys_data_s key_id,
const hal_security_keys_password_iv_tag_s key_pwd,
const hal_security_keys_data_s data,
const hal_security_keys_data_s key_id,
const hal_security_keys_password_iv_tag_s key_pwd,
const hal_security_keys_data_s data,
auto tz_algo_type = to_tz_algo_type(algo);
auto tz_hash_type = to_tz_hash_type(hash);
auto tz_algo_type = to_tz_algo_type(algo);
auto tz_hash_type = to_tz_hash_type(hash);
+ auto tz_padding_type = to_tz_padding_type(padding);
TZSerializer s_in;
if (tz_algo_type == ALGO_RSA)
s_in = makeSerializer(data, key_pwd, tz_hash_type, key_id);
else
TZSerializer s_in;
if (tz_algo_type == ALGO_RSA)
s_in = makeSerializer(data, key_pwd, tz_hash_type, key_id);
else
- s_in = makeSerializer(data, key_pwd, iv, key_id);
+ s_in = makeSerializer(data, key_pwd, tz_padding_type, iv, key_id);
TrustZoneMemory in_memory(*tz_context, s_in.GetSize(), TEEC_MEM_INPUT);
s_in.Serialize(in_memory);
TrustZoneMemory in_memory(*tz_context, s_in.GetSize(), TEEC_MEM_INPUT);
s_in.Serialize(in_memory);
int security_keys_decrypt_data(const hal_security_keys_context_s context,
const hal_security_keys_algo_type_e algo,
const hal_security_keys_hash_algorithm_e hash,
int security_keys_decrypt_data(const hal_security_keys_context_s context,
const hal_security_keys_algo_type_e algo,
const hal_security_keys_hash_algorithm_e hash,
+ const hal_security_keys_padding_algorithm_e padding,
const hal_security_keys_data_s key_id,
const hal_security_keys_password_iv_tag_s key_pwd,
const hal_security_keys_data_s data,
const hal_security_keys_data_s key_id,
const hal_security_keys_password_iv_tag_s key_pwd,
const hal_security_keys_data_s data,
auto tz_algo_type = to_tz_algo_type(algo);
auto tz_hash_type = to_tz_hash_type(hash);
auto tz_algo_type = to_tz_algo_type(algo);
auto tz_hash_type = to_tz_hash_type(hash);
+ auto tz_padding_type = to_tz_padding_type(padding);
TZSerializer s_in;
if (tz_algo_type == ALGO_RSA)
s_in = makeSerializer(data, key_pwd, tz_hash_type, key_id);
else
TZSerializer s_in;
if (tz_algo_type == ALGO_RSA)
s_in = makeSerializer(data, key_pwd, tz_hash_type, key_id);
else
- s_in = makeSerializer(data, key_pwd, iv, key_id);
+ s_in = makeSerializer(data, key_pwd, tz_padding_type, iv, key_id);
TrustZoneMemory in_memory(*tz_context, s_in.GetSize(), TEEC_MEM_INPUT);
s_in.Serialize(in_memory);
TrustZoneMemory in_memory(*tz_context, s_in.GetSize(), TEEC_MEM_INPUT);
s_in.Serialize(in_memory);
HASH_SHA512, /** SHA512 */
} tz_hash_type;
HASH_SHA512, /** SHA512 */
} tz_hash_type;
+/**
+ * Enumeration for padding algorithm.
+ */
+typedef enum {
+ PADDING_NONE, /** None */
+ PADDING_PKCS7, /** PKCS#7 */
+ PADDING_ISO9797_M2, /** ISO9797 method 2 padding */
+ PADDING_ZERO, /** Zero padding */
+} tz_padding_type;
+
/**
* Enumeration for data type, that can be stored on TA side.
*/
/**
* Enumeration for data type, that can be stored on TA side.
*/