-
Notifications
You must be signed in to change notification settings - Fork 10
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
EAD zeroconf: send full CRED_V in message_2 #117
Conversation
e6d443a
to
802806f
Compare
bc66f7d
to
06e1028
Compare
also refactor/simplify credential handling
06e1028
to
be1ae2a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments inline, as discussed offline.
@@ -36,7 +36,7 @@ jobs: | |||
uses: actions/checkout@v3 | |||
|
|||
- name: Run unit tests # note that we only add `--package edhoc-hacspec` when testing the hacspec version of the lib | |||
run: cargo test --package edhoc-rs --package edhoc-crypto --package edhoc-ead --no-default-features --features="${{ matrix.crypto_backend }}, ${{ matrix.ead }}" --no-fail-fast | |||
run: RUST_BACKTRACE=1 cargo test -p edhoc-rs -p edhoc-consts -p edhoc-ead-zeroconf --no-default-features --features="${{ matrix.crypto_backend }}, ${{ matrix.ead }}" --no-fail-fast -- --test-threads 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why replacing edhoc-ead
with edhoc-ead-zeroconf
?
consts/src/lib.rs
Outdated
|
||
pub fn parse_cred<'a>(cred: &'a [u8]) -> (BytesP256ElemLen, u8) { | ||
let subject_len = (cred[2] - CBOR_MAJOR_TEXT_STRING) as usize; | ||
let id_cred_offset: usize = 3 + subject_len + 8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment on magic numbers, ideally replace them with a macro
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed.
) | ||
} | ||
|
||
pub fn get_id_cred<'a>(cred: &'a [u8]) -> BytesIdCred { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: To verify if this way of constructing ID_CRED from CRED is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For context: it is hardcoded and assumes that ID_CRED is a kid in a COSE header map.
@@ -281,4 +303,231 @@ mod helpers { | |||
|
|||
(info, info_len) | |||
} | |||
|
|||
pub fn parse_cred<'a>(cred: &'a [u8]) -> (BytesP256ElemLen, u8) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please comment on the assumptions of this implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed.
lib/src/edhoc.rs
Outdated
id_cred_r = IdCred::FullCredential(&plaintext_2[4..4 + cred_len]); | ||
4 + cred_len | ||
} else { | ||
0xff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's return an Error here instead of 0xff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed.
c_r = c_r_2; | ||
|
||
// Step 3: If EAD is present make it available to the application | ||
let ead_success = if let Some(ead_2) = ead_2 { | ||
i_process_ead_2(ead_2, cred_r_expected, &h_message_1).is_ok() | ||
let (ead_ok, r_authenticated_via_ead, cred_r) = if let Some(ead_2) = ead_2 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible, rewrite to be more explicit, as discussed offline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tracked in #119 .
let ead_success = if let Some(ead_2) = ead_2 { | ||
i_process_ead_2(ead_2, cred_r_expected, &h_message_1).is_ok() | ||
let (ead_ok, r_authenticated_via_ead, cred_r) = if let Some(ead_2) = ead_2 { | ||
// if EAD-zeroconf is present, then id_cred must contain a full credential |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, this should check if the EAD handler is the zero touch draft handler. No action needed at this point, let's track.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tracked in #120.
ID_CRED_R, | ||
CRED_R, | ||
); | ||
let mut responder = EdhocResponderState::new(state_responder, R, CRED_V_TV, Some(CRED_I)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We currently instantiate the responder with CRED_I
of the Initiator. This should ideally be None
and the responder should fetch, for the time being through a mock up, the value of the CRED_I
based on ID_CRED_I
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tracked in #121.
Included in this PR:
Sending CRED_R in message_3 would also make sense, but at this point we still don't need it.