FreeRTOS-Plus/ThirdParty/WolfSSL-FIPS-Ready/wolfcrypt/src/ge_448.c
/* Create to a sliding window for the scalar multiplicaton.
 *
 * r  [in]  Array of indeces.
 * a  [in]  Scalar to break up.
 */
Create to a sliding window for the scalar multiplicaton.
r  [in]  Array of indeces.
a  [in]  Scalar to break up.
Create to a sliding window for the scalar multiplicaton . r [ in ] Array of indeces . a [ in ] Scalar to break up .
static void slide(int8_t *r, const uint8_t *a)
{
    int i;
    int b;
    int k;
    for (i = 0; i < 448; ++i) {
        r[i] = (a[i >> 3] >> (i & 7)) & 1;
    }
    for (i = 0; i < 448; ++i) {
        if (r[i] == 0) {
            continue;
        }
        for (b = 1; b <= 7 && i + b < 448; ++b) {
            if (r[i + b] == 0) {
                continue;
            }
            if (r[i] + (r[i + b] << b) <= 31) {
                r[i] += r[i + b] << b; r[i + b] = 0;
            }
            else if (r[i] - (r[i + b] << b) >= -31) {
                r[i] -= r[i + b] << b;
                for (k = i + b; k < 448; ++k) {
                    if (!r[k]) {
                        r[k] = 1;
                        break;
                    }
                    r[k] = 0;
                }
            }
            else {
                break;
            }
        }
    }
}
static void slide ( int8_t * r , const uint8_t * a ) { int i ; int b ; int k ; for ( i = 0 ; i < 448 ; ++ i ) { r [ i ] = ( a [ i >> 3 ] >> ( i & 7 ) ) & 1 ; } for ( i = 0 ; i < 448 ; ++ i ) { if ( r [ i ] == 0 ) { continue ; } for ( b = 1 ; b <= 7 && i + b < 448 ; ++ b ) { if ( r [ i + b ] == 0 ) { continue ; } if ( r [ i ] + ( r [ i + b ] << b ) <= 31 ) { r [ i ] += r [ i + b ] << b ; r [ i + b ] = 0 ; } else if ( r [ i ] - ( r [ i + b ] << b ) >= -31 ) { r [ i ] -= r [ i + b ] << b ; for ( k = i + b ; k < 448 ; ++ k ) { if ( ! r [ k ] ) { r [ k ] = 1 ; break ; } r [ k ] = 0 ; } } else { break ; } } } }
Create to a sliding window for the scalar multiplicaton.
Create to a sliding window for the scalar multiplicaton .