Commit 8327b063 authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

crypt32: Zero-pad RSA Private Key values as needed to fit PRIVATEKEYBLOB.

parent 59ba888e
...@@ -4002,18 +4002,19 @@ static BOOL WINAPI CRYPT_AsnDecodeRsaPrivKey(DWORD dwCertEncodingType, ...@@ -4002,18 +4002,19 @@ static BOOL WINAPI CRYPT_AsnDecodeRsaPrivKey(DWORD dwCertEncodingType,
&size, NULL, NULL); &size, NULL, NULL);
if (ret) if (ret)
{ {
halflen = decodedKey->modulus.cbData / 2; halflen = decodedKey->prime1.cbData;
if ((decodedKey->modulus.cbData != halflen * 2) || if (halflen < decodedKey->prime2.cbData)
(decodedKey->prime1.cbData != halflen) || halflen = decodedKey->prime2.cbData;
(decodedKey->prime2.cbData != halflen) || if (halflen < decodedKey->exponent1.cbData)
(decodedKey->exponent1.cbData != halflen) || halflen = decodedKey->exponent1.cbData;
(decodedKey->exponent2.cbData != halflen) || if (halflen < decodedKey->exponent2.cbData)
(decodedKey->coefficient.cbData != halflen) || halflen = decodedKey->exponent2.cbData;
(decodedKey->privexp.cbData != halflen * 2)) if (halflen < decodedKey->coefficient.cbData)
{ halflen = decodedKey->coefficient.cbData;
ret = FALSE; if (halflen * 2 < decodedKey->modulus.cbData)
SetLastError(CRYPT_E_BAD_ENCODE); halflen = decodedKey->modulus.cbData / 2 + decodedKey->modulus.cbData % 2;
} if (halflen * 2 < decodedKey->privexp.cbData)
halflen = decodedKey->privexp.cbData / 2 + decodedKey->privexp.cbData % 2;
if (ret) if (ret)
{ {
...@@ -4048,20 +4049,21 @@ static BOOL WINAPI CRYPT_AsnDecodeRsaPrivKey(DWORD dwCertEncodingType, ...@@ -4048,20 +4049,21 @@ static BOOL WINAPI CRYPT_AsnDecodeRsaPrivKey(DWORD dwCertEncodingType,
rsaPubKey->bitlen = halflen * 16; rsaPubKey->bitlen = halflen * 16;
vardata = (BYTE*)(rsaPubKey + 1); vardata = (BYTE*)(rsaPubKey + 1);
memset(vardata, 0, halflen * 9);
memcpy(vardata, memcpy(vardata,
decodedKey->modulus.pbData, halflen * 2); decodedKey->modulus.pbData, decodedKey->modulus.cbData);
memcpy(vardata + halflen * 2, memcpy(vardata + halflen * 2,
decodedKey->prime1.pbData, halflen); decodedKey->prime1.pbData, decodedKey->prime1.cbData);
memcpy(vardata + halflen * 3, memcpy(vardata + halflen * 3,
decodedKey->prime2.pbData, halflen); decodedKey->prime2.pbData, decodedKey->prime2.cbData);
memcpy(vardata + halflen * 4, memcpy(vardata + halflen * 4,
decodedKey->exponent1.pbData, halflen); decodedKey->exponent1.pbData, decodedKey->exponent1.cbData);
memcpy(vardata + halflen * 5, memcpy(vardata + halflen * 5,
decodedKey->exponent2.pbData, halflen); decodedKey->exponent2.pbData, decodedKey->exponent2.cbData);
memcpy(vardata + halflen * 6, memcpy(vardata + halflen * 6,
decodedKey->coefficient.pbData, halflen); decodedKey->coefficient.pbData, decodedKey->coefficient.cbData);
memcpy(vardata + halflen * 7, memcpy(vardata + halflen * 7,
decodedKey->privexp.pbData, halflen * 2); decodedKey->privexp.pbData, decodedKey->privexp.cbData);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment