Skip to content

Commit 52425b5

Browse files
authored
Fix manual_div_ceil Clippy lint (#492)
1 parent c8955c9 commit 52425b5

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/algorithms/pss.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub(crate) fn emsa_pss_encode(
2525
// See [1], section 9.1.1
2626
let h_len = hash.output_size();
2727
let s_len = salt.len();
28-
let em_len = (em_bits + 7) / 8;
28+
let em_len = em_bits.div_ceil(8);
2929

3030
// 1. If the length of M is greater than the input limitation for the
3131
// hash function (2^61 - 1 octets for SHA-1), output "message too
@@ -100,7 +100,7 @@ where
100100
// See [1], section 9.1.1
101101
let h_len = <D as Digest>::output_size();
102102
let s_len = salt.len();
103-
let em_len = (em_bits + 7) / 8;
103+
let em_len = em_bits.div_ceil(8);
104104

105105
// 1. If the length of M is greater than the input limitation for the
106106
// hash function (2^61 - 1 octets for SHA-1), output "message too
@@ -235,8 +235,8 @@ pub(crate) fn emsa_pss_verify(
235235
key_bits: usize,
236236
) -> Result<()> {
237237
let em_bits = key_bits - 1;
238-
let em_len = (em_bits + 7) / 8;
239-
let key_len = (key_bits + 7) / 8;
238+
let em_len = em_bits.div_ceil(8);
239+
let key_len = key_bits.div_ceil(8);
240240
let h_len = hash.output_size();
241241

242242
let em = &mut em[key_len - em_len..];
@@ -288,8 +288,8 @@ where
288288
D: Digest + FixedOutputReset,
289289
{
290290
let em_bits = key_bits - 1;
291-
let em_len = (em_bits + 7) / 8;
292-
let key_len = (key_bits + 7) / 8;
291+
let em_len = em_bits.div_ceil(8);
292+
let key_len = key_bits.div_ceil(8);
293293
let h_len = <D as Digest>::output_size();
294294

295295
let em = &mut em[key_len - em_len..];

src/traits/keys.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub trait PublicKeyParts {
1717
/// Returns the modulus size in bytes. Raw signatures and ciphertexts for
1818
/// or by this public key will have the same size.
1919
fn size(&self) -> usize {
20-
(self.n().bits() as usize + 7) / 8
20+
(self.n().bits() as usize).div_ceil(8)
2121
}
2222

2323
/// Returns the parameters for montgomery operations.

0 commit comments

Comments
 (0)