Skip to content

Commit bda4cee

Browse files
committed
ec/suite_b: Make NUM_LIMBS constants NonZeroUsize.
1 parent 1bb94b3 commit bda4cee

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/ec/suite_b/ops/elem.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ impl NumLimbs {
3535

3636
pub(super) const fn into(self) -> usize {
3737
match self {
38-
NumLimbs::P256 => P256_NUM_LIMBS,
39-
NumLimbs::P384 => P384_NUM_LIMBS,
38+
NumLimbs::P256 => P256_NUM_LIMBS.get(),
39+
NumLimbs::P384 => P384_NUM_LIMBS.get(),
4040
}
4141
}
4242
}

src/ec/suite_b/ops/p256.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ use super::{
1616
elem::{binary_op, binary_op_assign},
1717
elem_sqr_mul, elem_sqr_mul_acc, PublicModulus, *,
1818
};
19+
use crate::polyfill::unwrap_const;
1920
use cfg_if::cfg_if;
21+
use core::num::NonZeroUsize;
2022

21-
pub(super) const NUM_LIMBS: usize = 256 / LIMB_BITS;
23+
pub(super) const NUM_LIMBS: NonZeroUsize = unwrap_const(NonZeroUsize::new(256 / LIMB_BITS));
2224

2325
pub static COMMON_OPS: CommonOps = CommonOps {
2426
num_limbs: elem::NumLimbs::P256,

src/ec/suite_b/ops/p384.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ use super::{
1616
elem::{binary_op, binary_op_assign},
1717
elem_sqr_mul, elem_sqr_mul_acc, PublicModulus, *,
1818
};
19+
use crate::polyfill::unwrap_const;
20+
use core::num::NonZeroUsize;
1921

20-
pub(super) const NUM_LIMBS: usize = 384 / LIMB_BITS;
22+
pub(super) const NUM_LIMBS: NonZeroUsize = unwrap_const(NonZeroUsize::new(384 / LIMB_BITS));
2123

2224
pub static COMMON_OPS: CommonOps = CommonOps {
2325
num_limbs: elem::NumLimbs::P384,

0 commit comments

Comments
 (0)