From 1ee43a9673d35858317fb8a28e026ab6cc12824e Mon Sep 17 00:00:00 2001 From: The Wine Synchronizer Date: Fri, 4 Apr 2008 14:27:55 +0000 Subject: [PATCH] Autosyncing with Wine HEAD svn path=/trunk/; revision=32855 --- reactos/dll/win32/rsaenh/handle.c | 4 +- reactos/dll/win32/rsaenh/implglue.c | 4 +- reactos/dll/win32/rsaenh/mpi.c | 105 ++++++++++++------------- reactos/dll/win32/rsaenh/rsaenh.c | 43 +++++----- reactos/dll/win32/rsaenh/rsaenh.rbuild | 10 +-- 5 files changed, 81 insertions(+), 85 deletions(-) diff --git a/reactos/dll/win32/rsaenh/handle.c b/reactos/dll/win32/rsaenh/handle.c index fc4c717ff8b..0773813caa0 100644 --- a/reactos/dll/win32/rsaenh/handle.c +++ b/reactos/dll/win32/rsaenh/handle.c @@ -193,10 +193,10 @@ int alloc_handle_table(HANDLETABLE **lplpTable) int release_handle_table(HANDLETABLE *lpTable) { TRACE("(lpTable=%p)\n", lpTable); - + release_all_handles(lpTable); destroy_handle_table(lpTable); - return (int)HeapFree(GetProcessHeap(), 0, lpTable); + return HeapFree(GetProcessHeap(), 0, lpTable); } /****************************************************************************** diff --git a/reactos/dll/win32/rsaenh/implglue.c b/reactos/dll/win32/rsaenh/implglue.c index bb39a7b8c45..68a9380f6a7 100644 --- a/reactos/dll/win32/rsaenh/implglue.c +++ b/reactos/dll/win32/rsaenh/implglue.c @@ -134,7 +134,7 @@ BOOL finalize_hash_impl(ALG_ID aiAlgid, HASH_CONTEXT *pHashContext, BYTE *pbHash BOOL duplicate_hash_impl(ALG_ID aiAlgid, CONST HASH_CONTEXT *pSrcHashContext, HASH_CONTEXT *pDestHashContext) { - memcpy(pDestHashContext, pSrcHashContext, sizeof(HASH_CONTEXT)); + *pDestHashContext = *pSrcHashContext; return TRUE; } @@ -227,7 +227,7 @@ BOOL duplicate_key_impl(ALG_ID aiAlgid, CONST KEY_CONTEXT *pSrcKeyContext, case CALG_AES_128: case CALG_AES_192: case CALG_AES_256: - memcpy(pDestKeyContext, pSrcKeyContext, sizeof(KEY_CONTEXT)); + *pDestKeyContext = *pSrcKeyContext; break; case CALG_RSA_KEYX: case CALG_RSA_SIGN: diff --git a/reactos/dll/win32/rsaenh/mpi.c b/reactos/dll/win32/rsaenh/mpi.c index c6f083b6e2e..45c3b94d600 100644 --- a/reactos/dll/win32/rsaenh/mpi.c +++ b/reactos/dll/win32/rsaenh/mpi.c @@ -31,9 +31,6 @@ #include #include "tomcrypt.h" -/* table of first PRIME_SIZE primes */ -static const mp_digit __prime_tab[]; - /* Known optimal configurations CPU /Compiler /MUL CUTOFF/SQR CUTOFF ------------------------------------------------------------- @@ -1069,7 +1066,7 @@ int mp_div (const mp_int * a, const mp_int * b, mp_int * c, mp_int * d) /* normalize both x and y, ensure that y >= b/2, [b == 2**DIGIT_BIT] */ norm = mp_count_bits(&y) % DIGIT_BIT; - if (norm < (int)(DIGIT_BIT-1)) { + if (norm < DIGIT_BIT-1) { norm = (DIGIT_BIT-1) - norm; if ((res = mp_mul_2d (&x, norm, &x)) != MP_OKAY) { goto __Y; @@ -1285,7 +1282,7 @@ int mp_div_2d (const mp_int * a, int b, mp_int * c, mp_int * d) } /* shift by as many digits in the bit count */ - if (b >= (int)DIGIT_BIT) { + if (b >= DIGIT_BIT) { mp_rshd (c, b / DIGIT_BIT); } @@ -1390,9 +1387,9 @@ int mp_div_d (const mp_int * a, mp_digit b, mp_int * c, mp_digit * d) } else { t = 0; } - q.dp[ix] = (mp_digit)t; + q.dp[ix] = t; } - + if (d != NULL) { *d = (mp_digit)w; } @@ -1710,11 +1707,11 @@ mp_exptmod_fast (const mp_int * G, const mp_int * X, mp_int * P, mp_int * Y, int } /* read next digit and reset bitcnt */ buf = X->dp[digidx--]; - bitcnt = (int)DIGIT_BIT; + bitcnt = DIGIT_BIT; } /* grab the next msb from the exponent */ - y = (mp_digit)(buf >> (DIGIT_BIT - 1)) & 1; + y = (buf >> (DIGIT_BIT - 1)) & 1; buf <<= (mp_digit)1; /* if the bit is zero and mode == 0 then we ignore it @@ -2609,7 +2606,7 @@ mp_mod_2d (const mp_int * a, int b, mp_int * c) } /* if the modulus is larger than the value than return */ - if (b > (int) (a->used * DIGIT_BIT)) { + if (b > a->used * DIGIT_BIT) { res = mp_copy (a, c); return res; } @@ -2624,8 +2621,7 @@ mp_mod_2d (const mp_int * a, int b, mp_int * c) c->dp[x] = 0; } /* clear the digit that is not completely outside/inside the modulus */ - c->dp[b / DIGIT_BIT] &= - (mp_digit) ((((mp_digit) 1) << (((mp_digit) b) % DIGIT_BIT)) - ((mp_digit) 1)); + c->dp[b / DIGIT_BIT] &= (1 << ((mp_digit)b % DIGIT_BIT)) - 1; mp_clamp (c); return MP_OKAY; } @@ -2661,7 +2657,7 @@ int mp_montgomery_calc_normalization (mp_int * a, const mp_int * b) /* now compute C = A * B mod b */ - for (x = bits - 1; x < (int)DIGIT_BIT; x++) { + for (x = bits - 1; x < DIGIT_BIT; x++) { if ((res = mp_mul_2 (a, a)) != MP_OKAY) { return res; } @@ -2907,14 +2903,14 @@ int mp_mul_2d (const mp_int * a, int b, mp_int * c) } } - if (c->alloc < (int)(c->used + b/DIGIT_BIT + 1)) { + if (c->alloc < c->used + b/DIGIT_BIT + 1) { if ((res = mp_grow (c, c->used + b / DIGIT_BIT + 1)) != MP_OKAY) { return res; } } /* shift by as many digits in the bit count */ - if (b >= (int)DIGIT_BIT) { + if (b >= DIGIT_BIT) { if ((res = mp_lshd (c, b / DIGIT_BIT)) != MP_OKAY) { return res; } @@ -3035,6 +3031,45 @@ mp_mulmod (const mp_int * a, const mp_int * b, mp_int * c, mp_int * d) return res; } +/* table of first PRIME_SIZE primes */ +static const mp_digit __prime_tab[] = { + 0x0002, 0x0003, 0x0005, 0x0007, 0x000B, 0x000D, 0x0011, 0x0013, + 0x0017, 0x001D, 0x001F, 0x0025, 0x0029, 0x002B, 0x002F, 0x0035, + 0x003B, 0x003D, 0x0043, 0x0047, 0x0049, 0x004F, 0x0053, 0x0059, + 0x0061, 0x0065, 0x0067, 0x006B, 0x006D, 0x0071, 0x007F, 0x0083, + 0x0089, 0x008B, 0x0095, 0x0097, 0x009D, 0x00A3, 0x00A7, 0x00AD, + 0x00B3, 0x00B5, 0x00BF, 0x00C1, 0x00C5, 0x00C7, 0x00D3, 0x00DF, + 0x00E3, 0x00E5, 0x00E9, 0x00EF, 0x00F1, 0x00FB, 0x0101, 0x0107, + 0x010D, 0x010F, 0x0115, 0x0119, 0x011B, 0x0125, 0x0133, 0x0137, + + 0x0139, 0x013D, 0x014B, 0x0151, 0x015B, 0x015D, 0x0161, 0x0167, + 0x016F, 0x0175, 0x017B, 0x017F, 0x0185, 0x018D, 0x0191, 0x0199, + 0x01A3, 0x01A5, 0x01AF, 0x01B1, 0x01B7, 0x01BB, 0x01C1, 0x01C9, + 0x01CD, 0x01CF, 0x01D3, 0x01DF, 0x01E7, 0x01EB, 0x01F3, 0x01F7, + 0x01FD, 0x0209, 0x020B, 0x021D, 0x0223, 0x022D, 0x0233, 0x0239, + 0x023B, 0x0241, 0x024B, 0x0251, 0x0257, 0x0259, 0x025F, 0x0265, + 0x0269, 0x026B, 0x0277, 0x0281, 0x0283, 0x0287, 0x028D, 0x0293, + 0x0295, 0x02A1, 0x02A5, 0x02AB, 0x02B3, 0x02BD, 0x02C5, 0x02CF, + + 0x02D7, 0x02DD, 0x02E3, 0x02E7, 0x02EF, 0x02F5, 0x02F9, 0x0301, + 0x0305, 0x0313, 0x031D, 0x0329, 0x032B, 0x0335, 0x0337, 0x033B, + 0x033D, 0x0347, 0x0355, 0x0359, 0x035B, 0x035F, 0x036D, 0x0371, + 0x0373, 0x0377, 0x038B, 0x038F, 0x0397, 0x03A1, 0x03A9, 0x03AD, + 0x03B3, 0x03B9, 0x03C7, 0x03CB, 0x03D1, 0x03D7, 0x03DF, 0x03E5, + 0x03F1, 0x03F5, 0x03FB, 0x03FD, 0x0407, 0x0409, 0x040F, 0x0419, + 0x041B, 0x0425, 0x0427, 0x042D, 0x043F, 0x0443, 0x0445, 0x0449, + 0x044F, 0x0455, 0x045D, 0x0463, 0x0469, 0x047F, 0x0481, 0x048B, + + 0x0493, 0x049D, 0x04A3, 0x04A9, 0x04B1, 0x04BD, 0x04C1, 0x04C7, + 0x04CD, 0x04CF, 0x04D5, 0x04E1, 0x04EB, 0x04FD, 0x04FF, 0x0503, + 0x0509, 0x050B, 0x0511, 0x0515, 0x0517, 0x051B, 0x0527, 0x0529, + 0x052F, 0x0551, 0x0557, 0x055D, 0x0565, 0x0577, 0x0581, 0x058F, + 0x0593, 0x0595, 0x0599, 0x059F, 0x05A7, 0x05AB, 0x05AD, 0x05B3, + 0x05BF, 0x05C9, 0x05CB, 0x05CF, 0x05D1, 0x05D5, 0x05DB, 0x05E7, + 0x05F3, 0x05FB, 0x0607, 0x060D, 0x0611, 0x0617, 0x061F, 0x0623, + 0x062B, 0x062F, 0x063D, 0x0641, 0x0647, 0x0649, 0x064D, 0x0653 +}; + /* determines if an integers is divisible by one * of the first PRIME_SIZE primes or not * @@ -3811,44 +3846,6 @@ mp_zero (mp_int * a) memset (a->dp, 0, sizeof (mp_digit) * a->alloc); } -static const mp_digit __prime_tab[] = { - 0x0002, 0x0003, 0x0005, 0x0007, 0x000B, 0x000D, 0x0011, 0x0013, - 0x0017, 0x001D, 0x001F, 0x0025, 0x0029, 0x002B, 0x002F, 0x0035, - 0x003B, 0x003D, 0x0043, 0x0047, 0x0049, 0x004F, 0x0053, 0x0059, - 0x0061, 0x0065, 0x0067, 0x006B, 0x006D, 0x0071, 0x007F, 0x0083, - 0x0089, 0x008B, 0x0095, 0x0097, 0x009D, 0x00A3, 0x00A7, 0x00AD, - 0x00B3, 0x00B5, 0x00BF, 0x00C1, 0x00C5, 0x00C7, 0x00D3, 0x00DF, - 0x00E3, 0x00E5, 0x00E9, 0x00EF, 0x00F1, 0x00FB, 0x0101, 0x0107, - 0x010D, 0x010F, 0x0115, 0x0119, 0x011B, 0x0125, 0x0133, 0x0137, - - 0x0139, 0x013D, 0x014B, 0x0151, 0x015B, 0x015D, 0x0161, 0x0167, - 0x016F, 0x0175, 0x017B, 0x017F, 0x0185, 0x018D, 0x0191, 0x0199, - 0x01A3, 0x01A5, 0x01AF, 0x01B1, 0x01B7, 0x01BB, 0x01C1, 0x01C9, - 0x01CD, 0x01CF, 0x01D3, 0x01DF, 0x01E7, 0x01EB, 0x01F3, 0x01F7, - 0x01FD, 0x0209, 0x020B, 0x021D, 0x0223, 0x022D, 0x0233, 0x0239, - 0x023B, 0x0241, 0x024B, 0x0251, 0x0257, 0x0259, 0x025F, 0x0265, - 0x0269, 0x026B, 0x0277, 0x0281, 0x0283, 0x0287, 0x028D, 0x0293, - 0x0295, 0x02A1, 0x02A5, 0x02AB, 0x02B3, 0x02BD, 0x02C5, 0x02CF, - - 0x02D7, 0x02DD, 0x02E3, 0x02E7, 0x02EF, 0x02F5, 0x02F9, 0x0301, - 0x0305, 0x0313, 0x031D, 0x0329, 0x032B, 0x0335, 0x0337, 0x033B, - 0x033D, 0x0347, 0x0355, 0x0359, 0x035B, 0x035F, 0x036D, 0x0371, - 0x0373, 0x0377, 0x038B, 0x038F, 0x0397, 0x03A1, 0x03A9, 0x03AD, - 0x03B3, 0x03B9, 0x03C7, 0x03CB, 0x03D1, 0x03D7, 0x03DF, 0x03E5, - 0x03F1, 0x03F5, 0x03FB, 0x03FD, 0x0407, 0x0409, 0x040F, 0x0419, - 0x041B, 0x0425, 0x0427, 0x042D, 0x043F, 0x0443, 0x0445, 0x0449, - 0x044F, 0x0455, 0x045D, 0x0463, 0x0469, 0x047F, 0x0481, 0x048B, - - 0x0493, 0x049D, 0x04A3, 0x04A9, 0x04B1, 0x04BD, 0x04C1, 0x04C7, - 0x04CD, 0x04CF, 0x04D5, 0x04E1, 0x04EB, 0x04FD, 0x04FF, 0x0503, - 0x0509, 0x050B, 0x0511, 0x0515, 0x0517, 0x051B, 0x0527, 0x0529, - 0x052F, 0x0551, 0x0557, 0x055D, 0x0565, 0x0577, 0x0581, 0x058F, - 0x0593, 0x0595, 0x0599, 0x059F, 0x05A7, 0x05AB, 0x05AD, 0x05B3, - 0x05BF, 0x05C9, 0x05CB, 0x05CF, 0x05D1, 0x05D5, 0x05DB, 0x05E7, - 0x05F3, 0x05FB, 0x0607, 0x060D, 0x0611, 0x0617, 0x061F, 0x0623, - 0x062B, 0x062F, 0x063D, 0x0641, 0x0647, 0x0649, 0x064D, 0x0653 -}; - /* reverse an array, used for radix code */ void bn_reverse (unsigned char *s, int len) @@ -4068,7 +4065,7 @@ int s_mp_exptmod (const mp_int * G, const mp_int * X, mp_int * P, mp_int * Y) } /* read next digit and reset the bitcnt */ buf = X->dp[digidx--]; - bitcnt = (int) DIGIT_BIT; + bitcnt = DIGIT_BIT; } /* grab the next msb from the exponent */ diff --git a/reactos/dll/win32/rsaenh/rsaenh.c b/reactos/dll/win32/rsaenh/rsaenh.c index 2e5fd21cc84..34abb1a9b97 100644 --- a/reactos/dll/win32/rsaenh/rsaenh.c +++ b/reactos/dll/win32/rsaenh/rsaenh.c @@ -75,8 +75,7 @@ typedef struct tagCRYPTHASH #define RSAENH_MAX_BLOCK_SIZE 24 #define RSAENH_KEYSTATE_IDLE 0 #define RSAENH_KEYSTATE_ENCRYPTING 1 -#define RSAENH_KEYSTATE_DECRYPTING 2 -#define RSAENH_KEYSTATE_MASTERKEY 3 +#define RSAENH_KEYSTATE_MASTERKEY 2 typedef struct _RSAENH_SCHANNEL_INFO { SCHANNEL_ALG saEncAlg; @@ -549,7 +548,7 @@ static BOOL copy_hmac_info(PHMAC_INFO *dst, const HMAC_INFO *src) { if (!src) return FALSE; *dst = HeapAlloc(GetProcessHeap(), 0, sizeof(HMAC_INFO)); if (!*dst) return FALSE; - memcpy(*dst, src, sizeof(HMAC_INFO)); + **dst = *src; (*dst)->pbInnerString = NULL; (*dst)->pbOuterString = NULL; if ((*dst)->cbInnerString == 0) (*dst)->cbInnerString = RSAENH_HMAC_DEF_PAD_LEN; @@ -828,8 +827,8 @@ static HCRYPTKEY new_key(HCRYPTPROV hProv, ALG_ID aiAlgid, DWORD dwFlags, CRYPTK } } - hCryptKey = (HCRYPTKEY)new_object(&handle_table, sizeof(CRYPTKEY), RSAENH_MAGIC_KEY, - destroy_key, (OBJECTHDR**)&pCryptKey); + hCryptKey = new_object(&handle_table, sizeof(CRYPTKEY), RSAENH_MAGIC_KEY, + destroy_key, (OBJECTHDR**)&pCryptKey); if (hCryptKey != (HCRYPTKEY)INVALID_HANDLE_VALUE) { pCryptKey->aiAlgid = aiAlgid; @@ -1095,8 +1094,8 @@ static HCRYPTPROV new_key_container(PCCH pszContainerName, DWORD dwFlags, const KEYCONTAINER *pKeyContainer; HCRYPTPROV hKeyContainer; - hKeyContainer = (HCRYPTPROV)new_object(&handle_table, sizeof(KEYCONTAINER), RSAENH_MAGIC_CONTAINER, - destroy_key_container, (OBJECTHDR**)&pKeyContainer); + hKeyContainer = new_object(&handle_table, sizeof(KEYCONTAINER), RSAENH_MAGIC_CONTAINER, + destroy_key_container, (OBJECTHDR**)&pKeyContainer); if (hKeyContainer != (HCRYPTPROV)INVALID_HANDLE_VALUE) { lstrcpynA(pKeyContainer->szName, pszContainerName, MAX_PATH); @@ -1670,10 +1669,10 @@ BOOL WINAPI RSAENH_CPCreateHash(HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey, } } - *phHash = (HCRYPTHASH)new_object(&handle_table, sizeof(CRYPTHASH), RSAENH_MAGIC_HASH, - destroy_hash, (OBJECTHDR**)&pCryptHash); + *phHash = new_object(&handle_table, sizeof(CRYPTHASH), RSAENH_MAGIC_HASH, + destroy_hash, (OBJECTHDR**)&pCryptHash); if (!pCryptHash) return FALSE; - + pCryptHash->aiAlgid = Algid; pCryptHash->hKey = hKey; pCryptHash->hProv = hProv; @@ -1834,11 +1833,11 @@ BOOL WINAPI RSAENH_CPDuplicateHash(HCRYPTPROV hUID, HCRYPTHASH hHash, DWORD *pdw return FALSE; } - *phHash = (HCRYPTHASH)new_object(&handle_table, sizeof(CRYPTHASH), RSAENH_MAGIC_HASH, - destroy_hash, (OBJECTHDR**)&pDestHash); + *phHash = new_object(&handle_table, sizeof(CRYPTHASH), RSAENH_MAGIC_HASH, + destroy_hash, (OBJECTHDR**)&pDestHash); if (*phHash != (HCRYPTHASH)INVALID_HANDLE_VALUE) { - memcpy(pDestHash, pSrcHash, sizeof(CRYPTHASH)); + *pDestHash = *pSrcHash; duplicate_hash_impl(pSrcHash->aiAlgid, &pSrcHash->context, &pDestHash->context); copy_hmac_info(&pDestHash->pHMACInfo, pSrcHash->pHMACInfo); copy_data_blob(&pDestHash->tpPRFParams.blobLabel, &pSrcHash->tpPRFParams.blobLabel); @@ -1890,11 +1889,11 @@ BOOL WINAPI RSAENH_CPDuplicateKey(HCRYPTPROV hUID, HCRYPTKEY hKey, DWORD *pdwRes return FALSE; } - *phKey = (HCRYPTKEY)new_object(&handle_table, sizeof(CRYPTKEY), RSAENH_MAGIC_KEY, destroy_key, - (OBJECTHDR**)&pDestKey); + *phKey = new_object(&handle_table, sizeof(CRYPTKEY), RSAENH_MAGIC_KEY, destroy_key, + (OBJECTHDR**)&pDestKey); if (*phKey != (HCRYPTKEY)INVALID_HANDLE_VALUE) { - memcpy(pDestKey, pSrcKey, sizeof(CRYPTKEY)); + *pDestKey = *pSrcKey; copy_data_blob(&pDestKey->siSChannelInfo.blobServerRandom, &pSrcKey->siSChannelInfo.blobServerRandom); copy_data_blob(&pDestKey->siSChannelInfo.blobClientRandom, @@ -2115,9 +2114,9 @@ BOOL WINAPI RSAENH_CPDecrypt(HCRYPTPROV hProv, HCRYPTKEY hKey, HCRYPTHASH hHash, } if (pCryptKey->dwState == RSAENH_KEYSTATE_IDLE) - pCryptKey->dwState = RSAENH_KEYSTATE_DECRYPTING; + pCryptKey->dwState = RSAENH_KEYSTATE_ENCRYPTING; - if (pCryptKey->dwState != RSAENH_KEYSTATE_DECRYPTING) + if (pCryptKey->dwState != RSAENH_KEYSTATE_ENCRYPTING) { SetLastError(NTE_BAD_DATA); return FALSE; @@ -3028,11 +3027,11 @@ BOOL WINAPI RSAENH_CPGetProvParam(HCRYPTPROV hProv, DWORD dwParam, BYTE *pbData, DWORD dwTemp; HKEY hKey; - /* This is for dwParam 41, which does not seem to be documented - * on MSDN. IE6 SP1 asks for it in the 'About' dialog, however. + /* This is for dwParam PP_CRYPT_COUNT_KEY_USE. + * IE6 SP1 asks for it in the 'About' dialog. * Returning this BLOB seems to satisfy IE. The marked 0x00 seem * to be 'don't care's. If you know anything more specific about - * provider parameter 41, please report to wine-devel@winehq.org */ + * this provider parameter, please report to wine-devel@winehq.org */ static CONST BYTE abWTF[96] = { 0xb0, 0x25, 0x63, 0x86, 0x9c, 0xab, 0xb6, 0x37, 0xe8, 0x82, /**/0x00,/**/ 0x72, 0x06, 0xb2, /**/0x00,/**/ 0x3b, @@ -3176,7 +3175,7 @@ BOOL WINAPI RSAENH_CPGetProvParam(HCRYPTPROV hProv, DWORD dwParam, BYTE *pbData, sizeof(PROV_ENUMALGS_EX)); } - case 41: /* Undocumented. Asked for by IE About dialog */ + case PP_CRYPT_COUNT_KEY_USE: /* Asked for by IE About dialog */ return copy_param(pbData, pdwDataLen, abWTF, sizeof(abWTF)); default: diff --git a/reactos/dll/win32/rsaenh/rsaenh.rbuild b/reactos/dll/win32/rsaenh/rsaenh.rbuild index 0cf33901c34..e9805c06545 100644 --- a/reactos/dll/win32/rsaenh/rsaenh.rbuild +++ b/reactos/dll/win32/rsaenh/rsaenh.rbuild @@ -9,11 +9,6 @@ 0x600 0x600 - wine - crypt32 - advapi32 - kernel32 - ntdll aes.c des.c handle.c @@ -26,5 +21,10 @@ rsaenh.c version.rc rsaenh.spec + wine + crypt32 + advapi32 + kernel32 + ntdll