Skip to content

Commit

Permalink
keymanager/src/churp: Respond to requests only if node is in committee
Browse files Browse the repository at this point in the history
An enclave should respond to share reduction and SGX policy key share
requests only if it is part of the committee. Similarly, it should only
respond to bivariate share, proactivization, and share distribution
requests if the node has applied for the next committee.
  • Loading branch information
peternose committed Jul 25, 2024
1 parent 86cc53b commit 381407e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Empty file added .changelog/5792.trivial.md
Empty file.
16 changes: 16 additions & 0 deletions keymanager/src/churp/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,10 @@ impl<S: Suite> Instance<S> {
impl<S: Suite> Handler for Instance<S> {
fn verification_matrix(&self, req: &QueryRequest) -> Result<Vec<u8>> {
let status = self.verify_last_handoff(req.epoch)?;
if !status.committee.contains(&self.node_id) {
return Err(Error::NotInCommittee.into());
}

let shareholder = self.get_shareholder(status.handoff)?;
let vm = shareholder
.verifiable_share()
Expand All @@ -1197,6 +1201,9 @@ impl<S: Suite> Handler for Instance<S> {
req: &QueryRequest,
) -> Result<Vec<u8>> {
let status = self.verify_next_handoff(req.epoch)?;
if !status.committee.contains(&self.node_id) {
return Err(Error::NotInCommittee.into());
}

let kind = Self::handoff_kind(&status);
if !matches!(kind, HandoffKind::CommitteeChanged) {
Expand Down Expand Up @@ -1225,6 +1232,9 @@ impl<S: Suite> Handler for Instance<S> {
req: &QueryRequest,
) -> Result<Vec<u8>> {
let status = self.verify_next_handoff(req.epoch)?;
if !status.applications.contains_key(&self.node_id) {
return Err(Error::NotInCommittee.into());
}

let kind = Self::handoff_kind(&status);
if !matches!(kind, HandoffKind::CommitteeChanged) {
Expand Down Expand Up @@ -1254,6 +1264,9 @@ impl<S: Suite> Handler for Instance<S> {
req: &QueryRequest,
) -> Result<EncodedVerifiableSecretShare> {
let status = self.verify_next_handoff(req.epoch)?;
if !status.applications.contains_key(&self.node_id) {
return Err(Error::NotInCommittee.into());
}

let node_id = req.node_id.as_ref().ok_or(Error::NotAuthenticated)?;
if !status.applications.contains_key(node_id) {
Expand Down Expand Up @@ -1307,6 +1320,9 @@ impl<S: Suite> Handler for Instance<S> {
if status.handoff != req.epoch {
return Err(Error::HandoffMismatch.into());
}
if !status.committee.contains(&self.node_id) {
return Err(Error::NotInCommittee.into());
}

// Note that querying past key shares can fail at this point
// if the policy has changed.
Expand Down

0 comments on commit 381407e

Please sign in to comment.