CCF
Loading...
Searching...
No Matches
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
7#include "ccf/ds/json.h"
8
9#define FMT_HEADER_ONLY
10#include <fmt/format.h>
11#include <stdexcept>
12#include <string>
13
14namespace ccf::crypto
15{
16 // SNIPPET_START: supported_curves
17 enum class CurveID
18 {
20 NONE = 0,
27 X25519
28 };
29
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
43 {
44 switch (ec)
45 {
47 return MDType::SHA384;
49 return MDType::SHA256;
50 default:
51 {
52 throw std::logic_error(fmt::format("Unhandled CurveID: {}", ec));
53 }
54 }
55 }
56}
#define DECLARE_JSON_ENUM(TYPE,...)
Definition json.h:837
Definition base64.h:10
MDType get_md_for_ec(CurveID ec)
Definition curve.h:42
MDType
Definition md_type.h:10
CurveID
Definition curve.h:18
@ SECP384R1
The SECP384R1 curve.
@ CURVE25519
The CURVE25519 curve.
@ SECP256R1
The SECP256R1 curve.