Skip to content

Commit

Permalink
Compatibility for cose_signatures_config field in /join response (#6632)
Browse files Browse the repository at this point in the history
  • Loading branch information
achamayou authored Nov 13, 2024
1 parent 2eb532a commit 852609a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 7 deletions.
18 changes: 18 additions & 0 deletions src/node/rpc/cose_signatures_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the Apache 2.0 License.
#pragma once

#include "ccf/ds/json.h"

#include <string>

struct COSESignaturesConfig
{
std::string issuer;
std::string subject;

bool operator==(const COSESignaturesConfig& other) const = default;
};

DECLARE_JSON_TYPE(COSESignaturesConfig);
DECLARE_JSON_REQUIRED_FIELDS(COSESignaturesConfig, issuer, subject);
12 changes: 9 additions & 3 deletions src/node/rpc/node_call_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "enclave/interface.h"
#include "node/identity.h"
#include "node/ledger_secrets.h"
#include "node/rpc/cose_signatures_config.h"
#include "node/uvm_endorsements.h"

#include <nlohmann/json.hpp>
Expand Down Expand Up @@ -105,6 +106,8 @@ namespace ccf
std::optional<ServiceStatus> service_status = std::nullopt;

std::optional<ccf::crypto::Pem> endorsed_certificate = std::nullopt;
std::optional<COSESignaturesConfig> cose_signatures_config =
std::nullopt;

NetworkInfo() {}

Expand All @@ -114,13 +117,15 @@ namespace ccf
const LedgerSecretsMap& ledger_secrets,
const NetworkIdentity& identity,
ServiceStatus service_status,
const std::optional<ccf::crypto::Pem>& endorsed_certificate) :
const std::optional<ccf::crypto::Pem>& endorsed_certificate,
const std::optional<COSESignaturesConfig>& cose_signatures_config_) :
public_only(public_only),
last_recovered_signed_idx(last_recovered_signed_idx),
ledger_secrets(ledger_secrets),
identity(identity),
service_status(service_status),
endorsed_certificate(endorsed_certificate)
endorsed_certificate(endorsed_certificate),
cose_signatures_config(cose_signatures_config_)
{}

bool operator==(const NetworkInfo& other) const
Expand All @@ -130,7 +135,8 @@ namespace ccf
ledger_secrets == other.ledger_secrets &&
identity == other.identity &&
service_status == other.service_status &&
endorsed_certificate == other.endorsed_certificate;
endorsed_certificate == other.endorsed_certificate &&
cose_signatures_config == other.cose_signatures_config;
}

bool operator!=(const NetworkInfo& other) const
Expand Down
9 changes: 6 additions & 3 deletions src/node/rpc/node_frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ namespace ccf
this->network.ledger_secrets->get(tx),
*this->network.identity.get(),
service_status,
endorsed_certificate};
endorsed_certificate,
std::nullopt /* cose_signatures_config */};
}
return make_success(rep);
}
Expand Down Expand Up @@ -483,7 +484,8 @@ namespace ccf
args.tx, existing_node_info->ledger_secret_seqno),
*this->network.identity.get(),
active_service->status,
existing_node_info->endorsed_certificate);
existing_node_info->endorsed_certificate,
std::nullopt /* cose_signatures_config */);

return make_success(rep);
}
Expand Down Expand Up @@ -558,7 +560,8 @@ namespace ccf
args.tx, existing_node_info->ledger_secret_seqno),
*this->network.identity.get(),
active_service->status,
existing_node_info->endorsed_certificate);
existing_node_info->endorsed_certificate,
std::nullopt /* cose_signatures_config */);

return make_success(rep);
}
Expand Down
4 changes: 3 additions & 1 deletion src/node/rpc/serialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ namespace ccf
DECLARE_JSON_OPTIONAL_FIELDS(
JoinNetworkNodeToNode::Out::NetworkInfo,
service_status,
endorsed_certificate)
endorsed_certificate,
cose_signatures_config)

DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS(JoinNetworkNodeToNode::Out)
DECLARE_JSON_REQUIRED_FIELDS(JoinNetworkNodeToNode::Out, node_status)
DECLARE_JSON_OPTIONAL_FIELDS(
Expand Down

0 comments on commit 852609a

Please sign in to comment.