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
2849333f
Commit
2849333f
authored
Jul 28, 2008
by
Juan Lang
Committed by
Alexandre Julliard
Jul 29, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Implement CryptHashMessage.
parent
e0d28c89
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
16 deletions
+49
-16
message.c
dlls/crypt32/message.c
+49
-5
message.c
dlls/crypt32/tests/message.c
+0
-11
No files found.
dlls/crypt32/message.c
View file @
2849333f
...
...
@@ -218,9 +218,53 @@ BOOL WINAPI CryptHashMessage(PCRYPT_HASH_MESSAGE_PARA pHashPara,
DWORD
rgcbToBeHashed
[],
BYTE
*
pbHashedBlob
,
DWORD
*
pcbHashedBlob
,
BYTE
*
pbComputedHash
,
DWORD
*
pcbComputedHash
)
{
FIXME
(
"(%p, %d, %d, %p, %p, %p, %p, %p, %p): stub
\n
"
,
pHashPara
,
fDetachedHash
,
cToBeHashed
,
rgpbToBeHashed
,
rgcbToBeHashed
,
pbHashedBlob
,
pcbHashedBlob
,
pbComputedHash
,
pcbComputedHash
);
SetLastError
(
ERROR_CALL_NOT_IMPLEMENTED
);
return
FALSE
;
DWORD
i
,
flags
;
BOOL
ret
=
FALSE
;
HCRYPTMSG
msg
;
CMSG_HASHED_ENCODE_INFO
info
;
TRACE
(
"(%p, %d, %d, %p, %p, %p, %p, %p, %p)
\n
"
,
pHashPara
,
fDetachedHash
,
cToBeHashed
,
rgpbToBeHashed
,
rgcbToBeHashed
,
pbHashedBlob
,
pcbHashedBlob
,
pbComputedHash
,
pcbComputedHash
);
if
(
pHashPara
->
cbSize
!=
sizeof
(
CRYPT_HASH_MESSAGE_PARA
))
{
SetLastError
(
E_INVALIDARG
);
return
FALSE
;
}
/* Native seems to ignore any encoding type other than the expected
* PKCS_7_ASN_ENCODING
*/
if
(
GET_CMSG_ENCODING_TYPE
(
pHashPara
->
dwMsgEncodingType
)
!=
PKCS_7_ASN_ENCODING
)
return
TRUE
;
/* Native also seems to do nothing if the output parameter isn't given */
if
(
!
pcbHashedBlob
)
return
TRUE
;
flags
=
fDetachedHash
?
CMSG_DETACHED_FLAG
:
0
;
memset
(
&
info
,
0
,
sizeof
(
info
));
info
.
cbSize
=
sizeof
(
info
);
info
.
hCryptProv
=
pHashPara
->
hCryptProv
;
memcpy
(
&
info
.
HashAlgorithm
,
&
pHashPara
->
HashAlgorithm
,
sizeof
(
info
.
HashAlgorithm
));
info
.
pvHashAuxInfo
=
pHashPara
->
pvHashAuxInfo
;
msg
=
CryptMsgOpenToEncode
(
pHashPara
->
dwMsgEncodingType
,
flags
,
CMSG_HASHED
,
&
info
,
NULL
,
NULL
);
if
(
msg
)
{
for
(
i
=
0
,
ret
=
TRUE
;
ret
&&
i
<
cToBeHashed
;
i
++
)
ret
=
CryptMsgUpdate
(
msg
,
rgpbToBeHashed
[
i
],
rgcbToBeHashed
[
i
],
i
==
cToBeHashed
-
1
?
TRUE
:
FALSE
);
if
(
ret
)
{
ret
=
CryptMsgGetParam
(
msg
,
CMSG_CONTENT_PARAM
,
0
,
pbHashedBlob
,
pcbHashedBlob
);
if
(
ret
&&
pcbComputedHash
)
ret
=
CryptMsgGetParam
(
msg
,
CMSG_COMPUTED_HASH_PARAM
,
0
,
pbComputedHash
,
pcbComputedHash
);
}
CryptMsgClose
(
msg
);
}
return
ret
;
}
dlls/crypt32/tests/message.c
View file @
2849333f
...
...
@@ -271,27 +271,23 @@ static void test_hash_message(void)
memset
(
&
para
,
0
,
sizeof
(
para
));
SetLastError
(
0xdeadbeef
);
ret
=
CryptHashMessage
(
&
para
,
FALSE
,
0
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"expected E_INVALIDARG, got 0x%08x
\n
"
,
GetLastError
());
para
.
cbSize
=
sizeof
(
para
);
/* Not quite sure what "success" means in this case, but it does succeed */
SetLastError
(
0xdeadbeef
);
ret
=
CryptHashMessage
(
&
para
,
FALSE
,
0
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
ret
,
"CryptHashMessage failed: 0x%08x
\n
"
,
GetLastError
());
/* With a bogus encoding type it "succeeds" */
para
.
dwMsgEncodingType
=
0xdeadbeef
;
SetLastError
(
0xdeadbeef
);
ret
=
CryptHashMessage
(
&
para
,
FALSE
,
0
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
ret
,
"CryptHashMessage failed: 0x%08x
\n
"
,
GetLastError
());
/* According to MSDN, the third parameter (cToBeHashed) must be 1 if the
* second parameter (fDetached) is FALSE, but again it "succeeds."
*/
SetLastError
(
0xdeadbeef
);
ret
=
CryptHashMessage
(
&
para
,
FALSE
,
2
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
ret
,
"CryptHashMessage failed: 0x%08x
\n
"
,
GetLastError
());
/* Even passing parameters to hash results in "success." */
SetLastError
(
0xdeadbeef
);
...
...
@@ -301,13 +297,11 @@ static void test_hash_message(void)
para
.
dwMsgEncodingType
=
PKCS_7_ASN_ENCODING
;
SetLastError
(
0xdeadbeef
);
ret
=
CryptHashMessage
(
&
para
,
FALSE
,
2
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
ret
,
"CryptHashMessage failed: 0x%08x
\n
"
,
GetLastError
());
/* And with valid data to hash */
SetLastError
(
0xdeadbeef
);
ret
=
CryptHashMessage
(
&
para
,
FALSE
,
2
,
toHash
,
hashSize
,
NULL
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
ret
,
"CryptHashMessage failed: 0x%08x
\n
"
,
GetLastError
());
/* But requesting the size of the hashed blob and indicating there's data
* to hash results in a crash
...
...
@@ -323,7 +317,6 @@ static void test_hash_message(void)
SetLastError
(
0xdeadbeef
);
ret
=
CryptHashMessage
(
&
para
,
FALSE
,
2
,
toHash
,
hashSize
,
NULL
,
&
hashedBlobSize
,
NULL
,
NULL
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_UNKNOWN_ALGO
,
"expected CRYPT_E_UNKNOWN_ALGO, got 0x%08x (%d)
\n
"
,
GetLastError
(),
GetLastError
());
...
...
@@ -354,7 +347,6 @@ static void test_hash_message(void)
SetLastError
(
0xdeadbeef
);
ret
=
CryptHashMessage
(
&
para
,
TRUE
,
2
,
toHash
,
hashSize
,
NULL
,
&
hashedBlobSize
,
NULL
,
NULL
);
todo_wine
ok
(
ret
,
"CryptHashMessage failed: 0x%08x
\n
"
,
GetLastError
());
if
(
ret
)
{
...
...
@@ -373,7 +365,6 @@ static void test_hash_message(void)
SetLastError
(
0xdeadbeef
);
ret
=
CryptHashMessage
(
&
para
,
FALSE
,
1
,
toHash
,
hashSize
,
NULL
,
&
hashedBlobSize
,
NULL
,
NULL
);
todo_wine
ok
(
ret
,
"CryptHashMessage failed: 0x%08x
\n
"
,
GetLastError
());
if
(
ret
)
{
...
...
@@ -393,9 +384,7 @@ static void test_hash_message(void)
computedHashSize
=
0xdeadbeef
;
ret
=
CryptHashMessage
(
&
para
,
TRUE
,
2
,
toHash
,
hashSize
,
NULL
,
&
hashedBlobSize
,
NULL
,
&
computedHashSize
);
todo_wine
ok
(
ret
,
"CryptHashMessage failed: 0x%08x
\n
"
,
GetLastError
());
todo_wine
ok
(
computedHashSize
==
16
,
"expected hash size of 16, got %d
\n
"
,
computedHashSize
);
if
(
ret
)
...
...
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