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
d176e537
Commit
d176e537
authored
Oct 14, 2020
by
Hans Leidekker
Committed by
Alexandre Julliard
Oct 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dssenh: Implement CPSignHash.
Signed-off-by:
Hans Leidekker
<
hans@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
e1374be7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
6 deletions
+40
-6
main.c
dlls/dssenh/main.c
+33
-1
dssenh.c
dlls/dssenh/tests/dssenh.c
+7
-5
No files found.
dlls/dssenh/main.c
View file @
d176e537
...
@@ -718,10 +718,42 @@ BOOL WINAPI CPDeriveKey( HCRYPTPROV hprov, ALG_ID algid, HCRYPTHASH hhash, DWORD
...
@@ -718,10 +718,42 @@ BOOL WINAPI CPDeriveKey( HCRYPTPROV hprov, ALG_ID algid, HCRYPTHASH hhash, DWORD
return
FALSE
;
return
FALSE
;
}
}
static
DWORD
get_signature_length
(
DWORD
algid
)
{
switch
(
algid
)
{
case
AT_SIGNATURE
:
case
CALG_DSS_SIGN
:
return
40
;
default:
FIXME
(
"unhandled algorithm %u
\n
"
,
algid
);
return
0
;
}
}
#define MAX_HASH_LEN 20
BOOL
WINAPI
CPSignHash
(
HCRYPTPROV
hprov
,
HCRYPTHASH
hhash
,
DWORD
keyspec
,
const
WCHAR
*
desc
,
DWORD
flags
,
BYTE
*
sig
,
BOOL
WINAPI
CPSignHash
(
HCRYPTPROV
hprov
,
HCRYPTHASH
hhash
,
DWORD
keyspec
,
const
WCHAR
*
desc
,
DWORD
flags
,
BYTE
*
sig
,
DWORD
*
siglen
)
DWORD
*
siglen
)
{
{
return
FALSE
;
struct
container
*
container
=
(
struct
container
*
)
hprov
;
struct
hash
*
hash
=
(
struct
hash
*
)
hhash
;
UCHAR
hashval
[
MAX_HASH_LEN
];
ULONG
len
,
hashlen
=
sizeof
(
hashval
);
TRACE
(
"%p, %p, %u, %s, %08x, %p, %p
\n
"
,
(
void
*
)
hprov
,
(
void
*
)
hhash
,
keyspec
,
debugstr_w
(
desc
),
flags
,
sig
,
siglen
);
if
(
container
->
magic
!=
MAGIC_CONTAINER
||
!
container
->
sign_key
)
return
FALSE
;
if
(
hash
->
magic
!=
MAGIC_HASH
)
return
FALSE
;
if
(
!
(
len
=
get_signature_length
(
container
->
sign_key
->
algid
)))
return
FALSE
;
if
(
!
CPGetHashParam
(
hprov
,
hhash
,
HP_HASHVAL
,
hashval
,
&
hashlen
,
0
))
return
FALSE
;
if
(
*
siglen
<
len
)
{
*
siglen
=
len
;
return
TRUE
;
}
return
!
BCryptSignHash
(
container
->
sign_key
->
handle
,
NULL
,
hashval
,
hashlen
,
sig
,
*
siglen
,
siglen
,
0
);
}
}
BOOL
WINAPI
CPVerifySignature
(
HCRYPTPROV
hprov
,
HCRYPTHASH
hhash
,
const
BYTE
*
sig
,
DWORD
siglen
,
HCRYPTKEY
hpubkey
,
BOOL
WINAPI
CPVerifySignature
(
HCRYPTPROV
hprov
,
HCRYPTHASH
hhash
,
const
BYTE
*
sig
,
DWORD
siglen
,
HCRYPTKEY
hpubkey
,
...
...
dlls/dssenh/tests/dssenh.c
View file @
d176e537
...
@@ -889,12 +889,8 @@ static void test_signhash_array(HCRYPTPROV hProv, const struct signature_test *t
...
@@ -889,12 +889,8 @@ static void test_signhash_array(HCRYPTPROV hProv, const struct signature_test *t
ok
(
!
memcmp
(
hashValue1
,
hashValue2
,
hashLen2
),
"Hashes were not identical.
\n
"
);
ok
(
!
memcmp
(
hashValue1
,
hashValue2
,
hashLen2
),
"Hashes were not identical.
\n
"
);
/* Sign hash 1 */
/* Sign hash 1 */
signLen1
=
0
;
result
=
CryptSignHashA
(
hHash1
,
AT_SIGNATURE
,
NULL
,
0
,
NULL
,
&
signLen1
);
result
=
CryptSignHashA
(
hHash1
,
AT_SIGNATURE
,
NULL
,
0
,
NULL
,
&
signLen1
);
if
(
!
result
)
{
skip
(
"skipping sign tests
\n
"
);
return
;
}
ok
(
result
,
"Failed to get signature length, got %x
\n
"
,
GetLastError
());
ok
(
result
,
"Failed to get signature length, got %x
\n
"
,
GetLastError
());
ok
(
signLen1
==
40
,
"Expected a 40-byte signature, got %d
\n
"
,
signLen1
);
ok
(
signLen1
==
40
,
"Expected a 40-byte signature, got %d
\n
"
,
signLen1
);
...
@@ -902,6 +898,7 @@ static void test_signhash_array(HCRYPTPROV hProv, const struct signature_test *t
...
@@ -902,6 +898,7 @@ static void test_signhash_array(HCRYPTPROV hProv, const struct signature_test *t
ok
(
result
,
"Failed to sign hash, got %x
\n
"
,
GetLastError
());
ok
(
result
,
"Failed to sign hash, got %x
\n
"
,
GetLastError
());
/* Sign hash 2 */
/* Sign hash 2 */
signLen2
=
0
;
result
=
CryptSignHashA
(
hHash2
,
AT_SIGNATURE
,
NULL
,
0
,
NULL
,
&
signLen2
);
result
=
CryptSignHashA
(
hHash2
,
AT_SIGNATURE
,
NULL
,
0
,
NULL
,
&
signLen2
);
ok
(
result
,
"Failed to get signature length, got %x
\n
"
,
GetLastError
());
ok
(
result
,
"Failed to get signature length, got %x
\n
"
,
GetLastError
());
ok
(
signLen2
==
40
,
"Expected a 40-byte signature, got %d
\n
"
,
signLen2
);
ok
(
signLen2
==
40
,
"Expected a 40-byte signature, got %d
\n
"
,
signLen2
);
...
@@ -943,6 +940,11 @@ static void test_signhash_array(HCRYPTPROV hProv, const struct signature_test *t
...
@@ -943,6 +940,11 @@ static void test_signhash_array(HCRYPTPROV hProv, const struct signature_test *t
/* Verify signed hash 1 */
/* Verify signed hash 1 */
result
=
CryptVerifySignatureA
(
hHash1
,
signValue1
,
sizeof
(
signValue1
),
pubKey
,
NULL
,
0
);
result
=
CryptVerifySignatureA
(
hHash1
,
signValue1
,
sizeof
(
signValue1
),
pubKey
,
NULL
,
0
);
if
(
!
result
)
{
skip
(
"skipping sign tests
\n
"
);
return
;
}
ok
(
result
,
"Failed to verify signature, got %x
\n
"
,
GetLastError
());
ok
(
result
,
"Failed to verify signature, got %x
\n
"
,
GetLastError
());
result
=
CryptCreateHash
(
hProv
,
CALG_SHA
,
0
,
0
,
&
hHash2
);
result
=
CryptCreateHash
(
hProv
,
CALG_SHA
,
0
,
0
,
&
hHash2
);
...
...
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