diff options
| author | Michael Brown | 2024-11-27 13:56:22 +0100 |
|---|---|---|
| committer | Michael Brown | 2024-11-27 14:16:05 +0100 |
| commit | 96f385d7a48ffe259295991043a86b2cefce1891 (patch) | |
| tree | f32876fd70a7e1f5b182cc0dd47b28f9a57cb8c0 /src/include | |
| parent | [crypto] Eliminate temporary working space for bigint_mod_invert() (diff) | |
| download | ipxe-96f385d7a48ffe259295991043a86b2cefce1891.tar.gz ipxe-96f385d7a48ffe259295991043a86b2cefce1891.tar.xz ipxe-96f385d7a48ffe259295991043a86b2cefce1891.zip | |
[crypto] Use inverse size as effective size for bigint_mod_invert()
Montgomery reduction requires only the least significant element of an
inverse modulo 2^k, which in turn depends upon only the least
significant element of the invertend.
Use the inverse size (rather than the invertend size) as the effective
size for bigint_mod_invert(). This eliminates around 97% of the loop
iterations for a typical 2048-bit RSA modulus.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/ipxe/bigint.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/include/ipxe/bigint.h b/src/include/ipxe/bigint.h index e55c536c7..14f3c5f28 100644 --- a/src/include/ipxe/bigint.h +++ b/src/include/ipxe/bigint.h @@ -248,7 +248,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * @v inverse Big integer to hold result */ #define bigint_mod_invert( invertend, inverse ) do { \ - unsigned int size = bigint_size ( invertend ); \ + unsigned int size = bigint_size ( inverse ); \ bigint_mod_invert_raw ( (invertend)->element, \ (inverse)->element, size ); \ } while ( 0 ) |
