Botan 3.5.0
Crypto and TLS for C&
Botan::PCurve::PrimeOrderCurveId Class Referencefinal

Identifier for a named prime order curve. More...

#include <pcurves_id.h>

Public Types

enum class  Code : uint8_t {
  secp256r1 , secp384r1 , secp521r1 , secp256k1 ,
  brainpool256r1 , brainpool384r1 , brainpool512r1 , frp256v1 ,
  sm2p256v1
}
 

Public Member Functions

Code code () const
 
 PrimeOrderCurveId (Code id)
 
std::string to_string () const
 Convert the ID to it's commonly used name (inverse of from_string)
 

Static Public Member Functions

static std::vector< PrimeOrderCurveIdall ()
 
static std::optional< PrimeOrderCurveIdfrom_string (std::string_view name)
 Map a string to a curve identifier.
 

Detailed Description

Identifier for a named prime order curve.

Definition at line 27 of file pcurves_id.h.

Member Enumeration Documentation

◆ Code

enum class Botan::PCurve::PrimeOrderCurveId::Code : uint8_t
strong
Enumerator
secp256r1 

secp256r1 aka P-256

secp384r1 

secp384r1 aka P-384

secp521r1 

secp521r1 aka P-521

secp256k1 

secp256k1

brainpool256r1 

brainpool256r1

brainpool384r1 
brainpool512r1 
frp256v1 
sm2p256v1 

Definition at line 29 of file pcurves_id.h.

29 : uint8_t {
30 /// secp256r1 aka P-256
32 /// secp384r1 aka P-384
34 /// secp521r1 aka P-521
36 /// secp256k1
38 /// brainpool256r1
44 };

Constructor & Destructor Documentation

◆ PrimeOrderCurveId()

Botan::PCurve::PrimeOrderCurveId::PrimeOrderCurveId ( Code id)
inline

Definition at line 59 of file pcurves_id.h.

59: m_code(id) {}

Member Function Documentation

◆ all()

std::vector< PrimeOrderCurveId > Botan::PCurve::PrimeOrderCurveId::all ( )
static

Return a list of all of the defined PrimeOrderCurveId

Note this list always includes all curves, even if some were disabled at build time.

Definition at line 104 of file pcurves.cpp.

References brainpool256r1, brainpool384r1, brainpool512r1, frp256v1, secp256k1, secp256r1, secp384r1, secp521r1, and sm2p256v1.

◆ code()

Code Botan::PCurve::PrimeOrderCurveId::code ( ) const
inline

Definition at line 48 of file pcurves_id.h.

48{ return m_code; }

Referenced by to_string().

◆ from_string()

std::optional< PrimeOrderCurveId > Botan::PCurve::PrimeOrderCurveId::from_string ( std::string_view name)
static

Map a string to a curve identifier.

Definition at line 144 of file pcurves.cpp.

144 {
145 if(name == "secp256r1") {
147 } else if(name == "secp384r1") {
149 } else if(name == "secp521r1") {
151 } else if(name == "secp256k1") {
153 } else if(name == "brainpool256r1") {
155 } else if(name == "brainpool384r1") {
157 } else if(name == "brainpool512r1") {
159 } else if(name == "frp256v1") {
161 } else if(name == "sm2p256v1") {
163 } else {
164 return {};
165 }
166}
std::string name

References brainpool256r1, brainpool384r1, brainpool512r1, frp256v1, name, secp256k1, secp256r1, secp384r1, secp521r1, and sm2p256v1.

◆ to_string()

std::string Botan::PCurve::PrimeOrderCurveId::to_string ( ) const

Convert the ID to it's commonly used name (inverse of from_string)

Definition at line 118 of file pcurves.cpp.

118 {
119 switch(this->code()) {
121 return "secp256r1";
123 return "secp384r1";
125 return "secp521r1";
127 return "secp256k1";
129 return "brainpool256r1";
131 return "brainpool384r1";
133 return "brainpool512r1";
135 return "frp256v1";
137 return "sm2p256v1";
138 }
139
140 return "unknown";
141}

References brainpool256r1, brainpool384r1, brainpool512r1, code(), frp256v1, secp256k1, secp256r1, secp384r1, secp521r1, and sm2p256v1.


The documentation for this class was generated from the following files: