Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tayshawnna Jackson
wine
Commits
cb5385e3
Commit
cb5385e3
authored
16 years ago
by
Juan Lang
Committed by
Alexandre Julliard
16 years ago
Browse files
Options
Downloads
Patches
Plain Diff
crypt32: Implement CryptVerifyDetachedMessageSignature.
parent
9e6b3213
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dlls/crypt32/message.c
+97
-33
97 additions, 33 deletions
dlls/crypt32/message.c
dlls/crypt32/tests/message.c
+0
-10
0 additions, 10 deletions
dlls/crypt32/tests/message.c
with
97 additions
and
43 deletions
dlls/crypt32/message.c
+
97
−
33
View file @
cb5385e3
...
...
@@ -60,39 +60,6 @@ LONG WINAPI CryptGetMessageSignerCount(DWORD dwMsgEncodingType,
return
count
;
}
BOOL
WINAPI
CryptVerifyDetachedMessageSignature
(
PCRYPT_VERIFY_MESSAGE_PARA
pVerifyPara
,
DWORD
dwSignerIndex
,
const
BYTE
*
pbDetachedSignBlob
,
DWORD
cbDetachedSignBlob
,
DWORD
cToBeSigned
,
const
BYTE
*
rgpbToBeSigned
[],
DWORD
rgcbToBeSigned
[],
PCCERT_CONTEXT
*
ppSignerCert
)
{
FIXME
(
"(%p, %d, %p, %d, %d, %p, %p, %p): stub
\n
"
,
pVerifyPara
,
dwSignerIndex
,
pbDetachedSignBlob
,
cbDetachedSignBlob
,
cToBeSigned
,
rgpbToBeSigned
,
rgcbToBeSigned
,
ppSignerCert
);
return
FALSE
;
}
static
BOOL
CRYPT_CopyParam
(
void
*
pvData
,
DWORD
*
pcbData
,
const
void
*
src
,
DWORD
len
)
{
BOOL
ret
=
TRUE
;
if
(
!
pvData
)
*
pcbData
=
len
;
else
if
(
*
pcbData
<
len
)
{
*
pcbData
=
len
;
SetLastError
(
ERROR_MORE_DATA
);
ret
=
FALSE
;
}
else
{
*
pcbData
=
len
;
memcpy
(
pvData
,
src
,
len
);
}
return
ret
;
}
static
CERT_INFO
*
CRYPT_GetSignerCertInfoFromMsg
(
HCRYPTMSG
msg
,
DWORD
dwSignerIndex
)
{
...
...
@@ -136,6 +103,103 @@ static inline PCCERT_CONTEXT CRYPT_GetSignerCertificate(HCRYPTMSG msg,
pVerifyPara
->
dwMsgAndCertEncodingType
,
certInfo
,
store
);
}
BOOL
WINAPI
CryptVerifyDetachedMessageSignature
(
PCRYPT_VERIFY_MESSAGE_PARA
pVerifyPara
,
DWORD
dwSignerIndex
,
const
BYTE
*
pbDetachedSignBlob
,
DWORD
cbDetachedSignBlob
,
DWORD
cToBeSigned
,
const
BYTE
*
rgpbToBeSigned
[],
DWORD
rgcbToBeSigned
[],
PCCERT_CONTEXT
*
ppSignerCert
)
{
BOOL
ret
=
FALSE
;
HCRYPTMSG
msg
;
TRACE
(
"(%p, %d, %p, %d, %d, %p, %p, %p)
\n
"
,
pVerifyPara
,
dwSignerIndex
,
pbDetachedSignBlob
,
cbDetachedSignBlob
,
cToBeSigned
,
rgpbToBeSigned
,
rgcbToBeSigned
,
ppSignerCert
);
if
(
ppSignerCert
)
*
ppSignerCert
=
NULL
;
if
(
!
pVerifyPara
||
pVerifyPara
->
cbSize
!=
sizeof
(
CRYPT_VERIFY_MESSAGE_PARA
)
||
GET_CMSG_ENCODING_TYPE
(
pVerifyPara
->
dwMsgAndCertEncodingType
)
!=
PKCS_7_ASN_ENCODING
)
{
SetLastError
(
E_INVALIDARG
);
return
FALSE
;
}
msg
=
CryptMsgOpenToDecode
(
pVerifyPara
->
dwMsgAndCertEncodingType
,
CMSG_DETACHED_FLAG
,
0
,
pVerifyPara
->
hCryptProv
,
NULL
,
NULL
);
if
(
msg
)
{
ret
=
CryptMsgUpdate
(
msg
,
pbDetachedSignBlob
,
cbDetachedSignBlob
,
TRUE
);
if
(
ret
)
{
DWORD
i
;
for
(
i
=
0
;
ret
&&
i
<
cToBeSigned
;
i
++
)
ret
=
CryptMsgUpdate
(
msg
,
rgpbToBeSigned
[
i
],
rgcbToBeSigned
[
i
],
i
==
cToBeSigned
-
1
?
TRUE
:
FALSE
);
}
if
(
ret
)
{
CERT_INFO
*
certInfo
=
CRYPT_GetSignerCertInfoFromMsg
(
msg
,
dwSignerIndex
);
ret
=
FALSE
;
if
(
certInfo
)
{
HCERTSTORE
store
=
CertOpenStore
(
CERT_STORE_PROV_MSG
,
pVerifyPara
->
dwMsgAndCertEncodingType
,
pVerifyPara
->
hCryptProv
,
0
,
msg
);
if
(
store
)
{
PCCERT_CONTEXT
cert
=
CRYPT_GetSignerCertificate
(
msg
,
pVerifyPara
,
certInfo
,
store
);
if
(
cert
)
{
ret
=
CryptMsgControl
(
msg
,
0
,
CMSG_CTRL_VERIFY_SIGNATURE
,
cert
->
pCertInfo
);
if
(
ret
&&
ppSignerCert
)
*
ppSignerCert
=
cert
;
else
CertFreeCertificateContext
(
cert
);
}
else
SetLastError
(
CRYPT_E_NOT_FOUND
);
CertCloseStore
(
store
,
0
);
}
CryptMemFree
(
certInfo
);
}
}
CryptMsgClose
(
msg
);
}
TRACE
(
"returning %d
\n
"
,
ret
);
return
ret
;
}
static
BOOL
CRYPT_CopyParam
(
void
*
pvData
,
DWORD
*
pcbData
,
const
void
*
src
,
DWORD
len
)
{
BOOL
ret
=
TRUE
;
if
(
!
pvData
)
*
pcbData
=
len
;
else
if
(
*
pcbData
<
len
)
{
*
pcbData
=
len
;
SetLastError
(
ERROR_MORE_DATA
);
ret
=
FALSE
;
}
else
{
*
pcbData
=
len
;
memcpy
(
pvData
,
src
,
len
);
}
return
ret
;
}
BOOL
WINAPI
CryptVerifyMessageSignature
(
PCRYPT_VERIFY_MESSAGE_PARA
pVerifyPara
,
DWORD
dwSignerIndex
,
const
BYTE
*
pbSignedBlob
,
DWORD
cbSignedBlob
,
BYTE
*
pbDecoded
,
DWORD
*
pcbDecoded
,
PCCERT_CONTEXT
*
ppSignerCert
)
...
...
This diff is collapsed.
Click to expand it.
dlls/crypt32/tests/message.c
+
0
−
10
View file @
cb5385e3
...
...
@@ -335,34 +335,29 @@ static void test_verify_detached_message_signature(void)
SetLastError
(
0xdeadbeef
);
ret
=
CryptVerifyDetachedMessageSignature
(
NULL
,
0
,
NULL
,
0
,
0
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08x
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
CryptVerifyDetachedMessageSignature
(
&
para
,
0
,
NULL
,
0
,
0
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08x
\n
"
,
GetLastError
());
para
.
cbSize
=
sizeof
(
para
);
SetLastError
(
0xdeadbeef
);
ret
=
CryptVerifyDetachedMessageSignature
(
&
para
,
0
,
NULL
,
0
,
0
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08x
\n
"
,
GetLastError
());
para
.
dwMsgAndCertEncodingType
=
X509_ASN_ENCODING
;
SetLastError
(
0xdeadbeef
);
ret
=
CryptVerifyDetachedMessageSignature
(
&
para
,
0
,
NULL
,
0
,
0
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08x
\n
"
,
GetLastError
());
para
.
dwMsgAndCertEncodingType
=
PKCS_7_ASN_ENCODING
;
SetLastError
(
0xdeadbeef
);
ret
=
CryptVerifyDetachedMessageSignature
(
&
para
,
0
,
NULL
,
0
,
0
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_ASN1_EOD
,
"Expected CRYPT_E_ASN1_EOD, got %08x
\n
"
,
GetLastError
());
/* None of these messages contains a cert in the message itself, so the
...
...
@@ -377,13 +372,11 @@ static void test_verify_detached_message_signature(void)
SetLastError
(
0xdeadbeef
);
ret
=
CryptVerifyDetachedMessageSignature
(
&
para
,
0
,
signedContent
,
sizeof
(
signedContent
),
0
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_NOT_FOUND
,
"Expected CRYPT_E_NOT_FOUND, got %08x
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
CryptVerifyDetachedMessageSignature
(
&
para
,
0
,
detachedSignedContent
,
sizeof
(
detachedSignedContent
),
0
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_NOT_FOUND
,
"Expected CRYPT_E_NOT_FOUND, got %08x
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
...
...
@@ -391,14 +384,12 @@ static void test_verify_detached_message_signature(void)
cbContent
=
sizeof
(
msgData
);
ret
=
CryptVerifyDetachedMessageSignature
(
&
para
,
0
,
detachedSignedContent
,
sizeof
(
detachedSignedContent
),
1
,
&
pContent
,
&
cbContent
,
NULL
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_NOT_FOUND
,
"Expected CRYPT_E_NOT_FOUND, got %08x
\n
"
,
GetLastError
());
/* Passing the correct callback results in success */
para
.
pfnGetSignerCertificate
=
msg_get_signer_callback
;
ret
=
CryptVerifyDetachedMessageSignature
(
&
para
,
0
,
detachedSignedContent
,
sizeof
(
detachedSignedContent
),
1
,
&
pContent
,
&
cbContent
,
NULL
);
todo_wine
ok
(
ret
,
"CryptVerifyDetachedMessageSignature failed: %08x
\n
"
,
GetLastError
());
/* Not passing the correct data to be signed results in the signature not
...
...
@@ -407,7 +398,6 @@ static void test_verify_detached_message_signature(void)
SetLastError
(
0xdeadbeef
);
ret
=
CryptVerifyDetachedMessageSignature
(
&
para
,
0
,
detachedSignedContent
,
sizeof
(
detachedSignedContent
),
0
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
NTE_BAD_SIGNATURE
,
"expected NTE_BAD_SIGNATURE, got %08x
\n
"
,
GetLastError
());
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment