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
2d658db5
Commit
2d658db5
authored
Oct 31, 2011
by
Juan Lang
Committed by
Alexandre Julliard
Nov 01, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rsaenh: Infer private exponent length from data length.
parent
f0e2cba4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
7 deletions
+10
-7
implglue.c
dlls/rsaenh/implglue.c
+6
-2
implglue.h
dlls/rsaenh/implglue.h
+1
-1
rsaenh.c
dlls/rsaenh/rsaenh.c
+3
-3
rsaenh.c
dlls/rsaenh/tests/rsaenh.c
+0
-1
No files found.
dlls/rsaenh/implglue.c
View file @
2d658db5
...
...
@@ -482,7 +482,7 @@ BOOL export_private_key_impl(BYTE *pbDest, const KEY_CONTEXT *pKeyContext, DWORD
}
BOOL
import_private_key_impl
(
CONST
BYTE
*
pbSrc
,
KEY_CONTEXT
*
pKeyContext
,
DWORD
dwKeyLen
,
DWORD
dwPubExp
)
DWORD
dw
DataLen
,
DWORD
dw
PubExp
)
{
BYTE
*
pbTemp
,
*
pbBigNum
;
...
...
@@ -496,7 +496,7 @@ BOOL import_private_key_impl(CONST BYTE *pbSrc, KEY_CONTEXT *pKeyContext, DWORD
pbTemp
=
HeapAlloc
(
GetProcessHeap
(),
0
,
2
*
dwKeyLen
+
5
*
((
dwKeyLen
+
1
)
>>
1
));
if
(
!
pbTemp
)
return
FALSE
;
memcpy
(
pbTemp
,
pbSrc
,
2
*
dwKeyLen
+
5
*
((
dwKeyLen
+
1
)
>>
1
));
memcpy
(
pbTemp
,
pbSrc
,
min
(
dwDataLen
,
2
*
dwKeyLen
+
5
*
((
dwKeyLen
+
1
)
>>
1
)
));
pbBigNum
=
pbTemp
;
pKeyContext
->
rsa
.
type
=
PK_PRIVATE
;
...
...
@@ -518,6 +518,10 @@ BOOL import_private_key_impl(CONST BYTE *pbSrc, KEY_CONTEXT *pKeyContext, DWORD
reverse_bytes
(
pbBigNum
,
(
dwKeyLen
+
1
)
>>
1
);
mp_read_unsigned_bin
(
&
pKeyContext
->
rsa
.
qP
,
pbBigNum
,
(
dwKeyLen
+
1
)
>>
1
);
pbBigNum
+=
(
dwKeyLen
+
1
)
>>
1
;
/* The size of the private exponent d is inferred from the remaining
* data length.
*/
dwKeyLen
=
min
(
dwKeyLen
,
dwDataLen
-
(
pbBigNum
-
pbTemp
));
reverse_bytes
(
pbBigNum
,
dwKeyLen
);
mp_read_unsigned_bin
(
&
pKeyContext
->
rsa
.
d
,
pbBigNum
,
dwKeyLen
);
mp_set_int
(
&
pKeyContext
->
rsa
.
e
,
dwPubExp
);
...
...
dlls/rsaenh/implglue.h
View file @
2d658db5
...
...
@@ -98,7 +98,7 @@ BOOL import_public_key_impl(CONST BYTE *pbSrc, KEY_CONTEXT *pKeyContext, DWORD d
BOOL
export_private_key_impl
(
BYTE
*
pbDest
,
const
KEY_CONTEXT
*
pKeyContext
,
DWORD
dwKeyLen
,
DWORD
*
pdwPubExp
)
DECLSPEC_HIDDEN
;
BOOL
import_private_key_impl
(
CONST
BYTE
*
pbSrc
,
KEY_CONTEXT
*
pKeyContext
,
DWORD
dwKeyLen
,
DWORD
dwPubExp
)
DECLSPEC_HIDDEN
;
DWORD
dw
DataLen
,
DWORD
dw
PubExp
)
DECLSPEC_HIDDEN
;
BOOL
gen_rand_impl
(
BYTE
*
pbBuffer
,
DWORD
dwLen
)
DECLSPEC_HIDDEN
;
...
...
dlls/rsaenh/rsaenh.c
View file @
2d658db5
...
...
@@ -2745,10 +2745,10 @@ static BOOL import_private_key(HCRYPTPROV hProv, CONST BYTE *pbData, DWORD dwDat
return
FALSE
;
}
if
((
dwDataLen
<
sizeof
(
BLOBHEADER
)
+
sizeof
(
RSAPUBKEY
)
+
(
2
*
pRSAPubKey
->
bitlen
>>
3
)
+
(
5
*
((
pRSAPubKey
->
bitlen
+
8
)
>>
4
))))
(
pRSAPubKey
->
bitlen
>>
3
)
+
(
5
*
((
pRSAPubKey
->
bitlen
+
8
)
>>
4
))))
{
DWORD
expectedLen
=
sizeof
(
BLOBHEADER
)
+
sizeof
(
RSAPUBKEY
)
+
(
2
*
pRSAPubKey
->
bitlen
>>
3
)
+
(
5
*
((
pRSAPubKey
->
bitlen
+
8
)
>>
4
));
(
pRSAPubKey
->
bitlen
>>
3
)
+
(
5
*
((
pRSAPubKey
->
bitlen
+
8
)
>>
4
));
ERR
(
"blob too short for pub key: expect %d, got %d
\n
"
,
expectedLen
,
dwDataLen
);
...
...
@@ -2760,7 +2760,7 @@ static BOOL import_private_key(HCRYPTPROV hProv, CONST BYTE *pbData, DWORD dwDat
if
(
*
phKey
==
(
HCRYPTKEY
)
INVALID_HANDLE_VALUE
)
return
FALSE
;
setup_key
(
pCryptKey
);
ret
=
import_private_key_impl
((
CONST
BYTE
*
)(
pRSAPubKey
+
1
),
&
pCryptKey
->
context
,
pRSAPubKey
->
bitlen
/
8
,
pRSAPubKey
->
pubexp
);
pRSAPubKey
->
bitlen
/
8
,
dwDataLen
,
pRSAPubKey
->
pubexp
);
if
(
ret
)
{
if
(
dwFlags
&
CRYPT_EXPORTABLE
)
pCryptKey
->
dwPermissions
|=
CRYPT_EXPORT
;
...
...
dlls/rsaenh/tests/rsaenh.c
View file @
2d658db5
...
...
@@ -1573,7 +1573,6 @@ static void test_import_private(void)
for
(;
dwLen
<
sizeof
(
abPlainPrivateKey
);
dwLen
++
)
{
result
=
CryptImportKey
(
hProv
,
abPlainPrivateKey
,
dwLen
,
0
,
0
,
&
hKeyExchangeKey
);
todo_wine
ok
(
result
,
"CryptImportKey failed at size %d: %d (%08x)
\n
"
,
dwLen
,
GetLastError
(),
GetLastError
());
if
(
result
)
...
...
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