Commit 519478e0 authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

crypt32: Fix encoding OIDs with only two components.

parent fa65c3f6
......@@ -796,7 +796,7 @@ BOOL WINAPI CRYPT_AsnEncodeOid(DWORD dwCertEncodingType,
const char *ptr;
int val1, val2;
if (sscanf(pszObjId, "%d.%d.%n", &val1, &val2, &firstPos) != 2)
if (sscanf(pszObjId, "%d.%d%n", &val1, &val2, &firstPos) != 2)
{
SetLastError(CRYPT_E_ASN1_ERROR);
return FALSE;
......@@ -804,6 +804,11 @@ BOOL WINAPI CRYPT_AsnEncodeOid(DWORD dwCertEncodingType,
bytesNeeded++;
firstByte = val1 * 40 + val2;
ptr = pszObjId + firstPos;
if (*ptr == '.')
{
ptr++;
firstPos++;
}
while (ret && *ptr)
{
int pos;
......
......@@ -2536,17 +2536,22 @@ static CERT_EXTENSION criticalExt =
{ oid_basic_constraints2, TRUE, { 8, crit_ext_data } };
static CERT_EXTENSION nonCriticalExt =
{ oid_basic_constraints2, FALSE, { 8, noncrit_ext_data } };
static CHAR oid_short[] = "1.1";
static CERT_EXTENSION extWithShortOid =
{ oid_short, FALSE, { 0, NULL } };
static const BYTE ext0[] = { 0x30,0x00 };
static const BYTE ext1[] = { 0x30,0x14,0x30,0x12,0x06,0x03,0x55,0x1d,0x13,0x01,0x01,
0xff,0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01 };
static const BYTE ext2[] = { 0x30,0x11,0x30,0x0f,0x06,0x03,0x55,0x1d,0x13,0x04,
0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01 };
static const BYTE ext3[] = { 0x30,0x07,0x30,0x05,0x06,0x01,0x29,0x04,0x00 };
static const struct encodedExtensions exts[] = {
{ { 0, NULL }, ext0 },
{ { 1, &criticalExt }, ext1 },
{ { 1, &nonCriticalExt }, ext2 },
{ { 1, &extWithShortOid }, ext3 }
};
static void test_encodeExtensions(DWORD dwEncoding)
......
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