Skip to content

Commit 49c7800

Browse files
authored
0.8 install fixes (#945)
1 parent 9e45c65 commit 49c7800

File tree

5 files changed

+24
-35
lines changed

5 files changed

+24
-35
lines changed

CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include(${CCF_DIR}/cmake/preproject.cmake)
77

88
project(
99
ccf
10-
VERSION 0.8
10+
VERSION 0.8.1
1111
LANGUAGES C CXX
1212
)
1313

@@ -64,7 +64,6 @@ if("sgx" IN_LIST TARGET)
6464
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/3rdparty/hacl-star/evercrypt>
6565
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/3rdparty/hacl-star/evercrypt/kremlin>
6666
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/3rdparty/hacl-star/evercrypt/kremlin/kremlib>
67-
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/generated>
6867
)
6968

7069
target_link_libraries(ccf.enclave PUBLIC libbyz.enclave)
@@ -117,7 +116,6 @@ if("virtual" IN_LIST TARGET)
117116
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/3rdparty/hacl-star/evercrypt>
118117
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/3rdparty/hacl-star/evercrypt/kremlin>
119118
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/3rdparty/hacl-star/evercrypt/kremlin/kremlib>
120-
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/generated>
121119
)
122120

123121
target_link_libraries(ccf.virtual PUBLIC libbyz.host)

cmake/ccf_app.cmake

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,6 @@ function(use_oe_mbedtls name)
9090
)
9191
endfunction()
9292

93-
if(NOT CCF_GENERATED_DIR)
94-
set(CCF_GENERATED_DIR ${CCF_DIR}/generated)
95-
endif()
96-
9793
# Enclave library wrapper
9894
function(add_ccf_app name)
9995

cmake/common.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ endif()
110110
enable_language(ASM)
111111

112112
set(CCF_GENERATED_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated)
113-
include_directories(${CCF_DIR}/src ${CCF_GENERATED_DIR})
113+
include_directories(${CCF_DIR}/src)
114114

115115
include_directories(
116116
SYSTEM ${CCF_DIR}/3rdparty ${CCF_DIR}/3rdparty/hacl-star
@@ -247,7 +247,9 @@ if("sgx" IN_LIST TARGET)
247247
cchost ${CCF_DIR}/src/host/main.cpp ${CCF_GENERATED_DIR}/ccf_u.cpp
248248
)
249249
use_client_mbedtls(cchost)
250-
target_include_directories(cchost PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
250+
target_include_directories(
251+
cchost PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CCF_GENERATED_DIR}
252+
)
251253
add_san(cchost)
252254

253255
target_link_libraries(
@@ -423,9 +425,7 @@ function(add_e2e_test)
423425
# Make python test client framework importable
424426
set_property(
425427
TEST ${PARSED_ARGS_NAME} APPEND
426-
PROPERTY
427-
ENVIRONMENT
428-
"PYTHONPATH=${CCF_DIR}/tests:${CCF_GENERATED_DIR}:$ENV{PYTHONPATH}"
428+
PROPERTY ENVIRONMENT "PYTHONPATH=${CCF_DIR}/tests:$ENV{PYTHONPATH}"
429429
)
430430
if(${PARSED_ARGS_IS_SUITE})
431431
set_property(TEST ${PARSED_ARGS_NAME} APPEND PROPERTY LABELS suite)

src/node/networkencryption.h

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,24 @@
22
// Licensed under the Apache 2.0 License.
33
#pragma once
44

5-
#include "crypto/cryptobox.h"
65
#include "tls/25519.h"
76
#include "tls/entropy.h"
87

98
namespace ccf
109
{
1110
struct NetworkEncryptionKey
1211
{
13-
private:
14-
static constexpr auto KEY_SIZE = crypto::BoxKey::KEY_SIZE;
15-
16-
public:
1712
std::vector<uint8_t> private_raw;
1813

1914
bool operator==(const NetworkEncryptionKey& other) const
2015
{
2116
return private_raw == other.private_raw;
2217
}
2318

24-
NetworkEncryptionKey(bool random = false)
25-
{
26-
if (random)
27-
{
28-
private_raw = tls::create_entropy()->random(crypto::BoxKey::KEY_SIZE);
29-
}
30-
}
19+
NetworkEncryptionKey() = default;
3120

32-
std::vector<uint8_t> get_public_pem()
33-
{
34-
return tls::PublicX25519::write(
35-
crypto::BoxKey::public_from_private(private_raw))
36-
.raw();
37-
}
21+
NetworkEncryptionKey(std::vector<uint8_t>&& private_key_raw) :
22+
private_raw(std::move(private_key_raw))
23+
{}
3824
};
3925
}

src/node/nodestate.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@ namespace ccf
271271
network.identity =
272272
std::make_unique<NetworkIdentity>("CN=CCF Network");
273273
network.ledger_secrets = std::make_shared<LedgerSecrets>(seal);
274-
network.encryption_key = std::make_unique<NetworkEncryptionKey>(true);
274+
network.encryption_key = std::make_unique<NetworkEncryptionKey>(
275+
tls::create_entropy()->random(crypto::BoxKey::KEY_SIZE));
275276

276277
self = 0; // The first node id is always 0
277278

@@ -300,7 +301,7 @@ namespace ccf
300301
return Success<CreateNew::Out>(
301302
{node_cert,
302303
network.identity->cert,
303-
network.encryption_key->get_public_pem()});
304+
get_network_encryption_key_public_pem()});
304305
}
305306
case StartType::Join:
306307
{
@@ -320,7 +321,8 @@ namespace ccf
320321
std::make_unique<NetworkIdentity>("CN=CCF Network");
321322
// Create temporary network secrets but do not seal yet
322323
network.ledger_secrets = std::make_shared<LedgerSecrets>(seal, false);
323-
network.encryption_key = std::make_unique<NetworkEncryptionKey>(true);
324+
network.encryption_key = std::make_unique<NetworkEncryptionKey>(
325+
tls::create_entropy()->random(crypto::BoxKey::KEY_SIZE));
324326

325327
setup_history();
326328
setup_encryptor(network.consensus_type);
@@ -336,7 +338,7 @@ namespace ccf
336338
return Success<CreateNew::Out>(
337339
{node_cert,
338340
network.identity->cert,
339-
network.encryption_key->get_public_pem()});
341+
get_network_encryption_key_public_pem()});
340342
}
341343
default:
342344
{
@@ -408,7 +410,7 @@ namespace ccf
408410
network.ledger_secrets = std::make_shared<LedgerSecrets>(
409411
std::move(resp.network_info.ledger_secrets), seal);
410412
network.encryption_key = std::make_unique<NetworkEncryptionKey>(
411-
resp.network_info.encryption_key);
413+
std::move(resp.network_info.encryption_key));
412414

413415
self = resp.node_id;
414416

@@ -1328,6 +1330,13 @@ namespace ccf
13281330
}
13291331
}
13301332

1333+
std::vector<uint8_t> get_network_encryption_key_public_pem()
1334+
{
1335+
return tls::PublicX25519::write(crypto::BoxKey::public_from_private(
1336+
network.encryption_key->private_raw))
1337+
.raw();
1338+
}
1339+
13311340
void reset_quote()
13321341
{
13331342
quote.clear();

0 commit comments

Comments
 (0)