@@ -48,7 +48,7 @@ impl Okuchi {
4848
4949 // Enforce m < p. p is secret; use conservative bound: p ≥ 2^(p_bits-1).
5050 let max_bits = pub_key. plaintext_bound_bits ( ) ;
51- if plaintext. bits ( ) as usize > max_bits {
51+ if plaintext. bits ( ) > max_bits {
5252 return Err ( Error :: PlaintextTooLarge ) ;
5353 }
5454
@@ -114,7 +114,7 @@ impl Okuchi {
114114 } else {
115115 bytes. len ( ) . div_ceil ( max_block)
116116 } ;
117- let est_ct_bytes = pub_key. n ( ) . bits ( ) as usize / 8 + 1 ;
117+ let est_ct_bytes = pub_key. n ( ) . bits ( ) / 8 + 1 ;
118118 let mut out = Vec :: with_capacity ( 8 + block_count * ( 4 + est_ct_bytes) ) ;
119119
120120 out. extend_from_slice ( & ( block_count as u32 ) . to_be_bytes ( ) ) ;
@@ -256,7 +256,7 @@ impl Okuchi {
256256 max_block
257257 } ;
258258 let pad = expected. saturating_sub ( plain. len ( ) ) ;
259- result. extend ( std:: iter:: repeat ( 0u8 ) . take ( pad) ) ;
259+ result. extend ( std:: iter:: repeat_n ( 0u8 , pad) ) ;
260260 }
261261
262262 result. extend_from_slice ( & plain) ;
@@ -299,7 +299,7 @@ impl Okuchi {
299299 let blocks_b = Self :: parse_blocks ( packed_b) ?;
300300 let n = pub_key. n ( ) ;
301301
302- let est_ct_bytes = n. bits ( ) as usize / 8 + 1 ;
302+ let est_ct_bytes = n. bits ( ) / 8 + 1 ;
303303 let mut out = Vec :: with_capacity ( 8 + a_cnt * ( 4 + est_ct_bytes) ) ;
304304 out. extend_from_slice ( & ( a_cnt as u32 ) . to_be_bytes ( ) ) ;
305305 out. extend_from_slice ( & 0u32 . to_be_bytes ( ) ) ; // original_data_len = 0 sentinel
@@ -353,7 +353,7 @@ impl Okuchi {
353353 /// the block boundaries used by [`encrypt_stream`](Okuchi::encrypt_stream) and
354354 /// [`decrypt_stream`](Okuchi::decrypt_stream).
355355 fn max_plaintext_bytes ( pub_key : & PublicKey ) -> usize {
356- let n_bits = pub_key. n ( ) . bits ( ) as usize ;
356+ let n_bits = pub_key. n ( ) . bits ( ) ;
357357 let p_bits = n_bits / 3 ;
358358 let bytes = p_bits. saturating_sub ( 1 ) / 8 ;
359359 std:: cmp:: max ( 1 , bytes)
0 commit comments