Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void bigint_mulk32(__xdata unsigned char* res, __xdata unsigned char* a, __xdata unsigned char* b) {
- unsigned char carry_aa = bigint_add(res, a, a + 16, 0, 16);
- unsigned char carry_bb = bigint_add(res + 32, b, b + 16, 0, 16);
- unsigned char carry_temp;
- bigint_mulf(temp_buffer32, res, res + 32, 16);
- if(carry_aa & carry_bb) {
- carry_temp = bigint_add3(temp_buffer32 + 16, temp_buffer32 + 16, res, res + 32, 0, 16) + 1;
- } else if(carry_aa) {
- carry_temp = bigint_add(temp_buffer32 + 16, temp_buffer32 + 16, res + 32, 0, 16);
- } else if(carry_bb) {
- carry_temp = bigint_add(temp_buffer32 + 16, temp_buffer32 + 16, res, 0, 16);
- } else {
- carry_temp = 0;
- }
- bigint_mulf(res, a, b, 16);
- bigint_mulf(res + 32, a + 16, b + 16, 16);
- carry_temp += bigint_sub3(temp_buffer32, temp_buffer32, res, res + 32, 0, 32);
- carry_temp += bigint_add(res + 16, res+ 16, temp_buffer32, 0, 32);
- bigint_addcarry(res + 48, res + 48, carry_temp, 16);
- }
- void bigint_mulk64(__xdata unsigned char* res, __xdata unsigned char* a, __xdata unsigned char* b) {
- unsigned char carry_aa = bigint_add(res, a, a + 32, 0, 32);
- unsigned char carry_bb = bigint_add(res + 64, b, b + 32, 0, 32);
- unsigned char carry_temp;
- bigint_mulk32(temp_buffer64, res, res + 64);
- if(carry_aa & carry_bb) {
- carry_temp = bigint_add3(temp_buffer64 + 32, temp_buffer64 + 32, res, res + 64, 0, 32) + 1;
- } else if(carry_aa) {
- carry_temp = bigint_add(temp_buffer64 + 32, temp_buffer64 + 32, res + 64, 0, 32);
- } else if(carry_bb) {
- carry_temp = bigint_add(temp_buffer64 + 32, temp_buffer64 + 32, res, 0, 32);
- } else {
- carry_temp = 0;
- }
- bigint_mulk32(res, a, b);
- bigint_mulk32(res + 64, a + 32, b + 32);
- carry_temp += bigint_sub3(temp_buffer64, temp_buffer64, res, res + 64, 0, 64);
- carry_temp += bigint_add(res + 32, res+ 32, temp_buffer64, 0, 64);
- bigint_addcarry(res + 96, res + 96, carry_temp, 32);
- }
- void bigint_mulk128(__xdata unsigned char* res, __xdata unsigned char* a, __xdata unsigned char* b) {
- unsigned char carry_aa = bigint_add(res, a, a + 64, 0, 64);
- unsigned char carry_bb = bigint_add(res + 128, b, b + 64, 0, 64);
- unsigned char carry_temp;
- bigint_mulk64(temp_buffer128, res, res + 128);
- if(carry_aa & carry_bb) {
- carry_temp = bigint_add3(temp_buffer128 + 64, temp_buffer128 + 64, res, res + 128, 0, 64) + 1;
- } else if(carry_aa) {
- carry_temp = bigint_add(temp_buffer128 + 64, temp_buffer128 + 64, res + 128, 0, 64);
- } else if(carry_bb) {
- carry_temp = bigint_add(temp_buffer128 + 64, temp_buffer128 + 64, res, 0, 64);
- } else {
- carry_temp = 0;
- }
- bigint_mulk64(res, a, b);
- bigint_mulk64(res + 128, a + 64, b + 64);
- carry_temp += bigint_sub3(temp_buffer128, temp_buffer128, res, res + 128, 0, 128);
- carry_temp += bigint_add(res + 64, res+ 64, temp_buffer128, 0, 128);
- bigint_addcarry(res + 192, res + 192, carry_temp, 64);
- }
Add Comment
Please, Sign In to add comment