CCF
Loading...
Searching...
No Matches
include
ccf
crypto
curve.h
Go to the documentation of this file.
1
// Copyright (c) Microsoft Corporation. All rights reserved.
2
// Licensed under the Apache 2.0 License.
3
#pragma once
4
5
#include "
ccf/crypto/md_type.h
"
6
#include "
ccf/ds/enum_formatter.h
"
7
#include "
ccf/ds/json.h
"
8
9
#define FMT_HEADER_ONLY
10
#include <fmt/format.h>
11
#include <stdexcept>
12
#include <string>
13
14
namespace
ccf::crypto
15
{
16
// SNIPPET_START: supported_curves
17
enum class
CurveID
18
{
20
NONE
= 0,
22
SECP384R1
,
24
SECP256R1
,
26
CURVE25519
,
27
X25519
28
};
29
30
DECLARE_JSON_ENUM
(
31
CurveID
,
32
{{
CurveID::NONE
,
"None"
},
33
{
CurveID::SECP384R1
,
"Secp384R1"
},
34
{
CurveID::SECP256R1
,
"Secp256R1"
},
35
{
CurveID::CURVE25519
,
"Curve25519"
},
36
{
CurveID::X25519
,
"X25519"
}});
37
38
static
constexpr
CurveID
service_identity_curve_choice =
CurveID::SECP384R1
;
39
// SNIPPET_END: supported_curves
40
41
// Get message digest algorithm to use for given elliptic curve
42
inline
MDType
get_md_for_ec
(
CurveID
ec)
43
{
44
switch
(ec)
45
{
46
case
CurveID::SECP384R1
:
47
return
MDType::SHA384
;
48
case
CurveID::SECP256R1
:
49
return
MDType::SHA256
;
50
default
:
51
{
52
throw
std::logic_error(fmt::format(
"Unhandled CurveID: {}"
, ec));
53
}
54
}
55
}
56
}
enum_formatter.h
json.h
DECLARE_JSON_ENUM
#define DECLARE_JSON_ENUM(TYPE,...)
Definition
json.h:837
md_type.h
ccf::crypto
Definition
base64.h:10
ccf::crypto::get_md_for_ec
MDType get_md_for_ec(CurveID ec)
Definition
curve.h:42
ccf::crypto::MDType
MDType
Definition
md_type.h:10
ccf::crypto::MDType::SHA256
@ SHA256
ccf::crypto::MDType::SHA384
@ SHA384
ccf::crypto::CurveID
CurveID
Definition
curve.h:18
ccf::crypto::CurveID::SECP384R1
@ SECP384R1
The SECP384R1 curve.
ccf::crypto::CurveID::CURVE25519
@ CURVE25519
The CURVE25519 curve.
ccf::crypto::CurveID::NONE
@ NONE
No curve.
ccf::crypto::CurveID::SECP256R1
@ SECP256R1
The SECP256R1 curve.
ccf::crypto::CurveID::X25519
@ X25519
Generated by
1.9.8