Mercurial > dropbear
comparison des.c @ 143:5d99163f7e32 libtomcrypt-orig
import of libtomcrypt 0.99
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 19 Dec 2004 11:34:45 +0000 |
parents | 7faae8f46238 |
children | 8fc624ea2521 |
comparison
equal
deleted
inserted
replaced
15:6362d3854bb4 | 143:5d99163f7e32 |
---|---|
1375 *cook |= (*raw0 & 0x0000003fL) << 16; | 1375 *cook |= (*raw0 & 0x0000003fL) << 16; |
1376 *cook |= (*raw1 & 0x0003f000L) >> 4; | 1376 *cook |= (*raw1 & 0x0003f000L) >> 4; |
1377 *cook++ |= (*raw1 & 0x0000003fL); | 1377 *cook++ |= (*raw1 & 0x0000003fL); |
1378 } | 1378 } |
1379 | 1379 |
1380 memcpy(keyout, dough, sizeof dough); | 1380 XMEMCPY(keyout, dough, sizeof dough); |
1381 } | 1381 } |
1382 | 1382 |
1383 #ifdef CLEAN_STACK | 1383 #ifdef CLEAN_STACK |
1384 static void cookey(const ulong32 *raw1, ulong32 *keyout) | 1384 static void cookey(const ulong32 *raw1, ulong32 *keyout) |
1385 { | 1385 { |
1393 #else | 1393 #else |
1394 static void _desfunc(ulong32 *block, const ulong32 *keys) | 1394 static void _desfunc(ulong32 *block, const ulong32 *keys) |
1395 #endif | 1395 #endif |
1396 { | 1396 { |
1397 ulong32 work, right, leftt; | 1397 ulong32 work, right, leftt; |
1398 int round; | 1398 int cur_round; |
1399 | 1399 |
1400 leftt = block[0]; | 1400 leftt = block[0]; |
1401 right = block[1]; | 1401 right = block[1]; |
1402 | 1402 |
1403 #ifdef SMALL_CODE | 1403 #ifdef SMALL_CODE |
1437 leftt = (ulong32)(tmp >> 32); | 1437 leftt = (ulong32)(tmp >> 32); |
1438 right = (ulong32)(tmp & 0xFFFFFFFFUL); | 1438 right = (ulong32)(tmp & 0xFFFFFFFFUL); |
1439 } | 1439 } |
1440 #endif | 1440 #endif |
1441 | 1441 |
1442 for (round = 0; round < 8; round++) { | 1442 for (cur_round = 0; cur_round < 8; cur_round++) { |
1443 work = ROR(right, 4) ^ *keys++; | 1443 work = ROR(right, 4) ^ *keys++; |
1444 leftt ^= SP7[work & 0x3fL] | 1444 leftt ^= SP7[work & 0x3fL] |
1445 ^ SP5[(work >> 8) & 0x3fL] | 1445 ^ SP5[(work >> 8) & 0x3fL] |
1446 ^ SP3[(work >> 16) & 0x3fL] | 1446 ^ SP3[(work >> 16) & 0x3fL] |
1447 ^ SP1[(work >> 24) & 0x3fL]; | 1447 ^ SP1[(work >> 24) & 0x3fL]; |
1532 int des3_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey) | 1532 int des3_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey) |
1533 { | 1533 { |
1534 _ARGCHK(key != NULL); | 1534 _ARGCHK(key != NULL); |
1535 _ARGCHK(skey != NULL); | 1535 _ARGCHK(skey != NULL); |
1536 | 1536 |
1537 if( num_rounds != 0 && num_rounds != 16) { | 1537 if(num_rounds != 0 && num_rounds != 16) { |
1538 return CRYPT_INVALID_ROUNDS; | 1538 return CRYPT_INVALID_ROUNDS; |
1539 } | 1539 } |
1540 | 1540 |
1541 if (keylen != 24) { | 1541 if (keylen != 24) { |
1542 return CRYPT_INVALID_KEYSIZE; | 1542 return CRYPT_INVALID_KEYSIZE; |