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
1120a1cb
Commit
1120a1cb
authored
Sep 20, 2022
by
Paul Gofman
Committed by
Alexandre Julliard
Sep 21, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Support CRYPT_STRING_HEX in CryptStringToBinary().
parent
a79ec1c5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
123 additions
and
0 deletions
+123
-0
base64.c
dlls/crypt32/base64.c
+123
-0
base64.c
dlls/crypt32/tests/base64.c
+0
-0
No files found.
dlls/crypt32/base64.c
View file @
1120a1cb
...
@@ -943,6 +943,120 @@ static LONG DecodeAnyA(LPCSTR pszString, DWORD cchString,
...
@@ -943,6 +943,120 @@ static LONG DecodeAnyA(LPCSTR pszString, DWORD cchString,
return
ret
;
return
ret
;
}
}
static
BOOL
is_hex_string_special_char
(
WCHAR
c
)
{
switch
(
c
)
{
case
'-'
:
case
','
:
case
' '
:
case
'\t'
:
case
'\r'
:
case
'\n'
:
return
TRUE
;
default:
return
FALSE
;
}
}
static
WCHAR
wchar_from_str
(
BOOL
wide
,
const
void
**
str
,
DWORD
*
len
)
{
WCHAR
c
;
if
(
!*
len
)
return
0
;
--*
len
;
if
(
wide
)
c
=
*
(
*
(
const
WCHAR
**
)
str
)
++
;
else
c
=
*
(
*
(
const
char
**
)
str
)
++
;
return
c
?
c
:
0xffff
;
}
static
BYTE
digit_from_char
(
WCHAR
c
)
{
if
(
c
>=
'0'
&&
c
<=
'9'
)
return
c
-
'0'
;
c
=
towlower
(
c
);
if
(
c
>=
'a'
&&
c
<=
'f'
)
return
c
-
'a'
+
0xa
;
return
0xff
;
}
static
LONG
string_to_hex
(
const
void
*
str
,
BOOL
wide
,
DWORD
len
,
BYTE
*
hex
,
DWORD
*
hex_len
,
DWORD
*
skipped
,
DWORD
*
ret_flags
)
{
unsigned
int
byte_idx
=
0
;
BYTE
d1
,
d2
;
WCHAR
c
;
if
(
!
str
||
!
hex_len
)
return
ERROR_INVALID_PARAMETER
;
if
(
!
len
)
len
=
wide
?
wcslen
(
str
)
:
strlen
(
str
);
if
(
wide
&&
!
len
)
return
ERROR_INVALID_PARAMETER
;
if
(
skipped
)
*
skipped
=
0
;
if
(
ret_flags
)
*
ret_flags
=
0
;
while
((
c
=
wchar_from_str
(
wide
,
&
str
,
&
len
))
&&
is_hex_string_special_char
(
c
))
;
while
((
d1
=
digit_from_char
(
c
))
!=
0xff
)
{
if
((
d2
=
digit_from_char
(
wchar_from_str
(
wide
,
&
str
,
&
len
)))
==
0xff
)
{
if
(
!
hex
)
*
hex_len
=
0
;
return
ERROR_INVALID_DATA
;
}
if
(
hex
&&
byte_idx
<
*
hex_len
)
hex
[
byte_idx
]
=
(
d1
<<
4
)
|
d2
;
++
byte_idx
;
do
{
c
=
wchar_from_str
(
wide
,
&
str
,
&
len
);
}
while
(
c
==
'-'
||
c
==
','
);
}
while
(
c
)
{
if
(
!
is_hex_string_special_char
(
c
))
{
if
(
!
hex
)
*
hex_len
=
0
;
return
ERROR_INVALID_DATA
;
}
c
=
wchar_from_str
(
wide
,
&
str
,
&
len
);
}
if
(
hex
&&
byte_idx
>
*
hex_len
)
return
ERROR_MORE_DATA
;
if
(
ret_flags
)
*
ret_flags
=
CRYPT_STRING_HEX
;
*
hex_len
=
byte_idx
;
return
ERROR_SUCCESS
;
}
static
LONG
string_to_hexA
(
const
char
*
str
,
DWORD
len
,
BYTE
*
hex
,
DWORD
*
hex_len
,
DWORD
*
skipped
,
DWORD
*
ret_flags
)
{
return
string_to_hex
(
str
,
FALSE
,
len
,
hex
,
hex_len
,
skipped
,
ret_flags
);
}
BOOL
WINAPI
CryptStringToBinaryA
(
LPCSTR
pszString
,
BOOL
WINAPI
CryptStringToBinaryA
(
LPCSTR
pszString
,
DWORD
cchString
,
DWORD
dwFlags
,
BYTE
*
pbBinary
,
DWORD
*
pcbBinary
,
DWORD
cchString
,
DWORD
dwFlags
,
BYTE
*
pbBinary
,
DWORD
*
pcbBinary
,
DWORD
*
pdwSkip
,
DWORD
*
pdwFlags
)
DWORD
*
pdwSkip
,
DWORD
*
pdwFlags
)
...
@@ -988,6 +1102,8 @@ BOOL WINAPI CryptStringToBinaryA(LPCSTR pszString,
...
@@ -988,6 +1102,8 @@ BOOL WINAPI CryptStringToBinaryA(LPCSTR pszString,
decoder
=
DecodeAnyA
;
decoder
=
DecodeAnyA
;
break
;
break
;
case
CRYPT_STRING_HEX
:
case
CRYPT_STRING_HEX
:
decoder
=
string_to_hexA
;
break
;
case
CRYPT_STRING_HEXASCII
:
case
CRYPT_STRING_HEXASCII
:
case
CRYPT_STRING_HEXADDR
:
case
CRYPT_STRING_HEXADDR
:
case
CRYPT_STRING_HEXASCIIADDR
:
case
CRYPT_STRING_HEXASCIIADDR
:
...
@@ -1154,6 +1270,11 @@ static LONG DecodeAnyW(LPCWSTR pszString, DWORD cchString,
...
@@ -1154,6 +1270,11 @@ static LONG DecodeAnyW(LPCWSTR pszString, DWORD cchString,
return
ret
;
return
ret
;
}
}
static
LONG
string_to_hexW
(
const
WCHAR
*
str
,
DWORD
len
,
BYTE
*
hex
,
DWORD
*
hex_len
,
DWORD
*
skipped
,
DWORD
*
ret_flags
)
{
return
string_to_hex
(
str
,
TRUE
,
len
,
hex
,
hex_len
,
skipped
,
ret_flags
);
}
BOOL
WINAPI
CryptStringToBinaryW
(
LPCWSTR
pszString
,
BOOL
WINAPI
CryptStringToBinaryW
(
LPCWSTR
pszString
,
DWORD
cchString
,
DWORD
dwFlags
,
BYTE
*
pbBinary
,
DWORD
*
pcbBinary
,
DWORD
cchString
,
DWORD
dwFlags
,
BYTE
*
pbBinary
,
DWORD
*
pcbBinary
,
DWORD
*
pdwSkip
,
DWORD
*
pdwFlags
)
DWORD
*
pdwSkip
,
DWORD
*
pdwFlags
)
...
@@ -1199,6 +1320,8 @@ BOOL WINAPI CryptStringToBinaryW(LPCWSTR pszString,
...
@@ -1199,6 +1320,8 @@ BOOL WINAPI CryptStringToBinaryW(LPCWSTR pszString,
decoder
=
DecodeAnyW
;
decoder
=
DecodeAnyW
;
break
;
break
;
case
CRYPT_STRING_HEX
:
case
CRYPT_STRING_HEX
:
decoder
=
string_to_hexW
;
break
;
case
CRYPT_STRING_HEXASCII
:
case
CRYPT_STRING_HEXASCII
:
case
CRYPT_STRING_HEXADDR
:
case
CRYPT_STRING_HEXADDR
:
case
CRYPT_STRING_HEXASCIIADDR
:
case
CRYPT_STRING_HEXASCIIADDR
:
...
...
dlls/crypt32/tests/base64.c
View file @
1120a1cb
This diff is collapsed.
Click to expand it.
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