How to handle modular arithmetic with regard to two's-complement negative numbers? The reason for asking, is that this occurs in real life with CRT calculation of RSA decryption/signing. In CRT RSA, there's the need to calculate subtraction, and it's known negative numbers could occur, especially with multi-prime cases.
While RSA would eventually phase out when moderately-sized quantum computers are available, before QCs can reach that scale, scaling RSA parameters (especially towards using more primes) may be more feasible than rushing to adopt post-quantum schemes in the short term, therefore, it's still a bit relevant.
While it's easy to to do modular arithmetic in variable-time, it seems very difficult do it in constant-time and with limited space for holding working variables.
Q1: Is there a way to implement efficient constant-time modular arithmetic for signed two's-comlement integers in constant time?
Additional Q2 for refuting the use of such implementation: Is there alternative methods for computing CRT RSA decryption/signing that uses no more (or even less) number of working variables? (these &quot;working variables&quot; are big integers).
This answer answers Q1, as there may be merit other than just for calculating CRT RSA (e.g. the extended Euclidean algorithm).

Let's build it step-by-step.
First let's assume you've implemented the % operator for unsigned modular arithmetic in constant time, when you encounter a negative number x, we have the following:
x === -(-x)
Introducing the modulus p, and we have:
x (mod p) === p - (-x) (mod p)
Hence, the algorithm for negative numbers (in pseudo-code, not constant-time yet):
imod(x):
    x = -x
    x = x % p
    if x &gt; 0: x = p - x
    return x

Now, we want to generalize it to apply to also positive numbers, here's the full code in C (constant-time this time):
uint32_t imod(uint32_t x, uint32_t p)
{
    uint32_t neg = -(x &gt;&gt; 31);
    uint32_t z;

    // conditionally negate x.
    x ^= neg;
    x += neg &amp; 1;
    x = x % p;

    // test for 0.
    z = x;

    // Per suggestion by @fgrieu
    // The following code fragment involves:
    // 2 shifts, 4 bit-ops, and 2 additive ops.
    z |= z &gt;&gt; 16;
    z &amp;= 0xffffU;
    z = -(1 ^ ((z ^ (z - 1)) &gt;&gt; 31));

    // In comparison, the following requires:
    // 5 shifts, 6 bit-ops, and 1 additive ops.
    /* z |= z &gt;&gt; 16;
     * z |= z &gt;&gt; 8;
     * z |= z &gt;&gt; 4;
     * z |= z &gt;&gt; 2;
     * z |= z &gt;&gt; 1;
     * z = -(z &amp; 1);
     */

    neg &amp;= z;

    // conditionally compute p - x.
    x = ((~neg &amp; x) | (neg &amp; p)) - (neg &amp; x);
    return x;
}