security: Properly initialize state in `SigningInfo(const std::string&)` constructor

Change-Id: Ie5aad142ed6ab0545f6804677e9c8a537ddc9b97
refs: #3365
diff --git a/src/security/signing-info.cpp b/src/security/signing-info.cpp
index 283484b..0872167 100644
--- a/src/security/signing-info.cpp
+++ b/src/security/signing-info.cpp
@@ -40,8 +40,9 @@
 
 SigningInfo::SigningInfo(const std::string& signingStr)
 {
+  *this = SigningInfo();
+
   if (signingStr.empty()) {
-    *this = SigningInfo();
     return;
   }
 
diff --git a/tests/unit-tests/security/signing-info.t.cpp b/tests/unit-tests/security/signing-info.t.cpp
index 2481747..e75efd1 100644
--- a/tests/unit-tests/security/signing-info.t.cpp
+++ b/tests/unit-tests/security/signing-info.t.cpp
@@ -52,34 +52,42 @@
   info.setSigningIdentity(id);
   BOOST_CHECK_EQUAL(info.getSignerType(), SigningInfo::SIGNER_TYPE_ID);
   BOOST_CHECK_EQUAL(info.getSignerName(), id);
+  BOOST_CHECK_EQUAL(info.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
 
   SigningInfo infoId(SigningInfo::SIGNER_TYPE_ID, id);
   BOOST_CHECK_EQUAL(infoId.getSignerType(), SigningInfo::SIGNER_TYPE_ID);
   BOOST_CHECK_EQUAL(infoId.getSignerName(), id);
+  BOOST_CHECK_EQUAL(infoId.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
 
   info.setSigningKeyName(key);
   BOOST_CHECK_EQUAL(info.getSignerType(), SigningInfo::SIGNER_TYPE_KEY);
   BOOST_CHECK_EQUAL(info.getSignerName(), key);
+  BOOST_CHECK_EQUAL(info.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
 
   SigningInfo infoKey(SigningInfo::SIGNER_TYPE_KEY, key);
   BOOST_CHECK_EQUAL(infoKey.getSignerType(), SigningInfo::SIGNER_TYPE_KEY);
   BOOST_CHECK_EQUAL(infoKey.getSignerName(), key);
+  BOOST_CHECK_EQUAL(infoKey.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
 
   info.setSigningCertName(cert);
   BOOST_CHECK_EQUAL(info.getSignerType(), SigningInfo::SIGNER_TYPE_CERT);
   BOOST_CHECK_EQUAL(info.getSignerName(), cert);
+  BOOST_CHECK_EQUAL(info.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
 
   SigningInfo infoCert(SigningInfo::SIGNER_TYPE_CERT, cert);
   BOOST_CHECK_EQUAL(infoCert.getSignerType(), SigningInfo::SIGNER_TYPE_CERT);
   BOOST_CHECK_EQUAL(infoCert.getSignerName(), cert);
+  BOOST_CHECK_EQUAL(infoCert.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
 
   info.setSha256Signing();
   BOOST_CHECK_EQUAL(info.getSignerType(), SigningInfo::SIGNER_TYPE_SHA256);
   BOOST_CHECK_EQUAL(info.getSignerName(), SigningInfo::EMPTY_NAME);
+  BOOST_CHECK_EQUAL(info.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
 
   SigningInfo infoSha(SigningInfo::SIGNER_TYPE_SHA256);
   BOOST_CHECK_EQUAL(infoSha.getSignerType(), SigningInfo::SIGNER_TYPE_SHA256);
   BOOST_CHECK_EQUAL(infoSha.getSignerName(), SigningInfo::EMPTY_NAME);
+  BOOST_CHECK_EQUAL(infoSha.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
 }
 
 BOOST_AUTO_TEST_CASE(CustomSignatureInfo)
@@ -102,22 +110,27 @@
   SigningInfo infoDefault("");
   BOOST_CHECK_EQUAL(infoDefault.getSignerType(), SigningInfo::SIGNER_TYPE_NULL);
   BOOST_CHECK_EQUAL(infoDefault.getSignerName(), SigningInfo::EMPTY_NAME);
+  BOOST_CHECK_EQUAL(infoDefault.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
 
   SigningInfo infoId("id:/my-identity");
   BOOST_CHECK_EQUAL(infoId.getSignerType(), SigningInfo::SIGNER_TYPE_ID);
   BOOST_CHECK_EQUAL(infoId.getSignerName(), "/my-identity");
+  BOOST_CHECK_EQUAL(infoId.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
 
   SigningInfo infoKey("key:/my-key");
   BOOST_CHECK_EQUAL(infoKey.getSignerType(), SigningInfo::SIGNER_TYPE_KEY);
   BOOST_CHECK_EQUAL(infoKey.getSignerName(), "/my-key");
+  BOOST_CHECK_EQUAL(infoKey.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
 
   SigningInfo infoCert("cert:/my-cert");
   BOOST_CHECK_EQUAL(infoCert.getSignerType(), SigningInfo::SIGNER_TYPE_CERT);
   BOOST_CHECK_EQUAL(infoCert.getSignerName(), "/my-cert");
+  BOOST_CHECK_EQUAL(infoCert.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
 
   SigningInfo infoSha("id:/localhost/identity/digest-sha256");
   BOOST_CHECK_EQUAL(infoSha.getSignerType(), SigningInfo::SIGNER_TYPE_SHA256);
   BOOST_CHECK_EQUAL(infoSha.getSignerName(), SigningInfo::EMPTY_NAME);
+  BOOST_CHECK_EQUAL(infoSha.getDigestAlgorithm(), DIGEST_ALGORITHM_SHA256);
 }
 
 BOOST_AUTO_TEST_CASE(ToString)