improve the robustness of ndncert library
Change-Id: Iaabc4d8f28ca27a7e7f501ebd122c5231ceb3ac0
diff --git a/tests/unit-tests/crypto-helper.t.cpp b/tests/unit-tests/crypto-helper.t.cpp
index eda32d1..b6f8bd3 100644
--- a/tests/unit-tests/crypto-helper.t.cpp
+++ b/tests/unit-tests/crypto-helper.t.cpp
@@ -49,6 +49,16 @@
bobResult, bobResult + 32);
}
+BOOST_AUTO_TEST_CASE(EcdhWithRawKeyWrongInput)
+{
+ ECDHState aliceState;
+ auto alicePub = aliceState.getRawSelfPubKey();
+ BOOST_CHECK(alicePub != nullptr);
+ BOOST_CHECK(aliceState.context->publicKeyLen != 0);
+ uint8_t fakePub[] = {0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b};
+ BOOST_CHECK_THROW(aliceState.deriveSecret(fakePub, sizeof(fakePub)), CryptoError);
+}
+
BOOST_AUTO_TEST_CASE(EcdhWithBase64Key)
{
ECDHState aliceState;