Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/crypt32/tests/oid.c | 73 +++++++++++++++------------------------- 1 file changed, 27 insertions(+), 46 deletions(-)
diff --git a/dlls/crypt32/tests/oid.c b/dlls/crypt32/tests/oid.c index 8fc67b3353..0e1442334f 100644 --- a/dlls/crypt32/tests/oid.c +++ b/dlls/crypt32/tests/oid.c @@ -547,58 +547,39 @@ static void test_findOIDInfo(void) static CHAR oid_rsa_md5[] = szOID_RSA_MD5, oid_sha256[] = szOID_NIST_sha256; ALG_ID alg = CALG_SHA1; ALG_ID algs[2] = { CALG_MD5, CALG_RSA_SIGN }; + const struct oid_info + { + DWORD key_type; + void *key; + const char *oid; + ALG_ID algid; + ALG_ID broken_algid; + } oid_test_info [] = + { + { CRYPT_OID_INFO_OID_KEY, oid_rsa_md5, szOID_RSA_MD5, CALG_MD5 }, + { CRYPT_OID_INFO_NAME_KEY, sha1, szOID_OIWSEC_sha1, CALG_SHA1 }, + { CRYPT_OID_INFO_ALGID_KEY, &alg, szOID_OIWSEC_sha1, CALG_SHA1 }, + { CRYPT_OID_INFO_SIGN_KEY, algs, szOID_RSA_MD5RSA, CALG_MD5 }, + { CRYPT_OID_INFO_OID_KEY, oid_sha256, szOID_NIST_sha256, CALG_SHA_256, -1 }, + }; PCCRYPT_OID_INFO info; - - static const WCHAR sha256W[] = {'s','h','a','2','5','6',0}; + int i;
info = CryptFindOIDInfo(0, NULL, 0); ok(info == NULL, "Expected NULL\n"); - info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, oid_rsa_md5, 0); - ok(info != NULL, "Expected to find szOID_RSA_MD5\n"); - if (info) - { - ok(!strcmp(info->pszOID, szOID_RSA_MD5), "Expected %s, got %s\n", - szOID_RSA_MD5, info->pszOID); - ok(U(*info).Algid == CALG_MD5, "Expected CALG_MD5, got %d\n", - U(*info).Algid); - } - info = CryptFindOIDInfo(CRYPT_OID_INFO_NAME_KEY, sha1, 0); - ok(info != NULL, "Expected to find sha1\n"); - if (info) - { - ok(!strcmp(info->pszOID, szOID_OIWSEC_sha1), "Expected %s, got %s\n", - szOID_OIWSEC_sha1, info->pszOID); - ok(U(*info).Algid == CALG_SHA1, "Expected CALG_SHA1, got %d\n", - U(*info).Algid); - } - info = CryptFindOIDInfo(CRYPT_OID_INFO_ALGID_KEY, &alg, 0); - ok(info != NULL, "Expected to find sha1\n"); - if (info) - { - ok(!strcmp(info->pszOID, szOID_OIWSEC_sha1), "Expected %s, got %s\n", - szOID_OIWSEC_sha1, info->pszOID); - ok(U(*info).Algid == CALG_SHA1, "Expected CALG_SHA1, got %d\n", - U(*info).Algid); - } - info = CryptFindOIDInfo(CRYPT_OID_INFO_SIGN_KEY, algs, 0); - ok(info != NULL, "Expected to find md5RSA\n"); - if (info) - { - ok(!strcmp(info->pszOID, szOID_RSA_MD5RSA), "Expected %s, got %s\n", - szOID_RSA_MD5RSA, info->pszOID); - ok(U(*info).Algid == CALG_MD5, "Expected CALG_MD5, got %d\n", - U(*info).Algid); - }
- info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, oid_sha256, 0); - ok(info != NULL, "Expected to find szOID_RSA_MD5\n"); - if (info) + for (i = 0; i < ARRAY_SIZE(oid_test_info); i++) { - ok(!strcmp(info->pszOID, szOID_NIST_sha256), "Expected %s, got %s\n", - szOID_NIST_sha256, info->pszOID); - ok(!lstrcmpW(info->pwszName, sha256W), "pwszName = %s\n", wine_dbgstr_w(info->pwszName)); - ok(U(*info).Algid == CALG_SHA_256 || U(*info).Algid == -1, - "Expected CALG_MD5 or -1, got %d\n", U(*info).Algid); + const struct oid_info *test = &oid_test_info[i]; + + info = CryptFindOIDInfo(test->key_type, test->key, 0); + ok(info != NULL, "Failed to find %s.\n", test->oid); + if (info) + { + ok(!strcmp(info->pszOID, test->oid), "Unexpected OID %s, expected %s\n", info->pszOID, test->oid); + ok(U(*info).Algid == test->algid || broken(U(*info).Algid == test->broken_algid), + "Unexpected Algid %d, expected %d\n", U(*info).Algid, test->algid); + } } }
From: Michael Müller michael@fds-team.de
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/crypt32/tests/oid.c | 31 +++++++++++++++++++++++++++++++ include/wincrypt.h | 15 +++++++++++++++ 2 files changed, 46 insertions(+)
diff --git a/dlls/crypt32/tests/oid.c b/dlls/crypt32/tests/oid.c index 0e1442334f..00a6d5461e 100644 --- a/dlls/crypt32/tests/oid.c +++ b/dlls/crypt32/tests/oid.c @@ -22,6 +22,7 @@ #include <windef.h> #include <winbase.h> #include <winerror.h> +#define CRYPT_OID_INFO_HAS_EXTRA_FIELDS #include <wincrypt.h> #include <winreg.h>
@@ -543,8 +544,10 @@ static void test_enumOIDInfo(void)
static void test_findOIDInfo(void) { + static WCHAR sha256ECDSA[] = { 's','h','a','2','5','6','E','C','D','S','A',0 }; static WCHAR sha1[] = { 's','h','a','1',0 }; static CHAR oid_rsa_md5[] = szOID_RSA_MD5, oid_sha256[] = szOID_NIST_sha256; + static CHAR oid_ecdsa_sha256[] = szOID_ECDSA_SHA256; ALG_ID alg = CALG_SHA1; ALG_ID algs[2] = { CALG_MD5, CALG_RSA_SIGN }; const struct oid_info @@ -581,6 +584,34 @@ static void test_findOIDInfo(void) "Unexpected Algid %d, expected %d\n", U(*info).Algid, test->algid); } } + + info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, oid_ecdsa_sha256, 0); + if (info) + { + DWORD *data; + + ok(info->cbSize == sizeof(*info), "Unexpected structure size %d.\n", info->cbSize); + ok(!strcmp(info->pszOID, oid_ecdsa_sha256), "Expected %s, got %s\n", oid_ecdsa_sha256, info->pszOID); + ok(!lstrcmpW(info->pwszName, sha256ECDSA), "Expected %s, got %s\n", + wine_dbgstr_w(sha256ECDSA), wine_dbgstr_w(info->pwszName)); + ok(info->dwGroupId == CRYPT_SIGN_ALG_OID_GROUP_ID, + "Expected CRYPT_SIGN_ALG_OID_GROUP_ID, got %u\n", info->dwGroupId); + ok(U(*info).Algid == CALG_OID_INFO_CNG_ONLY, + "Expected CALG_OID_INFO_CNG_ONLY, got %d\n", U(*info).Algid); + + data = (DWORD *)info->ExtraInfo.pbData; + ok(info->ExtraInfo.cbData == 8, "Expected 8, got %d\n", info->ExtraInfo.cbData); + ok(data[0] == CALG_OID_INFO_PARAMETERS, "Expected CALG_OID_INFO_PARAMETERS, got %x\n", data[0]); + ok(data[1] == CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG, + "Expected CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG, got %x\n", data[1]); + + ok(!lstrcmpW(info->pwszCNGAlgid, BCRYPT_SHA256_ALGORITHM), "Expected %s, got %s\n", + wine_dbgstr_w(BCRYPT_SHA256_ALGORITHM), wine_dbgstr_w(info->pwszCNGAlgid)); + ok(!lstrcmpW(info->pwszCNGExtraAlgid, CRYPT_OID_INFO_ECC_PARAMETERS_ALGORITHM), "Expected %s, got %s\n", + wine_dbgstr_w(CRYPT_OID_INFO_ECC_PARAMETERS_ALGORITHM), wine_dbgstr_w(info->pwszCNGExtraAlgid)); + } + else + todo_wine win_skip("Host does not support ECDSA_SHA256, skipping test\n"); }
START_TEST(oid) diff --git a/include/wincrypt.h b/include/wincrypt.h index a7c24e7831..373acacd26 100644 --- a/include/wincrypt.h +++ b/include/wincrypt.h @@ -1244,6 +1244,17 @@ typedef BOOL (WINAPI *PFN_CRYPT_ENUM_OID_FUNC)(DWORD dwEncodingType,
#define CRYPT_MATCH_ANY_ENCODING_TYPE 0xffffffff
+#define CALG_OID_INFO_CNG_ONLY 0xffffffff +#define CALG_OID_INFO_PARAMETERS 0xfffffffe + +#define CRYPT_OID_INFO_HASH_PARAMETERS_ALGORITHM (const WCHAR []){'C','r','y','p','t','O','I','D','I','n','f','o','H','a','s','h','P','a','r','a','m','e','t','e','r','s',0} +#define CRYPT_OID_INFO_ECC_PARAMETERS_ALGORITHM (const WCHAR []){'C','r','y','p','t','O','I','D','I','n','f','o','E','C','C','P','a','r','a','m','e','t','e','r','s',0} +#define CRYPT_OID_INFO_MGF1_PARAMETERS_ALGORITHM (const WCHAR []){'C','r','y','p','t','O','I','D','I','n','f','o','M','g','f','1','P','a','r','a','m','e','t','e','r','s',0} +#define CRYPT_OID_INFO_NO_SIGN_ALGORITHM (const WCHAR []){'C','r','y','p','t','O','I','D','I','n','f','o','N','o','S','i','g','n',0} +#define CRYPT_OID_INFO_OAEP_PARAMETERS_ALGORITHM (const WCHAR []){'C','r','y','p','t','O','I','D','I','n','f','o','O','A','E','P','P','a','r','a','m','e','t','e','r','s',0} +#define CRYPT_OID_INFO_ECC_WRAP_PARAMETERS_ALGORITHM (const WCHAR []){'C','r','y','p','t','O','I','D','I','n','f','o','E','C','C','W','r','a','p','P','a','r','a','m','e','t','e','r','s',0} +#define CRYPT_OID_INFO_NO_PARAMETERS_ALGORITHM (const WCHAR []){'C','r','y','p','t','O','I','D','I','n','f','o','N','o','P','a','r','a','m','e','t','e','r','s',0} + typedef struct _CRYPT_OID_INFO { DWORD cbSize; LPCSTR pszOID; @@ -1255,6 +1266,10 @@ typedef struct _CRYPT_OID_INFO { DWORD dwLength; } DUMMYUNIONNAME; CRYPT_DATA_BLOB ExtraInfo; +#ifdef CRYPT_OID_INFO_HAS_EXTRA_FIELDS + LPCWSTR pwszCNGAlgid; + LPCWSTR pwszCNGExtraAlgid; +#endif } CRYPT_OID_INFO, *PCRYPT_OID_INFO; typedef const CRYPT_OID_INFO CCRYPT_OID_INFO, *PCCRYPT_OID_INFO;
From: Michael Müller michael@fds-team.de
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/crypt32/oid.c | 15 +++++++++++++++ dlls/crypt32/tests/oid.c | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/dlls/crypt32/oid.c b/dlls/crypt32/oid.c index 61b2cbc88e..c9b0b412cf 100644 --- a/dlls/crypt32/oid.c +++ b/dlls/crypt32/oid.c @@ -25,6 +25,7 @@ #define NONAMELESSUNION #include "windef.h" #include "winbase.h" +#define CRYPT_OID_INFO_HAS_EXTRA_FIELDS #include "wincrypt.h" #include "winreg.h" #include "winuser.h" @@ -1080,6 +1081,8 @@ static const WCHAR sha384RSA[] = { 's','h','a','3','8','4','R','S','A',0 }; static const WCHAR sha512RSA[] = { 's','h','a','5','1','2','R','S','A',0 }; static const WCHAR mosaicUpdatedSig[] = { 'm','o','s','a','i','c','U','p','d','a','t','e','d','S','i','g',0 }; +static const WCHAR sha256ECDSA[] = { 's','h','a','2','5','6','E','C','D','S','A',0 }; +static const WCHAR sha384ECDSA[] = { 's','h','a','3','8','4','E','C','D','S','A',0 }; static const WCHAR CN[] = { 'C','N',0 }; static const WCHAR L[] = { 'L',0 }; static const WCHAR O[] = { 'O',0 }; @@ -1126,12 +1129,14 @@ static const DWORD dssSign[2] = { CALG_DSS_SIGN, static const DWORD mosaicSign[2] = { CALG_DSS_SIGN, CRYPT_OID_INHIBIT_SIGNATURE_FORMAT_FLAG | CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG }; +static const DWORD ecdsaSign[2] = { CALG_OID_INFO_PARAMETERS, CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG }; static const CRYPT_DATA_BLOB rsaSignBlob = { sizeof(rsaSign), (LPBYTE)&rsaSign }; static const CRYPT_DATA_BLOB dssSignBlob = { sizeof(dssSign), (LPBYTE)dssSign }; static const CRYPT_DATA_BLOB mosaicSignBlob = { sizeof(mosaicSign), (LPBYTE)mosaicSign }; +static const CRYPT_DATA_BLOB ecdsaSignBlob = { sizeof(ecdsaSign), (BYTE *)ecdsaSign };
static const DWORD ia5String[] = { CERT_RDN_IA5_STRING, 0 }; static const DWORD numericString[] = { CERT_RDN_NUMERIC_STRING, 0 }; @@ -1153,6 +1158,8 @@ static const struct OIDInfoConstructor { UINT Algid; LPCWSTR pwszName; const CRYPT_DATA_BLOB *blob; + const WCHAR *pwszCNGAlgid; + const WCHAR *pwszCNGExtraAlgid; } oidInfoConstructors[] = { { 1, szOID_OIWSEC_sha1, CALG_SHA1, sha1, NULL }, { 1, szOID_OIWSEC_sha1, CALG_SHA1, sha, NULL }, @@ -1208,6 +1215,10 @@ static const struct OIDInfoConstructor { { 4, szOID_OIWSEC_dsaSHA1, CALG_SHA1, dsaSHA1, &dssSignBlob }, { 4, szOID_INFOSEC_mosaicUpdatedSig, CALG_SHA1, mosaicUpdatedSig, &mosaicSignBlob }, + { 4, szOID_ECDSA_SHA256, CALG_OID_INFO_CNG_ONLY, sha256ECDSA, &ecdsaSignBlob, + BCRYPT_SHA256_ALGORITHM, CRYPT_OID_INFO_ECC_PARAMETERS_ALGORITHM }, + { 4, szOID_ECDSA_SHA384, CALG_OID_INFO_CNG_ONLY, sha384ECDSA, &ecdsaSignBlob, + BCRYPT_SHA384_ALGORITHM, CRYPT_OID_INFO_ECC_PARAMETERS_ALGORITHM },
{ 5, szOID_COMMON_NAME, 0, CN, NULL }, { 5, szOID_LOCALITY_NAME, 0, L, NULL }, @@ -1422,6 +1433,8 @@ static void init_oid_info(void) info->info.ExtraInfo.pbData = oidInfoConstructors[i].blob->pbData; } + info->info.pwszCNGAlgid = oidInfoConstructors[i].pwszCNGAlgid; + info->info.pwszCNGExtraAlgid = oidInfoConstructors[i].pwszCNGExtraAlgid; list_add_tail(&oidInfo, &info->entry); } } @@ -1454,6 +1467,8 @@ static void init_oid_info(void) info->info.ExtraInfo.pbData = oidInfoConstructors[i].blob->pbData; } + info->info.pwszCNGAlgid = oidInfoConstructors[i].pwszCNGAlgid; + info->info.pwszCNGExtraAlgid = oidInfoConstructors[i].pwszCNGExtraAlgid; list_add_tail(&oidInfo, &info->entry); } } diff --git a/dlls/crypt32/tests/oid.c b/dlls/crypt32/tests/oid.c index 00a6d5461e..05822478cb 100644 --- a/dlls/crypt32/tests/oid.c +++ b/dlls/crypt32/tests/oid.c @@ -611,7 +611,7 @@ static void test_findOIDInfo(void) wine_dbgstr_w(CRYPT_OID_INFO_ECC_PARAMETERS_ALGORITHM), wine_dbgstr_w(info->pwszCNGExtraAlgid)); } else - todo_wine win_skip("Host does not support ECDSA_SHA256, skipping test\n"); + win_skip("Host does not support ECDSA_SHA256, skipping test\n"); }
START_TEST(oid)