Skip to content

Commit 744ab17

Browse files
authored
Merge branch 'develop' into send-recv-busy
2 parents f4d3969 + a68fae7 commit 744ab17

File tree

2 files changed

+17
-35
lines changed

2 files changed

+17
-35
lines changed

libraries/opensk/src/api/persist.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,7 @@ mod test {
521521
let mut env = TestEnv::default();
522522
let persist = env.persist();
523523

524-
let mut counter_value = 1;
525-
assert_eq!(persist.global_signature_counter().unwrap(), counter_value);
524+
let mut counter_value = persist.global_signature_counter().unwrap();
526525
for increment in 1..10 {
527526
assert!(persist.incr_global_signature_counter(increment).is_ok());
528527
counter_value += increment;

libraries/opensk/src/ctap/mod.rs

+16-33
Original file line numberDiff line numberDiff line change
@@ -1447,13 +1447,14 @@ mod test {
14471447
const VENDOR_CHANNEL: Channel = Channel::VendorHid([0x12, 0x34, 0x56, 0x78]);
14481448

14491449
fn check_make_response(
1450+
env: &mut impl Env,
14501451
make_credential_response: &CtapResult<ResponseData>,
14511452
flags: u8,
1452-
expected_aaguid: &[u8],
14531453
expected_credential_id_size: u8,
14541454
expected_extension_cbor: &[u8],
14551455
) {
1456-
const INITIAL_SIGNATURE_COUNTER: u32 = 1;
1456+
let expected_aaguid = env.customization().aaguid();
1457+
let signature_counter = env.persist().global_signature_counter().unwrap();
14571458
match make_credential_response.as_ref().unwrap() {
14581459
ResponseData::AuthenticatorMakeCredential(make_credential_response) => {
14591460
let AuthenticatorMakeCredentialResponse {
@@ -1468,9 +1469,9 @@ mod test {
14681469
let mut expected_auth_data = vec![
14691470
0xA3, 0x79, 0xA6, 0xF6, 0xEE, 0xAF, 0xB9, 0xA5, 0x5E, 0x37, 0x8C, 0x11, 0x80,
14701471
0x34, 0xE2, 0x75, 0x1E, 0x68, 0x2F, 0xAB, 0x9F, 0x2D, 0x30, 0xAB, 0x13, 0xD2,
1471-
0x12, 0x55, 0x86, 0xCE, 0x19, 0x47, flags, 0x00, 0x00, 0x00,
1472+
0x12, 0x55, 0x86, 0xCE, 0x19, 0x47, flags,
14721473
];
1473-
expected_auth_data.push(INITIAL_SIGNATURE_COUNTER as u8);
1474+
expected_auth_data.extend(&signature_counter.to_be_bytes());
14741475
expected_auth_data.extend(expected_aaguid);
14751476
expected_auth_data.extend(&[0x00, expected_credential_id_size]);
14761477
assert_eq!(
@@ -1648,13 +1649,7 @@ mod test {
16481649
let make_credential_response =
16491650
ctap_state.process_make_credential(&mut env, make_credential_params, DUMMY_CHANNEL);
16501651

1651-
check_make_response(
1652-
&make_credential_response,
1653-
0x41,
1654-
env.customization().aaguid(),
1655-
0x20,
1656-
&[],
1657-
);
1652+
check_make_response(&mut env, &make_credential_response, 0x41, 0x20, &[]);
16581653
}
16591654

16601655
#[test]
@@ -1668,9 +1663,9 @@ mod test {
16681663
ctap_state.process_make_credential(&mut env, make_credential_params, DUMMY_CHANNEL);
16691664

16701665
check_make_response(
1666+
&mut env,
16711667
&make_credential_response,
16721668
0x41,
1673-
env.customization().aaguid(),
16741669
CBOR_CREDENTIAL_ID_SIZE as u8,
16751670
&[],
16761671
);
@@ -1838,9 +1833,9 @@ mod test {
18381833
0xA1, 0x6B, 0x68, 0x6D, 0x61, 0x63, 0x2D, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0xF5,
18391834
];
18401835
check_make_response(
1836+
&mut env,
18411837
&make_credential_response,
18421838
0xC1,
1843-
env.customization().aaguid(),
18441839
CBOR_CREDENTIAL_ID_SIZE as u8,
18451840
&expected_extension_cbor,
18461841
);
@@ -1864,9 +1859,9 @@ mod test {
18641859
0xA1, 0x6B, 0x68, 0x6D, 0x61, 0x63, 0x2D, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0xF5,
18651860
];
18661861
check_make_response(
1862+
&mut env,
18671863
&make_credential_response,
18681864
0xC1,
1869-
env.customization().aaguid(),
18701865
0x20,
18711866
&expected_extension_cbor,
18721867
);
@@ -1886,13 +1881,7 @@ mod test {
18861881
make_credential_params.extensions = extensions;
18871882
let make_credential_response =
18881883
ctap_state.process_make_credential(&mut env, make_credential_params, DUMMY_CHANNEL);
1889-
check_make_response(
1890-
&make_credential_response,
1891-
0x41,
1892-
env.customization().aaguid(),
1893-
0x20,
1894-
&[],
1895-
);
1884+
check_make_response(&mut env, &make_credential_response, 0x41, 0x20, &[]);
18961885

18971886
// Second part: The extension is used.
18981887
assert_eq!(
@@ -1913,9 +1902,9 @@ mod test {
19131902
0x04,
19141903
];
19151904
check_make_response(
1905+
&mut env,
19161906
&make_credential_response,
19171907
0xC1,
1918-
env.customization().aaguid(),
19191908
0x20,
19201909
&expected_extension_cbor,
19211910
);
@@ -1938,9 +1927,9 @@ mod test {
19381927
0xA1, 0x68, 0x63, 0x72, 0x65, 0x64, 0x42, 0x6C, 0x6F, 0x62, 0xF5,
19391928
];
19401929
check_make_response(
1930+
&mut env,
19411931
&make_credential_response,
19421932
0xC1,
1943-
env.customization().aaguid(),
19441933
0x20,
19451934
&expected_extension_cbor,
19461935
);
@@ -1970,9 +1959,9 @@ mod test {
19701959
0xA1, 0x68, 0x63, 0x72, 0x65, 0x64, 0x42, 0x6C, 0x6F, 0x62, 0xF4,
19711960
];
19721961
check_make_response(
1962+
&mut env,
19731963
&make_credential_response,
19741964
0xC1,
1975-
env.customization().aaguid(),
19761965
0x20,
19771966
&expected_extension_cbor,
19781967
);
@@ -2047,13 +2036,7 @@ mod test {
20472036
DUMMY_CHANNEL,
20482037
);
20492038

2050-
check_make_response(
2051-
&make_credential_response,
2052-
0x45,
2053-
env.customization().aaguid(),
2054-
0x20,
2055-
&[],
2056-
);
2039+
check_make_response(&mut env, &make_credential_response, 0x45, 0x20, &[]);
20572040

20582041
let make_credential_response =
20592042
ctap_state.process_make_credential(&mut env, make_credential_params, DUMMY_CHANNEL);
@@ -2085,9 +2068,9 @@ mod test {
20852068
ctap_state.process_make_credential(&mut env, make_credential_params, DUMMY_CHANNEL);
20862069

20872070
check_make_response(
2071+
&mut env,
20882072
&make_credential_response,
20892073
0x41,
2090-
env.customization().aaguid(),
20912074
CBOR_CREDENTIAL_ID_SIZE as u8,
20922075
&[],
20932076
);
@@ -2784,9 +2767,9 @@ mod test {
27842767
0xA1, 0x68, 0x63, 0x72, 0x65, 0x64, 0x42, 0x6C, 0x6F, 0x62, 0xF5,
27852768
];
27862769
check_make_response(
2770+
&mut env,
27872771
&make_credential_response,
27882772
0xC1,
2789-
env.customization().aaguid(),
27902773
CBOR_CREDENTIAL_ID_SIZE as u8,
27912774
&expected_extension_cbor,
27922775
);

0 commit comments

Comments
 (0)