-
Notifications
You must be signed in to change notification settings - Fork 13
Refactoring adding psk method #415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 18 commits
34e12dc
65859e6
c557ed2
ded1c64
63781d0
086f95f
f8da180
3fcbf30
c9a7380
5570119
fb49f4b
a1d2693
d43018a
0c8e163
02b948e
d0192ec
cf72cd5
1469828
0755dc5
bfe7991
9e8bb4c
51ac9ad
cb918be
64013ff
86aeaa7
f7aad96
54e98ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,13 +8,12 @@ use crate::*; | |
|
|
||
| /// structs compatible with the C FFI | ||
|
|
||
| #[derive(Debug)] | ||
| #[repr(C)] | ||
| pub struct EdhocInitiator { | ||
| pub start: InitiatorStart, | ||
| pub wait_m2: WaitM2, | ||
| pub processing_m2: ProcessingM2C, | ||
| pub processed_m2: ProcessedM2, | ||
| pub processed_m2: ProcessedM2C, | ||
| pub wait_m4: WaitM4, | ||
| pub cred_i: *mut CredentialC, | ||
| pub completed: Completed, | ||
|
|
@@ -106,11 +105,15 @@ pub unsafe extern "C" fn initiator_parse_message_2( | |
| let state = core::ptr::read(&(*initiator_c).wait_m2); | ||
|
|
||
| let result = match i_parse_message_2(&state, crypto, &(*message_2)) { | ||
| Ok((state, c_r, id_cred_r, ead_2)) => { | ||
| Ok((state, c_r, details, ead_2)) => { | ||
| ProcessingM2C::copy_into_c(state, &mut (*initiator_c).processing_m2); | ||
| let c_r = c_r.as_slice(); | ||
| assert_eq!(c_r.len(), 1, "C API only supports short C_R"); | ||
| *c_r_out = c_r[0]; | ||
| let id_cred_r = match details { | ||
| ParsedMessage2Details::StatStat { id_cred_r } => id_cred_r, | ||
| ParsedMessage2Details::Psk {} => IdCred::new(), | ||
| }; | ||
| *id_cred_r_out = id_cred_r; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. on the PSK case, why write an empty
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I addressed that by adding a flag
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question, I don't know what is the right thing to do on C, but I guess better than adding a flag And yes, reading again I think your code is correct, they sohuld still have the empty value initialized in the PSK case, we just ignore it. |
||
|
|
||
| EadItemsC::copy_into_c(ead_2, ead_2_c_out); | ||
|
|
@@ -140,9 +143,15 @@ pub unsafe extern "C" fn initiator_verify_message_2( | |
|
|
||
| let state = core::ptr::read(&(*initiator_c).processing_m2).to_rust(); | ||
|
|
||
| match i_verify_message_2(&state, crypto, (*valid_cred_r).to_rust(), &(*i)) { | ||
| // FIXME | ||
|
WilliamTakeshi marked this conversation as resolved.
Outdated
|
||
| match i_verify_message_2( | ||
| &state, | ||
| crypto, | ||
| (*valid_cred_r).to_rust(), | ||
| InitiatorIdentity::StatStat { i: *i }, | ||
| ) { | ||
| Ok(state) => { | ||
| (*initiator_c).processed_m2 = state; | ||
| ProcessedM2C::copy_into_c(state, &mut (*initiator_c).processed_m2); | ||
| (*initiator_c).cred_i = cred_i; | ||
| 0 | ||
| } | ||
|
|
@@ -165,7 +174,7 @@ pub unsafe extern "C" fn initiator_prepare_message_3( | |
| } | ||
| let crypto = &mut default_crypto(); | ||
|
|
||
| let state = core::ptr::read(&(*initiator_c).processed_m2); | ||
| let state = core::ptr::read(&(*initiator_c).processed_m2).to_rust(); | ||
|
|
||
| let ead_3 = if ead_3_c.is_null() { | ||
| EadItems::new() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.