};
checkHash(CKMC_HASH_SHA1);
checkHash(CKMC_HASH_SHA256);
+ checkHash(CKMC_HASH_SHA384);
+ checkHash(CKMC_HASH_SHA512);
}
-RUNNER_TEST_MULTIPLE(TED_1370_rsa_invalid_hashes, SyncEnv, AsyncEnv)
+RUNNER_TEST_MULTIPLE(TED_1370_rsa_invalid_hash, SyncEnv, AsyncEnv)
{
// prepare buffers
RawBufferPtr plain = create_raw_buffer(createRandomBufferCAPI(126));
ckmc_param_list_h handle = NULL;
assert_positive(ckmc_generate_new_params, CKMC_ALGO_RSA_OAEP, &handle);
auto params = ParamListPtr(handle, ckmc_param_list_free);
+ setParam(params, CKMC_PARAM_ED_OAEP_HASH, CKMC_HASH_NONE);
- auto hashInvalid = [&](ckmc_hash_algo_e hash){
- setParam(params, CKMC_PARAM_ED_OAEP_HASH, static_cast<uint64_t>(hash));
-
- assert_crypto_result(EncryptionError::INVALID_PARAM,
- apiEncrypt,
- params.get(),
- aliases.pub.c_str(),
- nullptr,
- *plain.get(),
- &encrypted);
- };
+ assert_crypto_result(EncryptionError::INVALID_PARAM,
+ apiEncrypt,
+ params.get(),
+ aliases.pub.c_str(),
+ nullptr,
+ *plain.get(),
+ &encrypted);
- hashInvalid(CKMC_HASH_NONE);
- hashInvalid(CKMC_HASH_SHA384);
- hashInvalid(CKMC_HASH_SHA512);
}
/////////////////////////////////////////
RUNNER_TEST(TKW_RSAOAEP_EXPORT_INVALID_HASH){
ParamListPtr params = getDefaultParams(RSA_OAEP_ALGO);
ckmc_key_s *wrappedKey = nullptr;
+ setParam(params, CKMC_PARAM_ED_OAEP_HASH, CKMC_HASH_NONE);
- auto checkHash = [&](ckmc_hash_algo_e hash){
- setParam(params, CKMC_PARAM_ED_OAEP_HASH, hash);
-
- assert_invalid_param(ckmc_export_wrapped_key,
- params.get(),
- RSA_KEY_1024_PUB_ALIAS.c_str(),
- nullptr,
- AES_KEY_128_ALIAS.c_str(),
- nullptr,
- &wrappedKey);
- };
+ assert_invalid_param(ckmc_export_wrapped_key,
+ params.get(),
+ RSA_KEY_1024_PUB_ALIAS.c_str(),
+ nullptr,
+ AES_KEY_128_ALIAS.c_str(),
+ nullptr,
+ &wrappedKey);
- checkHash(CKMC_HASH_NONE);
- checkHash(CKMC_HASH_SHA384);
- checkHash(CKMC_HASH_SHA512);
}
RUNNER_TEST(TKW_WRONG_TYPE_WRAPPING_KEY){
RUNNER_TEST(TKW_IMPORT_EXPORT_RSA_HASH){
auto test = [](const Alias &wrappingKeyAlias, const Alias &unwrappingKeyAlias){
- for (auto hash : {CKMC_HASH_SHA1, CKMC_HASH_SHA256}) {
+ for (auto hash : {CKMC_HASH_SHA1, CKMC_HASH_SHA256, CKMC_HASH_SHA384, CKMC_HASH_SHA512}) {
// DEFAULT_IV will be ignored by RSA
testImportExportCustomParameters(RSA_OAEP_ALGO,
wrappingKeyAlias,
hash);
}
};
- test(RSA_KEY_1024_PUB_ALIAS, RSA_KEY_1024_PRV_ALIAS);
test(RSA_KEY_2048_PUB_ALIAS, RSA_KEY_2048_PRV_ALIAS);
test(RSA_KEY_3072_PUB_ALIAS, RSA_KEY_3072_PRV_ALIAS);
#ifndef TZ_LEGACY_BACKEND // no support for RSA 4k keys in old TEE implementations
#endif
}
+RUNNER_TEST(TKW_RSAOAEP_EXPORT_DATA_LIMIT){
+ ParamListPtr params = getDefaultParams(RSA_OAEP_ALGO);
+ ckmc_key_s *wrappedKey = nullptr;
+
+ auto checkHash = [&](ckmc_hash_algo_e hash){
+ setParam(params, CKMC_PARAM_ED_OAEP_HASH, hash);
+
+ assert_invalid_param(ckmc_export_wrapped_key,
+ params.get(),
+ RSA_KEY_1024_PUB_ALIAS.c_str(),
+ nullptr,
+ AES_KEY_256_ALIAS.c_str(),
+ nullptr,
+ &wrappedKey);
+ };
+
+ checkHash(CKMC_HASH_SHA384);
+ //checkHash(CKMC_HASH_SHA512); // TODO TA panicked while executing command
+}
+
RUNNER_TEST(TKW_RSA_WRAPPED_KEY){
ParamListPtr params = getDefaultParams(AES_CTR_ALGO);