@@ -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 :: from_slice ( & aaguid) . unwrap ( ) ;
99+ response. aaguid = Bytes :: try_from ( & aaguid) . unwrap ( ) ;
100100 response. options = Some ( options) ;
101101 response. transports = Some ( transports) ;
102102 // 1200
@@ -293,7 +293,7 @@ impl<UP: UserPresence, T: TrussedRequirements> Authenticator for crate::Authenti
293293 // Turns out it's size 92 (enum serialization not optimized yet...)
294294 // let mut wrapped_key = Bytes::<60>::new();
295295 // wrapped_key.extend_from_slice(&wrapped_key_msg).unwrap();
296- Key :: WrappedKey ( wrapped_key . to_bytes ( ) . map_err ( |_| Error :: Other ) ?)
296+ Key :: WrappedKey ( Bytes :: try_from ( & * wrapped_key ) . map_err ( |_| Error :: Other ) ?)
297297 }
298298 } ;
299299
@@ -450,7 +450,7 @@ impl<UP: UserPresence, T: TrussedRequirements> Authenticator for crate::Authenti
450450 attestation_algorithm. sign ( & mut self . trussed , attestation_key, & commitment) ;
451451 let packed = PackedAttestationStatement {
452452 alg : attestation_algorithm. into ( ) ,
453- sig : signature . to_bytes ( ) . map_err ( |_| Error :: Other ) ?,
453+ sig : Bytes :: try_from ( & * signature ) . map_err ( |_| Error :: Other ) ?,
454454 x5c : attestation_maybe. as_ref ( ) . map ( |attestation| {
455455 // See: https://www.w3.org/TR/webauthn-2/#sctn-packed-attestation-cert-requirements
456456 let cert = attestation. 1 . clone ( ) ;
@@ -1249,7 +1249,7 @@ impl<UP: UserPresence, T: TrussedRequirements> crate::Authenticator<UP, T> {
12491249 return Err ( Error :: PinPolicyViolation ) ;
12501250 }
12511251
1252- pin. resize_default ( pin_length) . unwrap ( ) ;
1252+ pin. resize_zero ( pin_length) . unwrap ( ) ;
12531253
12541254 Ok ( pin)
12551255 }
@@ -1286,7 +1286,7 @@ impl<UP: UserPresence, T: TrussedRequirements> crate::Authenticator<UP, T> {
12861286
12871287 // check pinAuth
12881288 let mut data: Bytes < { sizes:: MAX_CREDENTIAL_ID_LENGTH_PLUS_256 } > =
1289- Bytes :: from_slice ( & [ parameters. sub_command as u8 ] ) . unwrap ( ) ;
1289+ Bytes :: try_from ( & [ parameters. sub_command as u8 ] ) . unwrap ( ) ;
12901290 let len = 1 + match parameters. sub_command {
12911291 Subcommand :: EnumerateCredentialsBegin
12921292 | Subcommand :: DeleteCredential
@@ -1468,7 +1468,7 @@ impl<UP: UserPresence, T: TrussedRequirements> crate::Authenticator<UP, T> {
14681468 let cred_random = syscall ! ( self . trussed. derive_key(
14691469 Mechanism :: HmacSha256 ,
14701470 credential_key,
1471- Some ( Bytes :: from_slice ( & [ get_assertion_state. uv_performed as u8 ] ) . unwrap( ) ) ,
1471+ Some ( Bytes :: try_from ( & [ get_assertion_state. uv_performed as u8 ] ) . unwrap( ) ) ,
14721472 StorageAttributes :: new( ) . set_persistence( Location :: Volatile )
14731473 ) )
14741474 . key ;
@@ -1515,7 +1515,7 @@ impl<UP: UserPresence, T: TrussedRequirements> crate::Authenticator<UP, T> {
15151515
15161516 shared_secret. delete ( & mut self . trussed ) ;
15171517
1518- output. hmac_secret = Some ( Bytes :: from_slice ( & output_enc) . unwrap ( ) ) ;
1518+ output. hmac_secret = Some ( Bytes :: try_from ( & * output_enc) . unwrap ( ) ) ;
15191519 }
15201520
15211521 if extensions. third_party_payment . unwrap_or_default ( ) {
@@ -1619,10 +1619,8 @@ impl<UP: UserPresence, T: TrussedRequirements> crate::Authenticator<UP, T> {
16191619
16201620 let signing_algorithm =
16211621 SigningAlgorithm :: try_from ( credential. algorithm ( ) ) . map_err ( |_| Error :: Other ) ?;
1622- let signature = signing_algorithm
1623- . sign ( & mut self . trussed , key, & commitment)
1624- . to_bytes ( )
1625- . unwrap ( ) ;
1622+ let signature =
1623+ Bytes :: try_from ( & * signing_algorithm. sign ( & mut self . trussed , key, & commitment) ) . unwrap ( ) ;
16261624
16271625 // select preferred format or skip attestation statement
16281626 let att_stmt_fmt = data
@@ -1645,7 +1643,7 @@ impl<UP: UserPresence, T: TrussedRequirements> crate::Authenticator<UP, T> {
16451643 & commitment,
16461644 ) ;
16471645 (
1648- signature . to_bytes ( ) . map_err ( |_| Error :: Other ) ?,
1646+ Bytes :: try_from ( & * signature ) . map_err ( |_| Error :: Other ) ?,
16491647 signing_algorithm. into ( ) ,
16501648 )
16511649 } else {
0 commit comments