Loading src/crypto/rsa.cpp +9 −8 Changes for src/crypto/rsa.cpp: 9 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -539,7 +539,9 @@ namespace netplus { void rsa::add(const bigInt& a, const bigInt& b, bigInt& res) { uint64_t carry = 0; size_t max_len = std::max(a.used, b.used); const size_t au = a.used; const size_t bu = b.used; size_t max_len = std::max(au, bu); res.reserve(max_len + 1); res.used = 0; Loading @@ -547,8 +549,6 @@ namespace netplus { const uint32_t* ap = a.data.get(); const uint32_t* bp = b.data.get(); uint32_t* rp = res.data.get(); const size_t au = a.used; const size_t bu = b.used; for (size_t i = 0; i < max_len || carry; ++i) { uint64_t sum = carry Loading Loading @@ -627,12 +627,12 @@ namespace netplus { void rsa::subtract(const bigInt& a, const bigInt& b, bigInt& res) { int64_t borrow = 0; res.reserve(a.used); const uint32_t* __restrict__ ap = a.data.get(); const uint32_t* __restrict__ bp = b.data.get(); uint32_t* __restrict__ rp = res.data.get(); const size_t au = a.used; const size_t bu = b.used; res.reserve(au); const uint32_t* ap = a.data.get(); const uint32_t* bp = b.data.get(); uint32_t* rp = res.data.get(); for (size_t i = 0; i < au; ++i) { int64_t sub = (int64_t)ap[i] - (i < bu ? bp[i] : 0) - borrow; if (sub < 0) { Loading Loading @@ -1158,7 +1158,8 @@ namespace netplus { } rsa::bigInt rsa::bytesToBigIntBE(const std::vector<uint8_t>& bytes) { netplus::rsa::bigInt out(64); // 64 limbs = 2048 bits; adjust if needed size_t words = (bytes.size() + 3) / 4; netplus::rsa::bigInt out(std::max<size_t>(words + 1, 1)); out.used = 1; out.data[0] = 0; Loading Loading
src/crypto/rsa.cpp +9 −8 Changes for src/crypto/rsa.cpp: 9 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -539,7 +539,9 @@ namespace netplus { void rsa::add(const bigInt& a, const bigInt& b, bigInt& res) { uint64_t carry = 0; size_t max_len = std::max(a.used, b.used); const size_t au = a.used; const size_t bu = b.used; size_t max_len = std::max(au, bu); res.reserve(max_len + 1); res.used = 0; Loading @@ -547,8 +549,6 @@ namespace netplus { const uint32_t* ap = a.data.get(); const uint32_t* bp = b.data.get(); uint32_t* rp = res.data.get(); const size_t au = a.used; const size_t bu = b.used; for (size_t i = 0; i < max_len || carry; ++i) { uint64_t sum = carry Loading Loading @@ -627,12 +627,12 @@ namespace netplus { void rsa::subtract(const bigInt& a, const bigInt& b, bigInt& res) { int64_t borrow = 0; res.reserve(a.used); const uint32_t* __restrict__ ap = a.data.get(); const uint32_t* __restrict__ bp = b.data.get(); uint32_t* __restrict__ rp = res.data.get(); const size_t au = a.used; const size_t bu = b.used; res.reserve(au); const uint32_t* ap = a.data.get(); const uint32_t* bp = b.data.get(); uint32_t* rp = res.data.get(); for (size_t i = 0; i < au; ++i) { int64_t sub = (int64_t)ap[i] - (i < bu ? bp[i] : 0) - borrow; if (sub < 0) { Loading Loading @@ -1158,7 +1158,8 @@ namespace netplus { } rsa::bigInt rsa::bytesToBigIntBE(const std::vector<uint8_t>& bytes) { netplus::rsa::bigInt out(64); // 64 limbs = 2048 bits; adjust if needed size_t words = (bytes.size() + 3) / 4; netplus::rsa::bigInt out(std::max<size_t>(words + 1, 1)); out.used = 1; out.data[0] = 0; Loading