@@ -11,14 +11,8 @@ pub type Result<T> = std::result::Result<T, CryptoError>;
1111fn cose_key_to_public ( peer : & super :: COSEEC2Key ) ->Result < p256:: PublicKey > {
1212// SEC 1 encoded uncompressed point
1313let peer = p256:: EncodedPoint :: from_affine_coordinates (
14- peer. x
15- . as_slice ( )
16- . try_into ( )
17- . map_err ( |_|CryptoError :: MalformedInput ) ?,
18- peer. y
19- . as_slice ( )
20- . try_into ( )
21- . map_err ( |_|CryptoError :: MalformedInput ) ?,
14+ peer. x . as_slice ( ) . into ( ) ,
15+ peer. y . as_slice ( ) . into ( ) ,
2216false ,
2317) ;
2418 p256:: PublicKey :: from_encoded_point ( & peer)
@@ -51,11 +45,7 @@ pub fn encrypt_aes_256_cbc_no_pad(key: &[u8], iv: Option<&[u8]>, data: &[u8]) ->
5145Err ( _) =>return Err ( CryptoError :: LibraryFailure ) ,
5246} ;
5347
54- let iv = iv. unwrap_or ( & [ 0u8 ; AES_BLOCK_SIZE ] ) ;
55- let iv =match iv. try_into ( ) {
56- Ok ( iv) => iv,
57- Err ( _) =>return Err ( CryptoError :: LibraryFailure ) ,
58- } ;
48+ let iv = iv. unwrap_or ( & [ 0u8 ; AES_BLOCK_SIZE ] ) . into ( ) ;
5949
6050// Validate that the data is an exact multiple of the block size since we have no
6151// padding available.
@@ -90,11 +80,7 @@ pub fn decrypt_aes_256_cbc_no_pad(key: &[u8], iv: Option<&[u8]>, data: &[u8]) ->
9080Err ( _) =>return Err ( CryptoError :: LibraryFailure ) ,
9181} ;
9282
93- let iv = iv. unwrap_or ( & [ 0u8 ; AES_BLOCK_SIZE ] ) ;
94- let iv =match iv. try_into ( ) {
95- Ok ( iv) => iv,
96- Err ( _) =>return Err ( CryptoError :: LibraryFailure ) ,
97- } ;
83+ let iv = iv. unwrap_or ( & [ 0u8 ; AES_BLOCK_SIZE ] ) . into ( ) ;
9884
9985// See comments in `encrypt_aes_256_cbc_no_pad` for rationale.
10086let blocks = data. chunks_exact ( AES_BLOCK_SIZE ) ;