|
|
@@ -51,12 +51,12 @@ use std::collections::HashMap;
|
|
|
/// The minimum trust level a Lox credential must have to be allowed to
|
|
|
/// perform this protocol.
|
|
|
pub const MIN_TRUST_LEVEL: u32 = 3;
|
|
|
+const SESSION_ID: &[u8] = b"check_blockage";
|
|
|
|
|
|
-muCMZProtocol! { check_blockage<min_trust_level, max_trust_level>,
|
|
|
+muCMZProtocol! { check_blockage,
|
|
|
L: Lox { id: R, bucket: H, trust_level: R, level_since: H, invites_remaining: R, blockages: R },
|
|
|
M: MigrationKey { lox_id: J, from_bucket: H} ,
|
|
|
L.bucket = M.from_bucket,
|
|
|
- [min_trust_level..max_trust_leve].contains(L.trust_level),
|
|
|
}
|
|
|
|
|
|
pub fn request(
|
|
|
@@ -84,7 +84,7 @@ pub fn request(
|
|
|
))
|
|
|
}
|
|
|
};
|
|
|
- if level < MIN_TRUST_LEVEL {
|
|
|
+ if !(MIN_TRUST_LEVEL..=MAX_LEVEL as u32).contains(&level) {
|
|
|
return Err(CredentialError::InvalidField(
|
|
|
String::from("trust_level"),
|
|
|
format!("level {:?} not in range", level),
|
|
|
@@ -92,16 +92,11 @@ pub fn request(
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- let params = check_blockage::Params {
|
|
|
- min_trust_level: MIN_TRUST_LEVEL.into(),
|
|
|
- max_trust_level: (MAX_LEVEL as u32).into(),
|
|
|
- };
|
|
|
-
|
|
|
match check_blockage::prepare(
|
|
|
&mut rng,
|
|
|
+ SESSION_ID,
|
|
|
&L,
|
|
|
MigrationKey::using_pubkey(&mig_pubkeys),
|
|
|
- ¶ms,
|
|
|
) {
|
|
|
Ok(req_state) => Ok(req_state),
|
|
|
Err(e) => Err(CredentialError::CMZError(e)),
|
|
|
@@ -126,16 +121,33 @@ impl BridgeAuth {
|
|
|
|
|
|
match check_blockage::handle(
|
|
|
&mut rng,
|
|
|
+ SESSION_ID,
|
|
|
recvreq,
|
|
|
|L: &mut Lox, M: &mut MigrationKey| {
|
|
|
+ // Ensure the credential can be correctly shown: it must be the case
|
|
|
+ // that trust_level >= MIN_TRUST_LEVEL
|
|
|
+ if let Some(tl) = L.trust_level {
|
|
|
+ let level: u32 = match scalar_u32(&tl) {
|
|
|
+ Some(v) => v,
|
|
|
+ None => {
|
|
|
+ return Err(CMZError::RevealAttrMissing(
|
|
|
+ "trust_level",
|
|
|
+ "could not be converted to u32",
|
|
|
+ ))
|
|
|
+ }
|
|
|
+ };
|
|
|
+ if !(MIN_TRUST_LEVEL..=MAX_LEVEL as u32).contains(&level) {
|
|
|
+ return Err(CMZError::RevealAttrMissing(
|
|
|
+ "trust_level",
|
|
|
+ "level not in range",
|
|
|
+ ));
|
|
|
+ }
|
|
|
+ };
|
|
|
L.set_privkey(&self.lox_priv);
|
|
|
M.set_privkey(&self.migrationkey_priv);
|
|
|
M.lox_id = L.id;
|
|
|
M.from_bucket = L.bucket;
|
|
|
- Ok(check_blockage::Params {
|
|
|
- min_trust_level: MIN_TRUST_LEVEL.into(),
|
|
|
- max_trust_level: (MAX_LEVEL as u32).into(),
|
|
|
- })
|
|
|
+ Ok(())
|
|
|
},
|
|
|
|L: &Lox, _M: &MigrationKey| {
|
|
|
if self.id_filter.filter(&L.id.unwrap()) == SeenType::Seen {
|