XilinxProcessorIPLib/drivers/hdcp22_common/src/sha2.c
static void Sha256Transform(Sha256Type *Ctx, u8 *Data)
{
  volatile u32 i;
  u32 a,b,c,d,e,f,g,h,j,t1,t2,m[64];

   for (i=0,j=0; i < 16; ++i, j += 4)
      m[i] = (Data[j] << 24) | (Data[j+1] << 16) | (Data[j+2] << 8) | (Data[j+3]);
   for ( ; i < 64; ++i)
      m[i] = SIG1(m[i-2]) + m[i-7] + SIG0(m[i-15]) + m[i-16];

   a = Ctx->state[0];
   b = Ctx->state[1];
   c = Ctx->state[2];
   d = Ctx->state[3];
   e = Ctx->state[4];
   f = Ctx->state[5];
   g = Ctx->state[6];
   h = Ctx->state[7];

   for (i = 0; i < 64; ++i) {
      t1 = h + EP1(e) + CH(e,f,g) + k[i] + m[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;
   }

   Ctx->state[0] += a;
   Ctx->state[1] += b;
   Ctx->state[2] += c;
   Ctx->state[3] += d;
   Ctx->state[4] += e;
   Ctx->state[5] += f;
   Ctx->state[6] += g;
   Ctx->state[7] += h;
}
/*****************************************************************************/
/**
* This function executes a SHA256 transformation.
*
* @param  Ctx is the context data for SHA256.
* @param  Data is the data to transform.
*
* @return None.
*
* @note   None.
*
******************************************************************************/
This function executes a SHA256 transformation.
This function executes a SHA256 transformation .
static void Sha256Transform(Sha256Type *Ctx, u8 *Data)
{
  volatile u32 i;
  u32 a,b,c,d,e,f,g,h,j,t1,t2,m[64];
   for (i=0,j=0; i < 16; ++i, j += 4)
      m[i] = (Data[j] << 24) | (Data[j+1] << 16) | (Data[j+2] << 8) | (Data[j+3]);
   for ( ; i < 64; ++i)
      m[i] = SIG1(m[i-2]) + m[i-7] + SIG0(m[i-15]) + m[i-16];
   a = Ctx->state[0];
   b = Ctx->state[1];
   c = Ctx->state[2];
   d = Ctx->state[3];
   e = Ctx->state[4];
   f = Ctx->state[5];
   g = Ctx->state[6];
   h = Ctx->state[7];
   for (i = 0; i < 64; ++i) {
      t1 = h + EP1(e) + CH(e,f,g) + k[i] + m[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;
   }
   Ctx->state[0] += a;
   Ctx->state[1] += b;
   Ctx->state[2] += c;
   Ctx->state[3] += d;
   Ctx->state[4] += e;
   Ctx->state[5] += f;
   Ctx->state[6] += g;
   Ctx->state[7] += h;
}
static void Sha256Transform ( Sha256Type * Ctx , u8 * Data ) { volatile u32 i ; u32 a , b , c , d , e , f , g , h , j , t1 , t2 , m [ 64 ] ; for ( i = 0 , j = 0 ; i < 16 ; ++ i , j += 4 ) m [ i ] = ( Data [ j ] << 24 ) | ( Data [ j + 1 ] << 16 ) | ( Data [ j + 2 ] << 8 ) | ( Data [ j + 3 ] ) ; for ( ; i < 64 ; ++ i ) m [ i ] = SIG1 ( m [ i - 2 ] ) + m [ i - 7 ] + SIG0 ( m [ i - 15 ] ) + m [ i - 16 ] ; a = Ctx -> state [ 0 ] ; b = Ctx -> state [ 1 ] ; c = Ctx -> state [ 2 ] ; d = Ctx -> state [ 3 ] ; e = Ctx -> state [ 4 ] ; f = Ctx -> state [ 5 ] ; g = Ctx -> state [ 6 ] ; h = Ctx -> state [ 7 ] ; for ( i = 0 ; i < 64 ; ++ i ) { t1 = h + EP1 ( e ) + CH ( e , f , g ) + k [ i ] + m [ 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 ; } Ctx -> state [ 0 ] += a ; Ctx -> state [ 1 ] += b ; Ctx -> state [ 2 ] += c ; Ctx -> state [ 3 ] += d ; Ctx -> state [ 4 ] += e ; Ctx -> state [ 5 ] += f ; Ctx -> state [ 6 ] += g ; Ctx -> state [ 7 ] += h ; }
This function executes a SHA256 transformation.
This function executes a SHA256 transformation .