Botan  2.7.0
Crypto and TLS for C++11
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/oids.py on 2017-12-23
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  * Upper bounds for the length of distinguished name fields as given in RFC 5280, Appendix A.
19  * Only OIDS recognized by botan are considered, so far.
20  * Maps OID string representations instead of human readable strings in order
21  * to avoid an additional lookup.
22  */
23 static const std::map<Botan::OID, size_t> DN_UB =
24  {
25  { Botan::OID("2.5.4.10"), 64 }, // X520.Organization
26  { Botan::OID("2.5.4.11"), 64 }, // X520.OrganizationalUnit
27  { Botan::OID("2.5.4.12"), 64 }, // X520.Title
28  { Botan::OID("2.5.4.3"), 64 }, // X520.CommonName
29  { Botan::OID("2.5.4.4"), 40 }, // X520.Surname
30  { Botan::OID("2.5.4.42"), 32768 }, // X520.GivenName
31  { Botan::OID("2.5.4.43"), 32768 }, // X520.Initials
32  { Botan::OID("2.5.4.44"), 32768 }, // X520.GenerationalQualifier
33  { Botan::OID("2.5.4.46"), 64 }, // X520.DNQualifier
34  { Botan::OID("2.5.4.5"), 64 }, // X520.SerialNumber
35  { Botan::OID("2.5.4.6"), 3 }, // X520.Country
36  { Botan::OID("2.5.4.65"), 128 }, // X520.Pseudonym
37  { Botan::OID("2.5.4.7"), 128 }, // X520.Locality
38  { Botan::OID("2.5.4.8"), 128 } // X520.State
39  };
40 }
41 
42 namespace Botan {
43 
44 //static
45 size_t X509_DN::lookup_ub(const OID& oid)
46  {
47  auto ub_entry = DN_UB.find(oid);
48  if(ub_entry != DN_UB.end())
49  {
50  return ub_entry->second;
51  }
52  else
53  {
54  return 0;
55  }
56  }
57 }
58 
Definition: alg_id.cpp:13
static size_t lookup_ub(const OID &oid)
Definition: x509_dn_ub.cpp:45