• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ HOST_c2l函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中HOST_c2l函数的典型用法代码示例。如果您正苦于以下问题:C++ HOST_c2l函数的具体用法?C++ HOST_c2l怎么用?C++ HOST_c2l使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了HOST_c2l函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: sha256_comp

/*****************************************
 *       sha256 compression function     *
 *                                       *
 *   H   points to chaining input        *
 *   in  points to the message input     *
 *                                       *
 *****************************************/
void sha256_comp (hashblock res, const hashblock hash, const void *in)
	{
	uint32_t a,b,c,d,e,f,g,h,s0,s1,T1,T2;
	uint32_t    H[8];
	uint32_t	X[16],l;
	int i;
    // CHANGE type casting added due to c++
	const unsigned char *data=static_cast<const unsigned char*>(in);

	for (i = 0; i < SHA256_DIGEST_LENGTH/4; i++) {
	   HOST_c2l(hash, H[i]);
	}

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

	for (i=0;i<16;i++)
		{
		HOST_c2l(data,l); T1 = X[i] = l;
		T1 += h + Sigma1(e) + Ch(e,f,g) + K256[i];
		T2 = Sigma0(a) + Maj(a,b,c);
		h = g;
		g = f;
		f = e;
		e = d + T1;
		d = c;	c = b;	b = a;	a = T1 + T2;
		}

	for (;i<64;i++)
		{
		s0 = X[(i+1)&0x0f];	s0 = sigma0(s0);
		s1 = X[(i+14)&0x0f];	s1 = sigma1(s1);

		T1 = X[i&0xf] += s0 + s1 + X[(i+9)&0xf];
		T1 += h + Sigma1(e) + Ch(e,f,g) + K256[i];
		T2 = Sigma0(a) + Maj(a,b,c);
		h = g;	g = f;	f = e;	e = d + T1;
		d = c;	c = b;	b = a;	a = T1 + T2;
		}

	H[0] += a;	H[1] += b;	H[2] += c;	H[3] += d;
	H[4] += e;	H[5] += f;	H[6] += g;	H[7] += h;

	for (i = 0; i < SHA256_DIGEST_LENGTH/4; i++) {
	   HOST_l2c(H[i], res);
	}
}
开发者ID:Vieteg,项目名称:EACirc,代码行数:54,代码来源:omdsha256k128n96tau64v1_sha256.cpp


示例2: sha256_block

static void sha256_block (SHA256_CTX *ctx, const void *in, size_t num, int host)
	{
	unsigned MD32_REG_T a,b,c,d,e,f,g,h,s0,s1,T1,T2;
	SHA_LONG	X[16];
	int i;
	const unsigned char *data=in;

			while (num--) {

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

	if (host)
		{
		const SHA_LONG *W=(const SHA_LONG *)data;

		for (i=0;i<16;i++)
			{
			T1 = X[i] = W[i];
			T1 += h + Sigma1(e) + Ch(e,f,g) + K256[i];
			T2 = Sigma0(a) + Maj(a,b,c);
			h = g;	g = f;	f = e;	e = d + T1;
			d = c;	c = b;	b = a;	a = T1 + T2;
			}

		data += SHA256_CBLOCK;
		}
	else
		{
		SHA_LONG l;

		for (i=0;i<16;i++)
			{
			HOST_c2l(data,l); T1 = X[i] = l;
			T1 += h + Sigma1(e) + Ch(e,f,g) + K256[i];
			T2 = Sigma0(a) + Maj(a,b,c);
			h = g;	g = f;	f = e;	e = d + T1;
			d = c;	c = b;	b = a;	a = T1 + T2;
			}
		}

	for (;i<64;i++)
		{
		s0 = X[(i+1)&0x0f];	s0 = sigma0(s0);
		s1 = X[(i+14)&0x0f];	s1 = sigma1(s1);

		T1 = X[i&0xf] += s0 + s1 + X[(i+9)&0xf];
		T1 += h + Sigma1(e) + Ch(e,f,g) + K256[i];
		T2 = Sigma0(a) + Maj(a,b,c);
		h = g;	g = f;	f = e;	e = d + T1;
		d = c;	c = b;	b = a;	a = T1 + T2;
		}

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

			}
}
开发者ID:MatiasNAmendola,项目名称:AuroraUX-SunOS,代码行数:58,代码来源:sha256.c


示例3: while

void SHA1Provider::hash_block_data_order (const unsigned char* data, int num)
{
    CRYPTO_U32 A, B, C, D, E, T, l;
    int i;
    CRYPTO_U32 X[16];

    A = m_sha_ctx.h[0];
    B = m_sha_ctx.h[1];
    C = m_sha_ctx.h[2];
    D = m_sha_ctx.h[3];
    E = m_sha_ctx.h[4];

    while (true)
    {
        for (i = 0; i < 16; i++)
        {
            HOST_c2l(data,l);
            X[i]=l;
            BODY_00_15(X[i]);
        }
        for (i = 0; i < 4; i++)
        {
            BODY_16_19(X[i], X[i+2], X[i+8], X[(i+13)&15]);
        }
        for (; i < 24; i++)
        {
            BODY_20_39(X[i&15], X[(i+2)&15], X[(i+8)&15], X[(i+13)&15]);
        }
        for (i = 0; i < 20; i++)
        {
            BODY_40_59(X[(i+8)&15], X[(i+10)&15], X[i&15], X[(i+5)&15]);
        }
        for (i = 4; i < 24; i++)
        {
            BODY_60_79(X[(i+8)&15], X[(i+10)&15], X[i&15], X[(i+5)&15]);
        }

        m_sha_ctx.h[0] = (m_sha_ctx.h[0] + A) & 0xffffffffL;
        m_sha_ctx.h[1] = (m_sha_ctx.h[1] + B) & 0xffffffffL;
        m_sha_ctx.h[2] = (m_sha_ctx.h[2] + C) & 0xffffffffL;
        m_sha_ctx.h[3] = (m_sha_ctx.h[3] + D) & 0xffffffffL;
        m_sha_ctx.h[4] = (m_sha_ctx.h[4] + E) & 0xffffffffL;

        if (--num == 0) break;

        A = m_sha_ctx.h[0];
        B = m_sha_ctx.h[1];
        C = m_sha_ctx.h[2];
        D = m_sha_ctx.h[3];
        E = m_sha_ctx.h[4];

    }
}
开发者ID:BrunoDelb,项目名称:openkeystore,代码行数:53,代码来源:SHA1Provider.cpp


示例4: sha256_block_data_order

void sha256_block_data_order (SHA256_CTX *ctx, const void *in)
	{
	unsigned MD32_REG_T a,b,c,d,e,f,g,h,s0,s1,T1,T2,t;
	SHA_LONG	X[16],l,Ki;
	int i;
	const unsigned char *data=in;

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

	for (i=0;i<16;i++)
		{
		HOST_c2l(data,l); X[i] = l;
		Ki=K256[i];
		T1 = l + h + Sigma1(e) + Ch(e,f,g) + Ki;
		T2 = Sigma0(a) + Maj(a,b,c);
		h = g;	g = f;	f = e;	e = d + T1;
		d = c;	c = b;	b = a;	a = T1 + T2;
		}

	for (;i<64;i++)
		{
		s0 = X[(i+1)&0x0f];	s0 = sigma0(s0);
		s1 = X[(i+14)&0x0f];	s1 = sigma1(s1);

		T1 = X[i&0xf];
		t = X[(i+9)&0xf];
		T1 += s0 + s1 + t;
                X[i&0xf] = T1;
		Ki=K256[i];
		T1 += h + Sigma1(e) + Ch(e,f,g) + Ki;
		T2 = Sigma0(a) + Maj(a,b,c);
		h = g;	g = f;	f = e;	e = d + T1;
		d = c;	c = b;	b = a;	a = T1 + T2;
		}

	t=ctx->h[0]; ctx->h[0]=t+a;
	t=ctx->h[1]; ctx->h[1]=t+b;
	t=ctx->h[2]; ctx->h[2]=t+c;
	t=ctx->h[3]; ctx->h[3]=t+d;
	t=ctx->h[4]; ctx->h[4]=t+e;
	t=ctx->h[5]; ctx->h[5]=t+f;
	t=ctx->h[6]; ctx->h[6]=t+g;
	t=ctx->h[7]; ctx->h[7]=t+h;
       return;
}
开发者ID:GaloisInc,项目名称:hacrypto,代码行数:46,代码来源:sha.c


示例5: md4_block_data_order

void md4_block_data_order (MD4_CTX *c, const void *data_, size_t num)
{
    const unsigned char *data=data_;
    register unsigned MD32_REG_T A,B,C,D,l;
#ifndef MD32_XARRAY
    /* See comment in crypto/sha/sha_locl.h for details. */
    unsigned MD32_REG_T	XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
             XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
# define X(i)	XX##i
#else
    MD4_LONG XX[MD4_LBLOCK];
# define X(i)	XX[i]
#endif

    A=c->A;
    B=c->B;
    C=c->C;
    D=c->D;

    for (; num--;)
    {
        HOST_c2l(data,l);
        X( 0)=l;
        HOST_c2l(data,l);
        X( 1)=l;
        /* Round 0 */
        R0(A,B,C,D,X( 0), 3,0);
        HOST_c2l(data,l);
        X( 2)=l;
        R0(D,A,B,C,X( 1), 7,0);
        HOST_c2l(data,l);
        X( 3)=l;
        R0(C,D,A,B,X( 2),11,0);
        HOST_c2l(data,l);
        X( 4)=l;
        R0(B,C,D,A,X( 3),19,0);
        HOST_c2l(data,l);
        X( 5)=l;
        R0(A,B,C,D,X( 4), 3,0);
        HOST_c2l(data,l);
        X( 6)=l;
        R0(D,A,B,C,X( 5), 7,0);
        HOST_c2l(data,l);
        X( 7)=l;
        R0(C,D,A,B,X( 6),11,0);
        HOST_c2l(data,l);
        X( 8)=l;
        R0(B,C,D,A,X( 7),19,0);
        HOST_c2l(data,l);
        X( 9)=l;
        R0(A,B,C,D,X( 8), 3,0);
        HOST_c2l(data,l);
        X(10)=l;
        R0(D,A,B,C,X( 9), 7,0);
        HOST_c2l(data,l);
        X(11)=l;
        R0(C,D,A,B,X(10),11,0);
        HOST_c2l(data,l);
        X(12)=l;
        R0(B,C,D,A,X(11),19,0);
        HOST_c2l(data,l);
        X(13)=l;
        R0(A,B,C,D,X(12), 3,0);
        HOST_c2l(data,l);
        X(14)=l;
        R0(D,A,B,C,X(13), 7,0);
        HOST_c2l(data,l);
        X(15)=l;
        R0(C,D,A,B,X(14),11,0);
        R0(B,C,D,A,X(15),19,0);
        /* Round 1 */
        R1(A,B,C,D,X( 0), 3,0x5A827999L);
        R1(D,A,B,C,X( 4), 5,0x5A827999L);
        R1(C,D,A,B,X( 8), 9,0x5A827999L);
        R1(B,C,D,A,X(12),13,0x5A827999L);
        R1(A,B,C,D,X( 1), 3,0x5A827999L);
        R1(D,A,B,C,X( 5), 5,0x5A827999L);
        R1(C,D,A,B,X( 9), 9,0x5A827999L);
        R1(B,C,D,A,X(13),13,0x5A827999L);
        R1(A,B,C,D,X( 2), 3,0x5A827999L);
        R1(D,A,B,C,X( 6), 5,0x5A827999L);
        R1(C,D,A,B,X(10), 9,0x5A827999L);
        R1(B,C,D,A,X(14),13,0x5A827999L);
        R1(A,B,C,D,X( 3), 3,0x5A827999L);
        R1(D,A,B,C,X( 7), 5,0x5A827999L);
        R1(C,D,A,B,X(11), 9,0x5A827999L);
        R1(B,C,D,A,X(15),13,0x5A827999L);
        /* Round 2 */
        R2(A,B,C,D,X( 0), 3,0x6ED9EBA1L);
        R2(D,A,B,C,X( 8), 9,0x6ED9EBA1L);
        R2(C,D,A,B,X( 4),11,0x6ED9EBA1L);
        R2(B,C,D,A,X(12),15,0x6ED9EBA1L);
        R2(A,B,C,D,X( 2), 3,0x6ED9EBA1L);
        R2(D,A,B,C,X(10), 9,0x6ED9EBA1L);
        R2(C,D,A,B,X( 6),11,0x6ED9EBA1L);
        R2(B,C,D,A,X(14),15,0x6ED9EBA1L);
        R2(A,B,C,D,X( 1), 3,0x6ED9EBA1L);
        R2(D,A,B,C,X( 9), 9,0x6ED9EBA1L);
        R2(C,D,A,B,X( 5),11,0x6ED9EBA1L);
        R2(B,C,D,A,X(13),15,0x6ED9EBA1L);
//.........这里部分代码省略.........
开发者ID:siredblood,项目名称:tree-bumpkin-project,代码行数:101,代码来源:md4_dgst.c


示例6: sha256_block_data_order

static void sha256_block_data_order(SHA256_CTX *ctx, const void *in,
                                    size_t num)
{
    unsigned MD32_REG_T a, b, c, d, e, f, g, h, s0, s1, T1;
    SHA_LONG X[16];
    int i;
    const unsigned char *data = in;
    const union {
        long one;
        char little;
    } is_endian = {
        1
    };

    while (num--) {

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

        if (!is_endian.little && sizeof(SHA_LONG) == 4
            && ((size_t)in % 4) == 0) {
            const SHA_LONG *W = (const SHA_LONG *)data;

            T1 = X[0] = W[0];
            ROUND_00_15(0, a, b, c, d, e, f, g, h);
            T1 = X[1] = W[1];
            ROUND_00_15(1, h, a, b, c, d, e, f, g);
            T1 = X[2] = W[2];
            ROUND_00_15(2, g, h, a, b, c, d, e, f);
            T1 = X[3] = W[3];
            ROUND_00_15(3, f, g, h, a, b, c, d, e);
            T1 = X[4] = W[4];
            ROUND_00_15(4, e, f, g, h, a, b, c, d);
            T1 = X[5] = W[5];
            ROUND_00_15(5, d, e, f, g, h, a, b, c);
            T1 = X[6] = W[6];
            ROUND_00_15(6, c, d, e, f, g, h, a, b);
            T1 = X[7] = W[7];
            ROUND_00_15(7, b, c, d, e, f, g, h, a);
            T1 = X[8] = W[8];
            ROUND_00_15(8, a, b, c, d, e, f, g, h);
            T1 = X[9] = W[9];
            ROUND_00_15(9, h, a, b, c, d, e, f, g);
            T1 = X[10] = W[10];
            ROUND_00_15(10, g, h, a, b, c, d, e, f);
            T1 = X[11] = W[11];
            ROUND_00_15(11, f, g, h, a, b, c, d, e);
            T1 = X[12] = W[12];
            ROUND_00_15(12, e, f, g, h, a, b, c, d);
            T1 = X[13] = W[13];
            ROUND_00_15(13, d, e, f, g, h, a, b, c);
            T1 = X[14] = W[14];
            ROUND_00_15(14, c, d, e, f, g, h, a, b);
            T1 = X[15] = W[15];
            ROUND_00_15(15, b, c, d, e, f, g, h, a);

            data += SHA256_CBLOCK;
        } else {
            SHA_LONG l;

            HOST_c2l(data, l);
            T1 = X[0] = l;
            ROUND_00_15(0, a, b, c, d, e, f, g, h);
            HOST_c2l(data, l);
            T1 = X[1] = l;
            ROUND_00_15(1, h, a, b, c, d, e, f, g);
            HOST_c2l(data, l);
            T1 = X[2] = l;
            ROUND_00_15(2, g, h, a, b, c, d, e, f);
            HOST_c2l(data, l);
            T1 = X[3] = l;
            ROUND_00_15(3, f, g, h, a, b, c, d, e);
            HOST_c2l(data, l);
            T1 = X[4] = l;
            ROUND_00_15(4, e, f, g, h, a, b, c, d);
            HOST_c2l(data, l);
            T1 = X[5] = l;
            ROUND_00_15(5, d, e, f, g, h, a, b, c);
            HOST_c2l(data, l);
            T1 = X[6] = l;
            ROUND_00_15(6, c, d, e, f, g, h, a, b);
            HOST_c2l(data, l);
            T1 = X[7] = l;
            ROUND_00_15(7, b, c, d, e, f, g, h, a);
            HOST_c2l(data, l);
            T1 = X[8] = l;
            ROUND_00_15(8, a, b, c, d, e, f, g, h);
            HOST_c2l(data, l);
            T1 = X[9] = l;
            ROUND_00_15(9, h, a, b, c, d, e, f, g);
            HOST_c2l(data, l);
            T1 = X[10] = l;
            ROUND_00_15(10, g, h, a, b, c, d, e, f);
            HOST_c2l(data, l);
//.........这里部分代码省略.........
开发者ID:johnjohnsp1,项目名称:opensgx,代码行数:101,代码来源:sha256.c


示例7: md4_block_data_order

void md4_block_data_order(uint32_t *state, const uint8_t *data, size_t num) {
  uint32_t A, B, C, D, l;
  uint32_t X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15;

  A = state[0];
  B = state[1];
  C = state[2];
  D = state[3];

  for (; num--;) {
    HOST_c2l(data, l);
    X0 = l;
    HOST_c2l(data, l);
    X1 = l;
    /* Round 0 */
    R0(A, B, C, D, X0, 3, 0);
    HOST_c2l(data, l);
    X2 = l;
    R0(D, A, B, C, X1, 7, 0);
    HOST_c2l(data, l);
    X3 = l;
    R0(C, D, A, B, X2, 11, 0);
    HOST_c2l(data, l);
    X4 = l;
    R0(B, C, D, A, X3, 19, 0);
    HOST_c2l(data, l);
    X5 = l;
    R0(A, B, C, D, X4, 3, 0);
    HOST_c2l(data, l);
    X6 = l;
    R0(D, A, B, C, X5, 7, 0);
    HOST_c2l(data, l);
    X7 = l;
    R0(C, D, A, B, X6, 11, 0);
    HOST_c2l(data, l);
    X8 = l;
    R0(B, C, D, A, X7, 19, 0);
    HOST_c2l(data, l);
    X9 = l;
    R0(A, B, C, D, X8, 3, 0);
    HOST_c2l(data, l);
    X10 = l;
    R0(D, A, B, C, X9, 7, 0);
    HOST_c2l(data, l);
    X11 = l;
    R0(C, D, A, B, X10, 11, 0);
    HOST_c2l(data, l);
    X12 = l;
    R0(B, C, D, A, X11, 19, 0);
    HOST_c2l(data, l);
    X13 = l;
    R0(A, B, C, D, X12, 3, 0);
    HOST_c2l(data, l);
    X14 = l;
    R0(D, A, B, C, X13, 7, 0);
    HOST_c2l(data, l);
    X15 = l;
    R0(C, D, A, B, X14, 11, 0);
    R0(B, C, D, A, X15, 19, 0);
    /* Round 1 */
    R1(A, B, C, D, X0, 3, 0x5A827999L);
    R1(D, A, B, C, X4, 5, 0x5A827999L);
    R1(C, D, A, B, X8, 9, 0x5A827999L);
    R1(B, C, D, A, X12, 13, 0x5A827999L);
    R1(A, B, C, D, X1, 3, 0x5A827999L);
    R1(D, A, B, C, X5, 5, 0x5A827999L);
    R1(C, D, A, B, X9, 9, 0x5A827999L);
    R1(B, C, D, A, X13, 13, 0x5A827999L);
    R1(A, B, C, D, X2, 3, 0x5A827999L);
    R1(D, A, B, C, X6, 5, 0x5A827999L);
    R1(C, D, A, B, X10, 9, 0x5A827999L);
    R1(B, C, D, A, X14, 13, 0x5A827999L);
    R1(A, B, C, D, X3, 3, 0x5A827999L);
    R1(D, A, B, C, X7, 5, 0x5A827999L);
    R1(C, D, A, B, X11, 9, 0x5A827999L);
    R1(B, C, D, A, X15, 13, 0x5A827999L);
    /* Round 2 */
    R2(A, B, C, D, X0, 3, 0x6ED9EBA1L);
    R2(D, A, B, C, X8, 9, 0x6ED9EBA1L);
    R2(C, D, A, B, X4, 11, 0x6ED9EBA1L);
    R2(B, C, D, A, X12, 15, 0x6ED9EBA1L);
    R2(A, B, C, D, X2, 3, 0x6ED9EBA1L);
    R2(D, A, B, C, X10, 9, 0x6ED9EBA1L);
    R2(C, D, A, B, X6, 11, 0x6ED9EBA1L);
    R2(B, C, D, A, X14, 15, 0x6ED9EBA1L);
    R2(A, B, C, D, X1, 3, 0x6ED9EBA1L);
    R2(D, A, B, C, X9, 9, 0x6ED9EBA1L);
    R2(C, D, A, B, X5, 11, 0x6ED9EBA1L);
    R2(B, C, D, A, X13, 15, 0x6ED9EBA1L);
    R2(A, B, C, D, X3, 3, 0x6ED9EBA1L);
    R2(D, A, B, C, X11, 9, 0x6ED9EBA1L);
    R2(C, D, A, B, X7, 11, 0x6ED9EBA1L);
    R2(B, C, D, A, X15, 15, 0x6ED9EBA1L);

    A = state[0] += A;
    B = state[1] += B;
    C = state[2] += C;
    D = state[3] += D;
  }
}
开发者ID:ThomasWo,项目名称:proto-quic,代码行数:100,代码来源:md4.c


示例8: md4_block_data_order

void md4_block_data_order(MD4_CTX *c, const void *data_, size_t num) {
  const uint8_t *data = data_;
  uint32_t A, B, C, D, l;
  uint32_t X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15;

  A = c->A;
  B = c->B;
  C = c->C;
  D = c->D;

  for (; num--;) {
    HOST_c2l(data, l);
    X0 = l;
    HOST_c2l(data, l);
    X1 = l;
    /* Round 0 */
    R0(A, B, C, D, X0, 3, 0);
    HOST_c2l(data, l);
    X2 = l;
    R0(D, A, B, C, X1, 7, 0);
    HOST_c2l(data, l);
    X3 = l;
    R0(C, D, A, B, X2, 11, 0);
    HOST_c2l(data, l);
    X4 = l;
    R0(B, C, D, A, X3, 19, 0);
    HOST_c2l(data, l);
    X5 = l;
    R0(A, B, C, D, X4, 3, 0);
    HOST_c2l(data, l);
    X6 = l;
    R0(D, A, B, C, X5, 7, 0);
    HOST_c2l(data, l);
    X7 = l;
    R0(C, D, A, B, X6, 11, 0);
    HOST_c2l(data, l);
    X8 = l;
    R0(B, C, D, A, X7, 19, 0);
    HOST_c2l(data, l);
    X9 = l;
    R0(A, B, C, D, X8, 3, 0);
    HOST_c2l(data, l);
    X10 = l;
    R0(D, A, B, C, X9, 7, 0);
    HOST_c2l(data, l);
    X11 = l;
    R0(C, D, A, B, X10, 11, 0);
    HOST_c2l(data, l);
    X12 = l;
    R0(B, C, D, A, X11, 19, 0);
    HOST_c2l(data, l);
    X13 = l;
    R0(A, B, C, D, X12, 3, 0);
    HOST_c2l(data, l);
    X14 = l;
    R0(D, A, B, C, X13, 7, 0);
    HOST_c2l(data, l);
    X15 = l;
    R0(C, D, A, B, X14, 11, 0);
    R0(B, C, D, A, X15, 19, 0);
    /* Round 1 */
    R1(A, B, C, D, X0, 3, 0x5A827999L);
    R1(D, A, B, C, X4, 5, 0x5A827999L);
    R1(C, D, A, B, X8, 9, 0x5A827999L);
    R1(B, C, D, A, X12, 13, 0x5A827999L);
    R1(A, B, C, D, X1, 3, 0x5A827999L);
    R1(D, A, B, C, X5, 5, 0x5A827999L);
    R1(C, D, A, B, X9, 9, 0x5A827999L);
    R1(B, C, D, A, X13, 13, 0x5A827999L);
    R1(A, B, C, D, X2, 3, 0x5A827999L);
    R1(D, A, B, C, X6, 5, 0x5A827999L);
    R1(C, D, A, B, X10, 9, 0x5A827999L);
    R1(B, C, D, A, X14, 13, 0x5A827999L);
    R1(A, B, C, D, X3, 3, 0x5A827999L);
    R1(D, A, B, C, X7, 5, 0x5A827999L);
    R1(C, D, A, B, X11, 9, 0x5A827999L);
    R1(B, C, D, A, X15, 13, 0x5A827999L);
    /* Round 2 */
    R2(A, B, C, D, X0, 3, 0x6ED9EBA1L);
    R2(D, A, B, C, X8, 9, 0x6ED9EBA1L);
    R2(C, D, A, B, X4, 11, 0x6ED9EBA1L);
    R2(B, C, D, A, X12, 15, 0x6ED9EBA1L);
    R2(A, B, C, D, X2, 3, 0x6ED9EBA1L);
    R2(D, A, B, C, X10, 9, 0x6ED9EBA1L);
    R2(C, D, A, B, X6, 11, 0x6ED9EBA1L);
    R2(B, C, D, A, X14, 15, 0x6ED9EBA1L);
    R2(A, B, C, D, X1, 3, 0x6ED9EBA1L);
    R2(D, A, B, C, X9, 9, 0x6ED9EBA1L);
    R2(C, D, A, B, X5, 11, 0x6ED9EBA1L);
    R2(B, C, D, A, X13, 15, 0x6ED9EBA1L);
    R2(A, B, C, D, X3, 3, 0x6ED9EBA1L);
    R2(D, A, B, C, X11, 9, 0x6ED9EBA1L);
    R2(C, D, A, B, X7, 11, 0x6ED9EBA1L);
    R2(B, C, D, A, X15, 15, 0x6ED9EBA1L);

    A = c->A += A;
    B = c->B += B;
    C = c->C += C;
    D = c->D += D;
  }
//.........这里部分代码省略.........
开发者ID:a397871706,项目名称:plug,代码行数:101,代码来源:md4.c


示例9: sha256_block_data_order

static void sha256_block_data_order(SHA256_CTX *ctx, const void *in,
                                    size_t num)
{
    unsigned MD32_REG_T a, b, c, d, e, f, g, h, s0, s1, T1;
    SHA_LONG X[16];
    int i;
    const unsigned char *data = in;
    const union {
        long one;
        char little;
    } is_endian = {
        1
    };

    while (num--) {

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

        if (!is_endian.little && sizeof(SHA_LONG) == 4
            && ((size_t)in % 4) == 0) {
            const SHA_LONG *W = (const SHA_LONG *)data;

            T1 = X[0] = W[0];
            ROUND_00_15(0, a, b, c, d, e, f, g, h);
            T1 = X[1] = W[1];
            ROUND_00_15(1, h, a, b, c, d, e, f, g);
            T1 = X[2] = W[2];
            ROUND_00_15(2, g, h, a, b, c, d, e, f);
            T1 = X[3] = W[3];
            ROUND_00_15(3, f, g, h, a, b, c, d, e);
            T1 = X[4] = W[4];
            ROUND_00_15(4, e, f, g, h, a, b, c, d);
            T1 = X[5] = W[5];
            ROUND_00_15(5, d, e, f, g, h, a, b, c);
            T1 = X[6] = W[6];
            ROUND_00_15(6, c, d, e, f, g, h, a, b);
            T1 = X[7] = W[7];
            ROUND_00_15(7, b, c, d, e, f, g, h, a);
            T1 = X[8] = W[8];
            ROUND_00_15(8, a, b, c, d, e, f, g, h);
            T1 = X[9] = W[9];
            ROUND_00_15(9, h, a, b, c, d, e, f, g);
            T1 = X[10] = W[10];
            ROUND_00_15(10, g, h, a, b, c, d, e, f);
            T1 = X[11] = W[11];
            ROUND_00_15(11, f, g, h, a, b, c, d, e);
            T1 = X[12] = W[12];
            ROUND_00_15(12, e, f, g, h, a, b, c, d);
            T1 = X[13] = W[13];
            ROUND_00_15(13, d, e, f, g, h, a, b, c);
            T1 = X[14] = W[14];
            ROUND_00_15(14, c, d, e, f, g, h, a, b);
            T1 = X[15] = W[15];
            ROUND_00_15(15, b, c, d, e, f, g, h, a);

            data += SHA256_CBLOCK;
        } else {
            SHA_LONG l;

            E(DBF_ALWAYS, "LITTLE ENDIAN BRANCH!!!: is_endian.little = %ld, in=%08lx, (in %% 4) = %ld, sizeof(SHA_LONG) = %ld", is_endian.little, in, ((size_t)in % 4), sizeof(SHA_LONG));
            E(DBF_ALWAYS, "a=%08lx b=%08lx c=%08lx d=%08lx e=%08lx f=%08lx g=%08lx h=%08lx", a, b, c, d, e, f, g, h);
            #if defined(DEBUG)
            for(i=0; i < 16; i++)
            {
              const unsigned char *d = data + (i*4);
              D(DBF_ALWAYS, "%ld: %02lx %02lx %02lx %02lx", i, d[0], d[1], d[2], d[3]);
            }
            #endif

            (void)HOST_c2l(data, l);
            T1 = X[0] = l;
            ROUND_00_15(0, a, b, c, d, e, f, g, h);
            (void)HOST_c2l(data, l);
            T1 = X[1] = l;
            ROUND_00_15(1, h, a, b, c, d, e, f, g);
            (void)HOST_c2l(data, l);
            T1 = X[2] = l;
            ROUND_00_15(2, g, h, a, b, c, d, e, f);
            (void)HOST_c2l(data, l);
            T1 = X[3] = l;
            ROUND_00_15(3, f, g, h, a, b, c, d, e);
            (void)HOST_c2l(data, l);
            T1 = X[4] = l;
            ROUND_00_15(4, e, f, g, h, a, b, c, d);
            (void)HOST_c2l(data, l);
            T1 = X[5] = l;
            ROUND_00_15(5, d, e, f, g, h, a, b, c);
            (void)HOST_c2l(data, l);
            T1 = X[6] = l;
            ROUND_00_15(6, c, d, e, f, g, h, a, b);
            (void)HOST_c2l(data, l);
            T1 = X[7] = l;
            ROUND_00_15(7, b, c, d, e, f, g, h, a);
//.........这里部分代码省略.........
开发者ID:jens-maus,项目名称:amissl,代码行数:101,代码来源:sha256.c


示例10: sha256_block_data_order

static void sha256_block_data_order(uint32_t *state, const uint8_t *data,
                                    size_t num) {
  uint32_t a, b, c, d, e, f, g, h, s0, s1, T1;
  uint32_t X[16];
  int i;

  while (num--) {
    a = state[0];
    b = state[1];
    c = state[2];
    d = state[3];
    e = state[4];
    f = state[5];
    g = state[6];
    h = state[7];

    uint32_t l;

    HOST_c2l(data, l);
    T1 = X[0] = l;
    ROUND_00_15(0, a, b, c, d, e, f, g, h);
    HOST_c2l(data, l);
    T1 = X[1] = l;
    ROUND_00_15(1, h, a, b, c, d, e, f, g);
    HOST_c2l(data, l);
    T1 = X[2] = l;
    ROUND_00_15(2, g, h, a, b, c, d, e, f);
    HOST_c2l(data, l);
    T1 = X[3] = l;
    ROUND_00_15(3, f, g, h, a, b, c, d, e);
    HOST_c2l(data, l);
    T1 = X[4] = l;
    ROUND_00_15(4, e, f, g, h, a, b, c, d);
    HOST_c2l(data, l);
    T1 = X[5] = l;
    ROUND_00_15(5, d, e, f, g, h, a, b, c);
    HOST_c2l(data, l);
    T1 = X[6] = l;
    ROUND_00_15(6, c, d, e, f, g, h, a, b);
    HOST_c2l(data, l);
    T1 = X[7] = l;
    ROUND_00_15(7, b, c, d, e, f, g, h, a);
    HOST_c2l(data, l);
    T1 = X[8] = l;
    ROUND_00_15(8, a, b, c, d, e, f, g, h);
    HOST_c2l(data, l);
    T1 = X[9] = l;
    ROUND_00_15(9, h, a, b, c, d, e, f, g);
    HOST_c2l(data, l);
    T1 = X[10] = l;
    ROUND_00_15(10, g, h, a, b, c, d, e, f);
    HOST_c2l(data, l);
    T1 = X[11] = l;
    ROUND_00_15(11, f, g, h, a, b, c, d, e);
    HOST_c2l(data, l);
    T1 = X[12] = l;
    ROUND_00_15(12, e, f, g, h, a, b, c, d);
    HOST_c2l(data, l);
    T1 = X[13] = l;
    ROUND_00_15(13, d, e, f, g, h, a, b, c);
    HOST_c2l(data, l);
    T1 = X[14] = l;
    ROUND_00_15(14, c, d, e, f, g, h, a, b);
    HOST_c2l(data, l);
    T1 = X[15] = l;
    ROUND_00_15(15, b, c, d, e, f, g, h, a);

    for (i = 16; i < 64; i += 8) {
      ROUND_16_63(i + 0, a, b, c, d, e, f, g, h, X);
      ROUND_16_63(i + 1, h, a, b, c, d, e, f, g, X);
      ROUND_16_63(i + 2, g, h, a, b, c, d, e, f, X);
      ROUND_16_63(i + 3, f, g, h, a, b, c, d, e, X);
      ROUND_16_63(i + 4, e, f, g, h, a, b, c, d, X);
      ROUND_16_63(i + 5, d, e, f, g, h, a, b, c, X);
      ROUND_16_63(i + 6, c, d, e, f, g, h, a, b, X);
      ROUND_16_63(i + 7, b, c, d, e, f, g, h, a, X);
    }

    state[0] += a;
    state[1] += b;
    state[2] += c;
    state[3] += d;
    state[4] += e;
    state[5] += f;
    state[6] += g;
    state[7] += h;
  }
}
开发者ID:0x64616E69656C,项目名称:boringssl,代码行数:88,代码来源:sha256.c


示例11: sha1_compress

static void sha1_compress(ccdigest_state_t s, size_t num, const void *buf)
{
	const unsigned char *data=buf;
    register uint32_t A,B,C,D,E,T,l;
#ifndef MD32_XARRAY
	uint32_t    XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
				XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
#else
	uint32_t    XX[16];
#endif
    uint32_t *state=ccdigest_u32(s);

	A=state[0];
	B=state[1];
	C=state[2];
	D=state[3];
	E=state[4];

	for (;;)
		{

	HOST_c2l(data,l); X( 0)=l;		HOST_c2l(data,l); X( 1)=l;
	BODY_00_15( 0,A,B,C,D,E,T,X( 0));	HOST_c2l(data,l); X( 2)=l;
	BODY_00_15( 1,T,A,B,C,D,E,X( 1));	HOST_c2l(data,l); X( 3)=l;
	BODY_00_15( 2,E,T,A,B,C,D,X( 2));	HOST_c2l(data,l); X( 4)=l;
	BODY_00_15( 3,D,E,T,A,B,C,X( 3));	HOST_c2l(data,l); X( 5)=l;
	BODY_00_15( 4,C,D,E,T,A,B,X( 4));	HOST_c2l(data,l); X( 6)=l;
	BODY_00_15( 5,B,C,D,E,T,A,X( 5));	HOST_c2l(data,l); X( 7)=l;
	BODY_00_15( 6,A,B,C,D,E,T,X( 6));	HOST_c2l(data,l); X( 8)=l;
	BODY_00_15( 7,T,A,B,C,D,E,X( 7));	HOST_c2l(data,l); X( 9)=l;
	BODY_00_15( 8,E,T,A,B,C,D,X( 8));	HOST_c2l(data,l); X(10)=l;
	BODY_00_15( 9,D,E,T,A,B,C,X( 9));	HOST_c2l(data,l); X(11)=l;
	BODY_00_15(10,C,D,E,T,A,B,X(10));	HOST_c2l(data,l); X(12)=l;
	BODY_00_15(11,B,C,D,E,T,A,X(11));	HOST_c2l(data,l); X(13)=l;
	BODY_00_15(12,A,B,C,D,E,T,X(12));	HOST_c2l(data,l); X(14)=l;
	BODY_00_15(13,T,A,B,C,D,E,X(13));	HOST_c2l(data,l); X(15)=l;
	BODY_00_15(14,E,T,A,B,C,D,X(14));
	BODY_00_15(15,D,E,T,A,B,C,X(15));

	BODY_16_19(16,C,D,E,T,A,B,X( 0),X( 0),X( 2),X( 8),X(13));
	BODY_16_19(17,B,C,D,E,T,A,X( 1),X( 1),X( 3),X( 9),X(14));
	BODY_16_19(18,A,B,C,D,E,T,X( 2),X( 2),X( 4),X(10),X(15));
	BODY_16_19(19,T,A,B,C,D,E,X( 3),X( 3),X( 5),X(11),X( 0));

	BODY_20_31(20,E,T,A,B,C,D,X( 4),X( 4),X( 6),X(12),X( 1));
	BODY_20_31(21,D,E,T,A,B,C,X( 5),X( 5),X( 7),X(13),X( 2));
	BODY_20_31(22,C,D,E,T,A,B,X( 6),X( 6),X( 8),X(14),X( 3));
	BODY_20_31(23,B,C,D,E,T,A,X( 7),X( 7),X( 9),X(15),X( 4));
	BODY_20_31(24,A,B,C,D,E,T,X( 8),X( 8),X(10),X( 0),X( 5));
	BODY_20_31(25,T,A,B,C,D,E,X( 9),X( 9),X(11),X( 1),X( 6));
	BODY_20_31(26,E,T,A,B,C,D,X(10),X(10),X(12),X( 2),X( 7));
	BODY_20_31(27,D,E,T,A,B,C,X(11),X(11),X(13),X( 3),X( 8));
	BODY_20_31(28,C,D,E,T,A,B,X(12),X(12),X(14),X( 4),X( 9));
	BODY_20_31(29,B,C,D,E,T,A,X(13),X(13),X(15),X( 5),X(10));
	BODY_20_31(30,A,B,C,D,E,T,X(14),X(14),X( 0),X( 6),X(11));
	BODY_20_31(31,T,A,B,C,D,E,X(15),X(15),X( 1),X( 7),X(12));

	BODY_32_39(32,E,T,A,B,C,D,X( 0),X( 2),X( 8),X(13));
	BODY_32_39(33,D,E,T,A,B,C,X( 1),X( 3),X( 9),X(14));
	BODY_32_39(34,C,D,E,T,A,B,X( 2),X( 4),X(10),X(15));
	BODY_32_39(35,B,C,D,E,T,A,X( 3),X( 5),X(11),X( 0));
	BODY_32_39(36,A,B,C,D,E,T,X( 4),X( 6),X(12),X( 1));
	BODY_32_39(37,T,A,B,C,D,E,X( 5),X( 7),X(13),X( 2));
	BODY_32_39(38,E,T,A,B,C,D,X( 6),X( 8),X(14),X( 3));
	BODY_32_39(39,D,E,T,A,B,C,X( 7),X( 9),X(15),X( 4));

	BODY_40_59(40,C,D,E,T,A,B,X( 8),X(10),X( 0),X( 5));
	BODY_40_59(41,B,C,D,E,T,A,X( 9),X(11),X( 1),X( 6));
	BODY_40_59(42,A,B,C,D,E,T,X(10),X(12),X( 2),X( 7));
	BODY_40_59(43,T,A,B,C,D,E,X(11),X(13),X( 3),X( 8));
	BODY_40_59(44,E,T,A,B,C,D,X(12),X(14),X( 4),X( 9));
	BODY_40_59(45,D,E,T,A,B,C,X(13),X(15),X( 5),X(10));
	BODY_40_59(46,C,D,E,T,A,B,X(14),X( 0),X( 6),X(11));
	BODY_40_59(47,B,C,D,E,T,A,X(15),X( 1),X( 7),X(12));
	BODY_40_59(48,A,B,C,D,E,T,X( 0),X( 2),X( 8),X(13));
	BODY_40_59(49,T,A,B,C,D,E,X( 1),X( 3),X( 9),X(14));
	BODY_40_59(50,E,T,A,B,C,D,X( 2),X( 4),X(10),X(15));
	BODY_40_59(51,D,E,T,A,B,C,X( 3),X( 5),X(11),X( 0));
	BODY_40_59(52,C,D,E,T,A,B,X( 4),X( 6),X(12),X( 1));
	BODY_40_59(53,B,C,D,E,T,A,X( 5),X( 7),X(13),X( 2));
	BODY_40_59(54,A,B,C,D,E,T,X( 6),X( 8),X(14),X( 3));
	BODY_40_59(55,T,A,B,C,D,E,X( 7),X( 9),X(15),X( 4));
	BODY_40_59(56,E,T,A,B,C,D,X( 8),X(10),X( 0),X( 5));
	BODY_40_59(57,D,E,T,A,B,C,X( 9),X(11),X( 1),X( 6));
	BODY_40_59(58,C,D,E,T,A,B,X(10),X(12),X( 2),X( 7));
	BODY_40_59(59,B,C,D,E,T,A,X(11),X(13),X( 3),X( 8));

	BODY_60_79(60,A,B,C,D,E,T,X(12),X(14),X( 4),X( 9));
	BODY_60_79(61,T,A,B,C,D,E,X(13),X(15),X( 5),X(10));
	BODY_60_79(62,E,T,A,B,C,D,X(14),X( 0),X( 6),X(11));
	BODY_60_79(63,D,E,T,A,B,C,X(15),X( 1),X( 7),X(12));
	BODY_60_79(64,C,D,E,T,A,B,X( 0),X( 2),X( 8),X(13));
	BODY_60_79(65,B,C,D,E,T,A,X( 1),X( 3),X( 9),X(14));
	BODY_60_79(66,A,B,C,D,E,T,X( 2),X( 4),X(10),X(15));
	BODY_60_79(67,T,A,B,C,D,E,X( 3),X( 5),X(11),X( 0));
	BODY_60_79(68,E,T,A,B,C,D,X( 4),X( 6),X(12),X( 1));
	BODY_60_79(69,D,E,T,A,B,C,X( 5),X( 7),X(13),X( 2));
	BODY_60_79(70,C,D,E,T,A,B,X( 6),X( 8),X(14),X( 3));
	BODY_60_79(71,B,C,D,E,T,A,X( 7),X( 9),X(15),X( 4));
	BODY_60_79(72,A,B,C,D,E,T,X( 8),X(10),X( 0),X( 5));
//.........这里部分代码省略.........
开发者ID:aglab2,项目名称:darwin-xnu,代码行数:101,代码来源:ccsha1_eay.c


示例12: rtsmb_md4_block_data_order

void rtsmb_md4_block_data_order (RTSMB_MD4_CTX *c, const void *data_, int num)
	{
	const unsigned char *data;
	register unsigned long A,B,C,D,l;
	/*
	 * In case you wonder why A-D are declared as long and not
	 * as RTSMB_MD4_LONG. Doing so results in slight performance
	 * boost on LP64 architectures. The catch is we don't
	 * really care if 32 MSBs of a 64-bit register get polluted
	 * with eventual overflows as we *save* only 32 LSBs in
	 * *either* case. Now declaring 'em long excuses the compiler
	 * from keeping 32 MSBs zeroed resulting in 13% performance
	 * improvement under SPARC Solaris7/64 and 5% under AlphaLinux.
	 * Well, to be honest it should say that this *prevents* 
	 * performance degradation.
	 *
	 *				<[email protected]>
	 */
#ifndef MD32_XARRAY
	/* See comment in crypto/sha/sha_locl.h for details. */
	unsigned long	XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
			XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
# define X(i)	XX##i
#else
	RTSMB_MD4_LONG XX[RTSMB_MD4_LBLOCK];
# define X(i)	XX[i]
#endif
	data =data_;
	A=c->A;
	B=c->B;
	C=c->C;
	D=c->D;

	for (;num--;)
		{
	HOST_c2l(data,l); X( 0)=l;		HOST_c2l(data,l); X( 1)=l;
	/* Round 0 */
	R0(A,B,C,D,X( 0), 3,0);	HOST_c2l(data,l); X( 2)=l;
	R0(D,A,B,C,X( 1), 7,0);	HOST_c2l(data,l); X( 3)=l;
	R0(C,D,A,B,X( 2),11,0);	HOST_c2l(data,l); X( 4)=l;
	R0(B,C,D,A,X( 3),19,0);	HOST_c2l(data,l); X( 5)=l;
	R0(A,B,C,D,X( 4), 3,0);	HOST_c2l(data,l); X( 6)=l;
	R0(D,A,B,C,X( 5), 7,0);	HOST_c2l(data,l); X( 7)=l;
	R0(C,D,A,B,X( 6),11,0);	HOST_c2l(data,l); X( 8)=l;
	R0(B,C,D,A,X( 7),19,0);	HOST_c2l(data,l); X( 9)=l;
	R0(A,B,C,D,X( 8), 3,0);	HOST_c2l(data,l); X(10)=l;
	R0(D,A,B,C,X( 9), 7,0);	HOST_c2l(data,l); X(11)=l;
	R0(C,D,A,B,X(10),11,0);	HOST_c2l(data,l); X(12)=l;
	R0(B,C,D,A,X(11),19,0);	HOST_c2l(data,l); X(13)=l;
	R0(A,B,C,D,X(12), 3,0);	HOST_c2l(data,l); X(14)=l;
	R0(D,A,B,C,X(13), 7,0);	HOST_c2l(data,l); X(15)=l;
	R0(C,D,A,B,X(14),11,0);
	R0(B,C,D,A,X(15),19,0);
	/* Round 1 */
	R1(A,B,C,D,X( 0), 3,0x5A827999L);
	R1(D,A,B,C,X( 4), 5,0x5A827999L);
	R1(C,D,A,B,X( 8), 9,0x5A827999L);
	R1(B,C,D,A,X(12),13,0x5A827999L);
	R1(A,B,C,D,X( 1), 3,0x5A827999L);
	R1(D,A,B,C,X( 5), 5,0x5A827999L);
	R1(C,D,A,B,X( 9), 9,0x5A827999L);
	R1(B,C,D,A,X(13),13,0x5A827999L);
	R1(A,B,C,D,X( 2), 3,0x5A827999L);
	R1(D,A,B,C,X( 6), 5,0x5A827999L);
	R1(C,D,A,B,X(10), 9,0x5A827999L);
	R1(B,C,D,A,X(14),13,0x5A827999L);
	R1(A,B,C,D,X( 3), 3,0x5A827999L);
	R1(D,A,B,C,X( 7), 5,0x5A827999L);
	R1(C,D,A,B,X(11), 9,0x5A827999L);
	R1(B,C,D,A,X(15),13,0x5A827999L);
	/* Round 2 */
	R2(A,B,C,D,X( 0), 3,0x6ED9EBA1L);
	R2(D,A,B,C,X( 8), 9,0x6ED9EBA1L);
	R2(C,D,A,B,X( 4),11,0x6ED9EBA1L);
	R2(B,C,D,A,X(12),15,0x6ED9EBA1L);
	R2(A,B,C,D,X( 2), 3,0x6ED9EBA1L);
	R2(D,A,B,C,X(10), 9,0x6ED9EBA1L);
	R2(C,D,A,B,X( 6),11,0x6ED9EBA1L);
	R2(B,C,D,A,X(14),15,0x6ED9EBA1L);
	R2(A,B,C,D,X( 1), 3,0x6ED9EBA1L);
	R2(D,A,B,C,X( 9), 9,0x6ED9EBA1L);
	R2(C,D,A,B,X( 5),11,0x6ED9EBA1L);
	R2(B,C,D,A,X(13),15,0x6ED9EBA1L);
	R2(A,B,C,D,X( 3), 3,0x6ED9EBA1L);
	R2(D,A,B,C,X(11), 9,0x6ED9EBA1L);
	R2(C,D,A,B,X( 7),11,0x6ED9EBA1L);
	R2(B,C,D,A,X(15),15,0x6ED9EBA1L);

	A = c->A += A;
	B = c->B += B;
	C = c->C += C;
	D = c->D += D;
		}
	}
开发者ID:layerfsd,项目名称:cifssmb,代码行数:94,代码来源:md4_dgst.c


示例13: HASH_BLOCK_DATA_ORDER

static void HASH_BLOCK_DATA_ORDER(SHA_CTX *c, const void *p, size_t num) {
  const uint8_t *data = p;
  register unsigned MD32_REG_T A, B, C, D, E, T, l;
  unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, XX8, XX9, XX10,
      XX11, XX12, XX13, XX14, XX15;

  A = c->h0;
  B = c->h1;
  C = c->h2;
  D = c->h3;
  E = c->h4;

  for (;;) {
    const union {
      long one;
      char little;
    } is_endian = {1};

    if (!is_endian.little && ((size_t)p % 4) == 0) {
      const uint32_t *W = (const uint32_t *)data;

      X(0) = W[0];
      X(1) = W[1];
      BODY_00_15(0, A, B, C, D, E, T, X(0));
      X(2) = W[2];
      BODY_00_15(1, T, A, B, C, D, E, X(1));
      X(3) = W[3];
      BODY_00_15(2, E, T, A, B, C, D, X(2));
      X(4) = W[4];
      BODY_00_15(3, D, E, T, A, B, C, X(3));
      X(5) = W[5];
      BODY_00_15(4, C, D, E, T, A, B, X(4));
      X(6) = W[6];
      BODY_00_15(5, B, C, D, E, T, A, X(5));
      X(7) = W[7];
      BODY_00_15(6, A, B, C, D, E, T, X(6));
      X(8) = W[8];
      BODY_00_15(7, T, A, B, C, D, E, X(7));
      X(9) = W[9];
      BODY_00_15(8, E, T, A, B, C, D, X(8));
      X(10) = W[10];
      BODY_00_15(9, D, E, T, A, B, C, X(9));
      X(11) = W[11];
      BODY_00_15(10, C, D, E, T, A, B, X(10));
      X(12) = W[12];
      BODY_00_15(11, B, C, D, E, T, A, X(11));
      X(13) = W[13];
      BODY_00_15(12, A, B, C, D, E, T, X(12));
      X(14) = W[14];
      BODY_00_15(13, T, A, B, C, D, E, X(13));
      X(15) = W[15];
      BODY_00_15(14, E, T, A, B, C, D, X(14));
      BODY_00_15(15, D, E, T, A, B, C, X(15));

      data += HASH_CBLOCK;
    } else {
      (void)HOST_c2l(data, l);
      X(0) = l;
      (void)HOST_c2l(data, l);
      X(1) = l;
      BODY_00_15(0, A, B, C, D, E, T, X(0));
      (void)HOST_c2l(data, l);
      X(2) = l;
      BODY_00_15(1, T, A, B, C, D, E, X(1));
      (void)HOST_c2l(data, l);
      X(3) = l;
      BODY_00_15(2, E, T, A, B, C, D, X(2));
      (void)HOST_c2l(data, l);
      X(4) = l;
      BODY_00_15(3, D, E, T, A, B, C, X(3));
      (void)HOST_c2l(data, l);
      X(5) = l;
      BODY_00_15(4, C, D, E, T, A, B, X(4));
      (void)HOST_c2l(data, l);
      X(6) = l;
      BODY_00_15(5, B, C, D, E, T, A, X(5));
      (void)HOST_c2l(data, l);
      X(7) = l;
      BODY_00_15(6, A, B, C, D, E, T, X(6));
      (void)HOST_c2l(data, l);
      X(8) = l;
      BODY_00_15(7, T, A, B, C, D, E, X(7));
      (void)HOST_c2l(data, l);
      X(9) = l;
      BODY_00_15(8, E, T, A, B, C, D, X(8));
      (void)HOST_c2l(data, l);
      X(10) = l;
      BODY_00_15(9, D, E, T, A, B, C, X(9));
      (void)HOST_c2l(data, l);
      X(11) = l;
      BODY_00_15(10, C, D, E, T, A, B, X(10));
      (void)HOST_c2l(data, l);
      X(12) = l;
      BODY_00_15(11, B, C, D, E, T, A, X(11));
      (void)HOST_c2l(data, l);
      X(13) = l;
      BODY_00_15(12, A, B, C, D, E, T, X(12));
      (void)HOST_c2l(data, l);
      X(14) = l;
      BODY_00_15(13, T, A, B, C, D, E, X(13));
//.........这里部分代码省略.........
开发者ID:RobinWuDev,项目名称:Qt,代码行数:101,代码来源:sha1.c


示例14: MD4_BlockDataOrder

//MD4 Block data order setting
void __fastcall MD4_BlockDataOrder(
	MD4_CTX *c, 
	const void *data_, 
	size_t num)
{
	const unsigned char *data = (const unsigned char *)data_;
	register uint32_t A = 0, B = 0, C = 0, D = 0, l = 0;
	uint32_t XX0 = 0, XX1 = 0, XX2 = 0, XX3 = 0, XX4 = 0, XX5 = 0, XX6 = 0, XX7 = 0, XX8 = 0, XX9 = 0, XX10 = 0, XX11 = 0, XX12 = 0, XX13 = 0, XX14 = 0, XX15 = 0;
#define X(i)   XX ## i

	A = c->A;
	B = c->B;
	C = c->C;
	D = c->D;

	for (;num--;)
	{
		(void)HOST_c2l(data, l); X(0) = l;
		(void)HOST_c2l(data, l); X(1) = l;

	//Round 0
		R0(A, B, C, D, X(0), 3, 0); (void)HOST_c2l(data, l); X(2) = l;
		R0(D, A, B, C, X(1), 7, 0); (void)HOST_c2l(data, l); X(3) = l;
		R0(C, D, A, B, X(2), 11, 0); (void)HOST_c2l(data, l); X(4) = l;
		R0(B, C, D, A, X(3), 19, 0); (void)HOST_c2l(data, l); X(5) = l;
		R0(A, B, C, D, X(4), 3, 0); (void)HOST_c2l(data, l); X(6) = l;
		R0(D, A, B, C, X(5), 7, 0); (void)HOST_c2l(data, l); X(7) = l;
		R0(C, D, A, B, X(6), 11, 0); (void)HOST_c2l(data, l); X(8) = l;
		R0(B, C, D, A, X(7), 19, 0); (void)HOST_c2l(data, l); X(9) = l;
		R0(A, B, C, D, X(8), 3, 0); (void)HOST_c2l(data, l); X(10) = l;
		R0(D, A, B, C, X(9), 7, 0); (void)HOST_c2l(data, l); X(11) = l;
		R0(C, D, A, B, X(10), 11, 0); (void)HOST_c2l(data, l); X(12) = l;
		R0(B, C, D, A, X(11), 19, 0); (void)HOST_c2l(data, l); X(13) = l;
		R0(A, B, C, D, X(12), 3, 0); (void)HOST_c2l(data, l); X(14) = l;
		R0(D, A, B, C, X(13), 7, 0); (void)HOST_c2l(data, l); X(15) = l;
		R0(C, D, A, B, X(14), 11, 0);
		R0(B, C, D, A, X(15), 19, 0);
	//Round 1
		R1(A, B, C, D, X(0), 3, 0x5A827999L);
		R1(D, A, B, C, X(4), 5, 0x5A827999L);
		R1(C, D, A, B, X(8), 9, 0x5A827999L);
		R1(B, C, D, A, X(12), 13, 0x5A827999L);
		R1(A, B, C, D, X(1), 3, 0x5A827999L);
		R1(D, A, B, C, X(5), 5, 0x5A827999L);
		R1(C, D, A, B, X(9), 9, 0x5A827999L);
		R1(B, C, D, A, X(13), 13, 0x5A827999L);
		R1(A, B, C, D, X(2), 3, 0x5A827999L);
		R1(D, A, B, C, X(6), 5, 0x5A827999L);
		R1(C, D, A, B, X(10), 9, 0x5A827999L);
		R1(B, C, D, A, X(14), 13, 0x5A827999L);
		R1(A, B, C, D, X(3), 3, 0x5A827999L);
		R1(D, A, B, C, X(7), 5, 0x5A827999L);
		R1(C, D, A, B, X(11), 9, 0x5A827999L);
		R1(B, C, D, A, X(15), 13, 0x5A827999L);
	//Round 2
		R2(A, B, C, D, X(0), 3, 0x6ED9EBA1L);
		R2(D, A, B, C, X(8), 9, 0x6ED9EBA1L);
		R2(C, D, A, B, X(4), 11, 0x6ED9EBA1L);
		R2(B, C, D, A, X(12), 15, 0x6ED9EBA1L);
		R2(A, B, C, D, X(2), 3, 0x6ED9EBA1L);
		R2(D, A, B, C, X(10), 9, 0x6ED9EBA1L);
		R2(C, D, A, B, X(6), 11, 0x6ED9EBA1L);
		R2(B, C, D, A, X(14), 15, 0x6ED9EBA1L);
		R2(A, B, C, D, X(1), 3, 0x6ED9EBA1L);
		R2(D, A, B, C, X(9), 9, 0x6ED9EBA1L);
		R2(C, D, A, B, X(5), 11, 0x6ED9EBA1L);
		R2(B, C, D, A, X(13), 15, 0x6ED9EBA1L);
		R2(A, B, C, D, X(3), 3, 0x6ED9EBA1L);
		R2(D, A, B, C, X(11), 9, 0x6ED9EBA1L);
		R2(C, D, A, B, X(7), 11, 0x6ED9EBA1L);
		R2(B, C, D, A, X(15), 15, 0x6ED9EBA1L);

		A = c->A += A;
		B = c->B += B;
		C = c->C += C;
		D = c->D += D;
	}

	return;
}
开发者ID:ChaoWing,项目名称:Pcap_DNSProxy,代码行数:81,代码来源:MD4.cpp


示例15: sha256_block

static void sha256_block (SHA256_CTX *ctx, const void *in, size_t num, int host)
	{
	uint32_t a,b,c,d,e,f,g,h,s0,s1,T1;
	uint32_t	X[16];
	int i;
	const unsigned char *data=in;

			while (num--) {

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

	if (host)
		{
		const uint32_t *W=(const uint32_t *)data;

		T1 = X[0] = W[0];	ROUND_00_15(0,a,b,c,d,e,f,g,h);
		T1 = X[1] = W[1];	ROUND_00_15(1,h,a,b,c,d,e,f,g);
		T1 = X[2] = W[2];	ROUND_00_15(2,g,h,a,b,c,d,e,f);
		T1 = X[3] = W[3];	ROUND_00_15(3,f,g,h,a,b,c,d,e);
		T1 = X[4] = W[4];	ROUND_00_15(4,e,f,g,h,a,b,c,d);
		T1 = X[5] = W[5];	ROUND_00_15(5,d,e,f,g,h,a,b,c);
		T1 = X[6] = W[6];	ROUND_00_15(6,c,d,e,f,g,h,a,b);
		T1 = X[7] = W[7];	ROUND_00_15(7,b,c,d,e,f,g,h,a);
		T1 = X[8] = W[8];	ROUND_00_15(8,a,b,c,d,e,f,g,h);
		T1 = X[9] = W[9];	ROUND_00_15(9,h,a,b,c,d,e,f,g);
		T1 = X[10] = W[10];	ROUND_00_15(10,g,h,a,b,c,d,e,f);
		T1 = X[11] = W[11];	ROUND_00_15(11,f,g,h,a,b,c,d,e);
		T1 = X[12] = W[12];	ROUND_00_15(12,e,f,g,h,a,b,c,d);
		T1 = X[13] = W[13];	ROUND_00_15(13,d,e,f,g,h,a,b,c);
		T1 = X[14] = W[14];	ROUND_00_15(14,c,d,e,f,g,h,a,b);
		T1 = X[15] = W[15];	ROUND_00_15(15,b,c,d,e,f,g,h,a);

		data += SHA256_CBLOCK;
		}
	else
		{
		uint32_t l;

		HOST_c2l(data,l); T1 = X[0] = l;  ROUND_00_15(0,a,b,c,d,e,f,g,h);
		HOST_c2l(data,l); T1 = X[1] = l;  ROUND_00_15(1,h,a,b,c,d,e,f,g);
		HOST_c2l(data,l); T1 = X[2] = l;  ROUND_00_15(2,g,h,a,b,c,d,e,f);
		HOST_c2l(data,l); T1 = X[3] = l;  ROUND_00_15(3,f,g,h,a,b,c,d,e);
		HOST_c2l(data,l); T1 = X[4] = l;  ROUND_00_15(4,e,f,g,h,a,b,c,d);
		HOST_c2l(data,l); T1 = X[5] = l;  ROUND_00_15(5,d,e,f,g,h,a,b,c);
		HOST_c2l(data,l); T1 = X[6] = l;  ROUND_00_15(6,c,d,e,f,g,h,a,b);
		HOST_c2l(data,l); T1 = X[7] = l;  ROUND_00_15(7,b,c,d,e,f,g,h,a);
		HOST_c2l(data,l); T1 = X[8] = l;  ROUND_00_15(8,a,b,c,d,e,f,g,h);
		HOST_c2l(data,l); T1 = X[9] = l;  ROUND_00_15(9,h,a,b,c,d,e,f,g);
		HOST_c2l(data,l); T1 = X[10] = l; ROUND_00_15(10,g,h,a,b,c,d,e,f);
		HOST_c2l(data,l); T1 = X[11] = l; ROUND_00_15(11,f,g,h,a,b,c,d,e);
		HOST_c2l(data,l); T1 = X[12] = l; ROUND_00_15(12,e,f,g,h,a,b,c,d);
		HOST_c2l(data,l); T1 = X[13] = l; ROUND_00_15(13,d,e,f,g,h,a,b,c);
		HOST_c2l(data,l); T1 = X[14] = l; ROUND_00_15(14,c,d,e,f,g,h,a,b);
		HOST_c2l(data,l); T1 = X[15] = l; ROUND_00_15(15,b,c,d,e,f,g,h,a);
		}

	for (i=16;i<64;i+=8)
		{
		ROUND_16_63(i+0,a,b,c,d,e,f,g,h,X);
		ROUND_16_63(i+1,h,a,b,c,d,e,f,g,X);
		ROUND_16_63(i+2,g,h,a,b,c,d,e,f,X);
		ROUND_16_63(i+3,f,g,h,a,b,c,d,e,X);
		ROUND_16_63(i+4,e,f,g,h,a,b,c,d,X);
		ROUND_16_63(i+5,d,e,f,g,h,a,b,c,X);
		ROUND_16_63(i+6,c,d,e,f,g,h,a,b,X);
		ROUND_16_63(i+7,b,c,d,e,f,g,h,a,X);
		}

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

			}
	}
开发者ID:FlorentBecker,项目名称:nix,代码行数:74,代码来源:sha256.c



注:本文中的HOST_c2l函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ HOWTO函数代码示例发布时间:2022-05-30
下一篇:
C++ HOSTAPD_DEBUG函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap