security: New generalized signing API in KeyChain
A new API in KeyChain introduces a general interface to sign interest
and data packets and supply necessary signing information, such as
signing identity name, signing key name, or signing certificate name.
In addition, the supplied signing information can include additional
information that signer wants to include in the SignatureInfo of the
signed packet.
Old sign methods `KeyChain::sign(Packet, Name)`, `KeyChain::sign(uint8_t*, size_t, Name)`,
`KeyChain::signByIdentity(Packet, Name)`, `KeyChain::signByIdentity(uint8_t*, size_t, Name)`,
`KeyChain::signWithSha256(Data)`, and `KeyChain::signWithSha256(Interest)`
are now deprecated and will be removed in the next release.
Change-Id: I086e6c6522f70bcb7799e7dfc4cc4b2f8a3816a0
Refs: #2871, #1705
diff --git a/tests/unit-tests/security/signature-sha256-with-ecdsa.t.cpp b/tests/unit-tests/security/signature-sha256-with-ecdsa.t.cpp
index 22b324a..2df573b 100644
--- a/tests/unit-tests/security/signature-sha256-with-ecdsa.t.cpp
+++ b/tests/unit-tests/security/signature-sha256-with-ecdsa.t.cpp
@@ -114,7 +114,9 @@
Data testData("/SecurityTestSignatureSha256WithEcdsa/DataSignature/Data1");
char content[5] = "1234";
testData.setContent(reinterpret_cast<uint8_t*>(content), 5);
- BOOST_CHECK_NO_THROW(m_keyChain.signByIdentity(testData, identityName));
+ BOOST_CHECK_NO_THROW(m_keyChain.sign(testData,
+ security::SigningInfo(security::SigningInfo::SIGNER_TYPE_ID,
+ identityName)));
Block dataBlock(testData.wireEncode().wire(), testData.wireEncode().size());
Data testData2;
@@ -136,12 +138,16 @@
Interest interest11("/SecurityTestSignatureSha256WithEcdsa/InterestSignature/Interest1");
scheduler.scheduleEvent(time::milliseconds(100), [&] {
- BOOST_CHECK_NO_THROW(m_keyChain.signByIdentity(interest, identityName));
+ BOOST_CHECK_NO_THROW(m_keyChain.sign(interest,
+ security::SigningInfo(security::SigningInfo::SIGNER_TYPE_ID,
+ identityName)));
});
advanceClocks(time::milliseconds(100));
scheduler.scheduleEvent(time::milliseconds(100), [&] {
- BOOST_CHECK_NO_THROW(m_keyChain.signByIdentity(interest11, identityName));
+ BOOST_CHECK_NO_THROW(m_keyChain.sign(interest11,
+ security::SigningInfo(security::SigningInfo::SIGNER_TYPE_ID,
+ identityName)));
});
advanceClocks(time::milliseconds(100));