mirror of
https://github.com/ipxe/ipxe
synced 2026-05-04 03:03:43 +03:00
[crypto] Expose carry flag from big integer addition and subtraction
Expose the effective carry (or borrow) out flag from big integer addition and subtraction, and use this to elide an explicit bit test when performing x25519 reduction. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
+3
-2
@@ -564,6 +564,7 @@ void x25519_invert ( const union x25519_oct258 *invertend,
|
||||
*/
|
||||
static void x25519_reduce_by ( const x25519_t *subtrahend, x25519_t *value ) {
|
||||
x25519_t tmp;
|
||||
int underflow;
|
||||
|
||||
/* Conditionally subtract subtrahend
|
||||
*
|
||||
@@ -571,8 +572,8 @@ static void x25519_reduce_by ( const x25519_t *subtrahend, x25519_t *value ) {
|
||||
* time) if the subtraction underflows.
|
||||
*/
|
||||
bigint_copy ( value, &tmp );
|
||||
bigint_subtract ( subtrahend, value );
|
||||
bigint_swap ( value, &tmp, bigint_msb_is_set ( value ) );
|
||||
underflow = bigint_subtract ( subtrahend, value );
|
||||
bigint_swap ( value, &tmp, underflow );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user