- BOOST_REQUIRE_MESSAGE(input.m_type == output.m_type,
- "Algorithm types don't match: " << static_cast<int>(input.m_type) << "!="
- << static_cast<int>(output.m_type));
-
- // compare params
- auto iit = input.m_params.cbegin();
- auto oit = output.m_params.cbegin();
- for(;iit != input.m_params.cend() && oit != output.m_params.cend(); iit++, oit++ )
- {
- BOOST_REQUIRE_MESSAGE(iit->first == oit->first,
- "Param names do not match :" << static_cast<int>(iit->first) << "!="
- << static_cast<int>(oit->first));
- uint64_t integer[2];
- RawBuffer buffer[2];
- if(CKM_API_SUCCESS == iit->second->getInt(integer[0]))
- {
- BOOST_REQUIRE_MESSAGE(CKM_API_SUCCESS == oit->second->getInt(integer[1]),
- "Param types do not match");
- BOOST_REQUIRE_MESSAGE(integer[0] == integer[1], "Integer params do not match");
- }
- else if(CKM_API_SUCCESS == iit->second->getBuffer(buffer[0]))
- {
- BOOST_REQUIRE_MESSAGE(CKM_API_SUCCESS == oit->second->getBuffer(buffer[1]),
- "Param types do not match");
- BOOST_REQUIRE_MESSAGE(buffer[0] == buffer[1], "Integer params do not match");
- }
- else
- BOOST_FAIL("Wrong param type");
- }
-}
-
-BOOST_AUTO_TEST_CASE(Serialization_CryptoAlgorithm_broken_param) {
- CryptoAlgorithm ca;
- ca.m_type = AlgoType::AES_GCM;
- // unuspported param type
- ca.m_params.emplace(ParamName::ED_IV, BrokenParam::create());
-
- CryptoAlgorithmSerializable input(std::move(ca));
- BOOST_REQUIRE_THROW(auto buffer = MessageBuffer::Serialize(input),
- CryptoAlgorithmSerializable::UnsupportedParam);
+ checkIntParam(output, ParamName::ALGO_TYPE, static_cast<uint64_t>(AlgoType::AES_GCM));
+ checkBufferParam(output, ParamName::ED_IV, IV);
+ checkIntParam(output, ParamName::ED_TAG_LEN, 128);
+ checkBufferParam(output, ParamName::ED_AAD, AAD);
+
+ // wrong type
+ checkBufferParamNegative(output, ParamName::ALGO_TYPE);
+ checkIntParamNegative(output, ParamName::ED_IV);
+
+ // non-existing
+ checkBufferParamNegative(output, ParamName::ED_CTR);
+ checkIntParamNegative(output, ParamName::ED_CTR_LEN);
+ checkBufferParamNegative(output, ParamName::ED_LABEL);
+ checkIntParamNegative(output, ParamName::GEN_KEY_LEN);
+ checkIntParamNegative(output, ParamName::GEN_EC);
+ checkIntParamNegative(output, ParamName::SV_HASH_ALGO);
+ checkIntParamNegative(output, ParamName::SV_RSA_PADDING);
+
+ checkIntParamNegative(output, static_cast<ParamName>(666));