[CRYPT32] Sync with Wine Staging 1.7.47. CORE-9924

svn path=/trunk/; revision=68426
This commit is contained in:
Amine Khaldi 2015-07-19 13:13:36 +00:00
parent cf784b770c
commit c8467f6d31
3 changed files with 153 additions and 6 deletions

View file

@ -459,7 +459,7 @@ void ContextPropertyList_Copy(CONTEXT_PROPERTY_LIST *to,
void ContextPropertyList_Free(CONTEXT_PROPERTY_LIST *list) DECLSPEC_HIDDEN;
extern WINECRYPT_CERTSTORE empty_store;
extern WINECRYPT_CERTSTORE empty_store DECLSPEC_HIDDEN;
void init_empty_store(void) DECLSPEC_HIDDEN;
/**

View file

@ -3919,6 +3919,147 @@ static BOOL WINAPI CRYPT_AsnDecodeRsaPubKey(DWORD dwCertEncodingType,
return ret;
}
#define RSA2_MAGIC 0x32415352
struct DECODED_RSA_PRIV_KEY
{
DWORD version;
DWORD pubexp;
CRYPT_INTEGER_BLOB modulus;
CRYPT_INTEGER_BLOB privexp;
CRYPT_INTEGER_BLOB prime1;
CRYPT_INTEGER_BLOB prime2;
CRYPT_INTEGER_BLOB exponent1;
CRYPT_INTEGER_BLOB exponent2;
CRYPT_INTEGER_BLOB coefficient;
};
static BOOL WINAPI CRYPT_AsnDecodeRsaPrivKey(DWORD dwCertEncodingType,
LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo)
{
BOOL ret;
DWORD halflen;
__TRY
{
struct AsnDecodeSequenceItem items[] = {
{ ASN_INTEGER, offsetof(struct DECODED_RSA_PRIV_KEY, version),
CRYPT_AsnDecodeIntInternal, sizeof(DWORD), FALSE, FALSE, 0, 0 },
{ ASN_INTEGER, offsetof(struct DECODED_RSA_PRIV_KEY, modulus),
CRYPT_AsnDecodeUnsignedIntegerInternal, sizeof(CRYPT_INTEGER_BLOB),
FALSE, TRUE, offsetof(struct DECODED_RSA_PRIV_KEY, modulus.pbData),
0 },
{ ASN_INTEGER, offsetof(struct DECODED_RSA_PRIV_KEY, pubexp),
CRYPT_AsnDecodeIntInternal, sizeof(DWORD), FALSE, FALSE, 0, 0 },
{ ASN_INTEGER, offsetof(struct DECODED_RSA_PRIV_KEY, privexp),
CRYPT_AsnDecodeUnsignedIntegerInternal, sizeof(CRYPT_INTEGER_BLOB),
FALSE, TRUE, offsetof(struct DECODED_RSA_PRIV_KEY, privexp.pbData),
0 },
{ ASN_INTEGER, offsetof(struct DECODED_RSA_PRIV_KEY, prime1),
CRYPT_AsnDecodeUnsignedIntegerInternal, sizeof(CRYPT_INTEGER_BLOB),
FALSE, TRUE, offsetof(struct DECODED_RSA_PRIV_KEY, prime1.pbData),
0 },
{ ASN_INTEGER, offsetof(struct DECODED_RSA_PRIV_KEY, prime2),
CRYPT_AsnDecodeUnsignedIntegerInternal, sizeof(CRYPT_INTEGER_BLOB),
FALSE, TRUE, offsetof(struct DECODED_RSA_PRIV_KEY, prime2.pbData),
0 },
{ ASN_INTEGER, offsetof(struct DECODED_RSA_PRIV_KEY, exponent1),
CRYPT_AsnDecodeUnsignedIntegerInternal, sizeof(CRYPT_INTEGER_BLOB),
FALSE, TRUE, offsetof(struct DECODED_RSA_PRIV_KEY, exponent1.pbData),
0 },
{ ASN_INTEGER, offsetof(struct DECODED_RSA_PRIV_KEY, exponent2),
CRYPT_AsnDecodeUnsignedIntegerInternal, sizeof(CRYPT_INTEGER_BLOB),
FALSE, TRUE, offsetof(struct DECODED_RSA_PRIV_KEY, exponent2.pbData),
0 },
{ ASN_INTEGER, offsetof(struct DECODED_RSA_PRIV_KEY, coefficient),
CRYPT_AsnDecodeUnsignedIntegerInternal, sizeof(CRYPT_INTEGER_BLOB),
FALSE, TRUE, offsetof(struct DECODED_RSA_PRIV_KEY, coefficient.pbData),
0 },
};
struct DECODED_RSA_PRIV_KEY *decodedKey = NULL;
DWORD size = 0;
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
pbEncoded, cbEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL, &decodedKey,
&size, NULL, NULL);
if (ret)
{
halflen = decodedKey->modulus.cbData / 2;
if ((decodedKey->modulus.cbData != halflen * 2) ||
(decodedKey->prime1.cbData != halflen) ||
(decodedKey->prime2.cbData != halflen) ||
(decodedKey->exponent1.cbData != halflen) ||
(decodedKey->exponent2.cbData != halflen) ||
(decodedKey->coefficient.cbData != halflen) ||
(decodedKey->privexp.cbData != halflen * 2))
{
ret = FALSE;
SetLastError(CRYPT_E_BAD_ENCODE);
}
if (ret)
{
DWORD bytesNeeded = sizeof(BLOBHEADER) + sizeof(RSAPUBKEY) +
(halflen * 9);
if (!pvStructInfo)
{
*pcbStructInfo = bytesNeeded;
ret = TRUE;
}
else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara,
pvStructInfo, pcbStructInfo, bytesNeeded)))
{
BLOBHEADER *hdr;
RSAPUBKEY *rsaPubKey;
BYTE *vardata;
if (dwFlags & CRYPT_DECODE_ALLOC_FLAG)
pvStructInfo = *(BYTE **)pvStructInfo;
hdr = pvStructInfo;
hdr->bType = PRIVATEKEYBLOB;
hdr->bVersion = CUR_BLOB_VERSION;
hdr->reserved = 0;
hdr->aiKeyAlg = CALG_RSA_KEYX;
rsaPubKey = (RSAPUBKEY *)((BYTE *)pvStructInfo +
sizeof(BLOBHEADER));
rsaPubKey->magic = RSA2_MAGIC;
rsaPubKey->pubexp = decodedKey->pubexp;
rsaPubKey->bitlen = halflen * 16;
vardata = (BYTE*)(rsaPubKey + 1);
memcpy(vardata,
decodedKey->modulus.pbData, halflen * 2);
memcpy(vardata + halflen * 2,
decodedKey->prime1.pbData, halflen);
memcpy(vardata + halflen * 3,
decodedKey->prime2.pbData, halflen);
memcpy(vardata + halflen * 4,
decodedKey->exponent1.pbData, halflen);
memcpy(vardata + halflen * 5,
decodedKey->exponent2.pbData, halflen);
memcpy(vardata + halflen * 6,
decodedKey->coefficient.pbData, halflen);
memcpy(vardata + halflen * 7,
decodedKey->privexp.pbData, halflen * 2);
}
}
LocalFree(decodedKey);
}
}
__EXCEPT_PAGE_FAULT
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
__ENDTRY
return ret;
}
static BOOL CRYPT_AsnDecodeOctetsInternal(const BYTE *pbEncoded,
DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo,
DWORD *pcbDecoded)
@ -5485,6 +5626,9 @@ static BOOL CRYPT_AsnDecodeCMSSignerInfoInternal(const BYTE *pbEncoded,
offsetof(CMSG_CMS_SIGNER_INFO, AuthAttrs),
CRYPT_AsnDecodePKCSAttributesInternal, sizeof(CRYPT_ATTRIBUTES),
TRUE, TRUE, offsetof(CMSG_CMS_SIGNER_INFO, AuthAttrs.rgAttr), 0 },
/* FIXME: Tests show that CertOpenStore accepts such certificates, but
* how exactly should they be interpreted? */
{ ASN_CONSTRUCTOR | ASN_UNIVERSAL | 0x11, 0, NULL, 0, TRUE, FALSE, 0, 0 },
{ ASN_SEQUENCEOF, offsetof(CMSG_CMS_SIGNER_INFO, HashEncryptionAlgorithm),
CRYPT_AsnDecodeAlgorithmId, sizeof(CRYPT_ALGORITHM_IDENTIFIER),
FALSE, TRUE, offsetof(CMSG_CMS_SIGNER_INFO,
@ -5599,8 +5743,8 @@ BOOL CRYPT_AsnDecodeCMSSignedInfo(const BYTE *pbEncoded, DWORD cbEncoded,
offsetof(CRYPT_SIGNED_INFO, rgSignerInfo), 0 },
};
TRACE("%p, %d, %08x, %p, %p, %d\n", pbEncoded, cbEncoded, dwFlags,
pDecodePara, signedInfo, *pcbSignedInfo);
TRACE("%p, %d, %08x, %p, %p, %p\n", pbEncoded, cbEncoded, dwFlags,
pDecodePara, signedInfo, pcbSignedInfo);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
pbEncoded, cbEncoded, dwFlags, pDecodePara, signedInfo, pcbSignedInfo,
@ -5717,8 +5861,8 @@ BOOL CRYPT_AsnDecodePKCSEnvelopedData(const BYTE *pbEncoded, DWORD cbEncoded,
offsetof(CRYPT_ENVELOPED_DATA, encryptedContentInfo.contentType), 0 },
};
TRACE("%p, %d, %08x, %p, %p, %d\n", pbEncoded, cbEncoded, dwFlags,
pDecodePara, envelopedData, *pcbEnvelopedData);
TRACE("%p, %d, %08x, %p, %p, %p\n", pbEncoded, cbEncoded, dwFlags,
pDecodePara, envelopedData, pcbEnvelopedData);
ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
pbEncoded, cbEncoded, dwFlags, pDecodePara, envelopedData,
@ -5781,6 +5925,9 @@ static CryptDecodeObjectExFunc CRYPT_GetBuiltinDecoder(DWORD dwCertEncodingType,
case LOWORD(RSA_CSP_PUBLICKEYBLOB):
decodeFunc = CRYPT_AsnDecodeRsaPubKey;
break;
case LOWORD(PKCS_RSA_PRIVATE_KEY):
decodeFunc = CRYPT_AsnDecodeRsaPrivKey;
break;
case LOWORD(X509_UNICODE_NAME):
decodeFunc = CRYPT_AsnDecodeUnicodeName;
break;

View file

@ -59,7 +59,7 @@ reactos/dll/win32/comctl32 # Synced to WineStaging-1.7.37
reactos/dll/win32/comdlg32 # Synced to WineStaging-1.7.37
reactos/dll/win32/compstui # Synced to WineStaging-1.7.37
reactos/dll/win32/credui # Synced to WineStaging-1.7.37
reactos/dll/win32/crypt32 # Synced to WineStaging-1.7.37
reactos/dll/win32/crypt32 # Synced to WineStaging-1.7.47
reactos/dll/win32/cryptdlg # Synced to WineStaging-1.7.37
reactos/dll/win32/cryptdll # Synced to WineStaging-1.7.37
reactos/dll/win32/cryptnet # Synced to WineStaging-1.7.37