crypt32: Support the KeyId type of signer in CMSG_SIGNER_INFO_PARAM.
This commit is contained in:
parent
57a85f0d6b
commit
51b16fb857
|
@ -1977,10 +1977,58 @@ static DWORD CRYPT_SizeOfAttributes(const CRYPT_ATTRIBUTES *attr)
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DWORD CRYPT_SizeOfKeyIdAsIssuerAndSerial(const CRYPT_DATA_BLOB *keyId)
|
||||||
|
{
|
||||||
|
static char oid_key_rdn[] = szOID_KEYID_RDN;
|
||||||
|
DWORD size = 0;
|
||||||
|
CERT_RDN_ATTR attr;
|
||||||
|
CERT_RDN rdn = { 1, &attr };
|
||||||
|
CERT_NAME_INFO name = { 1, &rdn };
|
||||||
|
|
||||||
|
attr.pszObjId = oid_key_rdn;
|
||||||
|
attr.dwValueType = CERT_RDN_OCTET_STRING;
|
||||||
|
attr.Value.cbData = keyId->cbData;
|
||||||
|
attr.Value.pbData = keyId->pbData;
|
||||||
|
if (CryptEncodeObject(X509_ASN_ENCODING, X509_NAME, &name, NULL, &size))
|
||||||
|
size++; /* Only include size of special zero serial number on success */
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL CRYPT_CopyKeyIdAsIssuerAndSerial(CERT_NAME_BLOB *issuer,
|
||||||
|
CRYPT_INTEGER_BLOB *serialNumber, const CRYPT_DATA_BLOB *keyId, DWORD encodedLen,
|
||||||
|
LPBYTE *nextData)
|
||||||
|
{
|
||||||
|
static char oid_key_rdn[] = szOID_KEYID_RDN;
|
||||||
|
CERT_RDN_ATTR attr;
|
||||||
|
CERT_RDN rdn = { 1, &attr };
|
||||||
|
CERT_NAME_INFO name = { 1, &rdn };
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
|
/* Encode special zero serial number */
|
||||||
|
serialNumber->cbData = 1;
|
||||||
|
serialNumber->pbData = *nextData;
|
||||||
|
**nextData = 0;
|
||||||
|
(*nextData)++;
|
||||||
|
/* Encode issuer */
|
||||||
|
issuer->pbData = *nextData;
|
||||||
|
attr.pszObjId = oid_key_rdn;
|
||||||
|
attr.dwValueType = CERT_RDN_OCTET_STRING;
|
||||||
|
attr.Value.cbData = keyId->cbData;
|
||||||
|
attr.Value.pbData = keyId->pbData;
|
||||||
|
ret = CryptEncodeObject(X509_ASN_ENCODING, X509_NAME, &name, *nextData,
|
||||||
|
&encodedLen);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
*nextData += encodedLen;
|
||||||
|
issuer->cbData = encodedLen;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static BOOL CRYPT_CopySignerInfo(void *pvData, DWORD *pcbData,
|
static BOOL CRYPT_CopySignerInfo(void *pvData, DWORD *pcbData,
|
||||||
const CMSG_CMS_SIGNER_INFO *in)
|
const CMSG_CMS_SIGNER_INFO *in)
|
||||||
{
|
{
|
||||||
DWORD size = sizeof(CMSG_SIGNER_INFO);
|
DWORD size = sizeof(CMSG_SIGNER_INFO), rdnSize;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
TRACE("(%p, %d, %p)\n", pvData, pvData ? *pcbData : 0, in);
|
TRACE("(%p, %d, %p)\n", pvData, pvData ? *pcbData : 0, in);
|
||||||
|
@ -1992,8 +2040,8 @@ static BOOL CRYPT_CopySignerInfo(void *pvData, DWORD *pcbData,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FIXME("unsupported for key id\n");
|
rdnSize = CRYPT_SizeOfKeyIdAsIssuerAndSerial(&in->SignerId.KeyId);
|
||||||
return FALSE;
|
size += rdnSize;
|
||||||
}
|
}
|
||||||
if (in->HashAlgorithm.pszObjId)
|
if (in->HashAlgorithm.pszObjId)
|
||||||
size += strlen(in->HashAlgorithm.pszObjId) + 1;
|
size += strlen(in->HashAlgorithm.pszObjId) + 1;
|
||||||
|
@ -2023,6 +2071,7 @@ static BOOL CRYPT_CopySignerInfo(void *pvData, DWORD *pcbData,
|
||||||
LPBYTE nextData = (BYTE *)pvData + sizeof(CMSG_SIGNER_INFO);
|
LPBYTE nextData = (BYTE *)pvData + sizeof(CMSG_SIGNER_INFO);
|
||||||
CMSG_SIGNER_INFO *out = (CMSG_SIGNER_INFO *)pvData;
|
CMSG_SIGNER_INFO *out = (CMSG_SIGNER_INFO *)pvData;
|
||||||
|
|
||||||
|
ret = TRUE;
|
||||||
out->dwVersion = in->dwVersion;
|
out->dwVersion = in->dwVersion;
|
||||||
if (in->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER)
|
if (in->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER)
|
||||||
{
|
{
|
||||||
|
@ -2031,6 +2080,11 @@ static BOOL CRYPT_CopySignerInfo(void *pvData, DWORD *pcbData,
|
||||||
CRYPT_CopyBlob(&out->SerialNumber,
|
CRYPT_CopyBlob(&out->SerialNumber,
|
||||||
&in->SignerId.IssuerSerialNumber.SerialNumber, &nextData);
|
&in->SignerId.IssuerSerialNumber.SerialNumber, &nextData);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
ret = CRYPT_CopyKeyIdAsIssuerAndSerial(&out->Issuer, &out->SerialNumber,
|
||||||
|
&in->SignerId.KeyId, rdnSize, &nextData);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
CRYPT_CopyAlgorithmId(&out->HashAlgorithm, &in->HashAlgorithm,
|
CRYPT_CopyAlgorithmId(&out->HashAlgorithm, &in->HashAlgorithm,
|
||||||
&nextData);
|
&nextData);
|
||||||
CRYPT_CopyAlgorithmId(&out->HashEncryptionAlgorithm,
|
CRYPT_CopyAlgorithmId(&out->HashEncryptionAlgorithm,
|
||||||
|
@ -2041,7 +2095,7 @@ static BOOL CRYPT_CopySignerInfo(void *pvData, DWORD *pcbData,
|
||||||
nextData += (nextData - (LPBYTE)0) % sizeof(DWORD_PTR);
|
nextData += (nextData - (LPBYTE)0) % sizeof(DWORD_PTR);
|
||||||
CRYPT_CopyAttributes(&out->AuthAttrs, &in->AuthAttrs, &nextData);
|
CRYPT_CopyAttributes(&out->AuthAttrs, &in->AuthAttrs, &nextData);
|
||||||
CRYPT_CopyAttributes(&out->UnauthAttrs, &in->UnauthAttrs, &nextData);
|
CRYPT_CopyAttributes(&out->UnauthAttrs, &in->UnauthAttrs, &nextData);
|
||||||
ret = TRUE;
|
}
|
||||||
}
|
}
|
||||||
TRACE("returning %d\n", ret);
|
TRACE("returning %d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -2469,7 +2469,6 @@ static void test_decode_msg_get_param(void)
|
||||||
*/
|
*/
|
||||||
size = 0;
|
size = 0;
|
||||||
ret = CryptMsgGetParam(msg, CMSG_SIGNER_INFO_PARAM, 0, NULL, &size);
|
ret = CryptMsgGetParam(msg, CMSG_SIGNER_INFO_PARAM, 0, NULL, &size);
|
||||||
todo_wine
|
|
||||||
ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
|
ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
|
||||||
if (ret)
|
if (ret)
|
||||||
buf = CryptMemAlloc(size);
|
buf = CryptMemAlloc(size);
|
||||||
|
|
Loading…
Reference in New Issue