本文整理汇总了C++中LOAD32L函数的典型用法代码示例。如果您正苦于以下问题:C++ LOAD32L函数的具体用法?C++ LOAD32L怎么用?C++ LOAD32L使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LOAD32L函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: noekeon_ecb_encrypt
void noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *key)
#endif
{
unsigned long a,b,c,d,temp;
int r;
_ARGCHK(key != NULL);
_ARGCHK(pt != NULL);
_ARGCHK(ct != NULL);
LOAD32L(a,&pt[0]); LOAD32L(b,&pt[4]);
LOAD32L(c,&pt[8]); LOAD32L(d,&pt[12]);
#define ROUND(i) \
a ^= RC[r+i]; \
THETA(key->noekeon.K, a,b,c,d); \
PI1(a,b,c,d); \
GAMMA(a,b,c,d); \
PI2(a,b,c,d);
for (r = 0; r < 16; r += 2) {
ROUND(0);
ROUND(1);
}
#undef ROUND
a ^= RC[16];
THETA(key->noekeon.K, a, b, c, d);
STORE32L(a,&ct[0]); STORE32L(b,&ct[4]);
STORE32L(c,&ct[8]); STORE32L(d,&ct[12]);
}
开发者ID:TheTypoMaster,项目名称:AH4222,代码行数:33,代码来源:noekeon.c
示例2: rc6_ecb_encrypt
int rc6_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
#endif
{
ulong32 a,b,c,d,t,u, *K;
int r;
LTC_ARGCHK(skey != NULL);
LTC_ARGCHK(pt != NULL);
LTC_ARGCHK(ct != NULL);
LOAD32L(a,&pt[0]);LOAD32L(b,&pt[4]);LOAD32L(c,&pt[8]);LOAD32L(d,&pt[12]);
b += skey->rc6.K[0];
d += skey->rc6.K[1];
#define RND(a,b,c,d) \
t = (b * (b + b + 1)); t = ROLc(t, 5); \
u = (d * (d + d + 1)); u = ROLc(u, 5); \
a = ROL(a^t,u) + K[0]; \
c = ROL(c^u,t) + K[1]; K += 2;
K = skey->rc6.K + 2;
for (r = 0; r < 20; r += 4) {
RND(a,b,c,d);
RND(b,c,d,a);
RND(c,d,a,b);
RND(d,a,b,c);
}
#undef RND
a += skey->rc6.K[42];
c += skey->rc6.K[43];
STORE32L(a,&ct[0]);STORE32L(b,&ct[4]);STORE32L(c,&ct[8]);STORE32L(d,&ct[12]);
return CRYPT_OK;
}
开发者ID:jamesyan84,项目名称:mt36k_android_4.0.4,代码行数:35,代码来源:rc6.c
示例3: rc6_ecb_decrypt
void rc6_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
#endif
{
ulong32 a,b,c,d,t,u, *K;
int r;
LTC_ARGCHK(skey != NULL);
LTC_ARGCHK(pt != NULL);
LTC_ARGCHK(ct != NULL);
LOAD32L(a,&ct[0]);LOAD32L(b,&ct[4]);LOAD32L(c,&ct[8]);LOAD32L(d,&ct[12]);
a -= skey->rc6.K[42];
c -= skey->rc6.K[43];
#define RND(a,b,c,d) \
t = (b * (b + b + 1)); t = ROLc(t, 5); \
u = (d * (d + d + 1)); u = ROLc(u, 5); \
c = ROR(c - K[1], t) ^ u; \
a = ROR(a - K[0], u) ^ t; K -= 2;
K = skey->rc6.K + 40;
for (r = 0; r < 20; r += 4) {
RND(d,a,b,c);
RND(c,d,a,b);
RND(b,c,d,a);
RND(a,b,c,d);
}
#undef RND
b -= skey->rc6.K[0];
d -= skey->rc6.K[1];
STORE32L(a,&pt[0]);STORE32L(b,&pt[4]);STORE32L(c,&pt[8]);STORE32L(d,&pt[12]);
}
开发者ID:tch-opensrc,项目名称:TC72XX_LxG1.7.1mp1_OpenSrc,代码行数:35,代码来源:rc6.c
示例4: rc5_ecb_encrypt
int rc5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
#endif
{
ulong32 A, B, *K;
int r;
LTC_ARGCHK(skey != NULL);
LTC_ARGCHK(pt != NULL);
LTC_ARGCHK(ct != NULL);
LOAD32L(A, &pt[0]);
LOAD32L(B, &pt[4]);
A += skey->rc5.K[0];
B += skey->rc5.K[1];
K = skey->rc5.K + 2;
if ((skey->rc5.rounds & 1) == 0) {
for (r = 0; r < skey->rc5.rounds; r += 2) {
A = ROL(A ^ B, B) + K[0];
B = ROL(B ^ A, A) + K[1];
A = ROL(A ^ B, B) + K[2];
B = ROL(B ^ A, A) + K[3];
K += 4;
}
} else {
for (r = 0; r < skey->rc5.rounds; r++) {
A = ROL(A ^ B, B) + K[0];
B = ROL(B ^ A, A) + K[1];
K += 2;
}
}
STORE32L(A, &ct[0]);
STORE32L(B, &ct[4]);
return CRYPT_OK;
}
开发者ID:0omega,项目名称:platform_external_dropbear,代码行数:35,代码来源:rc5.c
示例5: noekeon_setup
int noekeon_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
{
unsigned long temp;
_ARGCHK(key != NULL);
_ARGCHK(skey != NULL);
if (keylen != 16) {
return CRYPT_INVALID_KEYSIZE;
}
if (num_rounds != 16 && num_rounds != 0) {
return CRYPT_INVALID_ROUNDS;
}
LOAD32L(skey->noekeon.K[0],&key[0]);
LOAD32L(skey->noekeon.K[1],&key[4]);
LOAD32L(skey->noekeon.K[2],&key[8]);
LOAD32L(skey->noekeon.K[3],&key[12]);
LOAD32L(skey->noekeon.dK[0],&key[0]);
LOAD32L(skey->noekeon.dK[1],&key[4]);
LOAD32L(skey->noekeon.dK[2],&key[8]);
LOAD32L(skey->noekeon.dK[3],&key[12]);
THETA(zero, skey->noekeon.dK[0], skey->noekeon.dK[1], skey->noekeon.dK[2], skey->noekeon.dK[3]);
return CRYPT_OK;
}
开发者ID:TheTypoMaster,项目名称:AH4222,代码行数:29,代码来源:noekeon.c
示例6: IV
/**
Set IV + counter data to the ChaCha state
@param st The ChaCha20 state
@param iv The IV data to add
@param ivlen The length of the IV (must be 12)
@param counter 32bit (unsigned) initial counter value
@return CRYPT_OK on success
*/
int chacha_ivctr32(chacha_state *st, const unsigned char *iv, unsigned long ivlen, ulong32 counter)
{
LTC_ARGCHK(st != NULL);
LTC_ARGCHK(iv != NULL);
/* 96bit IV + 32bit counter */
LTC_ARGCHK(ivlen == 12);
st->input[12] = counter;
LOAD32L(st->input[13], iv + 0);
LOAD32L(st->input[14], iv + 4);
LOAD32L(st->input[15], iv + 8);
st->ksleft = 0;
st->ivlen = ivlen;
return CRYPT_OK;
}
开发者ID:FirebirdSQL,项目名称:firebird,代码行数:23,代码来源:chacha_ivctr32.c
示例7: XORWORD
static void XORWORD(ulong32 w, const unsigned char *in, unsigned char *out)
{
ulong32 t;
LOAD32L(t, in);
t ^= w;
STORE32L(t, out);
}
开发者ID:dyemanov,项目名称:firebird,代码行数:7,代码来源:sober128_stream.c
示例8: XORWORD
static void XORWORD(ulong32 w, unsigned char *b)
{
ulong32 t;
LOAD32L(t, b);
t ^= w;
STORE32L(t, b);
}
开发者ID:0omega,项目名称:platform_external_dropbear,代码行数:7,代码来源:sober128.c
示例9: rc5_ecb_encrypt
void rc5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *key)
#endif
{
unsigned long A, B;
int r;
_ARGCHK(key != NULL);
_ARGCHK(pt != NULL);
_ARGCHK(ct != NULL);
LOAD32L(A, &pt[0]);
LOAD32L(B, &pt[4]);
A += key->rc5.K[0];
B += key->rc5.K[1];
for (r = 0; r < key->rc5.rounds; r++) {
A = ROL(A ^ B, B) + key->rc5.K[r+r+2];
B = ROL(B ^ A, A) + key->rc5.K[r+r+3];
}
STORE32L(A, &ct[0]);
STORE32L(B, &ct[4]);
}
开发者ID:TheTypoMaster,项目名称:AH4222,代码行数:20,代码来源:rc5.c
示例10: rc5_ecb_decrypt
void rc5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *key)
#endif
{
unsigned long A, B;
int r;
_ARGCHK(key != NULL);
_ARGCHK(pt != NULL);
_ARGCHK(ct != NULL);
LOAD32L(A, &ct[0]);
LOAD32L(B, &ct[4]);
for (r = key->rc5.rounds - 1; r >= 0; r--) {
B = ROR(B - key->rc5.K[r+r+3], A) ^ A;
A = ROR(A - key->rc5.K[r+r+2], B) ^ B;
}
A -= key->rc5.K[0];
B -= key->rc5.K[1];
STORE32L(A, &pt[0]);
STORE32L(B, &pt[4]);
}
开发者ID:TheTypoMaster,项目名称:AH4222,代码行数:20,代码来源:rc5.c
示例11: rc6_ecb_encrypt
void rc6_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *key)
#endif
{
unsigned long a,b,c,d,t,u;
int r;
_ARGCHK(key != NULL);
_ARGCHK(pt != NULL);
_ARGCHK(ct != NULL);
LOAD32L(a,&pt[0]);LOAD32L(b,&pt[4]);LOAD32L(c,&pt[8]);LOAD32L(d,&pt[12]);
b += key->rc6.K[0];
d += key->rc6.K[1];
for (r = 0; r < 20; r++) {
t = (b * (b + b + 1)); t = ROL(t, 5);
u = (d * (d + d + 1)); u = ROL(u, 5);
a = ROL(a^t,u) + key->rc6.K[r+r+2];
c = ROL(c^u,t) + key->rc6.K[r+r+3];
t = a; a = b; b = c; c = d; d = t;
}
a += key->rc6.K[42];
c += key->rc6.K[43];
STORE32L(a,&ct[0]);STORE32L(b,&ct[4]);STORE32L(c,&ct[8]);STORE32L(d,&ct[12]);
}
开发者ID:TheTypoMaster,项目名称:AH4222,代码行数:23,代码来源:rc6.c
示例12: rc6_ecb_decrypt
void rc6_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *key)
#endif
{
unsigned long a,b,c,d,t,u;
int r;
_ARGCHK(key != NULL);
_ARGCHK(pt != NULL);
_ARGCHK(ct != NULL);
LOAD32L(a,&ct[0]);LOAD32L(b,&ct[4]);LOAD32L(c,&ct[8]);LOAD32L(d,&ct[12]);
a -= key->rc6.K[42];
c -= key->rc6.K[43];
for (r = 19; r >= 0; r--) {
t = d; d = c; c = b; b = a; a = t;
t = (b * (b + b + 1)); t = ROL(t, 5);
u = (d * (d + d + 1)); u = ROL(u, 5);
c = ROR(c - key->rc6.K[r+r+3], t) ^ u;
a = ROR(a - key->rc6.K[r+r+2], u) ^ t;
}
b -= key->rc6.K[0];
d -= key->rc6.K[1];
STORE32L(a,&pt[0]);STORE32L(b,&pt[4]);STORE32L(c,&pt[8]);STORE32L(d,&pt[12]);
}
开发者ID:TheTypoMaster,项目名称:AH4222,代码行数:24,代码来源:rc6.c
示例13: rc5_ecb_decrypt
int rc5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
#endif
{
ulong32 A, B, *K;
int r;
LTC_ARGCHK(skey != NULL);
LTC_ARGCHK(pt != NULL);
LTC_ARGCHK(ct != NULL);
LOAD32L(A, &ct[0]);
LOAD32L(B, &ct[4]);
K = skey->rc5.K + (skey->rc5.rounds << 1);
if ((skey->rc5.rounds & 1) == 0) {
K -= 2;
for (r = skey->rc5.rounds - 1; r >= 0; r -= 2) {
B = ROR(B - K[3], A) ^ A;
A = ROR(A - K[2], B) ^ B;
B = ROR(B - K[1], A) ^ A;
A = ROR(A - K[0], B) ^ B;
K -= 4;
}
} else {
for (r = skey->rc5.rounds - 1; r >= 0; r--) {
B = ROR(B - K[1], A) ^ A;
A = ROR(A - K[0], B) ^ B;
K -= 2;
}
}
A -= skey->rc5.K[0];
B -= skey->rc5.K[1];
STORE32L(A, &pt[0]);
STORE32L(B, &pt[4]);
return CRYPT_OK;
}
开发者ID:0omega,项目名称:platform_external_dropbear,代码行数:36,代码来源:rc5.c
示例14: blake2s_init_param
/* init2 xors IV with input parameter block */
static int blake2s_init_param(hash_state *md, const unsigned char *P)
{
unsigned long i;
blake2s_init0(md);
/* IV XOR ParamBlock */
for (i = 0; i < 8; ++i) {
ulong32 tmp;
LOAD32L(tmp, P + i * 4);
md->blake2s.h[i] ^= tmp;
}
md->blake2s.outlen = P[O_DIGEST_LENGTH];
return CRYPT_OK;
}
开发者ID:libtom,项目名称:libtomcrypt,代码行数:17,代码来源:blake2s.c
示例15: blake2s_compress
static int blake2s_compress(hash_state *md, const unsigned char *buf)
#endif
{
unsigned long i;
ulong32 m[16];
ulong32 v[16];
for (i = 0; i < 16; ++i) {
LOAD32L(m[i], buf + i * sizeof(m[i]));
}
for (i = 0; i < 8; ++i)
v[i] = md->blake2s.h[i];
v[8] = blake2s_IV[0];
v[9] = blake2s_IV[1];
v[10] = blake2s_IV[2];
v[11] = blake2s_IV[3];
v[12] = md->blake2s.t[0] ^ blake2s_IV[4];
v[13] = md->blake2s.t[1] ^ blake2s_IV[5];
v[14] = md->blake2s.f[0] ^ blake2s_IV[6];
v[15] = md->blake2s.f[1] ^ blake2s_IV[7];
ROUND(0);
ROUND(1);
ROUND(2);
ROUND(3);
ROUND(4);
ROUND(5);
ROUND(6);
ROUND(7);
ROUND(8);
ROUND(9);
for (i = 0; i < 8; ++i)
md->blake2s.h[i] = md->blake2s.h[i] ^ v[i] ^ v[i + 8];
return CRYPT_OK;
}
开发者ID:libtom,项目名称:libtomcrypt,代码行数:39,代码来源:blake2s.c
示例16: LOAD32L
static void smix
(
uint8_t *b,
const size_t r,
uint64_t n,
uint32_t *t0,
uint32_t *t1,
uint32_t *t2
)
{
uint64_t i;
uint64_t tn;
uint64_t j;
for(i = 0; i < (r << 5); i++)
t1[i] = LOAD32L(b + (i << 2));
for(i = 0; i < n; i++)
{
memcpy(t0 + (r << 5) * i, t1, r << 7);
blockmix(t1, t2, r);
}
for(i = 0; i < n; i++)
{
/* integrify */
tn = (((uint64_t)t1[(r << 5) - 15] << 32)
| t1[(r << 5) - 16])
& (n - 1);
for(j = 0; j < (r << 5); j++)
t1[j] ^= t0[(r << 5) * tn + j];
blockmix(t1, t2, r);
}
for(i = 0; i < (r << 5); i++)
STORE32L(t1[i], b + (i << 2));
}
开发者ID:rofl0r,项目名称:kripto,代码行数:39,代码来源:scrypt.c
示例17: md5_compress
static void md5_compress(struct md5_state *md5, unsigned char *buf)
{
MD5_INT32 i, W[16], a, b, c, d;
assert(md5 != NULL);
assert(buf != NULL);
/* copy the state into 512-bits into W[0..15] */
for (i = 0; i < 16; i++) {
LOAD32L(W[i], buf + (4*i));
}
/* copy state */
a = md5->state[0];
b = md5->state[1];
c = md5->state[2];
d = md5->state[3];
FF(a,b,c,d,W[0],7,0xd76aa478UL);
FF(d,a,b,c,W[1],12,0xe8c7b756UL);
FF(c,d,a,b,W[2],17,0x242070dbUL);
FF(b,c,d,a,W[3],22,0xc1bdceeeUL);
FF(a,b,c,d,W[4],7,0xf57c0fafUL);
FF(d,a,b,c,W[5],12,0x4787c62aUL);
FF(c,d,a,b,W[6],17,0xa8304613UL);
FF(b,c,d,a,W[7],22,0xfd469501UL);
FF(a,b,c,d,W[8],7,0x698098d8UL);
FF(d,a,b,c,W[9],12,0x8b44f7afUL);
FF(c,d,a,b,W[10],17,0xffff5bb1UL);
FF(b,c,d,a,W[11],22,0x895cd7beUL);
FF(a,b,c,d,W[12],7,0x6b901122UL);
FF(d,a,b,c,W[13],12,0xfd987193UL);
FF(c,d,a,b,W[14],17,0xa679438eUL);
FF(b,c,d,a,W[15],22,0x49b40821UL);
GG(a,b,c,d,W[1],5,0xf61e2562UL);
GG(d,a,b,c,W[6],9,0xc040b340UL);
GG(c,d,a,b,W[11],14,0x265e5a51UL);
GG(b,c,d,a,W[0],20,0xe9b6c7aaUL);
GG(a,b,c,d,W[5],5,0xd62f105dUL);
GG(d,a,b,c,W[10],9,0x02441453UL);
GG(c,d,a,b,W[15],14,0xd8a1e681UL);
GG(b,c,d,a,W[4],20,0xe7d3fbc8UL);
GG(a,b,c,d,W[9],5,0x21e1cde6UL);
GG(d,a,b,c,W[14],9,0xc33707d6UL);
GG(c,d,a,b,W[3],14,0xf4d50d87UL);
GG(b,c,d,a,W[8],20,0x455a14edUL);
GG(a,b,c,d,W[13],5,0xa9e3e905UL);
GG(d,a,b,c,W[2],9,0xfcefa3f8UL);
GG(c,d,a,b,W[7],14,0x676f02d9UL);
GG(b,c,d,a,W[12],20,0x8d2a4c8aUL);
HH(a,b,c,d,W[5],4,0xfffa3942UL);
HH(d,a,b,c,W[8],11,0x8771f681UL);
HH(c,d,a,b,W[11],16,0x6d9d6122UL);
HH(b,c,d,a,W[14],23,0xfde5380cUL);
HH(a,b,c,d,W[1],4,0xa4beea44UL);
HH(d,a,b,c,W[4],11,0x4bdecfa9UL);
HH(c,d,a,b,W[7],16,0xf6bb4b60UL);
HH(b,c,d,a,W[10],23,0xbebfbc70UL);
HH(a,b,c,d,W[13],4,0x289b7ec6UL);
HH(d,a,b,c,W[0],11,0xeaa127faUL);
HH(c,d,a,b,W[3],16,0xd4ef3085UL);
HH(b,c,d,a,W[6],23,0x04881d05UL);
HH(a,b,c,d,W[9],4,0xd9d4d039UL);
HH(d,a,b,c,W[12],11,0xe6db99e5UL);
HH(c,d,a,b,W[15],16,0x1fa27cf8UL);
HH(b,c,d,a,W[2],23,0xc4ac5665UL);
II(a,b,c,d,W[0],6,0xf4292244UL);
II(d,a,b,c,W[7],10,0x432aff97UL);
II(c,d,a,b,W[14],15,0xab9423a7UL);
II(b,c,d,a,W[5],21,0xfc93a039UL);
II(a,b,c,d,W[12],6,0x655b59c3UL);
II(d,a,b,c,W[3],10,0x8f0ccc92UL);
II(c,d,a,b,W[10],15,0xffeff47dUL);
II(b,c,d,a,W[1],21,0x85845dd1UL);
II(a,b,c,d,W[8],6,0x6fa87e4fUL);
II(d,a,b,c,W[15],10,0xfe2ce6e0UL);
II(c,d,a,b,W[6],15,0xa3014314UL);
II(b,c,d,a,W[13],21,0x4e0811a1UL);
II(a,b,c,d,W[4],6,0xf7537e82UL);
II(d,a,b,c,W[11],10,0xbd3af235UL);
II(c,d,a,b,W[2],15,0x2ad7d2bbUL);
II(b,c,d,a,W[9],21,0xeb86d391UL);
md5->state[0] = md5->state[0] + a;
md5->state[1] = md5->state[1] + b;
md5->state[2] = md5->state[2] + c;
md5->state[3] = md5->state[3] + d;
}
开发者ID:liexusong,项目名称:xio,代码行数:88,代码来源:md5.c
示例18: rmd128_compress
static int rmd128_compress(hash_state *md, unsigned char *buf)
#endif
{
ulong32 aa,bb,cc,dd,aaa,bbb,ccc,ddd,X[16];
int i;
/* load words X */
for (i = 0; i < 16; i++){
LOAD32L(X[i], buf + (4 * i));
}
/* load state */
aa = aaa = md->rmd128.state[0];
bb = bbb = md->rmd128.state[1];
cc = ccc = md->rmd128.state[2];
dd = ddd = md->rmd128.state[3];
/* round 1 */
FF(aa, bb, cc, dd, X[ 0], 11);
FF(dd, aa, bb, cc, X[ 1], 14);
FF(cc, dd, aa, bb, X[ 2], 15);
FF(bb, cc, dd, aa, X[ 3], 12);
FF(aa, bb, cc, dd, X[ 4], 5);
FF(dd, aa, bb, cc, X[ 5], 8);
FF(cc, dd, aa, bb, X[ 6], 7);
FF(bb, cc, dd, aa, X[ 7], 9);
FF(aa, bb, cc, dd, X[ 8], 11);
FF(dd, aa, bb, cc, X[ 9], 13);
FF(cc, dd, aa, bb, X[10], 14);
FF(bb, cc, dd, aa, X[11], 15);
FF(aa, bb, cc, dd, X[12], 6);
FF(dd, aa, bb, cc, X[13], 7);
FF(cc, dd, aa, bb, X[14], 9);
FF(bb, cc, dd, aa, X[15], 8);
/* round 2 */
GG(aa, bb, cc, dd, X[ 7], 7);
GG(dd, aa, bb, cc, X[ 4], 6);
GG(cc, dd, aa, bb, X[13], 8);
GG(bb, cc, dd, aa, X[ 1], 13);
GG(aa, bb, cc, dd, X[10], 11);
GG(dd, aa, bb, cc, X[ 6], 9);
GG(cc, dd, aa, bb, X[15], 7);
GG(bb, cc, dd, aa, X[ 3], 15);
GG(aa, bb, cc, dd, X[12], 7);
GG(dd, aa, bb, cc, X[ 0], 12);
GG(cc, dd, aa, bb, X[ 9], 15);
GG(bb, cc, dd, aa, X[ 5], 9);
GG(aa, bb, cc, dd, X[ 2], 11);
GG(dd, aa, bb, cc, X[14], 7);
GG(cc, dd, aa, bb, X[11], 13);
GG(bb, cc, dd, aa, X[ 8], 12);
/* round 3 */
HH(aa, bb, cc, dd, X[ 3], 11);
HH(dd, aa, bb, cc, X[10], 13);
HH(cc, dd, aa, bb, X[14], 6);
HH(bb, cc, dd, aa, X[ 4], 7);
HH(aa, bb, cc, dd, X[ 9], 14);
HH(dd, aa, bb, cc, X[15], 9);
HH(cc, dd, aa, bb, X[ 8], 13);
HH(bb, cc, dd, aa, X[ 1], 15);
HH(aa, bb, cc, dd, X[ 2], 14);
HH(dd, aa, bb, cc, X[ 7], 8);
HH(cc, dd, aa, bb, X[ 0], 13);
HH(bb, cc, dd, aa, X[ 6], 6);
HH(aa, bb, cc, dd, X[13], 5);
HH(dd, aa, bb, cc, X[11], 12);
HH(cc, dd, aa, bb, X[ 5], 7);
HH(bb, cc, dd, aa, X[12], 5);
/* round 4 */
II(aa, bb, cc, dd, X[ 1], 11);
II(dd, aa, bb, cc, X[ 9], 12);
II(cc, dd, aa, bb, X[11], 14);
II(bb, cc, dd, aa, X[10], 15);
II(aa, bb, cc, dd, X[ 0], 14);
II(dd, aa, bb, cc, X[ 8], 15);
II(cc, dd, aa, bb, X[12], 9);
II(bb, cc, dd, aa, X[ 4], 8);
II(aa, bb, cc, dd, X[13], 9);
II(dd, aa, bb, cc, X[ 3], 14);
II(cc, dd, aa, bb, X[ 7], 5);
II(bb, cc, dd, aa, X[15], 6);
II(aa, bb, cc, dd, X[14], 8);
II(dd, aa, bb, cc, X[ 5], 6);
II(cc, dd, aa, bb, X[ 6], 5);
II(bb, cc, dd, aa, X[ 2], 12);
/* parallel round 1 */
III(aaa, bbb, ccc, ddd, X[ 5], 8);
III(ddd, aaa, bbb, ccc, X[14], 9);
III(ccc, ddd, aaa, bbb, X[ 7], 9);
III(bbb, ccc, ddd, aaa, X[ 0], 11);
III(aaa, bbb, ccc, ddd, X[ 9], 13);
III(ddd, aaa, bbb, ccc, X[ 2], 15);
III(ccc, ddd, aaa, bbb, X[11], 15);
III(bbb, ccc, ddd, aaa, X[ 4], 5);
III(aaa, bbb, ccc, ddd, X[13], 7);
III(ddd, aaa, bbb, ccc, X[ 6], 7);
//.........这里部分代码省略.........
开发者ID:WiseMan787,项目名称:ralink_sdk,代码行数:101,代码来源:rmd128.c
示例19: rmd256_compress
static int rmd256_compress(hash_state *md, unsigned char *buf)
#endif
{
ulong32 aa,bb,cc,dd,aaa,bbb,ccc,ddd,tmp,X[16];
int i;
/* load words X */
for (i = 0; i < 16; i++){
LOAD32L(X[i], buf + (4 * i));
}
/* load state */
aa = md->rmd256.state[0];
bb = md->rmd256.state[1];
cc = md->rmd256.state[2];
dd = md->rmd256.state[3];
aaa = md->rmd256.state[4];
bbb = md->rmd256.state[5];
ccc = md->rmd256.state[6];
ddd = md->rmd256.state[7];
/* round 1 */
FF(aa, bb, cc, dd, X[ 0], 11);
FF(dd, aa, bb, cc, X[ 1], 14);
FF(cc, dd, aa, bb, X[ 2], 15);
FF(bb, cc, dd, aa, X[ 3], 12);
FF(aa, bb, cc, dd, X[ 4], 5);
FF(dd, aa, bb, cc, X[ 5], 8);
FF(cc, dd, aa, bb, X[ 6], 7);
FF(bb, cc, dd, aa, X[ 7], 9);
FF(aa, bb, cc, dd, X[ 8], 11);
FF(dd, aa, bb, cc, X[ 9], 13);
FF(cc, dd, aa, bb, X[10], 14);
FF(bb, cc, dd, aa, X[11], 15);
FF(aa, bb, cc, dd, X[12], 6);
FF(dd, aa, bb, cc, X[13], 7);
FF(cc, dd, aa, bb, X[14], 9);
FF(bb, cc, dd, aa, X[15], 8);
/* parallel round 1 */
III(aaa, bbb, ccc, ddd, X[ 5], 8);
III(ddd, aaa, bbb, ccc, X[14], 9);
III(ccc, ddd, aaa, bbb, X[ 7], 9);
III(bbb, ccc, ddd, aaa, X[ 0], 11);
III(aaa, bbb, ccc, ddd, X[ 9], 13);
III(ddd, aaa, bbb, ccc, X[ 2], 15);
III(ccc, ddd, aaa, bbb, X[11], 15);
III(bbb, ccc, ddd, aaa, X[ 4], 5);
III(aaa, bbb, ccc, ddd, X[13], 7);
III(ddd, aaa, bbb, ccc, X[ 6], 7);
III(ccc, ddd, aaa, bbb, X[15], 8);
III(bbb, ccc, ddd, aaa, X[ 8], 11);
III(aaa, bbb, ccc, ddd, X[ 1], 14);
III(ddd, aaa, bbb, ccc, X[10], 14);
III(ccc, ddd, aaa, bbb, X[ 3], 12);
III(bbb, ccc, ddd, aaa, X[12], 6);
tmp = aa; aa = aaa; aaa = tmp;
/* round 2 */
GG(aa, bb, cc, dd, X[ 7], 7);
GG(dd, aa, bb, cc, X[ 4], 6);
GG(cc, dd, aa, bb, X[13], 8);
GG(bb, cc, dd, aa, X[ 1], 13);
GG(aa, bb, cc, dd, X[10], 11);
GG(dd, aa, bb, cc, X[ 6], 9);
GG(cc, dd, aa, bb, X[15], 7);
GG(bb, cc, dd, aa, X[ 3], 15);
GG(aa, bb, cc, dd, X[12], 7);
GG(dd, aa, bb, cc, X[ 0], 12);
GG(cc, dd, aa, bb, X[ 9], 15);
GG(bb, cc, dd, aa, X[ 5], 9);
GG(aa, bb, cc, dd, X[ 2], 11);
GG(dd, aa, bb, cc, X[14], 7);
GG(cc, dd, aa, bb, X[11], 13);
GG(bb, cc, dd, aa, X[ 8], 12);
/* parallel round 2 */
HHH(aaa, bbb, ccc, ddd, X[ 6], 9);
HHH(ddd, aaa, bbb, ccc, X[11], 13);
HHH(ccc, ddd, aaa, bbb, X[ 3], 15);
HHH(bbb, ccc, ddd, aaa, X[ 7], 7);
HHH(aaa, bbb, ccc, ddd, X[ 0], 12);
HHH(ddd, aaa, bbb, ccc, X[13], 8);
HHH(ccc, ddd, aaa, bbb, X[ 5], 9);
HHH(bbb, ccc, ddd, aaa, X[10], 11);
HHH(aaa, bbb, ccc, ddd, X[14], 7);
HHH(ddd, aaa, bbb, ccc, X[15], 7);
HHH(ccc, ddd, aaa, bbb, X[ 8], 12);
HHH(bbb, ccc, ddd, aaa, X[12], 7);
HHH(aaa, bbb, ccc, ddd, X[ 4], 6);
HHH(ddd, aaa, bbb, ccc, X[ 9], 15);
HHH(ccc, ddd, aaa, bbb, X[ 1], 13);
HHH(bbb, ccc, ddd, aaa, X[ 2], 11);
tmp = bb; bb = bbb; bbb = tmp;
/* round 3 */
HH(aa, bb, cc, dd, X[ 3], 11);
HH(dd, aa, bb, cc, X[10], 13);
//.........这里部分代码省略.........
开发者ID:dyemanov,项目名称:firebird,代码行数:101,代码来源:rmd256.c
示例20: dh_decrypt_key
/**
Decrypt a DH encrypted symmetric key
@param in The DH encrypted packet
@param inlen The length of the DH encrypted packet
@param out The plaintext
@param outlen [in/out] The max size and resulting size of the plaintext
@param key The private DH key corresponding to the public key that encrypted the plaintext
@return CRYPT_OK if successful
*/
int dh_decrypt_key(const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen,
dh_key *key)
{
unsigned char *shared_secret, *skey;
unsigned long x, y, z, hashsize, keysize;
int hash, err;
dh_key pubkey;
LTC_ARGCHK(in != NULL);
LTC_ARGCHK(out != NULL);
LTC_ARGCHK(outlen != NULL);
LTC_ARGCHK(key != NULL);
/* right key type? */
if (key->type != PK_PRIVATE) {
return CRYPT_PK_NOT_PRIVATE;
}
/* allocate ram */
shared_secret = XMALLOC(DH_BUF_SIZE);
skey = XMALLOC(MAXBLOCKSIZE);
if (shared_secret == NULL || skey == NULL) {
if (shared_secret != NULL) {
XFREE(shared_secret);
}
if (skey != NULL) {
XFREE(skey);
}
return CRYPT_MEM;
}
/* check if initial header should fit */
if (inlen < PACKET_SIZE+1+4+4) {
err = CRYPT_INVALID_PACKET;
goto LBL_ERR;
} else {
inlen -= PACKET_SIZE+1+4+4;
}
/* is header correct? */
if ((err = packet_valid_header((unsigned char *)in, PACKET_SECT_DH, PACKET_SUB_ENC_KEY)) != CRYPT_OK) {
goto LBL_ERR;
}
/* now lets get the hash name */
y = PACKET_SIZE;
hash = find_hash_id(in[y++]);
if (hash == -1) {
err = CRYPT_INVALID_HASH;
goto LBL_ERR;
}
/* common values */
hashsize = hash_descriptor[hash].hashsize;
/* get public key */
LOAD32L(x, in+y);
/* now check if the imported key will fit */
if (inlen < x) {
err = CRYPT_INVALID_PACKET;
goto LBL_ERR;
} else {
inlen -= x;
}
y += 4;
if ((err = dh_import(in+y, x, &pubkey)) != CRYPT_OK) {
goto LBL_ERR;
}
y += x;
/* make shared key */
x = DH_BUF_SIZE;
if ((err = dh_shared_secret(key, &pubkey, shared_secret, &x)) != CRYPT_OK) {
dh_free(&pubkey);
goto LBL_ERR;
}
dh_free(&pubkey);
z = MAXBLOCKSIZE;
if ((err = hash_memory(hash, shared_secret, x, skey, &z)) != CRYPT_OK) {
goto LBL_ERR;
}
/* load in the encrypted key */
LOAD32L(keysize, in+y);
/* will the out fit as part of the input */
if (inlen < keysize) {
//.........这里部分代码省略.........
开发者ID:adulau,项目名称:mosvm,代码行数:101,代码来源:dh_sys.c
注:本文中的LOAD32L函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论