20260410 完成五个rir 基于cir的三方回放,raw by hash 独立db,发现内存占用大,连续大rir 录制发生oom
This commit is contained in:
@@ -1,19 +1,21 @@
|
||||
use rpki::ccr::{
|
||||
CcrContentInfo, CcrDigestAlgorithm, ManifestInstance, ManifestState, RoaPayloadSet,
|
||||
RoaPayloadState, RouterKey, RouterKeySet, RouterKeyState, TrustAnchorState,
|
||||
compute_state_hash, decode_content_info, dump_content_info_json_value,
|
||||
RoaPayloadState, RouterKey, RouterKeySet, RouterKeyState, TrustAnchorState, compute_state_hash,
|
||||
decode_content_info, dump_content_info_json_value,
|
||||
encode::{
|
||||
encode_aspa_payload_state_payload_der, encode_content_info,
|
||||
encode_manifest_state_payload_der, encode_roa_payload_state_payload_der,
|
||||
encode_router_key_state_payload_der, encode_trust_anchor_state_payload_der,
|
||||
},
|
||||
verify::{verify_against_report_json_path, verify_against_vcir_store, verify_content_info_bytes},
|
||||
verify::{
|
||||
verify_against_report_json_path, verify_against_vcir_store, verify_content_info_bytes,
|
||||
},
|
||||
};
|
||||
use rpki::data_model::common::BigUnsigned;
|
||||
use rpki::storage::{
|
||||
PackTime, RocksStore, ValidatedCaInstanceResult, ValidatedManifestMeta,
|
||||
VcirArtifactKind, VcirArtifactRole, VcirArtifactValidationStatus, VcirAuditSummary,
|
||||
VcirChildEntry, VcirInstanceGate, VcirRelatedArtifact, VcirSummary,
|
||||
PackTime, RocksStore, ValidatedCaInstanceResult, ValidatedManifestMeta, VcirArtifactKind,
|
||||
VcirArtifactRole, VcirArtifactValidationStatus, VcirAuditSummary, VcirChildEntry,
|
||||
VcirInstanceGate, VcirRelatedArtifact, VcirSummary,
|
||||
};
|
||||
|
||||
fn sample_time() -> time::OffsetDateTime {
|
||||
@@ -45,28 +47,51 @@ fn sample_manifest_state() -> ManifestState {
|
||||
fn sample_roa_state() -> RoaPayloadState {
|
||||
let rps = vec![RoaPayloadSet {
|
||||
as_id: 64496,
|
||||
ip_addr_blocks: vec![vec![0x30, 0x08, 0x04, 0x02, 0x00, 0x01, 0x30, 0x02, 0x03, 0x00]],
|
||||
ip_addr_blocks: vec![vec![
|
||||
0x30, 0x08, 0x04, 0x02, 0x00, 0x01, 0x30, 0x02, 0x03, 0x00,
|
||||
]],
|
||||
}];
|
||||
let der = encode_roa_payload_state_payload_der(&rps).expect("encode rps");
|
||||
RoaPayloadState { rps, hash: compute_state_hash(&der) }
|
||||
RoaPayloadState {
|
||||
rps,
|
||||
hash: compute_state_hash(&der),
|
||||
}
|
||||
}
|
||||
|
||||
fn sample_aspa_state() -> rpki::ccr::AspaPayloadState {
|
||||
let aps = vec![rpki::ccr::AspaPayloadSet { customer_as_id: 64496, providers: vec![64497] }];
|
||||
let aps = vec![rpki::ccr::AspaPayloadSet {
|
||||
customer_as_id: 64496,
|
||||
providers: vec![64497],
|
||||
}];
|
||||
let der = encode_aspa_payload_state_payload_der(&aps).expect("encode aps");
|
||||
rpki::ccr::AspaPayloadState { aps, hash: compute_state_hash(&der) }
|
||||
rpki::ccr::AspaPayloadState {
|
||||
aps,
|
||||
hash: compute_state_hash(&der),
|
||||
}
|
||||
}
|
||||
|
||||
fn sample_ta_state() -> TrustAnchorState {
|
||||
let skis = vec![vec![0x11; 20]];
|
||||
let der = encode_trust_anchor_state_payload_der(&skis).expect("encode skis");
|
||||
TrustAnchorState { skis, hash: compute_state_hash(&der) }
|
||||
TrustAnchorState {
|
||||
skis,
|
||||
hash: compute_state_hash(&der),
|
||||
}
|
||||
}
|
||||
|
||||
fn sample_rks() -> RouterKeyState {
|
||||
let rksets = vec![RouterKeySet { as_id: 64496, router_keys: vec![RouterKey { ski: vec![0x22; 20], spki_der: vec![0x30, 0x00] }] }];
|
||||
let rksets = vec![RouterKeySet {
|
||||
as_id: 64496,
|
||||
router_keys: vec![RouterKey {
|
||||
ski: vec![0x22; 20],
|
||||
spki_der: vec![0x30, 0x00],
|
||||
}],
|
||||
}];
|
||||
let der = encode_router_key_state_payload_der(&rksets).expect("encode rk");
|
||||
RouterKeyState { rksets, hash: compute_state_hash(&der) }
|
||||
RouterKeyState {
|
||||
rksets,
|
||||
hash: compute_state_hash(&der),
|
||||
}
|
||||
}
|
||||
|
||||
fn sample_ccr() -> Vec<u8> {
|
||||
@@ -102,7 +127,10 @@ fn verify_content_info_bytes_rejects_tampered_manifest_hash() {
|
||||
content_info.content.mfts.as_mut().unwrap().hash[0] ^= 0x01;
|
||||
let der = encode_content_info(&content_info).expect("encode tampered ccr");
|
||||
let err = verify_content_info_bytes(&der).expect_err("tampered hash must fail");
|
||||
assert!(err.to_string().contains("ManifestState hash mismatch"), "{err}");
|
||||
assert!(
|
||||
err.to_string().contains("ManifestState hash mismatch"),
|
||||
"{err}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -128,8 +156,21 @@ fn verify_against_report_json_path_rejects_mismatching_report() {
|
||||
|
||||
let mut ci = decode_content_info(&sample_ccr()).expect("decode ccr");
|
||||
ci.content.vrps = Some(RoaPayloadState {
|
||||
rps: vec![RoaPayloadSet { as_id: 64496, ip_addr_blocks: vec![vec![0x30, 0x08, 0x04, 0x02, 0x00, 0x01, 0x30, 0x02, 0x03, 0x00]] }],
|
||||
hash: compute_state_hash(&encode_roa_payload_state_payload_der(&[RoaPayloadSet { as_id: 64496, ip_addr_blocks: vec![vec![0x30, 0x08, 0x04, 0x02, 0x00, 0x01, 0x30, 0x02, 0x03, 0x00]] }]).unwrap()),
|
||||
rps: vec![RoaPayloadSet {
|
||||
as_id: 64496,
|
||||
ip_addr_blocks: vec![vec![
|
||||
0x30, 0x08, 0x04, 0x02, 0x00, 0x01, 0x30, 0x02, 0x03, 0x00,
|
||||
]],
|
||||
}],
|
||||
hash: compute_state_hash(
|
||||
&encode_roa_payload_state_payload_der(&[RoaPayloadSet {
|
||||
as_id: 64496,
|
||||
ip_addr_blocks: vec![vec![
|
||||
0x30, 0x08, 0x04, 0x02, 0x00, 0x01, 0x30, 0x02, 0x03, 0x00,
|
||||
]],
|
||||
}])
|
||||
.unwrap(),
|
||||
),
|
||||
});
|
||||
verify_against_report_json_path(&ci, &report_path).expect_err("report mismatch expected");
|
||||
}
|
||||
@@ -184,7 +225,7 @@ fn verify_against_vcir_store_matches_manifest_hashes() {
|
||||
summary: VcirSummary {
|
||||
local_vrp_count: 0,
|
||||
local_aspa_count: 0,
|
||||
local_router_key_count: 0,
|
||||
local_router_key_count: 0,
|
||||
child_count: 1,
|
||||
accepted_object_count: 1,
|
||||
rejected_object_count: 0,
|
||||
|
||||
Reference in New Issue
Block a user