Skip to content

Commit 5007a79

Browse files
committed
Add XML attributes for certificate strength. #54
1 parent 0180392 commit 5007a79

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

sslscan.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,20 +1905,22 @@ int checkCertificate(struct sslCheckOptions *options, const SSL_METHOD *sslMetho
19051905
strtok(certAlgorithm, "\n");
19061906
if (strstr(certAlgorithm, "md5") || strstr(certAlgorithm, "sha1"))
19071907
{
1908+
printf_xml(" <signature-algorithm strength=\"weak\">");
19081909
printf("%s%s%s\n", COL_RED, certAlgorithm, RESET);
19091910
}
19101911
else if (strstr(certAlgorithm, "sha512") || strstr(certAlgorithm, "sha256"))
19111912
{
1913+
printf_xml(" <signature-algorithm strength=\"strong\">");
19121914
printf("%s%s%s\n", COL_GREEN, certAlgorithm, RESET);
19131915
}
19141916
else
19151917
{
1918+
printf_xml(" <signature-algorithm strength=\"acceptable\">");
19161919
printf("%s\n", certAlgorithm);
19171920
}
19181921

19191922
if (options->xmlOutput)
19201923
{
1921-
printf_xml(" <signature-algorithm>");
19221924
i2a_ASN1_OBJECT(fileBIO, x509Cert->cert_info->signature->algorithm);
19231925
printf_xml("</signature-algorithm>\n");
19241926
}
@@ -1941,20 +1943,22 @@ int checkCertificate(struct sslCheckOptions *options, const SSL_METHOD *sslMetho
19411943
if (publicKey->pkey.rsa)
19421944
{
19431945
keyBits = BN_num_bits(publicKey->pkey.rsa->n);
1946+
printf_xml(" <pk error=\"false\" type=\"RSA\" bits=\"%d\" ", BN_num_bits(publicKey->pkey.rsa->n));
19441947
if (keyBits < 2048 )
19451948
{
19461949
printf("RSA Key Strength: %s%d%s\n", COL_RED, keyBits, RESET);
1950+
printf_xml("strength=\"weak\" />\n");
19471951
}
19481952
else if (keyBits >= 4096 )
19491953
{
19501954
printf("RSA Key Strength: %s%d%s\n", COL_GREEN, keyBits, RESET);
1955+
printf_xml("strength=\"strong\" />\n");
19511956
}
19521957
else
19531958
{
19541959
printf("RSA Key Strength: %d\n", keyBits);
1960+
printf_xml("strength=\"acceptable\" />\n");
19551961
}
1956-
1957-
printf_xml(" <pk error=\"false\" type=\"RSA\" bits=\"%d\" />\n", BN_num_bits(publicKey->pkey.rsa->n));
19581962
}
19591963
else
19601964
{

0 commit comments

Comments
 (0)