Skip to content

Commit

Permalink
python: fix examples in python. Advanced state. Fix optional values
Browse files Browse the repository at this point in the history
  • Loading branch information
ElsaLopez133 committed Nov 5, 2024
1 parent 160e3b2 commit 25e1206
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lakers-python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ To deploy:
ln -s ../examples ./examples
MATURIN_PYPI_TOKEN=<your pypi token here> 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:
Expand Down
4 changes: 2 additions & 2 deletions lakers-python/src/initiator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand All @@ -160,7 +160,7 @@ impl PyEdhocInitiator {
) -> PyResult<Option<EADItem>> {
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)
Expand Down
4 changes: 2 additions & 2 deletions lakers-python/src/responder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl PyEdhocResponder {
py: Python<'a>,
ead_4: Option<EADItem>,
) -> PyResult<Bound<'a, PyBytes>> {
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()))
Expand All @@ -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(())
Expand Down
4 changes: 4 additions & 0 deletions lakers-python/test/test_lakers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 25e1206

Please sign in to comment.