diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ab053490..10a011314 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,6 @@ set(CMAKE_INSTALL_INCLUDEDIR include/lib3mf CACHE PATH "directory for installing option(USE_INCLUDED_ZLIB "Use included zlib" ON) option(USE_INCLUDED_LIBZIP "Use included libzip" ON) -option(USE_INCLUDED_GTEST "Used included gtest" ON) option(USE_INCLUDED_SSL "Use included libressl" ON) option(BUILD_FOR_CODECOVERAGE "Build for code coverage analysis" OFF) option(STRIP_BINARIES "Strip binaries (on non-apple)" ON) diff --git a/Include/Common/NMR_ErrorConst.h b/Include/Common/NMR_ErrorConst.h index 0d461286a..aaaf60fb8 100644 --- a/Include/Common/NMR_ErrorConst.h +++ b/Include/Common/NMR_ErrorConst.h @@ -1228,6 +1228,9 @@ Model error codes (0x8XXX) // A component resource is invalid #define NMR_ERROR_INVALIDCOMPONENTRESOURCE 0x810D +// A keystore element is not base64 encoded +#define NMR_ERROR_KEYSTOREINVALIDENCODING 0x810E + /*------------------------------------------------------------------- XML Parser Error Constants (0x9XXX) -------------------------------------------------------------------*/ diff --git a/Source/Common/NMR_Exception.cpp b/Source/Common/NMR_Exception.cpp index 0edd80259..6f5187159 100644 --- a/Source/Common/NMR_Exception.cpp +++ b/Source/Common/NMR_Exception.cpp @@ -418,6 +418,7 @@ namespace NMR { case NMR_ERROR_KEYSTOREDUPLICATEACCESSRIGHT: return "An AccessRight already exists for this consumer in a ResourceDataGroup"; case NMR_ERROR_KEYSTOREDUPLICATERESOURCEDATAGROUP: return "A resource data group already exist for this keyuuid"; case NMR_ERROR_KEYSTOREINVALIDALGORITHM: return "The algorithm attribute is invalid"; + case NMR_ERROR_KEYSTOREINVALIDENCODING: return "The keystore element value is not base64 encoded."; case NMR_ERROR_KEYSTOREINVALIDCOMPRESSION: return "The KeyStore ResourceData compression is invalid"; case NMR_ERROR_KEYSTOREINVALIDCIPHERVALUE: return "Invalid CipherValue elment value"; case NMR_ERROR_KEYSTOREINVALIDMGF: return "The mfgalgorithm attribute has invalid value"; diff --git a/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreCEKParams.cpp b/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreCEKParams.cpp index 378f4aed7..70552a1b8 100644 --- a/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreCEKParams.cpp +++ b/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreCEKParams.cpp @@ -131,6 +131,7 @@ namespace NMR { } catch (...) { // base64_decode throws an exception if the input is not valid base64 + m_pWarnings->addException(CNMRException(NMR_ERROR_KEYSTOREINVALIDENCODING), mrwInvalidOptionalValue); } } } diff --git a/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreCipherValue.cpp b/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreCipherValue.cpp index e7a61218d..5b9dcc55e 100644 --- a/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreCipherValue.cpp +++ b/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreCipherValue.cpp @@ -77,6 +77,7 @@ namespace NMR { } catch (...) { // base64_decode throws an exception if the input is not valid base64 + m_pWarnings->addException(CNMRException(NMR_ERROR_KEYSTOREINVALIDENCODING), NMR::eModelWarningLevel::mrwInvalidMandatoryValue); } } } diff --git a/Tests/CPP_Bindings/Source/SecureContent.cpp b/Tests/CPP_Bindings/Source/SecureContent.cpp index 9d4fe82f4..021db7328 100644 --- a/Tests/CPP_Bindings/Source/SecureContent.cpp +++ b/Tests/CPP_Bindings/Source/SecureContent.cpp @@ -395,7 +395,7 @@ namespace Lib3MF { TEST_F(SecureContentT, ModelReaderKeyStoreNoAttributesWarnings) { PReader reader3MF = readKeyStore(NEGATIVEUNENCRYPTEDKEYSTOREMISSINGATTRIBUTES); - CheckReaderWarnings(reader3MF, 6); + CheckReaderWarnings(reader3MF, 8); Lib3MF_uint32 iWarning = 0; // NMR_ERROR_KEYSTOREMISSINGCONSUMERID @@ -418,21 +418,32 @@ namespace Lib3MF { reader3MF->GetWarning(3, iWarning); ASSERT_EQ(0x8105, iWarning); + // NMR_ERROR_KEYSTOREINVALIDENCODING + // invalid key store element value in ResourceData + reader3MF->GetWarning(4, iWarning); + ASSERT_EQ(0x810E, iWarning); + + // NMR_ERROR_KEYSTOREINVALIDENCODING + // invalid key store element value in ResourceData + reader3MF->GetWarning(5, iWarning); + ASSERT_EQ(0x810E, iWarning); + + // NMR_ERROR_KEYSTOREMISSINGALGORTHM // missing encryptionalgorithm on cekparams - reader3MF->GetWarning(4, iWarning); + reader3MF->GetWarning(6, iWarning); ASSERT_EQ(0x810A, iWarning); // NMR_ERROR_MISSINGUUID //missing guid on keystore - reader3MF->GetWarning(5, iWarning); + reader3MF->GetWarning(7, iWarning); ASSERT_EQ(0x80B0, iWarning); } TEST_F(SecureContentT, ModelReaderKeyStoreInvalidAttributesWarnings) { PReader reader3MF = readKeyStore(NEGATIVEUNENCRYPTEDKEYSTOREINVALIDATTRIBUTES); - CheckReaderWarnings(reader3MF, 8); + CheckReaderWarnings(reader3MF, 10); Lib3MF_uint32 iWarning = 0; // NMR_ERROR_KEYSTOREDUPLICATECONSUMERID @@ -474,6 +485,16 @@ namespace Lib3MF { // invalid compression attribute in ResourceData reader3MF->GetWarning(7, iWarning); ASSERT_EQ(0x80F8, iWarning); + + // NMR_ERROR_KEYSTOREINVALIDENCODING + // invalid key store element value in ResourceData + reader3MF->GetWarning(8, iWarning); + ASSERT_EQ(0x810E, iWarning); + + // NMR_ERROR_KEYSTOREINVALIDENCODING + // invalid key store element value in ResourceData + reader3MF->GetWarning(9, iWarning); + ASSERT_EQ(0x810E, iWarning); } TEST_F(SecureContentT, CheckKeyStoreConsumers) {