asn1: Allow suppressing log messages when parsing algorithm identifiers

This commit is contained in:
Tobias Brunner
2023-03-30 10:46:46 +02:00
parent 4e73e9d3e9
commit 1326f805a8
3 changed files with 18 additions and 9 deletions
+14 -5
View File
@@ -648,18 +648,27 @@ int asn1_parse_algorithmIdentifier(chunk_t blob, int level0, chunk_t *parameters
if (asn1_unwrap(&blob, &blob) == ASN1_SEQUENCE)
{
DBG2(DBG_ASN, "L%d - algorithmIdentifier:", level0);
if (level0 >= 0)
{
DBG2(DBG_ASN, "L%d - algorithmIdentifier:", level0);
}
if (asn1_unwrap(&blob, &object) == ASN1_OID)
{
DBG2(DBG_ASN, "L%d - algorithm:", level0+1);
asn1_debug_simple_object(object, ASN1_OID, FALSE);
if (level0 >= 0)
{
DBG2(DBG_ASN, "L%d - algorithm:", level0+1);
asn1_debug_simple_object(object, ASN1_OID, FALSE);
}
alg = asn1_known_oid(object);
if (blob.len)
{
DBG2(DBG_ASN, "L%d - parameters:", level0+1);
DBG3(DBG_ASN, "%B", &blob);
if (level0 >= 0)
{
DBG2(DBG_ASN, "L%d - parameters:", level0+1);
DBG3(DBG_ASN, "%B", &blob);
}
if (parameters)
{
*parameters = blob;
+1 -1
View File
@@ -163,7 +163,7 @@ int asn1_unwrap(chunk_t *blob, chunk_t *content);
* Parses an ASN.1 algorithmIdentifier object
*
* @param blob ASN.1 coded blob
* @param level0 top-most level offset
* @param level0 top-most level offset (-1 to suppress log messages)
* @param params returns optional [ASN.1 coded] parameters
* @return known OID index or OID_UNKNOWN
*/
+3 -3
View File
@@ -81,11 +81,11 @@ START_TEST(test_asn1_parse_algorithmIdentifier)
parameters = chunk_empty;
if (i == 2)
{
alg = asn1_parse_algorithmIdentifier(algid, 0, NULL);
alg = asn1_parse_algorithmIdentifier(algid, _i, NULL);
}
else
{
alg = asn1_parse_algorithmIdentifier(algid, 0, &parameters);
alg = asn1_parse_algorithmIdentifier(algid, _i, &parameters);
if (test[i].empty)
{
ck_assert(parameters.len == 0 && parameters.ptr == NULL);
@@ -824,7 +824,7 @@ Suite *asn1_suite_create()
suite_add_tcase(s, tc);
tc = tcase_create("parse_algorithmIdentifier");
tcase_add_test(tc, test_asn1_parse_algorithmIdentifier);
tcase_add_loop_test(tc, test_asn1_parse_algorithmIdentifier, -1, 1);
suite_add_tcase(s, tc);
tc = tcase_create("known_oid");