Commit d40c7a5f authored by jan.koester's avatar jan.koester
Browse files

fixed

parent d8e2ba79
Loading
Loading
Loading
Loading
+56 −0
Original line number Diff line number Diff line
@@ -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

@@ -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;

@@ -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);
+6 −1
Original line number Diff line number Diff line
@@ -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;
@@ -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());
+3 −0
Original line number Diff line number Diff line
@@ -346,4 +346,7 @@ void tcp::getAddress(std::string& addr) {
    }
}

void tcp::flush_out() {
}

} // namespace netplus
+3 −0
Original line number Diff line number Diff line
@@ -284,4 +284,7 @@ void udp::getAddress(std::string& addr) {
    }
}

void udp::flush_out() {
}

} // namespace netplus