Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
mp_gf2m-priv.h File Reference
#include "mpi-priv.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define MP_DIGIT_BITS   32
#define gf2m_SQR1(w)
#define gf2m_SQR0(w)

Functions

void s_bmul_1x1 (mp_digit *rh, mp_digit *rl, const mp_digit a, const mp_digit b)
void s_bmul_2x2 (mp_digit *r, const mp_digit a1, const mp_digit a0, const mp_digit b1, const mp_digit b0)
void s_bmul_3x3 (mp_digit *r, const mp_digit a2, const mp_digit a1, const mp_digit a0, const mp_digit b2, const mp_digit b1, const mp_digit b0)
void s_bmul_4x4 (mp_digit *r, const mp_digit a3, const mp_digit a2, const mp_digit a1, const mp_digit a0, const mp_digit b3, const mp_digit b2, const mp_digit b1, const mp_digit b0)

Variables

const mp_digit mp_gf2m_sqr_tb [16]

Define Documentation

#define gf2m_SQR0 (   w)
Value:
mp_gf2m_sqr_tb[(w) >> 12 & 0xF] << 24 | mp_gf2m_sqr_tb[(w) >>  8 & 0xF] << 16 | \
    mp_gf2m_sqr_tb[(w) >>  4 & 0xF] <<  8 | mp_gf2m_sqr_tb[(w)       & 0xF]

Definition at line 58 of file mp_gf2m-priv.h.

#define gf2m_SQR1 (   w)
Value:
mp_gf2m_sqr_tb[(w) >> 28 & 0xF] << 24 | mp_gf2m_sqr_tb[(w) >> 24 & 0xF] << 16 | \
    mp_gf2m_sqr_tb[(w) >> 20 & 0xF] <<  8 | mp_gf2m_sqr_tb[(w) >> 16 & 0xF]

Definition at line 55 of file mp_gf2m-priv.h.

Definition at line 48 of file mp_gf2m-priv.h.


Function Documentation

void s_bmul_1x1 ( mp_digit rh,
mp_digit rl,
const mp_digit  a,
const mp_digit  b 
)

Definition at line 57 of file mp_gf2m.c.

{
    register mp_digit h, l, s;
    mp_digit tab[8], top2b = a >> 30; 
    register mp_digit a1, a2, a4;

    a1 = a & (0x3FFFFFFF); a2 = a1 << 1; a4 = a2 << 1;

    tab[0] =  0; tab[1] = a1;    tab[2] = a2;    tab[3] = a1^a2;
    tab[4] = a4; tab[5] = a1^a4; tab[6] = a2^a4; tab[7] = a1^a2^a4;

    s = tab[b       & 0x7]; l  = s;
    s = tab[b >>  3 & 0x7]; l ^= s <<  3; h  = s >> 29;
    s = tab[b >>  6 & 0x7]; l ^= s <<  6; h ^= s >> 26;
    s = tab[b >>  9 & 0x7]; l ^= s <<  9; h ^= s >> 23;
    s = tab[b >> 12 & 0x7]; l ^= s << 12; h ^= s >> 20;
    s = tab[b >> 15 & 0x7]; l ^= s << 15; h ^= s >> 17;
    s = tab[b >> 18 & 0x7]; l ^= s << 18; h ^= s >> 14;
    s = tab[b >> 21 & 0x7]; l ^= s << 21; h ^= s >> 11;
    s = tab[b >> 24 & 0x7]; l ^= s << 24; h ^= s >>  8;
    s = tab[b >> 27 & 0x7]; l ^= s << 27; h ^= s >>  5;
    s = tab[b >> 30      ]; l ^= s << 30; h ^= s >>  2;

    /* compensate for the top two bits of a */

    if (top2b & 01) { l ^= b << 30; h ^= b >> 2; } 
    if (top2b & 02) { l ^= b << 31; h ^= b >> 1; } 

    *rh = h; *rl = l;
} 

Definition at line 134 of file mp_gf2m.c.

{
    mp_digit m1, m0;
    /* r[3] = h1, r[2] = h0; r[1] = l1; r[0] = l0 */
    s_bmul_1x1(r+3, r+2, a1, b1);
    s_bmul_1x1(r+1, r, a0, b0);
    s_bmul_1x1(&m1, &m0, a0 ^ a1, b0 ^ b1);
    /* Correction on m1 ^= l1 ^ h1; m0 ^= l0 ^ h0; */
    r[2] ^= m1 ^ r[1] ^ r[3];  /* h0 ^= m1 ^ l1 ^ h1; */
    r[1]  = r[3] ^ r[2] ^ r[0] ^ m1 ^ m0;  /* l1 ^= l0 ^ h0 ^ m0; */
}

Here is the call graph for this function:

Definition at line 152 of file mp_gf2m.c.

{
       mp_digit zm[4];

       s_bmul_1x1(r+5, r+4, a2, b2);         /* fill top 2 words */
       s_bmul_2x2(zm, a1, a2^a0, b1, b2^b0); /* fill middle 4 words */
       s_bmul_2x2(r, a1, a0, b1, b0);        /* fill bottom 4 words */

       zm[3] ^= r[3];
       zm[2] ^= r[2]; 
       zm[1] ^= r[1] ^ r[5];
       zm[0] ^= r[0] ^ r[4];

       r[5]  ^= zm[3];
       r[4]  ^= zm[2];
       r[3]  ^= zm[1];
       r[2]  ^= zm[0];
}

Here is the call graph for this function:

Definition at line 176 of file mp_gf2m.c.

{
       mp_digit zm[4];

       s_bmul_2x2(r+4, a3, a2, b3, b2);            /* fill top 4 words */
       s_bmul_2x2(zm, a3^a1, a2^a0, b3^b1, b2^b0); /* fill middle 4 words */
       s_bmul_2x2(r, a1, a0, b1, b0);              /* fill bottom 4 words */

       zm[3] ^= r[3] ^ r[7]; 
       zm[2] ^= r[2] ^ r[6]; 
       zm[1] ^= r[1] ^ r[5]; 
       zm[0] ^= r[0] ^ r[4]; 

       r[5]  ^= zm[3];    
       r[4]  ^= zm[2];
       r[3]  ^= zm[1];    
       r[2]  ^= zm[0];
}

Here is the call graph for this function:


Variable Documentation

Definition at line 45 of file mp_gf2m.c.