diff options
Diffstat (limited to 'src/include/ipxe/bigint.h')
-rw-r--r-- | src/include/ipxe/bigint.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/include/ipxe/bigint.h b/src/include/ipxe/bigint.h index c556afbc1..c56b2155f 100644 --- a/src/include/ipxe/bigint.h +++ b/src/include/ipxe/bigint.h @@ -218,6 +218,35 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); } while ( 0 ) /** + * Reduce big integer + * + * @v minuend Big integer to be reduced + * @v modulus Big integer modulus + * @v result Big integer to hold result + * @v tmp Temporary working space + */ +#define bigint_reduce( minuend, modulus, result, tmp ) do { \ + unsigned int minuend_size = bigint_size (minuend); \ + unsigned int modulus_size = bigint_size (modulus); \ + bigint_reduce_raw ( (minuend)->element, minuend_size, \ + (modulus)->element, modulus_size, \ + (result)->element, tmp ); \ + } while ( 0 ) + +/** + * Calculate temporary working space required for reduction + * + * @v minuend Big integer to be reduced + * @ret len Length of temporary working space + */ +#define bigint_reduce_tmp_len( minuend ) ( { \ + unsigned int size = bigint_size (minuend); \ + sizeof ( struct { \ + bigint_t ( size ) temp_minuend; \ + bigint_t ( size ) temp_modulus; \ + } ); } ) + +/** * Perform modular multiplication of big integers * * @v multiplicand Big integer to be multiplied @@ -339,6 +368,11 @@ void bigint_multiply_raw ( const bigint_element_t *multiplicand0, const bigint_element_t *multiplier0, unsigned int multiplier_size, bigint_element_t *result0 ); +void bigint_reduce_raw ( const bigint_element_t *minuend0, + unsigned int minuend_size, + const bigint_element_t *modulus0, + unsigned int modulus_size, + bigint_element_t *result0, void *tmp ); void bigint_mod_multiply_raw ( const bigint_element_t *multiplicand0, const bigint_element_t *multiplier0, const bigint_element_t *modulus0, |