Skip to content

Commit

Permalink
EC: Remove an unreachable branch from big_endian_affine_from_jacobian.
Browse files Browse the repository at this point in the history
  • Loading branch information
briansmith committed Jun 20, 2024
1 parent 842dbbf commit 85df439
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/ec/suite_b/ecdh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fn ecdh(
// `big_endian_affine_from_jacobian` verifies that the result is not at
// infinity and also does an extra check to verify that the point is on
// the curve.
big_endian_affine_from_jacobian(private_key_ops, Some(out), None, &product, cpu)
big_endian_affine_from_jacobian(private_key_ops, out, None, &product, cpu)

// NSA Guide Step 5 & 6 are deferred to the caller. Again, we have a
// pretty liberal interpretation of the NIST's spec's "Destroy" that
Expand Down
2 changes: 1 addition & 1 deletion src/ec/suite_b/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ mod tests {
let (x, y) = actual_result[1..].split_at_mut(cops.len());
super::super::private_key::big_endian_affine_from_jacobian(
priv_ops,
Some(x),
x,
Some(y),
&product,
cpu,
Expand Down
10 changes: 4 additions & 6 deletions src/ec/suite_b/private_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ pub(super) fn public_from_private(

// `big_endian_affine_from_jacobian` verifies that the point is not at
// infinity and is on the curve.
big_endian_affine_from_jacobian(ops, Some(x_out), Some(y_out), &my_public_key, cpu)
big_endian_affine_from_jacobian(ops, x_out, Some(y_out), &my_public_key, cpu)
}

pub(super) fn affine_from_jacobian(
Expand Down Expand Up @@ -180,16 +180,14 @@ pub(super) fn affine_from_jacobian(

pub(super) fn big_endian_affine_from_jacobian(
ops: &PrivateKeyOps,
x_out: Option<&mut [u8]>,
x_out: &mut [u8],
y_out: Option<&mut [u8]>,
p: &Point,
cpu: cpu::Features,
) -> Result<(), error::Unspecified> {
let (x_aff, y_aff) = affine_from_jacobian(ops, p, cpu)?;
if let Some(x_out) = x_out {
let x = ops.common.elem_unencoded(&x_aff);
limb::big_endian_from_limbs(ops.leak_limbs(&x), x_out);
}
let x = ops.common.elem_unencoded(&x_aff);
limb::big_endian_from_limbs(ops.leak_limbs(&x), x_out);
if let Some(y_out) = y_out {
let y = ops.common.elem_unencoded(&y_aff);
limb::big_endian_from_limbs(ops.leak_limbs(&y), y_out);
Expand Down

0 comments on commit 85df439

Please sign in to comment.