Skip to content

Commit

Permalink
Add report_too_early to PrepareError (#2538)
Browse files Browse the repository at this point in the history
* Add report_too_early to PrepareError

* Add serialization test for HpkeConfigList
  • Loading branch information
divergentdave authored Jan 24, 2024
1 parent 2b64b2a commit ce9f0a4
Showing 1 changed file with 53 additions and 1 deletion.
54 changes: 53 additions & 1 deletion messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2335,6 +2335,7 @@ pub enum PrepareError {
BatchSaturated = 6,
TaskExpired = 7,
InvalidMessage = 8,
ReportTooEarly = 9,
}

impl Encode for PrepareError {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(&[
Expand Down Expand Up @@ -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"),
])
}

Expand Down

0 comments on commit ce9f0a4

Please sign in to comment.