Botan 3.9.0
Crypto and TLS for C&
x509_utils.h
Go to the documentation of this file.
1/*
2* (C) 2025 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#ifndef BOTAN_X509_UTILS_H_
8#define BOTAN_X509_UTILS_H_
9
10#include <botan/asn1_obj.h>
11#include <initializer_list>
12#include <optional>
13
14namespace Botan {
15
16inline std::optional<uint32_t> is_sub_element_of(const OID& oid, std::initializer_list<uint32_t> prefix) {
17 const auto& c = oid.get_components();
18
19 if(c.size() != prefix.size() + 1) {
20 return {};
21 }
22
23 if(!std::equal(c.begin(), c.end() - 1, prefix.begin(), prefix.end())) {
24 return {};
25 }
26
27 return c[c.size() - 1];
28}
29
30} // namespace Botan
31
32#endif
const std::vector< uint32_t > & get_components() const
Definition asn1_obj.h:321
std::optional< uint32_t > is_sub_element_of(const OID &oid, std::initializer_list< uint32_t > prefix)
Definition x509_utils.h:16