Coverage Report

Created: 2025-12-10 06:24

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl/crypto/x509/v3_authattid.c
Line
Count
Source
1
/*
2
 * Copyright 1999-2024 The OpenSSL Project Authors. All Rights Reserved.
3
 *
4
 * Licensed under the Apache License 2.0 (the "License").  You may not use
5
 * this file except in compliance with the License.  You can obtain a copy
6
 * in the file LICENSE in the source distribution or at
7
 * https://www.openssl.org/source/license.html
8
 */
9
10
#include <openssl/asn1t.h>
11
#include <openssl/x509v3.h>
12
#include <crypto/x509_acert.h>
13
#include <openssl/x509_acert.h>
14
#include "crypto/asn1.h"
15
#include "ext_dat.h"
16
17
DECLARE_ASN1_ITEM(OSSL_ISSUER_SERIAL)
18
19
ASN1_ITEM_TEMPLATE(OSSL_AUTHORITY_ATTRIBUTE_ID_SYNTAX) = ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_AUTHORITY_ATTRIBUTE_ID_SYNTAX, OSSL_ISSUER_SERIAL)
20
0
ASN1_ITEM_TEMPLATE_END(OSSL_AUTHORITY_ATTRIBUTE_ID_SYNTAX)
21
22
IMPLEMENT_ASN1_FUNCTIONS(OSSL_AUTHORITY_ATTRIBUTE_ID_SYNTAX)
23
24
static int i2r_ISSUER_SERIAL(X509V3_EXT_METHOD *method,
25
    OSSL_ISSUER_SERIAL *iss,
26
    BIO *out, int indent)
27
0
{
28
0
    if (iss->issuer != NULL) {
29
0
        BIO_printf(out, "%*sIssuer Names:\n", indent, "");
30
0
        OSSL_GENERAL_NAMES_print(out, iss->issuer, indent);
31
0
        BIO_puts(out, "\n");
32
0
    } else {
33
0
        BIO_printf(out, "%*sIssuer Names: <none>\n", indent, "");
34
0
    }
35
0
    BIO_printf(out, "%*sIssuer Serial: ", indent, "");
36
0
    if (i2a_ASN1_INTEGER(out, &(iss->serial)) <= 0)
37
0
        return 0;
38
0
    BIO_puts(out, "\n");
39
0
    if (iss->issuerUID != NULL) {
40
0
        BIO_printf(out, "%*sIssuer UID: ", indent, "");
41
0
        if (i2a_ASN1_STRING(out, iss->issuerUID, V_ASN1_BIT_STRING) <= 0)
42
0
            return 0;
43
0
        BIO_puts(out, "\n");
44
0
    } else {
45
0
        BIO_printf(out, "%*sIssuer UID: <none>\n", indent, "");
46
0
    }
47
0
    return 1;
48
0
}
49
50
static int i2r_auth_attr_id(X509V3_EXT_METHOD *method,
51
    OSSL_AUTHORITY_ATTRIBUTE_ID_SYNTAX *aids,
52
    BIO *out, int indent)
53
0
{
54
0
    int i;
55
0
    OSSL_ISSUER_SERIAL *aid;
56
57
0
    for (i = 0; i < sk_OSSL_ISSUER_SERIAL_num(aids); i++) {
58
0
        if (BIO_printf(out, "%*sIssuer-Serials:\n", indent, "") <= 0)
59
0
            return 0;
60
0
        aid = sk_OSSL_ISSUER_SERIAL_value(aids, i);
61
0
        if (i2r_ISSUER_SERIAL(method, aid, out, indent + 4) <= 0)
62
0
            return 0;
63
0
        if (BIO_puts(out, "\n") <= 0)
64
0
            return 0;
65
0
    }
66
0
    return 1;
67
0
}
68
69
const X509V3_EXT_METHOD ossl_v3_authority_attribute_identifier = {
70
    NID_authority_attribute_identifier, X509V3_EXT_MULTILINE,
71
    ASN1_ITEM_ref(OSSL_AUTHORITY_ATTRIBUTE_ID_SYNTAX),
72
    0, 0, 0, 0,
73
    0,
74
    0,
75
    0, 0,
76
    (X509V3_EXT_I2R)i2r_auth_attr_id,
77
    0,
78
    NULL
79
};