Skip to content

Commit

Permalink
0.8 install fixes (#945)
Browse files Browse the repository at this point in the history
  • Loading branch information
jumaffre authored Mar 12, 2020
1 parent 9e45c65 commit 49c7800
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 35 deletions.
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ include(${CCF_DIR}/cmake/preproject.cmake)

project(
ccf
VERSION 0.8
VERSION 0.8.1
LANGUAGES C CXX
)

Expand Down Expand Up @@ -64,7 +64,6 @@ if("sgx" IN_LIST TARGET)
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/3rdparty/hacl-star/evercrypt>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/3rdparty/hacl-star/evercrypt/kremlin>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/3rdparty/hacl-star/evercrypt/kremlin/kremlib>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/generated>
)

target_link_libraries(ccf.enclave PUBLIC libbyz.enclave)
Expand Down Expand Up @@ -117,7 +116,6 @@ if("virtual" IN_LIST TARGET)
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/3rdparty/hacl-star/evercrypt>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/3rdparty/hacl-star/evercrypt/kremlin>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/3rdparty/hacl-star/evercrypt/kremlin/kremlib>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/generated>
)

target_link_libraries(ccf.virtual PUBLIC libbyz.host)
Expand Down
4 changes: 0 additions & 4 deletions cmake/ccf_app.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ function(use_oe_mbedtls name)
)
endfunction()

if(NOT CCF_GENERATED_DIR)
set(CCF_GENERATED_DIR ${CCF_DIR}/generated)
endif()

# Enclave library wrapper
function(add_ccf_app name)

Expand Down
10 changes: 5 additions & 5 deletions cmake/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ endif()
enable_language(ASM)

set(CCF_GENERATED_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated)
include_directories(${CCF_DIR}/src ${CCF_GENERATED_DIR})
include_directories(${CCF_DIR}/src)

include_directories(
SYSTEM ${CCF_DIR}/3rdparty ${CCF_DIR}/3rdparty/hacl-star
Expand Down Expand Up @@ -247,7 +247,9 @@ if("sgx" IN_LIST TARGET)
cchost ${CCF_DIR}/src/host/main.cpp ${CCF_GENERATED_DIR}/ccf_u.cpp
)
use_client_mbedtls(cchost)
target_include_directories(cchost PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(
cchost PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CCF_GENERATED_DIR}
)
add_san(cchost)

target_link_libraries(
Expand Down Expand Up @@ -423,9 +425,7 @@ function(add_e2e_test)
# Make python test client framework importable
set_property(
TEST ${PARSED_ARGS_NAME} APPEND
PROPERTY
ENVIRONMENT
"PYTHONPATH=${CCF_DIR}/tests:${CCF_GENERATED_DIR}:$ENV{PYTHONPATH}"
PROPERTY ENVIRONMENT "PYTHONPATH=${CCF_DIR}/tests:$ENV{PYTHONPATH}"
)
if(${PARSED_ARGS_IS_SUITE})
set_property(TEST ${PARSED_ARGS_NAME} APPEND PROPERTY LABELS suite)
Expand Down
22 changes: 4 additions & 18 deletions src/node/networkencryption.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,24 @@
// Licensed under the Apache 2.0 License.
#pragma once

#include "crypto/cryptobox.h"
#include "tls/25519.h"
#include "tls/entropy.h"

namespace ccf
{
struct NetworkEncryptionKey
{
private:
static constexpr auto KEY_SIZE = crypto::BoxKey::KEY_SIZE;

public:
std::vector<uint8_t> private_raw;

bool operator==(const NetworkEncryptionKey& other) const
{
return private_raw == other.private_raw;
}

NetworkEncryptionKey(bool random = false)
{
if (random)
{
private_raw = tls::create_entropy()->random(crypto::BoxKey::KEY_SIZE);
}
}
NetworkEncryptionKey() = default;

std::vector<uint8_t> get_public_pem()
{
return tls::PublicX25519::write(
crypto::BoxKey::public_from_private(private_raw))
.raw();
}
NetworkEncryptionKey(std::vector<uint8_t>&& private_key_raw) :
private_raw(std::move(private_key_raw))
{}
};
}
19 changes: 14 additions & 5 deletions src/node/nodestate.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ namespace ccf
network.identity =
std::make_unique<NetworkIdentity>("CN=CCF Network");
network.ledger_secrets = std::make_shared<LedgerSecrets>(seal);
network.encryption_key = std::make_unique<NetworkEncryptionKey>(true);
network.encryption_key = std::make_unique<NetworkEncryptionKey>(
tls::create_entropy()->random(crypto::BoxKey::KEY_SIZE));

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

Expand Down Expand Up @@ -300,7 +301,7 @@ namespace ccf
return Success<CreateNew::Out>(
{node_cert,
network.identity->cert,
network.encryption_key->get_public_pem()});
get_network_encryption_key_public_pem()});
}
case StartType::Join:
{
Expand All @@ -320,7 +321,8 @@ namespace ccf
std::make_unique<NetworkIdentity>("CN=CCF Network");
// Create temporary network secrets but do not seal yet
network.ledger_secrets = std::make_shared<LedgerSecrets>(seal, false);
network.encryption_key = std::make_unique<NetworkEncryptionKey>(true);
network.encryption_key = std::make_unique<NetworkEncryptionKey>(
tls::create_entropy()->random(crypto::BoxKey::KEY_SIZE));

setup_history();
setup_encryptor(network.consensus_type);
Expand All @@ -336,7 +338,7 @@ namespace ccf
return Success<CreateNew::Out>(
{node_cert,
network.identity->cert,
network.encryption_key->get_public_pem()});
get_network_encryption_key_public_pem()});
}
default:
{
Expand Down Expand Up @@ -408,7 +410,7 @@ namespace ccf
network.ledger_secrets = std::make_shared<LedgerSecrets>(
std::move(resp.network_info.ledger_secrets), seal);
network.encryption_key = std::make_unique<NetworkEncryptionKey>(
resp.network_info.encryption_key);
std::move(resp.network_info.encryption_key));

self = resp.node_id;

Expand Down Expand Up @@ -1328,6 +1330,13 @@ namespace ccf
}
}

std::vector<uint8_t> get_network_encryption_key_public_pem()
{
return tls::PublicX25519::write(crypto::BoxKey::public_from_private(
network.encryption_key->private_raw))
.raw();
}

void reset_quote()
{
quote.clear();
Expand Down

0 comments on commit 49c7800

Please sign in to comment.