Skip to content

Commit d225188

Browse files
Fix lint
1 parent 2affd20 commit d225188

File tree

3 files changed

+31
-27
lines changed

3 files changed

+31
-27
lines changed

src/credential.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -795,20 +795,20 @@ mod test {
795795
fn credential_data() -> CredentialData {
796796
CredentialData {
797797
rp: Rp::new(PublicKeyCredentialRpEntity {
798-
id: String::from("John Doe"),
798+
id: String::try_from("John Doe").unwrap(),
799799
name: None,
800800
icon: None,
801801
}),
802802
user: User::new(PublicKeyCredentialUserEntity {
803-
id: Bytes::from_slice(&[1, 2, 3]).unwrap(),
803+
id: Bytes::try_from(&[1, 2, 3]).unwrap(),
804804
icon: None,
805805
name: None,
806806
display_name: None,
807807
}),
808808
creation_time: 123,
809809
use_counter: false,
810810
algorithm: -7,
811-
key: Key::WrappedKey(Bytes::from_slice(&[1, 2, 3]).unwrap()),
811+
key: Key::WrappedKey(Bytes::try_from(&[1, 2, 3]).unwrap()),
812812
hmac_secret: Some(false),
813813
cred_protect: None,
814814
use_short_id: Some(true),
@@ -822,15 +822,15 @@ mod test {
822822
rp: Rp {
823823
format: SerializationFormat::Long,
824824
inner: PublicKeyCredentialRpEntity {
825-
id: String::from("John Doe"),
825+
id: String::try_from("John Doe").unwrap(),
826826
name: None,
827827
icon: None,
828828
},
829829
},
830830
user: User {
831831
format: SerializationFormat::Long,
832832
inner: PublicKeyCredentialUserEntity {
833-
id: Bytes::from_slice(&[1, 2, 3]).unwrap(),
833+
id: Bytes::try_from(&[1, 2, 3]).unwrap(),
834834
icon: None,
835835
name: None,
836836
display_name: None,
@@ -839,7 +839,7 @@ mod test {
839839
creation_time: 123,
840840
use_counter: false,
841841
algorithm: -7,
842-
key: Key::WrappedKey(Bytes::from_slice(&[1, 2, 3]).unwrap()),
842+
key: Key::WrappedKey(Bytes::try_from(&[1, 2, 3]).unwrap()),
843843
hmac_secret: Some(false),
844844
cred_protect: None,
845845
use_short_id: None,
@@ -866,7 +866,7 @@ mod test {
866866
let between = Uniform::from(0..(N + 1));
867867
let n = between.sample(&mut OsRng);
868868

869-
bytes.resize_default(n).unwrap();
869+
bytes.resize_zero(n).unwrap();
870870

871871
OsRng.fill_bytes(&mut bytes);
872872
bytes
@@ -1080,7 +1080,7 @@ mod test {
10801080
#[test]
10811081
fn max_credential_id() {
10821082
let rp_id: String<256> = core::iter::repeat_n('?', 256).collect();
1083-
let key = Bytes::from_slice(&[u8::MAX; 128]).unwrap();
1083+
let key = Bytes::try_from(&[u8::MAX; 128]).unwrap();
10841084
let credential = StrippedCredential {
10851085
ctap: CtapVersion::Fido21Pre,
10861086
creation_time: u32::MAX,
@@ -1161,8 +1161,8 @@ mod test {
11611161

11621162
fn inner(&self) -> PublicKeyCredentialRpEntity {
11631163
PublicKeyCredentialRpEntity {
1164-
id: self.id.into(),
1165-
name: self.name.map(From::from),
1164+
id: self.id.try_into().unwrap(),
1165+
name: self.name.map(|n| n.try_into().unwrap()),
11661166
icon: None,
11671167
}
11681168
}
@@ -1226,10 +1226,10 @@ mod test {
12261226

12271227
fn inner(&self) -> PublicKeyCredentialUserEntity {
12281228
PublicKeyCredentialUserEntity {
1229-
id: Bytes::from_slice(self.id).unwrap(),
1230-
icon: self.icon.map(From::from),
1231-
name: self.name.map(From::from),
1232-
display_name: self.display_name.map(From::from),
1229+
id: Bytes::try_from(self.id).unwrap(),
1230+
icon: self.icon.map(|v| v.try_into().unwrap()),
1231+
name: self.name.map(|v| v.try_into().unwrap()),
1232+
display_name: self.display_name.map(|v| v.try_into().unwrap()),
12331233
}
12341234
}
12351235
}
@@ -1301,7 +1301,7 @@ mod test {
13011301
"
13021302
);
13031303

1304-
let credential = FullCredential::deserialize(&Bytes::from_slice(&data).unwrap()).unwrap();
1304+
let credential = FullCredential::deserialize(&Bytes::try_from(&data).unwrap()).unwrap();
13051305
assert!(matches!(credential.ctap, CtapVersion::Fido21Pre));
13061306
assert_eq!(credential.nonce, &hex!("F62CA01ED181A3D03D561FC7"));
13071307
assert_eq!(
@@ -1310,17 +1310,17 @@ mod test {
13101310
rp: Rp {
13111311
format: SerializationFormat::Long,
13121312
inner: PublicKeyCredentialRpEntity {
1313-
id: "webauthn.io".into(),
1313+
id: "webauthn.io".try_into().unwrap(),
13141314
name: None,
13151315
icon: None,
13161316
},
13171317
},
13181318
user: User {
13191319
format: SerializationFormat::Long,
13201320
inner: PublicKeyCredentialUserEntity {
1321-
id: Bytes::from_slice(&hex!("6447567A644445")).unwrap(),
1321+
id: Bytes::try_from(&hex!("6447567A644445")).unwrap(),
13221322
icon: None,
1323-
name: Some("test1".into()),
1323+
name: Some("test1".try_into().unwrap()),
13241324
display_name: None,
13251325
},
13261326
},

src/ctap2.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl<UP: UserPresence, T: TrussedRequirements> Authenticator for crate::Authenti
9696
let mut response = ctap2::get_info::Response::default();
9797
response.versions = versions;
9898
response.extensions = Some(extensions);
99-
response.aaguid = Bytes::try_from(&aaguid).unwrap();
99+
response.aaguid = Bytes::from(&aaguid);
100100
response.options = Some(options);
101101
response.transports = Some(transports);
102102
// 1200
@@ -900,11 +900,15 @@ impl<UP: UserPresence, T: TrussedRequirements> Authenticator for crate::Authenti
900900
fn vendor(&mut self, op: VendorOperation) -> Result<()> {
901901
info_now!("hello VO {:?}", &op);
902902
match op.into() {
903-
0x79 => syscall!(self.trussed.debug_dump_store()),
904-
_ => return Err(Error::InvalidCommand),
905-
};
906-
907-
Ok(())
903+
0x79 => {
904+
#[allow(deprecated)]
905+
{
906+
syscall!(self.trussed.debug_dump_store());
907+
}
908+
Err(Error::InvalidCommand)
909+
}
910+
_ => Err(Error::InvalidCommand),
911+
}
908912
}
909913

910914
#[inline(never)]
@@ -1286,7 +1290,7 @@ impl<UP: UserPresence, T: TrussedRequirements> crate::Authenticator<UP, T> {
12861290

12871291
// check pinAuth
12881292
let mut data: Bytes<{ sizes::MAX_CREDENTIAL_ID_LENGTH_PLUS_256 }> =
1289-
Bytes::try_from(&[parameters.sub_command as u8]).unwrap();
1293+
Bytes::from(&[parameters.sub_command as u8]);
12901294
let len = 1 + match parameters.sub_command {
12911295
Subcommand::EnumerateCredentialsBegin
12921296
| Subcommand::DeleteCredential
@@ -1468,7 +1472,7 @@ impl<UP: UserPresence, T: TrussedRequirements> crate::Authenticator<UP, T> {
14681472
let cred_random = syscall!(self.trussed.derive_key(
14691473
Mechanism::HmacSha256,
14701474
credential_key,
1471-
Some(Bytes::try_from(&[get_assertion_state.uv_performed as u8]).unwrap()),
1475+
Some(Bytes::from(&[get_assertion_state.uv_performed as u8])),
14721476
StorageAttributes::new().set_persistence(Location::Volatile)
14731477
))
14741478
.key;

src/ctap2/pin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ impl SharedSecret {
420420

421421
fn generate_iv<T: CryptoClient>(&self, trussed: &mut T) -> ShortData {
422422
match self {
423-
Self::V1 { .. } => ShortData::try_from(&[0; 16]).unwrap(),
423+
Self::V1 { .. } => ShortData::from(&[0; 16]),
424424
Self::V2 { .. } => {
425425
ShortData::try_from(&*syscall!(trussed.random_bytes(16)).bytes).unwrap()
426426
}

0 commit comments

Comments
 (0)