Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
achamayou committed Jan 2, 2025
1 parent f42a2e1 commit c571472
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 28 deletions.
5 changes: 0 additions & 5 deletions src/node/cose_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ namespace ccf::cose
{
CWT_ISS_INDEX,
CWT_SUB_INDEX,
CWT_IAT_INDEX,
CWT_END_INDEX,
};
QCBORItem cwt_items[CWT_END_INDEX + 1];
Expand All @@ -129,10 +128,6 @@ namespace ccf::cose
cwt_items[CWT_SUB_INDEX].uLabelType = QCBOR_TYPE_INT64;
cwt_items[CWT_SUB_INDEX].uDataType = QCBOR_TYPE_TEXT_STRING;

cwt_items[CWT_IAT_INDEX].label.int64 = crypto::COSE_PHEADER_KEY_IAT;
cwt_items[CWT_IAT_INDEX].uLabelType = QCBOR_TYPE_INT64;
cwt_items[CWT_IAT_INDEX].uDataType = QCBOR_TYPE_DATE_EPOCH;

cwt_items[CWT_END_INDEX].uLabelType = QCBOR_TYPE_NONE;

header_items[END_INDEX].uLabelType = QCBOR_TYPE_NONE;
Expand Down
26 changes: 19 additions & 7 deletions src/node/node_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -1051,20 +1051,32 @@ namespace ccf
throw std::logic_error("No signature found after recovery");
}

ccf::COSESignaturesConfig cs_cfg{};
auto lcs = tx.ro(network.cose_signatures)->get();
if (lcs.has_value())
{}
{
CoseSignature cs = lcs.value();
LOG_INFO_FMT("COSE signature found after recovery");
try
{
auto [issuer, subject] = cose::extract_iss_sub_from_sig(cs);
LOG_INFO_FMT(
"COSE signature issuer: {}, subject: {}", issuer, subject);
cs_cfg = ccf::COSESignaturesConfig{issuer, subject};
}
catch (const cose::COSEDecodeError& e)
{
LOG_FAIL_FMT("COSE signature decode error: {}", e.what());
throw;
}
}
else
{
throw std::logic_error("No COSE signature found after recovery");
LOG_INFO_FMT("No COSE signature found after recovery");
}
CoseSignature cs = lcs.value();

auto [issuer, subject] = cose::extract_iss_sub_from_sig(cs);

history->set_service_signing_identity(
network.identity->get_key_pair(),
ccf::COSESignaturesConfig{issuer, subject});
network.identity->get_key_pair(), cs_cfg);

auto h = dynamic_cast<MerkleTxHistory*>(history.get());
if (h)
Expand Down
32 changes: 16 additions & 16 deletions tests/recovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -1032,21 +1032,21 @@ def add(parser):
# can be dictated by the test. In particular, the signature interval is large
# enough to create in-progress ledger files that do not end on a signature. The
# test is also in control of the ledger chunking.
cr.add(
"recovery_corrupt_ledger",
run_corrupted_ledger,
package="samples/apps/logging/liblogging",
nodes=infra.e2e_args.min_nodes(cr.args, f=0), # 1 node suffices for recovery
sig_ms_interval=1000,
ledger_chunk_bytes="1GB",
snapshot_tx_interval=1000000,
)

cr.add(
"recovery_snapshot_alone",
run_recover_snapshot_alone,
package="samples/apps/logging/liblogging",
nodes=infra.e2e_args.min_nodes(cr.args, f=0), # 1 node suffices for recovery
)
# cr.add(
# "recovery_corrupt_ledger",
# run_corrupted_ledger,
# package="samples/apps/logging/liblogging",
# nodes=infra.e2e_args.min_nodes(cr.args, f=0), # 1 node suffices for recovery
# sig_ms_interval=1000,
# ledger_chunk_bytes="1GB",
# snapshot_tx_interval=1000000,
# )

# cr.add(
# "recovery_snapshot_alone",
# run_recover_snapshot_alone,
# package="samples/apps/logging/liblogging",
# nodes=infra.e2e_args.min_nodes(cr.args, f=0), # 1 node suffices for recovery
# )

cr.run()

0 comments on commit c571472

Please sign in to comment.