@@ -74,6 +74,12 @@ mp_err mp_balance_mul(const mp_int *a, const mp_int *b, mp_int *c)
7474 return s_mp_balance_mul (a , b , c );
7575}
7676#endif
77+ #ifdef BN_MP_DIV_3_C
78+ mp_err mp_div_3 (const mp_int * a , mp_int * c , mp_digit * d )
79+ {
80+ return s_mp_div_3 (a , c , d );
81+ }
82+ #endif
7783#ifdef BN_MP_EXPTMOD_FAST_C
7884mp_err mp_exptmod_fast (const mp_int * G , const mp_int * X , const mp_int * P , mp_int * Y , int redmode )
7985{
@@ -184,51 +190,97 @@ unsigned long mp_get_long(const mp_int *a)
184190#ifdef BN_MP_GET_LONG_LONG_C
185191unsigned long long mp_get_long_long (const mp_int * a )
186192{
187- return mp_get_mag_ull (a );
193+ return ( unsigned long long ) mp_get_mag_u64 (a );
188194}
189195#endif
196+ #ifdef BN_MP_GET_LL_C
197+ MP_GET_SIGNED (mp_get_ll , mp_get_mag_u64 , long long , uint64_t )
198+ #endif
199+ #ifdef BN_MP_GET_MAG_ULL_C
200+ MP_GET_MAG (mp_get_mag_ull , unsigned long long)
201+ #endif
202+ #ifdef BN_MP_INIT_LL_C
203+ MP_INIT_INT (mp_init_ll , mp_set_i64 , long long )
204+ #endif
205+ #ifdef BN_MP_SET_LL_C
206+ MP_SET_SIGNED (mp_set_ll , mp_set_i64 , long long , unsigned long long)
207+ #endif
208+ #ifdef BN_MP_INIT_ULL_C
209+ MP_INIT_INT (mp_init_ull , mp_set_u64 , unsigned long long)
210+ #endif
211+ #ifdef BN_MP_SET_ULL_C
212+ MP_SET_UNSIGNED (mp_set_ull , unsigned long long)
213+ #endif
190214#ifdef BN_MP_PRIME_IS_DIVISIBLE_C
191215mp_err mp_prime_is_divisible (const mp_int * a , mp_bool * result )
192216{
193217 return s_mp_prime_is_divisible (a , result );
194218}
195219#endif
220+ #ifdef BN_MP_LOG_U32_C
221+ mp_err mp_log_u32 (const mp_int * a , uint32_t base , uint32_t * c )
222+ {
223+ mp_err e ;
224+ int c_ ;
225+ if (base > MP_MIN (MP_DIGIT_MAX , INT_MAX )) {
226+ return MP_VAL ;
227+ }
228+ e = mp_log_n (a , (int )base , & c_ );
229+ * c = c_ ;
230+ return e ;
231+ }
232+ #endif
196233#ifdef BN_MP_EXPT_D_EX_C
197234mp_err mp_expt_d_ex (const mp_int * a , mp_digit b , mp_int * c , int fast )
198235{
199236 (void )fast ;
200- if (b > MP_MIN (MP_DIGIT_MAX , UINT32_MAX )) {
237+ if (b > MP_MIN (MP_DIGIT_MAX , INT_MAX )) {
201238 return MP_VAL ;
202239 }
203- return mp_expt_u32 (a , (uint32_t )b , c );
240+ return mp_expt_n (a , (int )b , c );
204241}
205242#endif
206243#ifdef BN_MP_EXPT_D_C
207244mp_err mp_expt_d (const mp_int * a , mp_digit b , mp_int * c )
208245{
209- if (b > MP_MIN (MP_DIGIT_MAX , UINT32_MAX )) {
246+ if (b > MP_MIN (MP_DIGIT_MAX , INT_MAX )) {
210247 return MP_VAL ;
211248 }
212- return mp_expt_u32 (a , (uint32_t )b , c );
249+ return mp_expt_n (a , (int )b , c );
250+ }
251+ #endif
252+ #ifdef BN_MP_EXPT_U32_C
253+ mp_err mp_expt_u32 (const mp_int * a , uint32_t b , mp_int * c )
254+ {
255+ if (b > MP_MIN (MP_DIGIT_MAX , INT_MAX )) {
256+ return MP_VAL ;
257+ }
258+ return mp_expt_n (a , (int )b , c );
213259}
214260#endif
215261#ifdef BN_MP_N_ROOT_EX_C
216262mp_err mp_n_root_ex (const mp_int * a , mp_digit b , mp_int * c , int fast )
217263{
218264 (void )fast ;
219- if (b > MP_MIN (MP_DIGIT_MAX , UINT32_MAX )) {
265+ if (b > MP_MIN (MP_DIGIT_MAX , INT_MAX )) {
220266 return MP_VAL ;
221267 }
222- return mp_root_u32 (a , (uint32_t )b , c );
268+ return mp_root_n (a , (int )b , c );
223269}
224270#endif
225271#ifdef BN_MP_N_ROOT_C
226272mp_err mp_n_root (const mp_int * a , mp_digit b , mp_int * c )
227273{
228- if (b > MP_MIN (MP_DIGIT_MAX , UINT32_MAX )) {
274+ if (b > MP_MIN (MP_DIGIT_MAX , INT_MAX )) {
229275 return MP_VAL ;
230276 }
231- return mp_root_u32 (a , (uint32_t )b , c );
277+ return mp_root_n (a , (int )b , c );
278+ }
279+ #endif
280+ #ifdef BN_MP_ROOT_U32_C
281+ mp_err mp_root_u32 (const mp_int * a , uint32_t b , mp_int * c )
282+ {
283+ return mp_root_n (a , (int )b , c );
232284}
233285#endif
234286#ifdef BN_MP_UNSIGNED_BIN_SIZE_C
0 commit comments