lib_hash_drbg/src/sha256.c
/*
 * Transform the sha256 hash state (H) using the 64 bytes in the data array
 *  FIPS180-4, Sec. 6.2.2 (pg. 22)
 *
 * Parameters:
 * SHA256_CTX* context - structure holding the sha256 context
 */
Transform the sha256 hash state (H) using the 64 bytes in the data array
FIPS180-4, Sec.

SHA256_CTX* context - structure holding the sha256 context
Transform the sha256 hash state ( H ) using the 64 bytes in the data array FIPS180 - 4 Sec . SHA256_CTX * context - structure holding the sha256 context
void
sha256_transform(SHA256_CTX* context)
{
    uint32_t a, b, c, d, e, f, g, h;
    uint32_t i;
    uint32_t T1, T2, W[64];
    for (i = 0; i < 16; i += 1) {
        W[i] = (context->data[4*i]     << 24) | (context->data[4*i + 1] << 16) |
               (context->data[4*i + 2] <<  8) | (context->data[4*i + 3]);
    }
    for (i = 16; i < 64; i += 1) {
        W[i] = SIG1(W[i - 2]) + W[i - 7] + SIG0(W[i - 15]) + W[i - 16];
    }
    a = context->H[0];
    b = context->H[1];
    c = context->H[2];
    d = context->H[3];
    e = context->H[4];
    f = context->H[5];
    g = context->H[6];
    h = context->H[7];
    for (i = 0; i < 64; i += 1) {
        T1 = h + EP1(e) + CH(e,f,g) + k[i] + W[i];
        T2 = EP0(a) + MAJ(a,b,c);
        h = g;
        g = f;
        f = e;
        e = d + T1;
        d = c;
        c = b;
        b = a;
        a = T1 + T2;
    }
    context->H[0] += a;
    context->H[1] += b;
    context->H[2] += c;
    context->H[3] += d;
    context->H[4] += e;
    context->H[5] += f;
    context->H[6] += g;
    context->H[7] += h;
}
void sha256_transform ( SHA256_CTX * context ) { uint32_t a , b , c , d , e , f , g , h ; uint32_t i ; uint32_t T1 , T2 , W [ 64 ] ; for ( i = 0 ; i < 16 ; i += 1 ) { W [ i ] = ( context -> data [ 4 * i ] << 24 ) | ( context -> data [ 4 * i + 1 ] << 16 ) | ( context -> data [ 4 * i + 2 ] << 8 ) | ( context -> data [ 4 * i + 3 ] ) ; } for ( i = 16 ; i < 64 ; i += 1 ) { W [ i ] = SIG1 ( W [ i - 2 ] ) + W [ i - 7 ] + SIG0 ( W [ i - 15 ] ) + W [ i - 16 ] ; } a = context -> H [ 0 ] ; b = context -> H [ 1 ] ; c = context -> H [ 2 ] ; d = context -> H [ 3 ] ; e = context -> H [ 4 ] ; f = context -> H [ 5 ] ; g = context -> H [ 6 ] ; h = context -> H [ 7 ] ; for ( i = 0 ; i < 64 ; i += 1 ) { T1 = h + EP1 ( e ) + CH ( e , f , g ) + k [ i ] + W [ i ] ; T2 = EP0 ( a ) + MAJ ( a , b , c ) ; h = g ; g = f ; f = e ; e = d + T1 ; d = c ; c = b ; b = a ; a = T1 + T2 ; } context -> H [ 0 ] += a ; context -> H [ 1 ] += b ; context -> H [ 2 ] += c ; context -> H [ 3 ] += d ; context -> H [ 4 ] += e ; context -> H [ 5 ] += f ; context -> H [ 6 ] += g ; context -> H [ 7 ] += h ; }
Transform the sha256 hash state (H) using the 64 bytes in the data array
  FIPS180-4, Sec.
Transform the sha256 hash state ( H ) using the 64 bytes in the data array FIPS180 - 4 Sec .
/*
     * Prepare the message schedule
     *  First reading in the data
     */ /*
     * Then mixing the existing data
     */ /*
     * Initialize the eight working variables
     */ /*
     * Loop 64 times, mixing the working variables
     */ /*
     * Finally, add the working variables back to the context
     */