openwsn-berkeley / lakers

EDHOC implemented in Rust, optimized for microcontrollers, with bindings for C and Python.
https://crates.io/crates/lakers
BSD 3-Clause "New" or "Revised" License
12 stars 10 forks source link

Python: parse_message_2 produces id_cred_r as array #256

Closed chrysn closed 2 months ago

chrysn commented 2 months ago

The 2nd return value of parse_message_2, id_cred_r, currently has values like [10] or [162, 2, 96, 8, 161, 1, 165, 1, 2, 2, ...]. What it represents is the binary value of ID_CRED_R, a byte string, and it should be represented as such in Python.

(Haven't had a look at the Python implementation yet, might manage a PR.)

chrysn commented 2 months ago

Something similar was fixed in 0e2b07bae3f39ae5048cf17269664f35a81658ee already. I think the general rule should be that binary data in return values should not be Vec but PyBytes. (In function arguments it can be convenient to have them as Vec<[u8]> from an API PoV; from a performance PoV it may just as well be a &[u8] if that works). PR available, let's see if CI likes it.