Skip to content

Commit d01862e

Browse files
Upgrade to serde-indexed v0.2.0
1 parent 70843ff commit d01862e

File tree

15 files changed

+158
-93
lines changed

15 files changed

+158
-93
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
[submodule "solo/src/ext"]
22
path = solo/src/ext
33
url = https://github.com/AlfioEmanueleFresta/solo.git
4-
[submodule "serde-indexed"]
5-
path = serde-indexed
6-
url = git@github.com:AlfioEmanueleFresta/serde-indexed.git

Cargo.lock

Lines changed: 6 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libwebauthn/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ futures = "0.3.5"
3030
tokio = { version = "1.1.1", features = ["full"] }
3131
serde = "1.0.110"
3232
serde_cbor = "0.11.1"
33-
serde-indexed = { path = "../serde-indexed" }
33+
serde-indexed = "0.2.0"
3434
serde_derive = "1.0.123"
3535
serde_repr = "0.1.6"
3636
serde_bytes = "0.11.5"

libwebauthn/src/proto/ctap2/cbor/serde.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ mod tests {
5353
use serde_indexed::{DeserializeIndexed, SerializeIndexed};
5454

5555
#[derive(Debug, PartialEq, SerializeIndexed, DeserializeIndexed)]
56-
#[serde_indexed(offset = 1)]
5756
struct TestStruct {
57+
#[serde(index = 0x01)]
5858
pub a: u8,
59+
#[serde(index = 0x02)]
5960
pub b: u8,
6061
}
6162

libwebauthn/src/proto/ctap2/model/authenticator_config.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,24 @@ use serde_repr::{Deserialize_repr, Serialize_repr};
66
use super::Ctap2PinUvAuthProtocol;
77

88
#[derive(Debug, Clone, SerializeIndexed)]
9-
#[serde_indexed(offset = 1)]
109
pub struct Ctap2AuthenticatorConfigRequest {
1110
// subCommand (0x01)
11+
#[serde(index = 0x01)]
1212
pub subcommand: Ctap2AuthenticatorConfigCommand,
1313

1414
// subCommandParams (0x02)
1515
#[serde(skip_serializing_if = "Option::is_none")]
16+
#[serde(index = 0x02)]
1617
pub subcommand_params: Option<Ctap2AuthenticatorConfigParams>,
1718

1819
///pinUvAuthProtocol (0x03)
1920
#[serde(skip_serializing_if = "Option::is_none")]
21+
#[serde(index = 0x03)]
2022
pub protocol: Option<Ctap2PinUvAuthProtocol>,
2123

2224
/// pinUvAuthParam (0x04):
2325
#[serde(skip_serializing_if = "Option::is_none")]
26+
#[serde(index = 0x04)]
2427
pub uv_auth_param: Option<ByteBuf>,
2528
}
2629

@@ -106,17 +109,19 @@ pub enum Ctap2AuthenticatorConfigParams {
106109
}
107110

108111
#[derive(Debug, Clone, SerializeIndexed)]
109-
#[serde_indexed(offset = 1)]
110112
pub struct Ctap2SetMinPINLengthParams {
111113
// newMinPINLength (0x01)
112114
#[serde(skip_serializing_if = "Option::is_none")]
115+
#[serde(index = 0x01)]
113116
pub new_min_pin_length: Option<u64>,
114117

115118
// minPinLengthRPIDs (0x02)
116119
#[serde(skip_serializing_if = "Option::is_none")]
120+
#[serde(index = 0x02)]
117121
pub min_pin_length_rpids: Option<Vec<String>>,
118122

119123
// forceChangePin (0x03)
120124
#[serde(skip_serializing_if = "Option::is_none")]
125+
#[serde(index = 0x03)]
121126
pub force_change_pin: Option<bool>,
122127
}

libwebauthn/src/proto/ctap2/model/bio_enrollment.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,35 @@ use std::time::Duration;
99
pub struct Ctap2BioEnrollmentRequest {
1010
// modality (0x01) Unsigned Integer Optional The user verification modality being requested
1111
#[serde(skip_serializing_if = "Option::is_none")]
12+
#[serde(index = 0x01)]
1213
pub modality: Option<Ctap2BioEnrollmentModality>,
1314

1415
// subCommand (0x02) Unsigned Integer Optional The authenticator user verification sub command currently being requested
1516
#[serde(skip_serializing_if = "Option::is_none")]
17+
#[serde(index = 0x02)]
1618
pub subcommand: Option<Ctap2BioEnrollmentSubcommand>,
1719

1820
// subCommandParams (0x03) CBOR Map Optional Map of subCommands parameters. This parameter MAY be omitted when the subCommand does not take any arguments.
1921
#[serde(skip_serializing_if = "Option::is_none")]
22+
#[serde(index = 0x03)]
2023
pub subcommand_params: Option<Ctap2BioEnrollmentParams>,
2124

2225
// pinUvAuthProtocol (0x04) Unsigned Integer Optional PIN/UV protocol version chosen by the platform.
2326
#[serde(skip_serializing_if = "Option::is_none")]
27+
#[serde(index = 0x04)]
2428
pub protocol: Option<Ctap2PinUvAuthProtocol>,
2529

2630
// pinUvAuthParam (0x05) Byte String Optional First 16 bytes of HMAC-SHA-256 of contents using pinUvAuthToken.
2731
#[serde(skip_serializing_if = "Option::is_none")]
32+
#[serde(index = 0x05)]
2833
pub uv_auth_param: Option<ByteBuf>,
2934

3035
// getModality (0x06) Boolean Optional Get the user verification type modality. This MUST be set to true.
3136
#[serde(skip_serializing_if = "Option::is_none")]
37+
#[serde(index = 0x06)]
3238
pub get_modality: Option<bool>,
3339

34-
#[serde(skip_serializing_if = "always_skip_bool")]
40+
#[serde(skip)]
3541
pub use_legacy_preview: bool,
3642
}
3743

@@ -48,63 +54,73 @@ pub enum Ctap2BioEnrollmentSubcommand {
4854
}
4955

5056
#[derive(Debug, Clone, SerializeIndexed)]
51-
#[serde_indexed(offset = 1)]
5257
pub struct Ctap2BioEnrollmentParams {
5358
#[serde(skip_serializing_if = "Option::is_none")]
59+
#[serde(index = 0x01)]
5460
template_id: Option<ByteBuf>,
5561

5662
#[serde(skip_serializing_if = "Option::is_none")]
63+
#[serde(index = 0x02)]
5764
template_friendly_name: Option<String>,
5865

5966
#[serde(skip_serializing_if = "Option::is_none")]
67+
#[serde(index = 0x03)]
6068
timeout_milliseconds: Option<u64>,
6169
}
6270

6371
#[derive(Debug, Default, Clone, DeserializeIndexed)]
64-
#[serde_indexed(offset = 1)]
6572
pub struct Ctap2BioEnrollmentResponse {
6673
// modality (0x01) Unsigned Integer Optional The user verification modality.
6774
#[serde(skip_serializing_if = "Option::is_none")]
75+
#[serde(index = 0x01)]
6876
pub modality: Option<Ctap2BioEnrollmentModality>,
6977

7078
// fingerprintKind (0x02) Unsigned Integer Optional Indicates the type of fingerprint sensor. For touch type sensor, its value is 1. For swipe type sensor its value is 2.
7179
#[serde(skip_serializing_if = "Option::is_none")]
80+
#[serde(index = 0x02)]
7281
pub fingerprint_kind: Option<Ctap2BioEnrollmentFingerprintKind>,
7382

7483
// maxCaptureSamplesRequiredForEnroll (0x03) Unsigned Integer Optional Indicates the maximum good samples required for enrollment.
7584
#[serde(skip_serializing_if = "Option::is_none")]
85+
#[serde(index = 0x03)]
7686
pub max_capture_samples_required_for_enroll: Option<u64>,
7787

7888
// templateId (0x04) Byte String Optional Template Identifier.
7989
#[serde(skip_serializing_if = "Option::is_none")]
90+
#[serde(index = 0x04)]
8091
pub template_id: Option<ByteBuf>,
8192

8293
// lastEnrollSampleStatus (0x05) Unsigned Integer Optional Last enrollment sample status.
8394
#[serde(skip_serializing_if = "Option::is_none")]
95+
#[serde(index = 0x05)]
8496
pub last_enroll_sample_status: Option<Ctap2LastEnrollmentSampleStatus>,
8597

8698
// remainingSamples (0x06) Unsigned Integer Optional Number of more sample required for enrollment to complete
8799
#[serde(skip_serializing_if = "Option::is_none")]
100+
#[serde(index = 0x06)]
88101
pub remaining_samples: Option<u64>,
89102

90103
// templateInfos (0x07) CBOR ARRAY Optional Array of templateInfo’s
91104
#[serde(skip_serializing_if = "Option::is_none")]
105+
#[serde(index = 0x07)]
92106
pub template_infos: Option<Vec<Ctap2BioEnrollmentTemplateId>>,
93107

94108
// maxTemplateFriendlyName (0x08) Unsigned Integer Optional Indicates the maximum number of bytes the authenticator will accept as a templateFriendlyName.
95109
#[serde(skip_serializing_if = "Option::is_none")]
110+
#[serde(index = 0x08)]
96111
pub max_template_friendly_name: Option<u64>,
97112
}
98113

99114
#[derive(Debug, Clone, DeserializeIndexed)]
100-
#[serde_indexed(offset = 1)]
101115
pub struct Ctap2BioEnrollmentTemplateId {
102116
// templateId (0x01) Byte String Required Template Identifier.
103117
#[serde(skip_serializing_if = "Option::is_none")]
118+
#[serde(index = 0x01)]
104119
pub template_id: Option<ByteBuf>,
105120

106121
// templateFriendlyName (0x02) String Optional Template Friendly Name.
107122
#[serde(skip_serializing_if = "Option::is_none")]
123+
#[serde(index = 0x02)]
108124
pub template_friendly_name: Option<String>,
109125
}
110126

@@ -262,9 +278,3 @@ impl Ctap2BioEnrollmentRequest {
262278
}
263279
}
264280
}
265-
266-
// Required by serde_indexed, as serde(skip) isn't supported yet:
267-
// https://github.com/trussed-dev/serde-indexed/pull/14
268-
fn always_skip_bool(_v: &bool) -> bool {
269-
true
270-
}

0 commit comments

Comments
 (0)