Guest User

Untitled

a guest
Jan 21st, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.83 KB | None | 0 0
  1. void bigint_mulk32(__xdata unsigned char* res, __xdata unsigned char* a, __xdata unsigned char* b) {
  2.     unsigned char carry_aa = bigint_add(res, a, a + 16, 0, 16);
  3.     unsigned char carry_bb = bigint_add(res + 32, b, b + 16, 0, 16);
  4.     unsigned char carry_temp;
  5.     bigint_mulf(temp_buffer32, res, res + 32, 16);
  6.     if(carry_aa & carry_bb) {
  7.         carry_temp = bigint_add3(temp_buffer32 + 16, temp_buffer32 + 16, res, res + 32, 0, 16) + 1;
  8.     } else if(carry_aa) {
  9.         carry_temp = bigint_add(temp_buffer32 + 16, temp_buffer32 + 16, res + 32, 0, 16);
  10.     } else if(carry_bb) {
  11.         carry_temp = bigint_add(temp_buffer32 + 16, temp_buffer32 + 16, res, 0, 16);
  12.     } else {
  13.         carry_temp = 0;
  14.     }
  15.     bigint_mulf(res, a, b, 16);
  16.     bigint_mulf(res + 32, a + 16, b + 16, 16);
  17.     carry_temp += bigint_sub3(temp_buffer32, temp_buffer32, res, res + 32, 0, 32);
  18.     carry_temp += bigint_add(res + 16, res+ 16, temp_buffer32, 0, 32);
  19.     bigint_addcarry(res + 48, res + 48, carry_temp, 16);
  20. }
  21.  
  22. void bigint_mulk64(__xdata unsigned char* res, __xdata unsigned char* a, __xdata unsigned char* b) {
  23.     unsigned char carry_aa = bigint_add(res, a, a + 32, 0, 32);
  24.     unsigned char carry_bb = bigint_add(res + 64, b, b + 32, 0, 32);
  25.     unsigned char carry_temp;
  26.     bigint_mulk32(temp_buffer64, res, res + 64);
  27.     if(carry_aa & carry_bb) {
  28.         carry_temp = bigint_add3(temp_buffer64 + 32, temp_buffer64 + 32, res, res + 64, 0, 32) + 1;
  29.     } else if(carry_aa) {
  30.         carry_temp = bigint_add(temp_buffer64 + 32, temp_buffer64 + 32, res + 64, 0, 32);
  31.     } else if(carry_bb) {
  32.         carry_temp = bigint_add(temp_buffer64 + 32, temp_buffer64 + 32, res, 0, 32);
  33.     } else {
  34.         carry_temp = 0;
  35.     }
  36.     bigint_mulk32(res, a, b);
  37.     bigint_mulk32(res + 64, a + 32, b + 32);
  38.     carry_temp += bigint_sub3(temp_buffer64, temp_buffer64, res, res + 64, 0, 64);
  39.     carry_temp += bigint_add(res + 32, res+ 32, temp_buffer64, 0, 64);
  40.     bigint_addcarry(res + 96, res + 96, carry_temp, 32);
  41. }
  42.  
  43. void bigint_mulk128(__xdata unsigned char* res, __xdata unsigned char* a, __xdata unsigned char* b) {
  44.     unsigned char carry_aa = bigint_add(res, a, a + 64, 0, 64);
  45.     unsigned char carry_bb = bigint_add(res + 128, b, b + 64, 0, 64);
  46.     unsigned char carry_temp;
  47.     bigint_mulk64(temp_buffer128, res, res + 128);
  48.     if(carry_aa & carry_bb) {
  49.         carry_temp = bigint_add3(temp_buffer128 + 64, temp_buffer128 + 64, res, res + 128, 0, 64) + 1;
  50.     } else if(carry_aa) {
  51.         carry_temp = bigint_add(temp_buffer128 + 64, temp_buffer128 + 64, res + 128, 0, 64);
  52.     } else if(carry_bb) {
  53.         carry_temp = bigint_add(temp_buffer128 + 64, temp_buffer128 + 64, res, 0, 64);
  54.     } else {
  55.         carry_temp = 0;
  56.     }
  57.     bigint_mulk64(res, a, b);
  58.     bigint_mulk64(res + 128, a + 64, b + 64);
  59.     carry_temp += bigint_sub3(temp_buffer128, temp_buffer128, res, res + 128, 0, 128);
  60.     carry_temp += bigint_add(res + 64, res+ 64, temp_buffer128, 0, 128);
  61.     bigint_addcarry(res + 192, res + 192, carry_temp, 64);
  62. }
Add Comment
Please, Sign In to add comment