/src/botan/src/lib/x509/x509_dn_ub.cpp
Line | Count | Source |
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-05-29 |
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 | | |
14 | | #include <botan/asn1_obj.h> |
15 | | #include <map> |
16 | | |
17 | | namespace Botan { |
18 | | |
19 | | namespace { |
20 | | |
21 | | /** |
22 | | * Upper bounds for the length of distinguished name fields as given in RFC 5280, Appendix A. |
23 | | * Only OIDS recognized by botan are considered, so far. |
24 | | * Maps OID string representations instead of human readable strings in order |
25 | | * to avoid an additional lookup. |
26 | | */ |
27 | | const std::map<OID, size_t> DN_UB = { |
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 | | } // namespace |
46 | | |
47 | | //static |
48 | 4 | size_t X509_DN::lookup_ub(const OID& oid) { |
49 | 4 | auto ub_entry = DN_UB.find(oid); |
50 | 4 | if(ub_entry != DN_UB.end()) { |
51 | 3 | return ub_entry->second; |
52 | 3 | } else { |
53 | 1 | return 0; |
54 | 1 | } |
55 | 4 | } |
56 | | |
57 | | } // namespace Botan |