Loading src/crypto/rsa.cpp +56 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,16 @@ namespace netplus { } } // Move constructor for bigInt netplus::rsa::bigInt::bigInt(bigInt&& other) noexcept : data(std::move(other.data)), used(other.used), capacity(other.capacity) { other.used = 0; other.capacity = 0; } netplus::rsa::bigInt& netplus::rsa::bigInt::operator=(const bigInt& other) { if (this == &other) return *this; // Self-assignment check Loading @@ -71,6 +81,20 @@ namespace netplus { return *this; } // Move assignment for bigInt netplus::rsa::bigInt& netplus::rsa::bigInt::operator=(bigInt&& other) noexcept { if (this == &other) return *this; data = std::move(other.data); used = other.used; capacity = other.capacity; other.used = 0; other.capacity = 0; return *this; } void rsa::bigInt::shiftLeft(size_t n) { if (n == 0 || isZero()) return; Loading Loading @@ -204,6 +228,38 @@ namespace netplus { rsa::rsa(){ } // Copy constructor rsa::rsa(const rsa& src) : n(src.n), e(src.e), d(src.d) { } // Move constructor rsa::rsa(rsa&& src) noexcept : n(std::move(src.n)), e(std::move(src.e)), d(std::move(src.d)) { } // Copy assignment rsa& rsa::operator=(const rsa& src) { if (this != &src) { n = src.n; e = src.e; d = src.d; } return *this; } // Move assignment rsa& rsa::operator=(rsa&& src) noexcept { if (this != &src) { n = std::move(src.n); e = std::move(src.e); d = std::move(src.d); } return *this; } // R = 2^(32*nwords), so R2 = R*R mod N rsa::bigInt rsa::calculateR2Mod(const bigInt& mod) { bigInt r(mod.used * 4 + 2); Loading src/crypto/rsa.h +6 −1 Original line number Diff line number Diff line Loading @@ -54,8 +54,10 @@ namespace netplus { bigInt(const bigInt& other); bigInt(bigInt&& other) noexcept; netplus::rsa::bigInt& operator=(const bigInt& other); netplus::rsa::bigInt& operator=(bigInt&& other) noexcept; // Helper to check bit state for modPow bool isBitSet(size_t bit) const; Loading @@ -81,6 +83,9 @@ namespace netplus { rsa(); rsa(const rsa& src); rsa(rsa&& src) noexcept; rsa& operator=(const rsa& src); rsa& operator=(rsa&& src) noexcept; explicit operator bool() const { return !(n.isZero() || d.isZero()); Loading src/posix/tcp.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -346,4 +346,7 @@ void tcp::getAddress(std::string& addr) { } } void tcp::flush_out() { } } // namespace netplus src/posix/udp.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -284,4 +284,7 @@ void udp::getAddress(std::string& addr) { } } void udp::flush_out() { } } // namespace netplus Loading
src/crypto/rsa.cpp +56 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,16 @@ namespace netplus { } } // Move constructor for bigInt netplus::rsa::bigInt::bigInt(bigInt&& other) noexcept : data(std::move(other.data)), used(other.used), capacity(other.capacity) { other.used = 0; other.capacity = 0; } netplus::rsa::bigInt& netplus::rsa::bigInt::operator=(const bigInt& other) { if (this == &other) return *this; // Self-assignment check Loading @@ -71,6 +81,20 @@ namespace netplus { return *this; } // Move assignment for bigInt netplus::rsa::bigInt& netplus::rsa::bigInt::operator=(bigInt&& other) noexcept { if (this == &other) return *this; data = std::move(other.data); used = other.used; capacity = other.capacity; other.used = 0; other.capacity = 0; return *this; } void rsa::bigInt::shiftLeft(size_t n) { if (n == 0 || isZero()) return; Loading Loading @@ -204,6 +228,38 @@ namespace netplus { rsa::rsa(){ } // Copy constructor rsa::rsa(const rsa& src) : n(src.n), e(src.e), d(src.d) { } // Move constructor rsa::rsa(rsa&& src) noexcept : n(std::move(src.n)), e(std::move(src.e)), d(std::move(src.d)) { } // Copy assignment rsa& rsa::operator=(const rsa& src) { if (this != &src) { n = src.n; e = src.e; d = src.d; } return *this; } // Move assignment rsa& rsa::operator=(rsa&& src) noexcept { if (this != &src) { n = std::move(src.n); e = std::move(src.e); d = std::move(src.d); } return *this; } // R = 2^(32*nwords), so R2 = R*R mod N rsa::bigInt rsa::calculateR2Mod(const bigInt& mod) { bigInt r(mod.used * 4 + 2); Loading
src/crypto/rsa.h +6 −1 Original line number Diff line number Diff line Loading @@ -54,8 +54,10 @@ namespace netplus { bigInt(const bigInt& other); bigInt(bigInt&& other) noexcept; netplus::rsa::bigInt& operator=(const bigInt& other); netplus::rsa::bigInt& operator=(bigInt&& other) noexcept; // Helper to check bit state for modPow bool isBitSet(size_t bit) const; Loading @@ -81,6 +83,9 @@ namespace netplus { rsa(); rsa(const rsa& src); rsa(rsa&& src) noexcept; rsa& operator=(const rsa& src); rsa& operator=(rsa&& src) noexcept; explicit operator bool() const { return !(n.isZero() || d.isZero()); Loading
src/posix/tcp.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -346,4 +346,7 @@ void tcp::getAddress(std::string& addr) { } } void tcp::flush_out() { } } // namespace netplus
src/posix/udp.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -284,4 +284,7 @@ void udp::getAddress(std::string& addr) { } } void udp::flush_out() { } } // namespace netplus