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
4c46bd92
Commit
4c46bd92
authored
Nov 16, 2022
by
Hans Leidekker
Committed by
Alexandre Julliard
Dec 06, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcrypt: Validate key type.
parent
f95c2e46
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
15 deletions
+31
-15
bcrypt_main.c
dlls/bcrypt/bcrypt_main.c
+31
-15
No files found.
dlls/bcrypt/bcrypt_main.c
View file @
4c46bd92
...
...
@@ -121,6 +121,26 @@ builtin_algorithms[] =
{
BCRYPT_RNG_ALGORITHM
,
BCRYPT_RNG_INTERFACE
,
0
,
0
,
0
},
};
static
inline
BOOL
is_symmetric_key
(
struct
key
*
key
)
{
return
builtin_algorithms
[
key
->
alg_id
].
class
==
BCRYPT_CIPHER_INTERFACE
;
}
static
inline
BOOL
is_asymmetric_encryption_key
(
struct
key
*
key
)
{
return
builtin_algorithms
[
key
->
alg_id
].
class
==
BCRYPT_ASYMMETRIC_ENCRYPTION_INTERFACE
;
}
static
inline
BOOL
is_agreement_key
(
struct
key
*
key
)
{
return
builtin_algorithms
[
key
->
alg_id
].
class
==
BCRYPT_SECRET_AGREEMENT_INTERFACE
;
}
static
inline
BOOL
is_signature_key
(
struct
key
*
key
)
{
return
builtin_algorithms
[
key
->
alg_id
].
class
==
BCRYPT_SIGNATURE_INTERFACE
||
key
->
alg_id
==
ALG_ID_RSA
;
}
static
BOOL
match_operation_type
(
ULONG
type
,
ULONG
class
)
{
if
(
!
type
)
return
TRUE
;
...
...
@@ -1119,11 +1139,6 @@ static NTSTATUS key_asymmetric_create( enum alg_id alg_id, ULONG bitlen, struct
return
STATUS_SUCCESS
;
}
static
BOOL
key_is_symmetric
(
struct
key
*
key
)
{
return
builtin_algorithms
[
key
->
alg_id
].
class
==
BCRYPT_CIPHER_INTERFACE
;
}
static
BOOL
is_equal_vector
(
const
UCHAR
*
vector
,
ULONG
len
,
const
UCHAR
*
vector2
,
ULONG
len2
)
{
if
(
!
vector
&&
!
vector2
)
return
TRUE
;
...
...
@@ -1505,7 +1520,7 @@ static NTSTATUS key_symmetric_decrypt( struct key *key, UCHAR *input, ULONG inpu
static
void
key_destroy
(
struct
key
*
key
)
{
if
(
key_is_symmetric
(
key
))
if
(
is_symmetric_key
(
key
))
{
UNIX_CALL
(
key_symmetric_destroy
,
key
);
free
(
key
->
u
.
s
.
vector
);
...
...
@@ -1868,7 +1883,7 @@ static NTSTATUS key_duplicate( struct key *key_orig, struct key *key_copy )
key_copy
->
hdr
=
key_orig
->
hdr
;
key_copy
->
alg_id
=
key_orig
->
alg_id
;
if
(
key_is_symmetric
(
key_orig
))
if
(
is_symmetric_key
(
key_orig
))
{
if
(
!
(
buffer
=
malloc
(
key_orig
->
u
.
s
.
secret_len
)))
return
STATUS_NO_MEMORY
;
memcpy
(
buffer
,
key_orig
->
u
.
s
.
secret
,
key_orig
->
u
.
s
.
secret_len
);
...
...
@@ -1977,11 +1992,7 @@ NTSTATUS WINAPI BCryptSignHash( BCRYPT_KEY_HANDLE handle, void *padding, UCHAR *
ret_len
,
flags
);
if
(
!
key
)
return
STATUS_INVALID_HANDLE
;
if
(
key_is_symmetric
(
key
))
{
FIXME
(
"signing with symmetric keys not yet supported
\n
"
);
return
STATUS_NOT_IMPLEMENTED
;
}
if
(
!
is_signature_key
(
key
))
return
STATUS_NOT_SUPPORTED
;
params
.
key
=
key
;
params
.
padding
=
padding
;
...
...
@@ -2003,8 +2014,8 @@ NTSTATUS WINAPI BCryptVerifySignature( BCRYPT_KEY_HANDLE handle, void *padding,
TRACE
(
"%p, %p, %p, %lu, %p, %lu, %#lx
\n
"
,
handle
,
padding
,
hash
,
hash_len
,
signature
,
signature_len
,
flags
);
if
(
!
key
)
return
STATUS_INVALID_HANDLE
;
if
(
!
is_signature_key
(
key
))
return
STATUS_NOT_SUPPORTED
;
if
(
!
hash
||
!
hash_len
||
!
signature
||
!
signature_len
)
return
STATUS_INVALID_PARAMETER
;
if
(
key_is_symmetric
(
key
))
return
STATUS_NOT_SUPPORTED
;
params
.
key
=
key
;
params
.
padding
=
padding
;
...
...
@@ -2039,7 +2050,7 @@ NTSTATUS WINAPI BCryptEncrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG inp
if
(
!
key
)
return
STATUS_INVALID_HANDLE
;
if
(
key_is_symmetric
(
key
))
if
(
is_symmetric_key
(
key
))
{
if
(
flags
&
~
BCRYPT_BLOCK_PADDING
)
{
...
...
@@ -2057,6 +2068,8 @@ NTSTATUS WINAPI BCryptEncrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG inp
FIXME
(
"flags %#lx not implemented
\n
"
,
flags
);
return
STATUS_NOT_IMPLEMENTED
;
}
if
(
!
is_asymmetric_encryption_key
(
key
))
return
STATUS_NOT_SUPPORTED
;
asymmetric_params
.
input
=
input
;
asymmetric_params
.
input_len
=
input_len
;
asymmetric_params
.
key
=
key
;
...
...
@@ -2081,7 +2094,7 @@ NTSTATUS WINAPI BCryptDecrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG inp
if
(
!
key
)
return
STATUS_INVALID_HANDLE
;
if
(
key_is_symmetric
(
key
))
if
(
is_symmetric_key
(
key
))
{
if
(
flags
&
~
BCRYPT_BLOCK_PADDING
)
{
...
...
@@ -2100,6 +2113,8 @@ NTSTATUS WINAPI BCryptDecrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG inp
FIXME
(
"flags %#lx not implemented
\n
"
,
flags
);
return
STATUS_NOT_IMPLEMENTED
;
}
if
(
!
is_asymmetric_encryption_key
(
key
))
return
STATUS_NOT_SUPPORTED
;
params
.
key
=
key
;
params
.
input
=
input
;
params
.
input_len
=
input_len
;
...
...
@@ -2300,6 +2315,7 @@ NTSTATUS WINAPI BCryptSecretAgreement( BCRYPT_KEY_HANDLE privkey_handle, BCRYPT_
FIXME
(
"%p, %p, %p, %#lx
\n
"
,
privkey_handle
,
pubkey_handle
,
ret_handle
,
flags
);
if
(
!
privkey
||
!
pubkey
)
return
STATUS_INVALID_HANDLE
;
if
(
!
is_agreement_key
(
privkey
)
||
!
is_agreement_key
(
pubkey
))
return
STATUS_NOT_SUPPORTED
;
if
(
!
ret_handle
)
return
STATUS_INVALID_PARAMETER
;
if
(
!
(
secret
=
calloc
(
1
,
sizeof
(
*
secret
)
)))
return
STATUS_NO_MEMORY
;
...
...
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