Lines Matching refs:biR
60 static bigint *bi_int_divide(BI_CTX *ctx, bigint *biR, comp denom);
66 static bigint *comp_right_shift(bigint *biR, int num_shifts);
67 static bigint *comp_left_shift(bigint *biR, int num_shifts);
218 bigint *biR = alloc(ctx, 1); in int_to_bi() local
219 biR->comps[0] = i; in int_to_bi()
220 return biR; in int_to_bi()
230 bigint *biR = alloc(ctx, bi->size); in bi_clone() local
232 memcpy(biR->comps, bi->comps, bi->size*COMP_BYTE_SIZE); in bi_clone()
233 return biR; in bi_clone()
320 bigint *biR = alloc(ctx, n + 1); in bi_int_multiply() local
322 comp *r = biR->comps; in bi_int_multiply()
339 return trim(biR); in bi_int_multiply()
476 static bigint *bi_int_divide(BI_CTX *ctx __unused, bigint *biR, comp denom) in bi_int_divide() argument
478 int i = biR->size - 1; in bi_int_divide()
481 check(biR); in bi_int_divide()
485 r = (r<<COMP_BIT_SIZE) + biR->comps[i]; in bi_int_divide()
486 biR->comps[i] = (comp)(r / denom); in bi_int_divide()
490 return trim(biR); in bi_int_divide()
528 static bigint *comp_right_shift(bigint *biR, int num_shifts) in comp_right_shift() argument
530 int i = biR->size-num_shifts; in comp_right_shift()
531 comp *x = biR->comps; in comp_right_shift()
532 comp *y = &biR->comps[num_shifts]; in comp_right_shift()
534 check(biR); in comp_right_shift()
538 biR->comps[0] = 0; /* return 0 */ in comp_right_shift()
539 biR->size = 1; in comp_right_shift()
540 return biR; in comp_right_shift()
548 biR->size -= num_shifts; in comp_right_shift()
549 return biR; in comp_right_shift()
555 static bigint *comp_left_shift(bigint *biR, int num_shifts) in comp_left_shift() argument
557 int i = biR->size-1; in comp_left_shift()
560 check(biR); in comp_left_shift()
564 return biR; in comp_left_shift()
567 more_comps(biR, biR->size + num_shifts); in comp_left_shift()
569 x = &biR->comps[i+num_shifts]; in comp_left_shift()
570 y = &biR->comps[i]; in comp_left_shift()
577 memset(biR->comps, 0, num_shifts*COMP_BYTE_SIZE); /* zero LS comps */ in comp_left_shift()
578 return biR; in comp_left_shift()
591 bigint *biR = alloc(ctx, (size+COMP_BYTE_SIZE-1)/COMP_BYTE_SIZE); in bi_import() local
594 memset(biR->comps, 0, biR->size*COMP_BYTE_SIZE); in bi_import()
598 biR->comps[offset] += data[i] << (j*8); in bi_import()
607 return trim(biR); in bi_import()
622 bigint *biR = alloc(ctx, (size+COMP_NUM_NIBBLES-1)/COMP_NUM_NIBBLES); in bi_str_import() local
624 memset(biR->comps, 0, biR->size*COMP_BYTE_SIZE); in bi_str_import()
629 biR->comps[offset] += num << (j*4); in bi_str_import()
638 return biR; in bi_str_import()
778 bigint *biR = alloc(ctx, n + t); in regular_multiply() local
779 comp *sr = biR->comps; in regular_multiply()
787 memset(biR->comps, 0, ((n+t)*COMP_BYTE_SIZE)); in regular_multiply()
809 return trim(biR); in regular_multiply()
901 bigint *biR = alloc(ctx, t*2); in regular_square() local
902 comp *w = biR->comps; in regular_square()
906 memset(w, 0, biR->size*COMP_BYTE_SIZE); in regular_square()
945 return trim(biR); in regular_square()
1041 bigint *biR; in alloc() local
1046 biR = ctx->free_list; in alloc()
1047 ctx->free_list = biR->next; in alloc()
1050 if (biR->refs != 0) in alloc()
1058 more_comps(biR, size); in alloc()
1063 biR = (bigint *)malloc(sizeof(bigint)); in alloc()
1064 biR->comps = (comp*)malloc(size * COMP_BYTE_SIZE); in alloc()
1065 biR->max_comps = size; /* give some space to spare */ in alloc()
1068 biR->size = size; in alloc()
1069 biR->refs = 1; in alloc()
1070 biR->next = NULL; in alloc()
1072 return biR; in alloc()
1222 bigint *biR; in partial_multiply() local
1229 biR = alloc(ctx, n + t); in partial_multiply()
1232 sr = biR->comps; in partial_multiply()
1244 biR->comps[0] = 0; /* return 0 */ in partial_multiply()
1245 biR->size = 1; in partial_multiply()
1246 return biR; in partial_multiply()
1285 return trim(biR); in partial_multiply()
1374 bigint *biR = int_to_bi(ctx, 1); in bi_mod_power() local
1383 bi_free(ctx, biR); in bi_mod_power()
1384 biR = ctx->bi_R_mod_m[mod_offset]; /* A */ in bi_mod_power()
1424 biR = bi_residue(ctx, bi_square(ctx, biR)); in bi_mod_power()
1433 biR = bi_residue(ctx, bi_multiply(ctx, biR, ctx->g[part_exp])); in bi_mod_power()
1438 biR = bi_residue(ctx, bi_square(ctx, biR)); in bi_mod_power()
1454 return ctx->use_classical ? biR : bi_mont(ctx, biR); /* convert back */ in bi_mod_power()
1456 return biR; in bi_mod_power()
1474 bigint *biR, *tmp_biR; in bi_mod_power2() local
1485 biR = bi_clone(ctx, tmp_biR); in bi_mod_power2()
1493 return biR; in bi_mod_power2()