Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
ac28066b
Commit
ac28066b
authored
Aug 02, 2007
by
Juan Lang
Committed by
Alexandre Julliard
Aug 03, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Test and fix getting a certificate context's key identifier property.
parent
c98f605b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
6 deletions
+91
-6
cert.c
dlls/crypt32/cert.c
+27
-6
cert.c
dlls/crypt32/tests/cert.c
+64
-0
No files found.
dlls/crypt32/cert.c
View file @
ac28066b
...
...
@@ -242,6 +242,33 @@ static BOOL WINAPI CertContext_GetProperty(void *context, DWORD dwPropId,
FIXME
(
"CERT_SIGNATURE_HASH_PROP_ID unimplemented
\n
"
);
SetLastError
(
CRYPT_E_NOT_FOUND
);
break
;
case
CERT_KEY_IDENTIFIER_PROP_ID
:
{
PCERT_EXTENSION
ext
=
CertFindExtension
(
szOID_SUBJECT_KEY_IDENTIFIER
,
pCertContext
->
pCertInfo
->
cExtension
,
pCertContext
->
pCertInfo
->
rgExtension
);
if
(
ext
)
{
CRYPT_DATA_BLOB
*
value
;
DWORD
size
;
ret
=
CryptDecodeObjectEx
(
X509_ASN_ENCODING
,
szOID_SUBJECT_KEY_IDENTIFIER
,
ext
->
Value
.
pbData
,
ext
->
Value
.
cbData
,
CRYPT_DECODE_ALLOC_FLAG
,
NULL
,
&
value
,
&
size
);
if
(
ret
)
{
ret
=
CertContext_CopyParam
(
pvData
,
pcbData
,
value
->
pbData
,
value
->
cbData
);
CertContext_SetProperty
(
context
,
dwPropId
,
0
,
value
);
LocalFree
(
value
);
}
}
else
SetLastError
(
ERROR_INVALID_DATA
);
break
;
}
default:
SetLastError
(
CRYPT_E_NOT_FOUND
);
}
...
...
@@ -300,12 +327,6 @@ BOOL WINAPI CertGetCertificateContextProperty(PCCERT_CONTEXT pCertContext,
ret
=
CertContext_CopyParam
(
pvData
,
pcbData
,
&
state
,
sizeof
(
state
));
}
break
;
case
CERT_KEY_IDENTIFIER_PROP_ID
:
ret
=
CertContext_GetProperty
((
void
*
)
pCertContext
,
dwPropId
,
pvData
,
pcbData
);
if
(
!
ret
)
SetLastError
(
ERROR_INVALID_DATA
);
break
;
case
CERT_KEY_PROV_HANDLE_PROP_ID
:
{
CERT_KEY_CONTEXT
keyContext
;
...
...
dlls/crypt32/tests/cert.c
View file @
ac28066b
...
...
@@ -324,6 +324,30 @@ static void checkHash(const BYTE *data, DWORD dataLen, ALG_ID algID,
}
static
WCHAR
cspNameW
[]
=
{
'W'
,
'i'
,
'n'
,
'e'
,
'C'
,
'r'
,
'y'
,
'p'
,
't'
,
'T'
,
'e'
,
'm'
,
'p'
,
0
};
static
const
BYTE
v1CertWithPubKey
[]
=
{
0x30
,
0x81
,
0x95
,
0x02
,
0x01
,
0x01
,
0x30
,
0x02
,
0x06
,
0x00
,
0x30
,
0x15
,
0x31
,
0x13
,
0x30
,
0x11
,
0x06
,
0x03
,
0x55
,
0x04
,
0x03
,
0x13
,
0x0a
,
0x4a
,
0x75
,
0x61
,
0x6e
,
0x20
,
0x4c
,
0x61
,
0x6e
,
0x67
,
0x00
,
0x30
,
0x22
,
0x18
,
0x0f
,
0x31
,
0x36
,
0x30
,
0x31
,
0x30
,
0x31
,
0x30
,
0x31
,
0x30
,
0x30
,
0x30
,
0x30
,
0x30
,
0x30
,
0x5a
,
0x18
,
0x0f
,
0x31
,
0x36
,
0x30
,
0x31
,
0x30
,
0x31
,
0x30
,
0x31
,
0x30
,
0x30
,
0x30
,
0x30
,
0x30
,
0x30
,
0x5a
,
0x30
,
0x15
,
0x31
,
0x13
,
0x30
,
0x11
,
0x06
,
0x03
,
0x55
,
0x04
,
0x03
,
0x13
,
0x0a
,
0x4a
,
0x75
,
0x61
,
0x6e
,
0x20
,
0x4c
,
0x61
,
0x6e
,
0x67
,
0x00
,
0x30
,
0x22
,
0x30
,
0x0d
,
0x06
,
0x09
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x01
,
0x01
,
0x01
,
0x05
,
0x00
,
0x03
,
0x11
,
0x00
,
0x00
,
0x01
,
0x02
,
0x03
,
0x04
,
0x05
,
0x06
,
0x07
,
0x08
,
0x09
,
0x0a
,
0x0b
,
0x0c
,
0x0d
,
0x0e
,
0x0f
,
0xa3
,
0x16
,
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
v1CertWithSubjectKeyId
[]
=
{
0x30
,
0x7b
,
0x02
,
0x01
,
0x01
,
0x30
,
0x02
,
0x06
,
0x00
,
0x30
,
0x15
,
0x31
,
0x13
,
0x30
,
0x11
,
0x06
,
0x03
,
0x55
,
0x04
,
0x03
,
0x13
,
0x0a
,
0x4a
,
0x75
,
0x61
,
0x6e
,
0x20
,
0x4c
,
0x61
,
0x6e
,
0x67
,
0x00
,
0x30
,
0x22
,
0x18
,
0x0f
,
0x31
,
0x36
,
0x30
,
0x31
,
0x30
,
0x31
,
0x30
,
0x31
,
0x30
,
0x30
,
0x30
,
0x30
,
0x30
,
0x30
,
0x5a
,
0x18
,
0x0f
,
0x31
,
0x36
,
0x30
,
0x31
,
0x30
,
0x31
,
0x30
,
0x31
,
0x30
,
0x30
,
0x30
,
0x30
,
0x30
,
0x30
,
0x5a
,
0x30
,
0x15
,
0x31
,
0x13
,
0x30
,
0x11
,
0x06
,
0x03
,
0x55
,
0x04
,
0x03
,
0x13
,
0x0a
,
0x4a
,
0x75
,
0x61
,
0x6e
,
0x20
,
0x4c
,
0x61
,
0x6e
,
0x67
,
0x00
,
0x30
,
0x07
,
0x30
,
0x02
,
0x06
,
0x00
,
0x03
,
0x01
,
0x00
,
0xa3
,
0x17
,
0x30
,
0x15
,
0x30
,
0x13
,
0x06
,
0x03
,
0x55
,
0x1d
,
0x0e
,
0x04
,
0x0c
,
0x04
,
0x0a
,
0x4a
,
0x75
,
0x61
,
0x6e
,
0x20
,
0x4c
,
0x61
,
0x6e
,
0x67
,
0x00
};
static
const
BYTE
subjectKeyId
[]
=
{
0x4a
,
0x75
,
0x61
,
0x6e
,
0x20
,
0x4c
,
0x61
,
0x6e
,
0x67
,
0x00
};
static
void
testCertProperties
(
void
)
{
...
...
@@ -493,6 +517,46 @@ static void testCertProperties(void)
GetLastError
());
ok
(
keyContext
.
hCryptProv
==
0
,
"Expected no hCryptProv
\n
"
);
/* According to MSDN the subject key id can be stored as a property,
* as a subject key extension, or as the SHA1 hash of the public key,
* but this cert has none of them:
*/
ret
=
CertGetCertificateContextProperty
(
context
,
CERT_KEY_IDENTIFIER_PROP_ID
,
NULL
,
&
size
);
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_DATA
,
"Expected ERROR_INVALID_DATA, got %08x
\n
"
,
GetLastError
());
CertFreeCertificateContext
(
context
);
/* This cert does have a public key, but its subject key identifier still
* isn't available: */
context
=
CertCreateCertificateContext
(
X509_ASN_ENCODING
,
v1CertWithPubKey
,
sizeof
(
v1CertWithPubKey
));
ret
=
CertGetCertificateContextProperty
(
context
,
CERT_KEY_IDENTIFIER_PROP_ID
,
NULL
,
&
size
);
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_DATA
,
"Expected ERROR_INVALID_DATA, got %08x
\n
"
,
GetLastError
());
CertFreeCertificateContext
(
context
);
/* This cert with a subject key extension can have its key identifier
* property retrieved:
*/
context
=
CertCreateCertificateContext
(
X509_ASN_ENCODING
,
v1CertWithSubjectKeyId
,
sizeof
(
v1CertWithSubjectKeyId
));
ret
=
CertGetCertificateContextProperty
(
context
,
CERT_KEY_IDENTIFIER_PROP_ID
,
NULL
,
&
size
);
ok
(
ret
,
"CertGetCertificateContextProperty failed: %08x
\n
"
,
GetLastError
());
if
(
ret
)
{
LPBYTE
buf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
if
(
buf
)
{
ret
=
CertGetCertificateContextProperty
(
context
,
CERT_KEY_IDENTIFIER_PROP_ID
,
buf
,
&
size
);
ok
(
ret
,
"CertGetCertificateContextProperty failed: %08x
\n
"
,
GetLastError
());
ok
(
!
memcmp
(
buf
,
subjectKeyId
,
size
),
"Unexpected subject key id
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
}
}
CertFreeCertificateContext
(
context
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment