fix: klockwork reported success / failure check fix
This commit is contained in:
83
commands.cpp
83
commands.cpp
@@ -282,51 +282,54 @@ bool cmd_get_certificate_hashes(std::vector<cert_hash_entry>& hash_entries)
|
|||||||
for (int i = 0; i < (int) amt_hash_handles.Length; i++)
|
for (int i = 0; i < (int) amt_hash_handles.Length; i++)
|
||||||
{
|
{
|
||||||
// get each entry
|
// get each entry
|
||||||
AMT_STATUS status = pthi_GetCertificateHashEntry(amt_hash_handles.Handles[i], &certhash_entry);
|
AMT_STATUS amt_status = pthi_GetCertificateHashEntry(amt_hash_handles.Handles[i], &certhash_entry);
|
||||||
|
|
||||||
int hashSize;
|
if (amt_status == 0)
|
||||||
cert_hash_entry tmp;
|
|
||||||
switch (certhash_entry.HashAlgorithm) {
|
|
||||||
case 0: // MD5
|
|
||||||
hashSize = 16;
|
|
||||||
tmp.algorithm = "MD5";
|
|
||||||
break;
|
|
||||||
case 1: // SHA1
|
|
||||||
hashSize = 20;
|
|
||||||
tmp.algorithm = "SHA1";
|
|
||||||
break;
|
|
||||||
case 2: // SHA256
|
|
||||||
hashSize = 32;
|
|
||||||
tmp.algorithm = "SHA256";
|
|
||||||
break;
|
|
||||||
case 3: // SHA512
|
|
||||||
hashSize = 64;
|
|
||||||
tmp.algorithm = "SHA512";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
hashSize = 0;
|
|
||||||
tmp.algorithm = "UNKNOWN";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (certhash_entry.IsActive == 1)
|
|
||||||
{
|
{
|
||||||
std::string cert_name(certhash_entry.Name.Buffer, certhash_entry.Name.Length);
|
int hashSize;
|
||||||
tmp.name = cert_name;
|
cert_hash_entry tmp;
|
||||||
tmp.is_default = certhash_entry.IsDefault;
|
switch (certhash_entry.HashAlgorithm) {
|
||||||
tmp.is_active = certhash_entry.IsActive;
|
case 0: // MD5
|
||||||
|
hashSize = 16;
|
||||||
std::string hashString;
|
tmp.algorithm = "MD5";
|
||||||
for (int i = 0; i < hashSize; i++)
|
break;
|
||||||
{
|
case 1: // SHA1
|
||||||
char hex[10];
|
hashSize = 20;
|
||||||
snprintf(hex, 10, "%02x", certhash_entry.CertificateHash[i]);
|
tmp.algorithm = "SHA1";
|
||||||
hashString += hex;
|
break;
|
||||||
|
case 2: // SHA256
|
||||||
|
hashSize = 32;
|
||||||
|
tmp.algorithm = "SHA256";
|
||||||
|
break;
|
||||||
|
case 3: // SHA512
|
||||||
|
hashSize = 64;
|
||||||
|
tmp.algorithm = "SHA512";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
hashSize = 0;
|
||||||
|
tmp.algorithm = "UNKNOWN";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp.hash = hashString;
|
if (certhash_entry.IsActive == 1)
|
||||||
|
{
|
||||||
|
std::string cert_name(certhash_entry.Name.Buffer, certhash_entry.Name.Length);
|
||||||
|
tmp.name = cert_name;
|
||||||
|
tmp.is_default = certhash_entry.IsDefault;
|
||||||
|
tmp.is_active = certhash_entry.IsActive;
|
||||||
|
|
||||||
hash_entries.push_back(tmp);
|
std::string hashString;
|
||||||
|
for (int i = 0; i < hashSize; i++)
|
||||||
|
{
|
||||||
|
char hex[10];
|
||||||
|
snprintf(hex, 10, "%02x", certhash_entry.CertificateHash[i]);
|
||||||
|
hashString += hex;
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp.hash = hashString;
|
||||||
|
|
||||||
|
hash_entries.push_back(tmp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user