CCF
Loading...
Searching...
No Matches
identity.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/curve.h"
8#include "crypto/certs.h"
10
11#include <openssl/crypto.h>
12#include <string>
13#include <vector>
14
15namespace ccf
16{
18 {
21
22 bool operator==(const NetworkIdentity& other) const = default;
23
25 const std::string& subject_name,
26 ccf::crypto::CurveID curve_id,
27 const std::string& valid_from,
28 size_t validity_period_days)
29 {
30 auto identity_key_pair =
31 std::make_shared<ccf::crypto::KeyPair_OpenSSL>(curve_id);
32 priv_key = identity_key_pair->private_key_pem();
33
34 cert = ccf::crypto::create_self_signed_cert(
35 identity_key_pair,
36 subject_name,
37 {} /* SAN */,
38 valid_from,
39 validity_period_days);
40 }
41
42 NetworkIdentity(const NetworkIdentity& other) = default;
43
44 NetworkIdentity() = default;
45
47 {
48 OPENSSL_cleanse(priv_key.data(), priv_key.size());
49 }
50
52 const std::string& valid_from, size_t validity_period_days)
53 {
54 return ccf::crypto::create_self_signed_cert(
57 {} /* SAN */,
58 valid_from,
59 validity_period_days);
60 }
61
62 void set_certificate(const ccf::crypto::Pem& new_cert)
63 {
64 cert = new_cert;
65 }
66
67 std::shared_ptr<ccf::crypto::KeyPair_OpenSSL> get_key_pair()
68 {
69 return std::make_shared<ccf::crypto::KeyPair_OpenSSL>(priv_key);
70 }
71 };
72}
Definition pem.h:18
size_t size() const
Definition pem.h:61
uint8_t * data()
Definition pem.h:51
CurveID
Definition curve.h:18
std::string get_subject_name(const Pem &cert)
Definition verifier.cpp:53
Definition app_interface.h:14
Definition identity.h:18
NetworkIdentity(const std::string &subject_name, ccf::crypto::CurveID curve_id, const std::string &valid_from, size_t validity_period_days)
Definition identity.h:24
ccf::crypto::Pem renew_certificate(const std::string &valid_from, size_t validity_period_days)
Definition identity.h:51
void set_certificate(const ccf::crypto::Pem &new_cert)
Definition identity.h:62
std::shared_ptr< ccf::crypto::KeyPair_OpenSSL > get_key_pair()
Definition identity.h:67
NetworkIdentity()=default
NetworkIdentity(const NetworkIdentity &other)=default
ccf::crypto::Pem cert
Definition identity.h:20
ccf::crypto::Pem priv_key
Definition identity.h:19
bool operator==(const NetworkIdentity &other) const =default
virtual ~NetworkIdentity()
Definition identity.h:46