Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions sw/otbn/crypto/p384_keygen_from_seed.s
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/* Copyright zeroRISC Inc. */
/* Licensed under the Apache License, Version 2.0, see LICENSE for details. */
/* SPDX-License-Identifier: Apache-2.0 */

/* Copyright lowRISC contributors (OpenTitan project). */
/* Licensed under the Apache License, Version 2.0, see LICENSE for details. */
/* SPDX-License-Identifier: Apache-2.0 */
Expand Down Expand Up @@ -98,17 +102,14 @@ p384_key_from_seed:
bn.sub w24, w10, w16
bn.subb w25, w11, w17

/* Clear flags. */
bn.sub w31, w31, w31

/* Compute d1. Because 2^384 < 2 * n, a conditional subtraction is
sufficient to reduce. Similarly to the carry bit, the conditional bit here
is not very sensitive because the shares are large relative to n.
[w6,w5] <= x1 mod n = d1 */
bn.sel w5, w10, w24, FG0.C
bn.sel w6, w11, w25, FG0.C

/* Clear w25 before over writing it with a different share. */
/* Clear w25 before over writing it with a different share and clear flags. */
bn.xor w25, w25, w25

/* Dummy instruction to avoid consecutive share access. */
Expand Down