Botan 3.7.1
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>
14#include <string_view>
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 /// secp192r1 aka P-192
31 secp192r1,
32 /// secp224r1 aka P-224
33 secp224r1,
34 /// secp256r1 aka P-256
35 secp256r1,
36 /// secp384r1 aka P-384
37 secp384r1,
38 /// secp521r1 aka P-521
39 secp521r1,
40 /// secp256k1
41 secp256k1,
42 /// brainpool256r1
43 brainpool256r1,
44 brainpool384r1,
45 brainpool512r1,
46 frp256v1,
47 sm2p256v1,
48 numsp512d1,
49 };
50
51 using enum Code;
52
53 Code code() const { return m_code; }
54
55 /// Convert the ID to it's commonly used name (inverse of from_string)
56 std::string to_string() const;
57
58 PrimeOrderCurveId(Code id) : m_code(id) {}
59
60 /// Map a string to a curve identifier
61 static std::optional<PrimeOrderCurveId> from_string(std::string_view name);
62
63#if defined(BOTAN_HAS_ASN1)
64 /// Map an OID to a curve identifier
65 ///
66 /// Uses the internal OID table
67 static std::optional<PrimeOrderCurveId> from_oid(const OID& oid);
68#endif
69
70 private:
71 const Code m_code;
72};
73
74} // namespace Botan::PCurve
75
76#endif
#define BOTAN_TEST_API
Definition api.h:39
Identifier for a named prime order curve.
Definition pcurves_id.h:27
std::string name
int(* final)(unsigned char *, CTX *)