security: Add SignatureSha256
Change-Id: Id9a61f898d12a6b289a24adb594471b26d3513d6
diff --git a/src/security/key-chain.hpp b/src/security/key-chain.hpp
index e1fcb79..28642ae 100644
--- a/src/security/key-chain.hpp
+++ b/src/security/key-chain.hpp
@@ -12,9 +12,11 @@
#include "identity-certificate.hpp"
#include "public-key.hpp"
#include "signature-sha256-with-rsa.hpp"
+#include "signature-sha256.hpp"
#include "secured-bag.hpp"
#include "../interest.hpp"
#include "../util/random.hpp"
+#include "../util/crypto.hpp"
//PublicInfo
#include "sec-public-info-sqlite3.hpp"
@@ -288,7 +290,7 @@
// We either get or create the signing certificate, sign packet! (no exception unless fatal error in TPM)
sign(packet, signingCertificateName);
}
-
+
/**
* @brief Sign the byte array using the default certificate of a particular identity.
*
@@ -316,6 +318,24 @@
}
/**
+ * @brief Set Sha256 weak signature.
+ *
+ * @param data.
+ */
+ void
+ signWithSha256(Data& data)
+ {
+ SignatureSha256 sig;
+ data.setSignature(sig);
+
+ Block sigValue(Tlv::SignatureValue,
+ crypto::sha256(data.wireEncode().value(),
+ data.wireEncode().value_size() - data.getSignature().getValue().size()));
+ data.setSignatureValue(sigValue);
+
+ }
+
+ /**
* @brief Generate a self-signed certificate for a public key.
*
* @param keyName The name of the public key.