crypt32: Added support for szOID_NIST_sha* OIDs.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2018-01-29 19:51:21 +01:00 committed by Alexandre Julliard
parent 13e0671959
commit 86c998e551
3 changed files with 30 additions and 5 deletions

View File

@ -1053,6 +1053,9 @@ static const WCHAR rc2[] = { 'r','c','2',0 };
static const WCHAR rc4[] = { 'r','c','4',0 };
static const WCHAR sha[] = { 's','h','a',0 };
static const WCHAR sha1[] = { 's','h','a','1',0 };
static const WCHAR sha256[] = { 's','h','a','2','5','6',0 };
static const WCHAR sha384[] = { 's','h','a','3','8','4',0 };
static const WCHAR sha512[] = { 's','h','a','5','1','2',0 };
static const WCHAR RSA[] = { 'R','S','A',0 };
static const WCHAR RSA_KEYX[] = { 'R','S','A','_','K','E','Y','X',0 };
static const WCHAR RSA_SIGN[] = { 'R','S','A','_','S','I','G','N',0 };
@ -1157,6 +1160,10 @@ static const struct OIDInfoConstructor {
{ 1, szOID_RSA_MD5, CALG_MD5, md5, NULL },
{ 1, szOID_RSA_MD4, CALG_MD4, md4, NULL },
{ 1, szOID_RSA_MD2, CALG_MD2, md2, NULL },
/* NOTE: Windows Vista+ uses -1 instead of CALG_SHA_* following SHA entries. */
{ 1, szOID_NIST_sha256, CALG_SHA_256, sha256, NULL },
{ 1, szOID_NIST_sha384, CALG_SHA_384, sha384, NULL },
{ 1, szOID_NIST_sha512, CALG_SHA_512, sha512, NULL },
{ 2, szOID_OIWSEC_desCBC, CALG_DES, des, NULL },
{ 2, szOID_RSA_DES_EDE3_CBC, CALG_3DES, tripledes, NULL },

View File

@ -36,6 +36,7 @@ struct OIDToAlgID
LPCSTR oid;
LPCSTR altOid;
DWORD algID;
DWORD altAlgID;
};
static const struct OIDToAlgID oidToAlgID[] = {
@ -72,6 +73,9 @@ static const struct OIDToAlgID oidToAlgID[] = {
{ szOID_OIWDIR_md2RSA, NULL, CALG_MD2 },
{ szOID_INFOSEC_mosaicUpdatedSig, NULL, CALG_SHA },
{ szOID_INFOSEC_mosaicKMandUpdSig, NULL, CALG_DSS_SIGN },
{ szOID_NIST_sha256, NULL, CALG_SHA_256, -1 },
{ szOID_NIST_sha384, NULL, CALG_SHA_384, -1 },
{ szOID_NIST_sha512, NULL, CALG_SHA_512, -1 }
};
static const struct OIDToAlgID algIDToOID[] = {
@ -104,10 +108,7 @@ static void testOIDToAlgID(void)
for (i = 0; i < sizeof(oidToAlgID) / sizeof(oidToAlgID[0]); i++)
{
alg = CertOIDToAlgId(oidToAlgID[i].oid);
/* Not all Windows installations support all these, so make sure it's
* at least not the wrong one.
*/
ok(alg == 0 || alg == oidToAlgID[i].algID,
ok(alg == oidToAlgID[i].algID || (oidToAlgID[i].altAlgID && alg == oidToAlgID[i].altAlgID),
"Expected %d, got %d\n", oidToAlgID[i].algID, alg);
}
}
@ -126,6 +127,7 @@ static void testAlgIDToOID(void)
{
oid = CertAlgIdToOID(algIDToOID[i].algID);
/* Allow failure, not every version of Windows supports every algo */
ok(oid != NULL || broken(!oid), "CertAlgIdToOID failed, expected %s\n", algIDToOID[i].oid);
if (oid)
{
if (strcmp(oid, algIDToOID[i].oid))
@ -542,11 +544,13 @@ static void test_enumOIDInfo(void)
static void test_findOIDInfo(void)
{
static WCHAR sha1[] = { 's','h','a','1',0 };
static CHAR oid_rsa_md5[] = szOID_RSA_MD5;
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 };
PCCRYPT_OID_INFO info;
static const WCHAR sha256W[] = {'s','h','a','2','5','6',0};
info = CryptFindOIDInfo(0, NULL, 0);
ok(info == NULL, "Expected NULL\n");
info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, oid_rsa_md5, 0);
@ -585,6 +589,17 @@ static void test_findOIDInfo(void)
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)
{
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);
}
}
START_TEST(oid)

View File

@ -2941,6 +2941,9 @@ typedef struct _CTL_FIND_SUBJECT_PARA
#define szOID_INFOSEC_mosaicUpdatedSig "2.16.840.1.101.2.1.1.19"
#define szOID_INFOSEC_mosaicKMandUpdSig "2.16.840.1.101.2.1.1.20"
#define szOID_INFOSEC_mosaicUpdateInteg "2.16.840.1.101.2.1.1.21"
#define szOID_NIST_sha256 "2.16.840.1.101.3.4.2.1"
#define szOID_NIST_sha384 "2.16.840.1.101.3.4.2.2"
#define szOID_NIST_sha512 "2.16.840.1.101.3.4.2.3"
#define szOID_COMMON_NAME "2.5.4.3"
#define szOID_SUR_NAME "2.5.4.4"
#define szOID_DEVICE_SERIAL_NUMBER "2.5.4.5"