Skip to content
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

Merged
merged 15 commits into from
Nov 3, 2023

Conversation

geonnave
Copy link
Collaborator

@geonnave geonnave commented Oct 31, 2023

Included in this PR:

  • have Initiator and Responder constructors accept optional type for its counterpart (:warning: this changes the API!)
  • send full CRED_V in message_2
  • add a mocked W (only the needed parts to make the handshake with zero-touch work)

Sending CRED_R in message_3 would also make sense, but at this point we still don't need it.

@geonnave geonnave marked this pull request as ready for review November 2, 2023 13:29
@geonnave geonnave force-pushed the flexible-creds branch 4 times, most recently from bc66f7d to 06e1028 Compare November 2, 2023 18:01
Copy link
Contributor

@malishav malishav left a 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
Copy link
Contributor

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?


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;
Copy link
Contributor

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

Copy link
Collaborator Author

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 {
Copy link
Contributor

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.

Copy link
Collaborator Author

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) {
Copy link
Contributor

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

Copy link
Collaborator Author

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
Copy link
Contributor

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

Copy link
Collaborator Author

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 {
Copy link
Contributor

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

Copy link
Collaborator Author

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
Copy link
Contributor

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.

Copy link
Collaborator Author

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));
Copy link
Contributor

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tracked in #121.

@geonnave geonnave merged commit c132cb2 into openwsn-berkeley:main Nov 3, 2023
24 checks passed
@geonnave geonnave deleted the flexible-creds branch November 3, 2023 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants