123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #include <tommath.h>
- #ifdef BN_MP_LCM_C
- int mp_lcm (mp_int * a, mp_int * b, mp_int * c)
- {
- int res;
- mp_int t1, t2;
- if ((res = mp_init_multi (&t1, &t2, NULL)) != MP_OKAY) {
- return res;
- }
-
- if ((res = mp_gcd (a, b, &t1)) != MP_OKAY) {
- goto LBL_T;
- }
-
- if (mp_cmp_mag(a, b) == MP_LT) {
-
- if ((res = mp_div(a, &t1, &t2, NULL)) != MP_OKAY) {
- goto LBL_T;
- }
- res = mp_mul(b, &t2, c);
- } else {
-
- if ((res = mp_div(b, &t1, &t2, NULL)) != MP_OKAY) {
- goto LBL_T;
- }
- res = mp_mul(a, &t2, c);
- }
-
- c->sign = MP_ZPOS;
- LBL_T:
- mp_clear_multi (&t1, &t2, NULL);
- return res;
- }
- #endif
|