aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/tls/tls_algos.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-02-08 05:21:34 -0500
committerJack Lloyd <[email protected]>2018-02-13 07:48:56 -0500
commitb558340da83e2fadc14ac25eb95d3bbac5c973a6 (patch)
tree82c6879e1a24849bd4132e8570cf31e7a5379429 /src/lib/tls/tls_algos.cpp
parentf8744562284897c18d2c02102191a77de1a2afa0 (diff)
Use enums for TLS key exchange group params
Diffstat (limited to 'src/lib/tls/tls_algos.cpp')
-rw-r--r--src/lib/tls/tls_algos.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/lib/tls/tls_algos.cpp b/src/lib/tls/tls_algos.cpp
index 33b00d519..ce32963b7 100644
--- a/src/lib/tls/tls_algos.cpp
+++ b/src/lib/tls/tls_algos.cpp
@@ -115,6 +115,43 @@ Auth_Method auth_method_from_string(const std::string& str)
throw Invalid_Argument("Bad signature method " + str);
}
+bool group_param_is_dh(Group_Params group)
+ {
+ uint16_t group_id = static_cast<uint16_t>(group);
+ return (group_id >= 256 && group_id < 512);
+ }
+
+Group_Params group_param_from_string(const std::string& group_name)
+ {
+ if(group_name == "secp256r1")
+ return Group_Params::SECP256R1;
+ if(group_name == "secp384r1")
+ return Group_Params::SECP384R1;
+ if(group_name == "secp521r1")
+ return Group_Params::SECP521R1;
+ if(group_name == "brainpool256r1")
+ return Group_Params::BRAINPOOL256R1;
+ if(group_name == "brainpool384r1")
+ return Group_Params::BRAINPOOL384R1;
+ if(group_name == "brainpool512r1")
+ return Group_Params::BRAINPOOL512R1;
+ if(group_name == "x25519")
+ return Group_Params::X25519;
+
+ if(group_name == "ffdhe/ietf/2048")
+ return Group_Params::FFDHE_2048;
+ if(group_name == "ffdhe/ietf/3072")
+ return Group_Params::FFDHE_3072;
+ if(group_name == "ffdhe/ietf/4096")
+ return Group_Params::FFDHE_4096;
+ if(group_name == "ffdhe/ietf/6144")
+ return Group_Params::FFDHE_6144;
+ if(group_name == "ffdhe/ietf/8192")
+ return Group_Params::FFDHE_8192;
+
+ return Group_Params::NONE; // unknown
+ }
+
std::string group_param_to_string(Group_Params group)
{
switch(group)