/src/openssl/crypto/x509/v3_authattid.c
Line | Count | Source (jump to first uncovered line) |
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) = |
20 | | ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_AUTHORITY_ATTRIBUTE_ID_SYNTAX, OSSL_ISSUER_SERIAL) |
21 | | ASN1_ITEM_TEMPLATE_END(OSSL_AUTHORITY_ATTRIBUTE_ID_SYNTAX) |
22 | | |
23 | | IMPLEMENT_ASN1_FUNCTIONS(OSSL_AUTHORITY_ATTRIBUTE_ID_SYNTAX) |
24 | | |
25 | | static int i2r_ISSUER_SERIAL(X509V3_EXT_METHOD *method, |
26 | | OSSL_ISSUER_SERIAL *iss, |
27 | | BIO *out, int indent) |
28 | 0 | { |
29 | 0 | if (iss->issuer != NULL) { |
30 | 0 | BIO_printf(out, "%*sIssuer Names:\n", indent, ""); |
31 | 0 | OSSL_GENERAL_NAMES_print(out, iss->issuer, indent); |
32 | 0 | BIO_puts(out, "\n"); |
33 | 0 | } else { |
34 | 0 | BIO_printf(out, "%*sIssuer Names: <none>\n", indent, ""); |
35 | 0 | } |
36 | 0 | BIO_printf(out, "%*sIssuer Serial: ", indent, ""); |
37 | 0 | if (i2a_ASN1_INTEGER(out, &(iss->serial)) <= 0) |
38 | 0 | return 0; |
39 | 0 | BIO_puts(out, "\n"); |
40 | 0 | if (iss->issuerUID != NULL) { |
41 | 0 | BIO_printf(out, "%*sIssuer UID: ", indent, ""); |
42 | 0 | if (i2a_ASN1_STRING(out, iss->issuerUID, V_ASN1_BIT_STRING) <= 0) |
43 | 0 | return 0; |
44 | 0 | BIO_puts(out, "\n"); |
45 | 0 | } else { |
46 | 0 | BIO_printf(out, "%*sIssuer UID: <none>\n", indent, ""); |
47 | 0 | } |
48 | 0 | return 1; |
49 | 0 | } |
50 | | |
51 | | static int i2r_auth_attr_id(X509V3_EXT_METHOD *method, |
52 | | OSSL_AUTHORITY_ATTRIBUTE_ID_SYNTAX *aids, |
53 | | BIO *out, int indent) |
54 | 0 | { |
55 | 0 | int i; |
56 | 0 | OSSL_ISSUER_SERIAL *aid; |
57 | |
|
58 | 0 | for (i = 0; i < sk_OSSL_ISSUER_SERIAL_num(aids); i++) { |
59 | 0 | if (BIO_printf(out, "%*sIssuer-Serials:\n", indent, "") <= 0) |
60 | 0 | return 0; |
61 | 0 | aid = sk_OSSL_ISSUER_SERIAL_value(aids, i); |
62 | 0 | if (i2r_ISSUER_SERIAL(method, aid, out, indent + 4) <= 0) |
63 | 0 | return 0; |
64 | 0 | if (BIO_puts(out, "\n") <= 0) |
65 | 0 | return 0; |
66 | 0 | } |
67 | 0 | return 1; |
68 | 0 | } |
69 | | |
70 | | const X509V3_EXT_METHOD ossl_v3_authority_attribute_identifier = { |
71 | | NID_authority_attribute_identifier, X509V3_EXT_MULTILINE, |
72 | | ASN1_ITEM_ref(OSSL_AUTHORITY_ATTRIBUTE_ID_SYNTAX), |
73 | | 0, 0, 0, 0, |
74 | | 0, |
75 | | 0, |
76 | | 0, 0, |
77 | | (X509V3_EXT_I2R)i2r_auth_attr_id, |
78 | | 0, |
79 | | NULL |
80 | | }; |