Debian Codegraph @

debian/rust-vendor/openssl-src/openssl/crypto/x509/v3_authattid.c

raw
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 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 {
28 if (iss->issuer != NULL) {
29 BIO_printf(out, "%*sIssuer Names:\n", indent, "");
30 OSSL_GENERAL_NAMES_print(out, iss->issuer, indent);
31 BIO_puts(out, "\n");
32 } else {
33 BIO_printf(out, "%*sIssuer Names: <none>\n", indent, "");
34 }
35 BIO_printf(out, "%*sIssuer Serial: ", indent, "");
36 if (i2a_ASN1_INTEGER(out, &(iss->serial)) <= 0)
37 return 0;
38 BIO_puts(out, "\n");
39 if (iss->issuerUID != NULL) {
40 BIO_printf(out, "%*sIssuer UID: ", indent, "");
41 if (i2a_ASN1_STRING(out, iss->issuerUID, V_ASN1_BIT_STRING) <= 0)
42 return 0;
43 BIO_puts(out, "\n");
44 } else {
45 BIO_printf(out, "%*sIssuer UID: <none>\n", indent, "");
46 }
47 return 1;
48 }
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 {
54 int i;
55 OSSL_ISSUER_SERIAL *aid;
56
57 for (i = 0; i < sk_OSSL_ISSUER_SERIAL_num(aids); i++) {
58 if (BIO_printf(out, "%*sIssuer-Serials:\n", indent, "") <= 0)
59 return 0;
60 aid = sk_OSSL_ISSUER_SERIAL_value(aids, i);
61 if (i2r_ISSUER_SERIAL(method, aid, out, indent + 4) <= 0)
62 return 0;
63 if (BIO_puts(out, "\n") <= 0)
64 return 0;
65 }
66 return 1;
67 }
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 };