MCPcopy Create free account
hub / github.com/Tripwire/tripwire-open-source / PositiveAdd

Function PositiveAdd

src/cryptlib/integer.cpp:1645–1669  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1643}
1644
1645void PositiveAdd(Integer &sum, const Integer &a, const Integer& b)
1646{
1647 word carry;
1648 if (a.reg.size == b.reg.size)
1649 carry = Add(sum.reg, a.reg, b.reg, a.reg.size);
1650 else if (a.reg.size > b.reg.size)
1651 {
1652 carry = Add(sum.reg, a.reg, b.reg, b.reg.size);
1653 CopyWords(sum.reg+b.reg.size, a.reg+b.reg.size, a.reg.size-b.reg.size);
1654 carry = Increment(sum.reg+b.reg.size, a.reg.size-b.reg.size, carry);
1655 }
1656 else
1657 {
1658 carry = Add(sum.reg, a.reg, b.reg, a.reg.size);
1659 CopyWords(sum.reg+a.reg.size, b.reg+a.reg.size, b.reg.size-a.reg.size);
1660 carry = Increment(sum.reg+a.reg.size, b.reg.size-a.reg.size, carry);
1661 }
1662
1663 if (carry)
1664 {
1665 sum.reg.CleanGrow(2*sum.reg.size);
1666 sum.reg[sum.reg.size/2] = 1;
1667 }
1668 sum.sign = Integer::POSITIVE;
1669}
1670
1671void PositiveSubtract(Integer &diff, const Integer &a, const Integer& b)
1672{

Callers 3

operator+Function · 0.85
integer.cppFile · 0.85
operator-Function · 0.85

Calls 3

CopyWordsFunction · 0.85
IncrementFunction · 0.85
CleanGrowMethod · 0.80

Tested by

no test coverage detected