Hi Nikolay,
Is there a reason why you didn't include tests in this series?
Alistair.
From: Michael Müller <michael@fds-team.de> Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> --- dlls/crypt32/decode.c | 45 +++++++++++++++++++++++++++++++++++++++++++ include/wincrypt.h | 15 +++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/dlls/crypt32/decode.c b/dlls/crypt32/decode.c index a61316016f..4f11d0d60f 100644 --- a/dlls/crypt32/decode.c +++ b/dlls/crypt32/decode.c @@ -5973,6 +5973,46 @@ BOOL CRYPT_AsnDecodePKCSEnvelopedData(const BYTE *pbEncoded, DWORD cbEncoded, return ret; } +static BOOL WINAPI CRYPT_AsnDecodeObjectIdentifier(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + CRYPT_DECODE_PARA *pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) +{ + DWORD bytesNeeded = 0; + BOOL ret; + + __TRY + { + ret = CRYPT_AsnDecodeOidInternal(pbEncoded, cbEncoded, dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, + NULL, &bytesNeeded, NULL); + if (ret) + { + if (!pvStructInfo) + *pcbStructInfo = bytesNeeded; + else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, pvStructInfo, pcbStructInfo, bytesNeeded))) + { + LPSTR *info; + + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + + info = pvStructInfo; + *info = (void *)((BYTE *)info + sizeof(*info)); + ret = CRYPT_AsnDecodeOidInternal(pbEncoded, cbEncoded, dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, + pvStructInfo, &bytesNeeded, NULL); + if (!ret && (dwFlags & CRYPT_DECODE_ALLOC_FLAG)) + CRYPT_FreeSpace(pDecodePara, info); + } + } + } + __EXCEPT_PAGE_FAULT + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY + return ret; +} + static CryptDecodeObjectExFunc CRYPT_GetBuiltinDecoder(DWORD dwCertEncodingType, LPCSTR lpszStructType) { @@ -6112,6 +6152,9 @@ static CryptDecodeObjectExFunc CRYPT_GetBuiltinDecoder(DWORD dwCertEncodingType, case LOWORD(CMS_SIGNER_INFO): decodeFunc = CRYPT_AsnDecodeCMSSignerInfo; break; + case LOWORD(X509_OBJECT_IDENTIFIER): + decodeFunc = CRYPT_AsnDecodeObjectIdentifier; + break; } } else if (!strcmp(lpszStructType, szOID_CERT_EXTENSIONS)) @@ -6166,6 +6209,8 @@ static CryptDecodeObjectExFunc CRYPT_GetBuiltinDecoder(DWORD dwCertEncodingType, decodeFunc = CRYPT_AsnDecodePolicyQualifierUserNotice; else if (!strcmp(lpszStructType, szOID_CTL)) decodeFunc = CRYPT_AsnDecodeCTL; + else if (!strcmp(lpszStructType, szOID_ECC_PUBLIC_KEY)) + decodeFunc = CRYPT_AsnDecodeObjectIdentifier; return decodeFunc; } diff --git a/include/wincrypt.h b/include/wincrypt.h index 6e71fb902e..a7c24e7831 100644 --- a/include/wincrypt.h +++ b/include/wincrypt.h @@ -288,6 +288,11 @@ typedef struct _CERT_KEY_ATTRIBUTES_INFO { PCERT_PRIVATE_KEY_VALIDITY pPrivateKeyUsagePeriod; } CERT_KEY_ATTRIBUTES_INFO, *PCERT_KEY_ATTRIBUTES_INFO; +typedef struct _CERT_ECC_SIGNATURE { + CRYPT_UINT_BLOB r; + CRYPT_UINT_BLOB s; +} CERT_ECC_SIGNATURE, *PCERT_ECC_SIGNATURE; + /* byte 0 */ #define CERT_DIGITAL_SIGNATURE_KEY_USAGE 0x80 #define CERT_NON_REPUDIATION_KEY_USAGE 0x40 @@ -2878,6 +2883,12 @@ typedef struct _CTL_FIND_SUBJECT_PARA #define szOID_X957 "1.2.840.10040" #define szOID_X957_DSA "1.2.840.10040.4.1" #define szOID_X957_SHA1DSA "1.2.840.10040.4.3" +#define szOID_ECC_PUBLIC_KEY "1.2.840.10045.2.1" +#define szOID_ECC_CURVE_P256 "1.2.840.10045.3.1.7" +#define szOID_ECDSA_SPECIFIED "1.2.840.10045.4.3" +#define szOID_ECDSA_SHA256 "1.2.840.10045.4.3.2" +#define szOID_ECDSA_SHA384 "1.2.840.10045.4.3.3" +#define szOID_ECDSA_SHA512 "1.2.840.10045.4.3.4" #define szOID_DS "2.5" #define szOID_DSALG "2.5.8" #define szOID_DSALG_CRPT "2.5.8.1" @@ -2919,6 +2930,8 @@ typedef struct _CTL_FIND_SUBJECT_PARA #define szOID_OIWDIR_SIGN "1.3.14.7.2.3" #define szOID_OIWDIR_md2 "1.3.14.7.2.2.1" #define szOID_OIWDIR_md2RSA "1.3.14.7.2.3.1" +#define szOID_ECC_CURVE_P384 "1.3.132.0.34" +#define szOID_ECC_CURVE_P521 "1.3.132.0.35" #define szOID_INFOSEC "2.16.840.1.101.2.1" #define szOID_INFOSEC_sdnsSignature "2.16.840.1.101.2.1.1.1" #define szOID_INFOSEC_mosaicSignature "2.16.840.1.101.2.1.1.2" @@ -3223,6 +3236,7 @@ typedef struct _CTL_FIND_SUBJECT_PARA #define X509_PKIX_POLICY_QUALIFIER_USERNOTICE ((LPCSTR)46) #define X509_DH_PUBLICKEY X509_MULTI_BYTE_UINT #define X509_DH_PARAMETERS ((LPCSTR)47) +#define X509_ECC_SIGNATURE ((LPCSTR)47) #define PKCS_ATTRIBUTES ((LPCSTR)48) #define PKCS_SORTED_CTL ((LPCSTR)49) #define X942_DH_PARAMETERS ((LPCSTR)50) @@ -3240,6 +3254,7 @@ typedef struct _CTL_FIND_SUBJECT_PARA #define CMC_ADD_EXTENSIONS ((LPCSTR)62) #define CMC_ADD_ATTRIBUTES ((LPCSTR)63) #define X509_CERTIFICATE_TEMPLATE ((LPCSTR)64) +#define X509_OBJECT_IDENTIFIER ((LPCSTR)73) #define PKCS7_SIGNER_INFO ((LPCSTR)500) #define CMS_SIGNER_INFO ((LPCSTR)501)