Botan 3.8.0
Crypto and TLS for C&
x509_dn_ub.cpp
Go to the documentation of this file.
1/*
2* (C) 2017 Fabian Weissberg, Rohde & Schwarz Cybersecurity
3* 2025 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#include <botan/pkix_types.h>
9
10#include <botan/asn1_obj.h>
11#include <botan/internal/x509_utils.h>
12
13namespace Botan {
14
15//static
16size_t X509_DN::lookup_ub(const OID& oid) {
17 /*
18 * See RFC 5280 Appendix A.1 starting with comment "-- Upper Bounds"
19 */
20 if(auto iso_dn = is_sub_element_of(oid, {2, 5, 4})) {
21 switch(*iso_dn) {
22 case 3:
23 // X520.CommonName
24 return 64;
25 case 4:
26 // X520.Surname
27 return 40;
28 case 5:
29 // X520.SerialNumber
30 return 64;
31 case 6:
32 // X520.Country
33 return 3;
34 case 7:
35 // X520.Locality
36 return 128;
37 case 8:
38 // X520.State
39 return 128;
40 case 9:
41 // X520.StreetAddress
42 return 128;
43 case 10:
44 // X520.Organization
45 return 64;
46 case 11:
47 // X520.OrganizationalUnit
48 return 64;
49 case 12:
50 // X520.Title
51 return 64;
52 case 42:
53 // X520.GivenName
54 return 16;
55 case 43:
56 // X520.Initials
57 return 5;
58 case 44:
59 // X520.GenerationalQualifier
60 return 3;
61 case 46:
62 // X520.DNQualifier
63 return 64;
64 case 65:
65 // X520.Pseudonym
66 return 128;
67 default:
68 return 0;
69 }
70 }
71
72 return 0;
73}
74
75} // namespace Botan
static size_t lookup_ub(const OID &oid)
std::optional< uint32_t > is_sub_element_of(const OID &oid, std::initializer_list< uint32_t > prefix)
Definition x509_utils.h:16