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,
29 X25519
30 };
31
33 CurveID,
34 {{CurveID::NONE, "None"},
35 {CurveID::SECP384R1, "Secp384R1"},
36 {CurveID::SECP256R1, "Secp256R1"},
37 {CurveID::SECP256K1, "Secp256K1"},
38 {CurveID::CURVE25519, "Curve25519"},
39 {CurveID::X25519, "X25519"}});
40
41 static constexpr CurveID service_identity_curve_choice = CurveID::SECP384R1;
42 // SNIPPET_END: supported_curves
43
44 // Get message digest algorithm to use for given elliptic curve
46 {
47 switch (ec)
48 {
50 return MDType::SHA384;
52 return MDType::SHA256;
54 return MDType::SHA256;
55 default:
56 {
57 throw std::logic_error(fmt::format("Unhandled CurveID: {}", ec));
58 }
59 }
60 }
61}
#define DECLARE_JSON_ENUM(TYPE,...)
Definition json.h:835
Definition base64.h:9
MDType get_md_for_ec(CurveID ec)
Definition curve.h:45
MDType
Definition md_type.h:10
CurveID
Definition curve.h:18
@ SECP384R1
The SECP384R1 curve.
@ SECP256K1
The SECP256K1 curve.
@ CURVE25519
The CURVE25519 curve.
@ SECP256R1
The SECP256R1 curve.