Commit 374f20a5 authored by jan.koester's avatar jan.koester
Browse files

exx hardening

parent 404b7dd2
Loading
Loading
Loading
Loading
+8 −1
Changes for src/crypto/ecc_p256.cpp: 8 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ static const P256Point P256_G_STD = []{
    g.mont = false;
    g.x = u256::fromBigEndian(P256_GX_BE);
    g.y = u256::fromBigEndian(P256_GY_BE);
    g.z = u256::zero(); // unused in affine representation, zeroed for hygiene
    return g;
}();

@@ -51,6 +52,7 @@ P256Point P256Point::toAffine() const

    if (inf) {
        P.inf = true;
        P.x = u256::zero(); P.y = u256::zero(); P.z = u256::zero();
        return P;
    }

@@ -58,6 +60,7 @@ P256Point P256Point::toAffine() const
    u256 z_std = z.fromMontgomery();
    if (z_std.isZero()) {
        P.inf = true;
        P.x = u256::zero(); P.y = u256::zero(); P.z = u256::zero();
        return P;
    }

@@ -143,7 +146,10 @@ P256Point P256Point::addJacobian(const P256Point& other) const {

    if (u1 == u2) {
        if (s1 == s2) return doubled();
        P256Point r; r.inf = true; r.mont = true; return r;
        P256Point r;
        r.inf = true; r.mont = true;
        r.x = u256::zero(); r.y = u256::zero(); r.z = u256::zero();
        return r;
    }

    u256 h = u2.montgomerySub(u1);
@@ -261,6 +267,7 @@ P256Point P256Point::scalarMulBase(const uint8_t priv[32])
        P256Point R;
        R.inf = true;
        R.mont = false;
        R.x = u256::zero(); R.y = u256::zero(); R.z = u256::zero();
        return R;
    }
    return basePoint().scalarMul(priv);