Botan 3.5.0
Crypto and TLS for C&
pcurves_id.h
Go to the documentation of this file.
1/*
2* (C) 2024 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#ifndef BOTAN_PCURVES_ID_H_
8#define BOTAN_PCURVES_ID_H_
9
10#include <botan/secmem.h>
11#include <botan/types.h>
12#include <optional>
13#include <string_view>
14#include <vector>
15
16namespace Botan {
17
18#if defined(BOTAN_HAS_ASN1)
19class OID;
20#endif
21
22} // namespace Botan
23
24namespace Botan::PCurve {
25
26/// Identifier for a named prime order curve
28 public:
29 enum class Code : uint8_t {
30 /// secp256r1 aka P-256
31 secp256r1,
32 /// secp384r1 aka P-384
33 secp384r1,
34 /// secp521r1 aka P-521
35 secp521r1,
36 /// secp256k1
37 secp256k1,
38 /// brainpool256r1
39 brainpool256r1,
40 brainpool384r1,
41 brainpool512r1,
42 frp256v1,
43 sm2p256v1,
44 };
45
46 using enum Code;
47
48 Code code() const { return m_code; }
49
50 /// Return a list of all of the defined PrimeOrderCurveId
51 ///
52 /// Note this list always includes all curves, even if some were
53 /// disabled at build time.
54 static std::vector<PrimeOrderCurveId> all();
55
56 /// Convert the ID to it's commonly used name (inverse of from_string)
57 std::string to_string() const;
58
59 PrimeOrderCurveId(Code id) : m_code(id) {}
60
61 /// Map a string to a curve identifier
62 static std::optional<PrimeOrderCurveId> from_string(std::string_view name);
63
64#if defined(BOTAN_HAS_ASN1)
65 /// Map an OID to a curve identifier
66 ///
67 /// Uses the internal OID table
68 static std::optional<PrimeOrderCurveId> from_oid(const OID& oid);
69#endif
70
71 private:
72 const Code m_code;
73};
74
75} // namespace Botan::PCurve
76
77#endif
Identifier for a named prime order curve.
Definition pcurves_id.h:27
std::string name
int(* final)(unsigned char *, CTX *)
#define BOTAN_TEST_API
Definition compiler.h:51