diff --git a/lakers-python/README.md b/lakers-python/README.md index abc0eabd..227dcfb6 100644 --- a/lakers-python/README.md +++ b/lakers-python/README.md @@ -42,7 +42,7 @@ To deploy: ln -s ../examples ./examples MATURIN_PYPI_TOKEN= maturin publish ``` - +.take().ok_or(StateMismatch)?, ## Requirements The maturin executable must be available. The recommended way is to install and use it in a virtual environment: diff --git a/lakers-python/src/initiator.rs b/lakers-python/src/initiator.rs index aaa46468..c158aaca 100644 --- a/lakers-python/src/initiator.rs +++ b/lakers-python/src/initiator.rs @@ -144,7 +144,7 @@ impl PyEdhocInitiator { } pub fn completed_without_message_4<'a>(&mut self, py: Python<'a>) -> PyResult<()> { - match i_complete_without_message_4(&self.wait_m4) { + match i_complete_without_message_4(&self.wait_m4.take().ok_or(StateMismatch)?) { Ok(state) => { self.completed = Some(state); Ok(()) @@ -160,7 +160,7 @@ impl PyEdhocInitiator { ) -> PyResult> { let message_4 = EdhocMessageBuffer::new_from_slice(message_4.as_slice())?; - match i_process_message_4(&mut self.wait_m4, &mut default_crypto(), &message_4) { + match i_process_message_4(&mut self.wait_m4.take().ok_or(StateMismatch)?, &mut default_crypto(), &message_4) { Ok((state, ead_4)) => { self.completed = Some(state); Ok(ead_4) diff --git a/lakers-python/src/responder.rs b/lakers-python/src/responder.rs index 0c545b33..c861138c 100644 --- a/lakers-python/src/responder.rs +++ b/lakers-python/src/responder.rs @@ -140,7 +140,7 @@ impl PyEdhocResponder { py: Python<'a>, ead_4: Option, ) -> PyResult> { - match r_prepare_message_4(&self.processed_m3, &mut default_crypto(), &ead_4) { + match r_prepare_message_4(&self.processed_m3.take().ok_or(StateMismatch)?, &mut default_crypto(), &ead_4) { Ok((state, message_4)) => { self.completed = Some(state); Ok(PyBytes::new_bound(py, message_4.as_slice())) @@ -150,7 +150,7 @@ impl PyEdhocResponder { } pub fn completed_without_message_4<'a>(&mut self, py: Python<'a>) -> PyResult<()> { - match r_complete_without_message_4(&self.processed_m3) { + match r_complete_without_message_4(&self.processed_m3.take().ok_or(StateMismatch)?) { Ok(state) => { self.completed = Some(state); Ok(()) diff --git a/lakers-python/test/test_lakers.py b/lakers-python/test/test_lakers.py index 9dc93715..710445ff 100644 --- a/lakers-python/test/test_lakers.py +++ b/lakers-python/test/test_lakers.py @@ -69,6 +69,10 @@ def _test_handshake(cred_r_transfer, cred_i_transfer): assert i_prk_out == r_prk_out + # advanced state + responder.completed_without_message_4() + initiator.completed_without_message_4() + i_oscore_secret = initiator.edhoc_exporter(0, [], 16) i_oscore_salt = initiator.edhoc_exporter(1, [], 8) r_oscore_secret = responder.edhoc_exporter(0, [], 16)