/src/botan/src/lib/x509/x509_dn_ub.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * DN_UB maps: Upper bounds on the length of DN strings |
3 | | * |
4 | | * This file was automatically generated by ./src/scripts/oids.py on 2019-10-21 |
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/x509_dn.h> |
13 | | #include <botan/asn1_oid.h> |
14 | | #include <map> |
15 | | |
16 | | namespace { |
17 | | |
18 | | /** |
19 | | * Upper bounds for the length of distinguished name fields as given in RFC 5280, Appendix A. |
20 | | * Only OIDS recognized by botan are considered, so far. |
21 | | * Maps OID string representations instead of human readable strings in order |
22 | | * to avoid an additional lookup. |
23 | | */ |
24 | | static const std::map<Botan::OID, size_t> DN_UB = |
25 | | { |
26 | | { Botan::OID({2,5,4,10}), 64 }, // X520.Organization |
27 | | { Botan::OID({2,5,4,11}), 64 }, // X520.OrganizationalUnit |
28 | | { Botan::OID({2,5,4,12}), 64 }, // X520.Title |
29 | | { Botan::OID({2,5,4,3}), 64 }, // X520.CommonName |
30 | | { Botan::OID({2,5,4,4}), 40 }, // X520.Surname |
31 | | { Botan::OID({2,5,4,42}), 32768 }, // X520.GivenName |
32 | | { Botan::OID({2,5,4,43}), 32768 }, // X520.Initials |
33 | | { Botan::OID({2,5,4,44}), 32768 }, // X520.GenerationalQualifier |
34 | | { Botan::OID({2,5,4,46}), 64 }, // X520.DNQualifier |
35 | | { Botan::OID({2,5,4,5}), 64 }, // X520.SerialNumber |
36 | | { Botan::OID({2,5,4,6}), 3 }, // X520.Country |
37 | | { Botan::OID({2,5,4,65}), 128 }, // X520.Pseudonym |
38 | | { Botan::OID({2,5,4,7}), 128 }, // X520.Locality |
39 | | { Botan::OID({2,5,4,8}), 128 }, // X520.State |
40 | | { Botan::OID({2,5,4,9}), 128 } // X520.StreetAddress |
41 | | }; |
42 | | } |
43 | | |
44 | | namespace Botan { |
45 | | |
46 | | //static |
47 | | size_t X509_DN::lookup_ub(const OID& oid) |
48 | 0 | { |
49 | 0 | auto ub_entry = DN_UB.find(oid); |
50 | 0 | if(ub_entry != DN_UB.end()) |
51 | 0 | { |
52 | 0 | return ub_entry->second; |
53 | 0 | } |
54 | 0 | else |
55 | 0 | { |
56 | 0 | return 0; |
57 | 0 | } |
58 | 0 | } |
59 | | } |
60 | | |