Skip to content

Commit c64d5b0

Browse files
authored
Merge pull request #227 from geonnave/fix-test-ead
Fx: re-enable test for ead authz handshake
2 parents b7075a1 + 13c303d commit c64d5b0

File tree

3 files changed

+35
-20
lines changed

3 files changed

+35
-20
lines changed

.github/workflows/build-and-test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ jobs:
4444
fail-fast: false
4545
matrix:
4646
crypto_backend: [lakers-crypto/psa, lakers-crypto/rustcrypto]
47-
ead: [lakers-ead/ead-none, lakers-ead/ead-authz]
47+
ead: [ead-none, ead-authz]
4848

4949
steps:
5050
- name: Checkout repo
5151
uses: actions/checkout@v3
5252

5353
- name: Run unit tests with feature matrix # note that we only add `--package lakers-ead-authz` when testing with that config
54-
run: RUST_BACKTRACE=1 cargo test -p lakers -p lakers-crypto -p lakers-shared ${{ matrix.ead == 'lakers-ead/ead-authz' && '-p lakers-ead-authz' || '' }} --no-default-features --features="${{ matrix.crypto_backend }}, ${{ matrix.ead }}" --no-fail-fast -- --test-threads 1
54+
run: RUST_BACKTRACE=1 cargo test -p lakers -p lakers-crypto -p lakers-shared ${{ matrix.ead == 'ead-authz' && '-p lakers-ead-authz' || '' }} --no-default-features --features="${{ matrix.crypto_backend }}, test-${{ matrix.ead }}" --no-fail-fast -- --test-threads 1
5555

5656

5757
build-edhoc-package:

lib/Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ lakers-crypto.workspace = true
1717
hexlit = "0.5.3"
1818

1919
[features]
20-
default = [ "lakers-ead/ead-none" ]
20+
# NOTE: the ead features are just needed for multiplexing tests
21+
default = [ "test-ead-none" ]
22+
test-ead-none = [ "lakers-ead/ead-none" ]
23+
test-ead-authz = [ "lakers-ead/ead-authz" ]
2124

2225
[lib]
2326
crate-type = ["rlib"]

lib/src/lib.rs

+29-17
Original file line numberDiff line numberDiff line change
@@ -482,26 +482,29 @@ pub fn credential_check_or_fetch<'a>(
482482
}
483483

484484
#[cfg(test)]
485-
mod test {
486-
use super::*;
487-
485+
mod test_vectors_common {
488486
use hexlit::hex;
489487

490-
use lakers_crypto::default_crypto;
491-
492-
const ID_CRED_I: &[u8] = &hex!("a104412b");
493-
const ID_CRED_R: &[u8] = &hex!("a104410a");
494-
const CRED_I: &[u8] = &hex!("A2027734322D35302D33312D46462D45462D33372D33322D333908A101A5010202412B2001215820AC75E9ECE3E50BFC8ED60399889522405C47BF16DF96660A41298CB4307F7EB62258206E5DE611388A4B8A8211334AC7D37ECB52A387D257E6DB3C2A93DF21FF3AFFC8");
495-
const I: &[u8] = &hex!("fb13adeb6518cee5f88417660841142e830a81fe334380a953406a1305e8706b");
496-
const R: &[u8] = &hex!("72cc4761dbd4c78f758931aa589d348d1ef874a7e303ede2f140dcf3e6aa4aac");
497-
const _G_I_Y_COORD: &[u8] =
488+
pub const ID_CRED_I: &[u8] = &hex!("a104412b");
489+
pub const ID_CRED_R: &[u8] = &hex!("a104410a");
490+
pub const CRED_I: &[u8] = &hex!("A2027734322D35302D33312D46462D45462D33372D33322D333908A101A5010202412B2001215820AC75E9ECE3E50BFC8ED60399889522405C47BF16DF96660A41298CB4307F7EB62258206E5DE611388A4B8A8211334AC7D37ECB52A387D257E6DB3C2A93DF21FF3AFFC8");
491+
pub const I: &[u8] = &hex!("fb13adeb6518cee5f88417660841142e830a81fe334380a953406a1305e8706b");
492+
pub const R: &[u8] = &hex!("72cc4761dbd4c78f758931aa589d348d1ef874a7e303ede2f140dcf3e6aa4aac");
493+
pub const _G_I_Y_COORD: &[u8] =
498494
&hex!("6e5de611388a4b8a8211334ac7d37ecb52a387d257e6db3c2a93df21ff3affc8"); // not used
499-
const CRED_R: &[u8] = &hex!("A2026008A101A5010202410A2001215820BBC34960526EA4D32E940CAD2A234148DDC21791A12AFBCBAC93622046DD44F02258204519E257236B2A0CE2023F0931F1F386CA7AFDA64FCDE0108C224C51EABF6072");
495+
pub const CRED_R: &[u8] = &hex!("A2026008A101A5010202410A2001215820BBC34960526EA4D32E940CAD2A234148DDC21791A12AFBCBAC93622046DD44F02258204519E257236B2A0CE2023F0931F1F386CA7AFDA64FCDE0108C224C51EABF6072");
500496

501-
const MESSAGE_1_TV_FIRST_TIME: &str =
497+
pub const MESSAGE_1_TV_FIRST_TIME: &str =
502498
"03065820741a13d7ba048fbb615e94386aa3b61bea5b3d8f65f32620b749bee8d278efa90e";
503-
const MESSAGE_1_TV: &str =
499+
pub const MESSAGE_1_TV: &str =
504500
"0382060258208af6f430ebe18d34184017a9a11bf511c8dff8f834730b96c1b7c8dbca2fc3b637";
501+
}
502+
503+
#[cfg(test)]
504+
mod test {
505+
use super::*;
506+
use lakers_crypto::default_crypto;
507+
use test_vectors_common::*;
505508

506509
#[test]
507510
fn test_new_initiator() {
@@ -560,7 +563,7 @@ mod test {
560563
assert!(conn_id >= -24 && conn_id <= 23);
561564
}
562565

563-
#[cfg(feature = "ead-none")]
566+
#[cfg(feature = "test-ead-none")]
564567
#[test]
565568
fn test_handshake() {
566569
let cred_i = CredentialRPK::new(CRED_I.try_into().unwrap()).unwrap();
@@ -626,6 +629,16 @@ mod test {
626629

627630
assert_eq!(i_prk_out_new, r_prk_out_new);
628631
}
632+
}
633+
634+
#[cfg(feature = "test-ead-authz")]
635+
#[cfg(test)]
636+
mod test_authz {
637+
use super::*;
638+
use hexlit::hex;
639+
use lakers_crypto::default_crypto;
640+
use lakers_ead::*;
641+
use test_vectors_common::*;
629642

630643
// U
631644
const ID_U_TV: &[u8] = &hex!("a104412b");
@@ -639,9 +652,8 @@ mod test {
639652
const LOC_W_TV: &[u8] = &hex!("636F61703A2F2F656E726F6C6C6D656E742E736572766572");
640653

641654
// TODO: have a setup_test function that prepares the common objects for the ead tests
642-
#[cfg(feature = "ead-authz")]
643655
#[test]
644-
fn test_ead_authz() {
656+
fn test_handshake_authz() {
645657
let cred_i = CredentialRPK::new(CRED_I.try_into().unwrap()).unwrap();
646658
let cred_r = CredentialRPK::new(CRED_R.try_into().unwrap()).unwrap();
647659

0 commit comments

Comments
 (0)