Lines Matching refs:bb
508 big_add_abs(BIGNUM *result, BIGNUM *aa, BIGNUM *bb)
516 if (aa->len > bb->len) {
517 shorter = bb->len;
522 longer = bb->len;
523 longerarg = bb;
534 b = bb->value;
584 /* result=aa-bb it is assumed that aa>=bb */
586 big_sub_pos(BIGNUM *result, BIGNUM *aa, BIGNUM *bb)
593 if (aa->len > bb->len) {
594 shorter = bb->len;
607 b = bb->value;
636 /* returns -1 if |aa|<|bb|, 0 if |aa|==|bb| 1 if |aa|>|bb| */
638 big_cmp_abs(BIGNUM *aa, BIGNUM *bb)
642 if (aa->len > bb->len) {
643 for (i = aa->len - 1; i > bb->len - 1; i--) {
648 } else if (aa->len < bb->len) {
649 for (i = bb->len - 1; i > aa->len - 1; i--) {
650 if (bb->value[i] > 0) {
658 if (aa->value[i] > bb->value[i]) {
660 } else if (aa->value[i] < bb->value[i]) {
670 big_sub(BIGNUM *result, BIGNUM *aa, BIGNUM *bb)
674 if ((bb->sign == -1) && (aa->sign == 1)) {
675 if ((err = big_add_abs(result, aa, bb)) != BIG_OK) {
679 } else if ((aa->sign == -1) && (bb->sign == 1)) {
680 if ((err = big_add_abs(result, aa, bb)) != BIG_OK) {
684 } else if ((aa->sign == 1) && (bb->sign == 1)) {
685 if (big_cmp_abs(aa, bb) >= 0) {
686 if ((err = big_sub_pos(result, aa, bb)) != BIG_OK) {
691 if ((err = big_sub_pos(result, bb, aa)) != BIG_OK) {
697 if (big_cmp_abs(aa, bb) >= 0) {
698 if ((err = big_sub_pos(result, aa, bb)) != BIG_OK) {
703 if ((err = big_sub_pos(result, bb, aa)) != BIG_OK) {
714 big_add(BIGNUM *result, BIGNUM *aa, BIGNUM *bb)
718 if ((bb->sign == -1) && (aa->sign == -1)) {
719 if ((err = big_add_abs(result, aa, bb)) != BIG_OK) {
723 } else if ((aa->sign == 1) && (bb->sign == 1)) {
724 if ((err = big_add_abs(result, aa, bb)) != BIG_OK) {
728 } else if ((aa->sign == 1) && (bb->sign == -1)) {
729 if (big_cmp_abs(aa, bb) >= 0) {
730 if ((err = big_sub_pos(result, aa, bb)) != BIG_OK) {
735 if ((err = big_sub_pos(result, bb, aa)) != BIG_OK) {
741 if (big_cmp_abs(aa, bb) >= 0) {
742 if ((err = big_sub_pos(result, aa, bb)) != BIG_OK) {
747 if ((err = big_sub_pos(result, bb, aa)) != BIG_OK) {
853 * result = aa - (2^BIG_CHUNK_SIZE)^lendiff * bb
855 * aa, bb, and result should be positive
858 big_sub_pos_high(BIGNUM *result, BIGNUM *aa, BIGNUM *bb)
863 lendiff = aa->len - bb->len;
869 aa1.len = bb->len;
871 (void) big_sub_pos(&res1, &aa1, bb);
883 * (2^BIG_CHUNK_SIZE)^lendiff * |bb|
884 * aa->len should be >= bb->len
887 big_cmp_abs_high(BIGNUM *aa, BIGNUM *bb)
892 lendiff = aa->len - bb->len;
893 aa1.len = bb->len;
897 return (big_cmp_abs(&aa1, bb));
1016 * result = aa/bb remainder = aa mod bb
1017 * it is assumed that aa and bb are positive
1020 big_div_pos(BIGNUM *result, BIGNUM *remainder, BIGNUM *aa, BIGNUM *bb)
1034 b = bb->value;
1036 blen = bb->len;
1044 bb->len = blen;
1049 if (big_cmp_abs(aa, bb) < 0) {
1093 big_shiftleft(&bblow, bb, offs);
1549 * result = aa * bb result->value should be big enough to hold the result
1555 big_mul(BIGNUM *result, BIGNUM *aa, BIGNUM *bb)
1563 if (aa == bb) {
1566 diff = big_cmp_abs(aa, bb);
1570 aa = bb;
1571 bb = tt;
1575 b = bb->value;
1577 blen = bb->len;
1585 bb->len = blen;
1594 /* aa or bb might be an alias to result */
1596 b = bb->value;
1606 sign = aa->sign * bb->sign;