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
10975136
Commit
10975136
authored
Aug 26, 2008
by
Juan Lang
Committed by
Alexandre Julliard
Aug 27, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Add tests for CryptVerifyDetachedHashMessage.
parent
6372b628
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
110 additions
and
0 deletions
+110
-0
message.c
dlls/crypt32/tests/message.c
+110
-0
No files found.
dlls/crypt32/tests/message.c
View file @
10975136
...
...
@@ -84,6 +84,115 @@ static void test_msg_get_signer_count(void)
ok
(
count
==
1
,
"Expected 1, got %d
\n
"
,
count
);
}
static
BYTE
detachedHashContent
[]
=
{
0x30
,
0x3f
,
0x06
,
0x09
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x01
,
0x07
,
0x05
,
0xa0
,
0x32
,
0x30
,
0x30
,
0x02
,
0x01
,
0x00
,
0x30
,
0x0c
,
0x06
,
0x08
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x02
,
0x05
,
0x05
,
0x00
,
0x30
,
0x0b
,
0x06
,
0x09
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x01
,
0x07
,
0x01
,
0x04
,
0x10
,
0x08
,
0xd6
,
0xc0
,
0x5a
,
0x21
,
0x51
,
0x2a
,
0x79
,
0xa1
,
0xdf
,
0xeb
,
0x9d
,
0x2a
,
0x8f
,
0x26
,
0x2f
};
static
const
BYTE
msgData
[]
=
{
1
,
2
,
3
,
4
};
static
void
test_verify_detached_message_hash
(
void
)
{
BOOL
ret
;
CRYPT_HASH_MESSAGE_PARA
para
;
DWORD
size
,
hashSize
;
const
BYTE
*
pMsgData
=
msgData
;
BYTE
hash
[
16
];
if
(
0
)
{
ret
=
CryptVerifyDetachedMessageHash
(
NULL
,
NULL
,
0
,
0
,
NULL
,
NULL
,
NULL
,
NULL
);
}
memset
(
&
para
,
0
,
sizeof
(
para
));
SetLastError
(
0xdeadbeef
);
ret
=
CryptVerifyDetachedMessageHash
(
&
para
,
NULL
,
0
,
0
,
NULL
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"expected E_INVALIDARG, got %08x
\n
"
,
GetLastError
());
para
.
cbSize
=
sizeof
(
para
);
SetLastError
(
0xdeadbeef
);
ret
=
CryptVerifyDetachedMessageHash
(
&
para
,
NULL
,
0
,
0
,
NULL
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"expected E_INVALIDARG, got %08x
\n
"
,
GetLastError
());
para
.
dwMsgEncodingType
=
PKCS_7_ASN_ENCODING
;
SetLastError
(
0xdeadbeef
);
ret
=
CryptVerifyDetachedMessageHash
(
&
para
,
NULL
,
0
,
0
,
NULL
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_ASN1_EOD
,
"expected CRYPT_E_ASN1_EOD, got %08x
\n
"
,
GetLastError
());
para
.
dwMsgEncodingType
=
X509_ASN_ENCODING
;
SetLastError
(
0xdeadbeef
);
ret
=
CryptVerifyDetachedMessageHash
(
&
para
,
NULL
,
0
,
0
,
NULL
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"expected E_INVALIDARG, got %08x
\n
"
,
GetLastError
());
para
.
dwMsgEncodingType
=
X509_ASN_ENCODING
|
PKCS_7_ASN_ENCODING
;
SetLastError
(
0xdeadbeef
);
ret
=
CryptVerifyDetachedMessageHash
(
&
para
,
NULL
,
0
,
0
,
NULL
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_ASN1_EOD
,
"expected CRYPT_E_ASN1_EOD, got %08x
\n
"
,
GetLastError
());
/* Curiously, passing no data to hash succeeds.. */
ret
=
CryptVerifyDetachedMessageHash
(
&
para
,
detachedHashContent
,
sizeof
(
detachedHashContent
),
0
,
NULL
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
ret
,
"CryptVerifyDetachedMessageHash failed: %08x
\n
"
,
GetLastError
());
/* as does passing the actual content of the message to hash.. */
size
=
sizeof
(
msgData
);
pMsgData
=
msgData
;
ret
=
CryptVerifyDetachedMessageHash
(
&
para
,
detachedHashContent
,
sizeof
(
detachedHashContent
),
1
,
&
pMsgData
,
&
size
,
NULL
,
NULL
);
todo_wine
ok
(
ret
,
"CryptVerifyDetachedMessageHash failed: %08x
\n
"
,
GetLastError
());
/* while passing data to hash that isn't the content of the message fails.
*/
size
=
sizeof
(
detachedHashContent
);
pMsgData
=
detachedHashContent
;
SetLastError
(
0xdeadbeef
);
ret
=
CryptVerifyDetachedMessageHash
(
&
para
,
detachedHashContent
,
sizeof
(
detachedHashContent
),
1
,
&
pMsgData
,
&
size
,
NULL
,
NULL
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_HASH_VALUE
,
"expected CRYPT_E_HASH_VALUE, got %08x
\n
"
,
GetLastError
());
/* Getting the size of the hash while passing no hash data causes the
* hash to be checked (and fail.)
*/
SetLastError
(
0xdeadbeef
);
ret
=
CryptVerifyDetachedMessageHash
(
&
para
,
detachedHashContent
,
sizeof
(
detachedHashContent
),
0
,
NULL
,
NULL
,
NULL
,
&
hashSize
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_HASH_VALUE
,
"expected CRYPT_E_HASH_VALUE, got %08x
\n
"
,
GetLastError
());
size
=
sizeof
(
msgData
);
pMsgData
=
msgData
;
ret
=
CryptVerifyDetachedMessageHash
(
&
para
,
detachedHashContent
,
sizeof
(
detachedHashContent
),
1
,
&
pMsgData
,
&
size
,
NULL
,
&
hashSize
);
todo_wine
{
ok
(
ret
,
"CryptVerifyDetachedMessageHash failed: %08x
\n
"
,
GetLastError
());
ok
(
hashSize
==
sizeof
(
hash
),
"unexpected size %d
\n
"
,
hashSize
);
}
hashSize
=
1
;
SetLastError
(
0xdeadbeef
);
ret
=
CryptVerifyDetachedMessageHash
(
&
para
,
detachedHashContent
,
sizeof
(
detachedHashContent
),
1
,
&
pMsgData
,
&
size
,
hash
,
&
hashSize
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
ERROR_MORE_DATA
,
"expected ERROR_MORE_DATA, got %08x
\n
"
,
GetLastError
());
hashSize
=
sizeof
(
hash
);
ret
=
CryptVerifyDetachedMessageHash
(
&
para
,
detachedHashContent
,
sizeof
(
detachedHashContent
),
1
,
&
pMsgData
,
&
size
,
hash
,
&
hashSize
);
todo_wine
ok
(
ret
,
"CryptVerifyDetachedMessageHash failed: %08x
\n
"
,
GetLastError
());
}
static
const
BYTE
signedContent
[]
=
{
0x30
,
0x81
,
0xb2
,
0x06
,
0x09
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x01
,
0x07
,
0x02
,
0xa0
,
0x81
,
0xa4
,
0x30
,
0x81
,
0xa1
,
0x02
,
0x01
,
0x01
,
0x31
,
0x0e
,
0x30
,
0x0c
,
0x06
,
0x08
,
0x2a
,
...
...
@@ -404,6 +513,7 @@ static void test_hash_message(void)
START_TEST
(
message
)
{
test_msg_get_signer_count
();
test_verify_detached_message_hash
();
test_verify_message_signature
();
test_hash_message
();
}
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