Botan 3.0.0
Crypto and TLS for C&
x509_dn_ub.cpp
Go to the documentation of this file.
1/*
2* DN_UB maps: Upper bounds on the length of DN strings
3*
4* This file was automatically generated by ./src/scripts/dev_tools/gen_oids.py on 2023-02-22
5*
6* All manual edits to this file will be lost. Edit the script
7* then regenerate this source file.
8*
9* Botan is released under the Simplified BSD License (see license.txt)
10*/
11
12#include <botan/pkix_types.h>
13#include <botan/asn1_obj.h>
14#include <map>
15
16namespace Botan {
17
18namespace {
19
20/**
21 * Upper bounds for the length of distinguished name fields as given in RFC 5280, Appendix A.
22 * Only OIDS recognized by botan are considered, so far.
23 * Maps OID string representations instead of human readable strings in order
24 * to avoid an additional lookup.
25 */
26const std::map<OID, size_t> DN_UB =
27 {
28 { OID({2,5,4,10}), 64 }, // X520.Organization
29 { OID({2,5,4,11}), 64 }, // X520.OrganizationalUnit
30 { OID({2,5,4,12}), 64 }, // X520.Title
31 { OID({2,5,4,3}), 64 }, // X520.CommonName
32 { OID({2,5,4,4}), 40 }, // X520.Surname
33 { OID({2,5,4,42}), 32768 }, // X520.GivenName
34 { OID({2,5,4,43}), 32768 }, // X520.Initials
35 { OID({2,5,4,44}), 32768 }, // X520.GenerationalQualifier
36 { OID({2,5,4,46}), 64 }, // X520.DNQualifier
37 { OID({2,5,4,5}), 64 }, // X520.SerialNumber
38 { OID({2,5,4,6}), 3 }, // X520.Country
39 { OID({2,5,4,65}), 128 }, // X520.Pseudonym
40 { OID({2,5,4,7}), 128 }, // X520.Locality
41 { OID({2,5,4,8}), 128 }, // X520.State
42 { OID({2,5,4,9}), 128 } // X520.StreetAddress
43 };
44
45}
46
47//static
48size_t X509_DN::lookup_ub(const OID& oid)
49 {
50 auto ub_entry = DN_UB.find(oid);
51 if(ub_entry != DN_UB.end())
52 {
53 return ub_entry->second;
54 }
55 else
56 {
57 return 0;
58 }
59 }
60}
61
static size_t lookup_ub(const OID &oid)
Definition: x509_dn_ub.cpp:48
Definition: alg_id.cpp:12