From 479f3111233806ce937e5334d16c3623b1b3d6d4 Mon Sep 17 00:00:00 2001 From: Matthew LeVan Date: Wed, 22 Nov 2023 13:27:44 -0500 Subject: [PATCH] address @ashelkovnykov's comments, pt. 1 --- rust/ares/src/jets/lock/aes.rs | 23 ++++++++++++++--------- rust/ares/src/jets/lock/ed.rs | 2 -- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/rust/ares/src/jets/lock/aes.rs b/rust/ares/src/jets/lock/aes.rs index 1297d7d..7ca7971 100644 --- a/rust/ares/src/jets/lock/aes.rs +++ b/rust/ares/src/jets/lock/aes.rs @@ -1,8 +1,8 @@ use crate::interpreter::Context; use crate::jets::bits::util::met; use crate::jets::util::slot; -use crate::jets::{Error, JetErr, Result}; -use crate::noun::{IndirectAtom, Noun, D}; +use crate::jets::{JetErr, Result}; +use crate::noun::{IndirectAtom, Noun}; use urcrypt_sys::*; crate::gdb!(); @@ -13,8 +13,7 @@ pub fn jet_siva_en(context: &mut Context, subject: Noun) -> Result { let key = slot(subject, 60)?.as_atom()?; let atoms = slot(subject, 61)?; - if (met(3, key) as usize) > 32 { - // XX vere punts; we should do the same in the future + if met(3, key) > 32 { Err(JetErr::Punt) } else { unsafe { @@ -40,6 +39,10 @@ pub fn jet_siva_de(context: &mut Context, subject: Noun) -> Result { let key = slot(subject, 60)?.as_atom()?; let ads = slot(subject, 61)?; + if met(3, key) > 64 { + return Err(JetErr::Punt); + } + unsafe { let (mut _key_ida, key_bytes) = IndirectAtom::new_raw_mut_bytes(stack, 32); key_bytes[0..key.as_bytes().len()].copy_from_slice(key.as_bytes()); @@ -62,9 +65,8 @@ pub fn jet_sivb_en(context: &mut Context, subject: Noun) -> Result { let key = slot(subject, 60)?.as_atom()?; let atoms = slot(subject, 61)?; - if (met(3, key) as usize) > 48 { - // XX vere punts; we should do the same in the future - Err(JetErr::Fail(Error::NonDeterministic(D(0)))) + if met(3, key) > 48 { + Err(JetErr::Punt) } else { unsafe { let (mut _key_ida, key_bytes) = IndirectAtom::new_raw_mut_bytes(stack, 48); @@ -89,6 +91,10 @@ pub fn jet_sivb_de(context: &mut Context, subject: Noun) -> Result { let key = slot(subject, 60)?.as_atom()?; let ads = slot(subject, 61)?; + if met(3, key) > 48 { + return Err(JetErr::Punt); + } + unsafe { let (mut _key_ida, key_bytes) = IndirectAtom::new_raw_mut_bytes(stack, 48); key_bytes[0..key.as_bytes().len()].copy_from_slice(key.as_bytes()); @@ -111,8 +117,7 @@ pub fn jet_sivc_en(context: &mut Context, subject: Noun) -> Result { let key = slot(subject, 60)?.as_atom()?; let atoms = slot(subject, 61)?; - if (met(3, key) as usize) > 64 { - // XX vere punts; we should do the same in the future + if met(3, key) > 64 { Err(JetErr::Punt) } else { unsafe { diff --git a/rust/ares/src/jets/lock/ed.rs b/rust/ares/src/jets/lock/ed.rs index 49c6795..a2decb6 100644 --- a/rust/ares/src/jets/lock/ed.rs +++ b/rust/ares/src/jets/lock/ed.rs @@ -95,13 +95,11 @@ pub fn jet_veri(context: &mut Context, subject: Noun) -> Result { unsafe { let sig_bytes = sig.as_bytes(); - // vere punts; we should do the same in the future if sig_bytes.len() > 64 { return Err(JetErr::Punt); }; let pub_bytes = puk.as_bytes(); - // vere punts; we should do the same in the future if pub_bytes.len() > 32 { return Err(JetErr::Punt); };