From ce9f0a42b6e61f5cc0b5d470246310689c48cee2 Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 24 Jan 2024 10:27:04 -0600 Subject: [PATCH] Add report_too_early to PrepareError (#2538) * Add report_too_early to PrepareError * Add serialization test for HpkeConfigList --- messages/src/lib.rs | 54 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/messages/src/lib.rs b/messages/src/lib.rs index d9b1fd0c2..509518408 100644 --- a/messages/src/lib.rs +++ b/messages/src/lib.rs @@ -2335,6 +2335,7 @@ pub enum PrepareError { BatchSaturated = 6, TaskExpired = 7, InvalidMessage = 8, + ReportTooEarly = 9, } impl Encode for PrepareError { @@ -2933,7 +2934,7 @@ mod tests { AggregationJobContinueReq, AggregationJobInitializeReq, AggregationJobResp, AggregationJobStep, BatchId, BatchSelector, Collection, CollectionReq, Duration, Extension, ExtensionType, FixedSize, FixedSizeQuery, HpkeAeadId, HpkeCiphertext, HpkeConfig, - HpkeConfigId, HpkeKdfId, HpkeKemId, HpkePublicKey, InputShareAad, Interval, + HpkeConfigId, HpkeConfigList, HpkeKdfId, HpkeKemId, HpkePublicKey, InputShareAad, Interval, PartialBatchSelector, PlaintextInputShare, PrepareContinue, PrepareError, PrepareInit, PrepareResp, PrepareStepResult, Query, Report, ReportId, ReportIdChecksum, ReportMetadata, ReportShare, Role, TaskId, Time, TimeInterval, Url, @@ -3351,6 +3352,53 @@ mod tests { ]) } + #[test] + fn roundtrip_hpke_config_list() { + roundtrip_encoding(&[( + HpkeConfigList::new(Vec::from([ + HpkeConfig::new( + HpkeConfigId::from(12), + HpkeKemId::P256HkdfSha256, + HpkeKdfId::HkdfSha512, + HpkeAeadId::Aes256Gcm, + HpkePublicKey::from(Vec::new()), + ), + HpkeConfig::new( + HpkeConfigId::from(12), + HpkeKemId::P256HkdfSha256, + HpkeKdfId::HkdfSha512, + HpkeAeadId::Other(0x9999), + HpkePublicKey::from(Vec::new()), + ), + ])), + concat!( + "0012", + concat!( + "0C", // id + "0010", // kem_id + "0003", // kdf_id + "0002", // aead_id + concat!( + // public_key + "0000", // length + "", // opaque data + ) + ), + concat!( + "0C", // id + "0010", // kem_id + "0003", // kdf_id + "9999", // aead_id + concat!( + // public_key + "0000", // length + "", // opaque data + ) + ), + ), + )]); + } + #[test] fn roundtrip_report_metadata() { roundtrip_encoding(&[ @@ -4313,6 +4361,10 @@ mod tests { (PrepareError::HpkeUnknownConfigId, "03"), (PrepareError::HpkeDecryptError, "04"), (PrepareError::VdafPrepError, "05"), + (PrepareError::BatchSaturated, "06"), + (PrepareError::TaskExpired, "07"), + (PrepareError::InvalidMessage, "08"), + (PrepareError::ReportTooEarly, "09"), ]) }