Skip to content

Commit

Permalink
Replace manual serialization of hpke info and aad with structs
Browse files Browse the repository at this point in the history
  • Loading branch information
mendess committed Nov 27, 2024
1 parent 61db156 commit 596fc75
Show file tree
Hide file tree
Showing 9 changed files with 268 additions and 149 deletions.
7 changes: 3 additions & 4 deletions crates/daphne-server/src/roles/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use daphne::{
audit_log::AuditLog,
error::DapAbort,
fatal_error,
hpke::{self, HpkeConfig, HpkeProvider, HpkeReceiverConfig},
hpke::{self, info_and_aad, HpkeConfig, HpkeProvider, HpkeReceiverConfig},
messages::{self, BatchId, BatchSelector, HpkeCiphertext, TaskId, Time},
metrics::DaphneMetrics,
roles::{
Expand Down Expand Up @@ -363,11 +363,10 @@ pub struct HpkeDecrypter(Marc<Vec<HpkeReceiverConfig>>);
impl hpke::HpkeDecrypter for HpkeDecrypter {
fn hpke_decrypt(
&self,
info: &[u8],
aad: &[u8],
info: impl info_and_aad::InfoAndAad,
ciphertext: &HpkeCiphertext,
) -> Result<Vec<u8>, DapError> {
self.0.hpke_decrypt(info, aad, ciphertext)
self.0.hpke_decrypt(info, ciphertext)
}
}

Expand Down
15 changes: 7 additions & 8 deletions crates/daphne/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,14 @@ impl DapMediaType {
}
}

/// A role in the DAP aggregation protocol. The numeric value associated with each variant is the
/// numeric value used when serializing the sender and receiver roles in hpke encryption.
/// A role in the DAP aggregation protocol.
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum DapRole {
Collector = 0,
Client = 1,
Leader = 2,
Helper = 3,
Collector,
Client,
Leader,
Helper,
}

impl DapRole {
Expand Down Expand Up @@ -116,8 +115,8 @@ impl fmt::Display for DapRole {
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum DapAggregatorRole {
Leader = 2,
Helper = 3,
Leader,
Helper,
}

impl DapAggregatorRole {
Expand Down
Loading

0 comments on commit 596fc75

Please sign in to comment.