Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
0f5f8f98
Commit
0f5f8f98
authored
Mar 10, 2022
by
Hans Leidekker
Committed by
Alexandre Julliard
Mar 10, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ncrypt: Always map bcrypt return values.
Signed-off-by:
Hans Leidekker
<
hans@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
bd55fe14
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
18 deletions
+20
-18
main.c
dlls/ncrypt/main.c
+20
-18
No files found.
dlls/ncrypt/main.c
View file @
0f5f8f98
...
...
@@ -37,6 +37,7 @@ static SECURITY_STATUS map_ntstatus(NTSTATUS status)
switch
(
status
)
{
case
STATUS_INVALID_HANDLE
:
return
NTE_INVALID_HANDLE
;
case
NTE_BAD_DATA
:
return
NTE_BAD_DATA
;
default:
FIXME
(
"unhandled status %#lx
\n
"
,
status
);
return
NTE_INTERNAL_ERROR
;
...
...
@@ -123,7 +124,7 @@ static SECURITY_STATUS set_object_property(struct object *object, const WCHAR *n
static
struct
object
*
create_key_object
(
enum
algid
algid
,
NCRYPT_PROV_HANDLE
provider
)
{
struct
object
*
object
;
NTSTATUS
ret
;
NTSTATUS
status
;
if
(
!
(
object
=
allocate_object
(
KEY
)))
{
...
...
@@ -135,10 +136,10 @@ static struct object *create_key_object(enum algid algid, NCRYPT_PROV_HANDLE pro
{
case
RSA
:
{
ret
=
BCryptOpenAlgorithmProvider
(
&
object
->
key
.
bcrypt_alg
,
BCRYPT_RSA_ALGORITHM
,
NULL
,
0
);
if
(
ret
!=
ERROR
_SUCCESS
)
status
=
BCryptOpenAlgorithmProvider
(
&
object
->
key
.
bcrypt_alg
,
BCRYPT_RSA_ALGORITHM
,
NULL
,
0
);
if
(
status
!=
STATUS
_SUCCESS
)
{
ERR
(
"Error opening algorithm provider
\n
"
);
ERR
(
"Error opening algorithm provider
%#lx
\n
"
,
status
);
free
(
object
);
return
NULL
;
}
...
...
@@ -174,7 +175,7 @@ SECURITY_STATUS WINAPI NCryptCreatePersistedKey(NCRYPT_PROV_HANDLE provider, NCR
if
(
!
lstrcmpiW
(
algid
,
BCRYPT_RSA_ALGORITHM
))
{
NTSTATUS
ret
;
NTSTATUS
status
;
DWORD
default_bitlen
=
1024
;
if
(
!
(
object
=
create_key_object
(
RSA
,
provider
)))
...
...
@@ -183,13 +184,13 @@ SECURITY_STATUS WINAPI NCryptCreatePersistedKey(NCRYPT_PROV_HANDLE provider, NCR
return
NTE_NO_MEMORY
;
}
ret
=
BCryptGenerateKeyPair
(
object
->
key
.
bcrypt_alg
,
&
object
->
key
.
bcrypt_key
,
default_bitlen
,
0
);
if
(
ret
!=
ERROR
_SUCCESS
)
status
=
BCryptGenerateKeyPair
(
object
->
key
.
bcrypt_alg
,
&
object
->
key
.
bcrypt_key
,
default_bitlen
,
0
);
if
(
status
!=
STATUS
_SUCCESS
)
{
ERR
(
"Error generating key pair
\n
"
);
ERR
(
"Error generating key pair
%#lx
\n
"
,
status
);
BCryptCloseAlgorithmProvider
(
object
->
key
.
bcrypt_alg
,
0
);
free
(
object
);
return
NTE_INTERNAL_ERROR
;
return
map_ntstatus
(
status
)
;
}
set_object_property
(
object
,
NCRYPT_LENGTH_PROPERTY
,
(
BYTE
*
)
&
default_bitlen
,
sizeof
(
default_bitlen
));
...
...
@@ -278,15 +279,16 @@ SECURITY_STATUS WINAPI NCryptFreeBuffer(PVOID buf)
static
SECURITY_STATUS
free_key_object
(
struct
key
*
key
)
{
NTSTATUS
ret
=
BCryptDestroyKey
(
key
->
bcrypt_key
);
if
(
BCryptCloseAlgorithmProvider
(
key
->
bcrypt_alg
,
0
))
return
NTE_INVALID_HANDLE
;
return
ret
?
NTE_INVALID_HANDLE
:
ERROR_SUCCESS
;
NTSTATUS
status
,
status2
;
status
=
BCryptDestroyKey
(
key
->
bcrypt_key
);
if
((
status2
=
BCryptCloseAlgorithmProvider
(
key
->
bcrypt_alg
,
0
)))
return
map_ntstatus
(
status2
);
return
status
?
map_ntstatus
(
status
)
:
ERROR_SUCCESS
;
}
SECURITY_STATUS
WINAPI
NCryptFreeObject
(
NCRYPT_HANDLE
handle
)
{
struct
object
*
object
=
(
struct
object
*
)
handle
;
SECURITY_STATUS
ret
=
ERROR
_SUCCESS
;
SECURITY_STATUS
ret
=
STATUS
_SUCCESS
;
unsigned
int
i
;
TRACE
(
"(%#Ix)
\n
"
,
handle
);
...
...
@@ -378,7 +380,7 @@ SECURITY_STATUS WINAPI NCryptImportKey(NCRYPT_PROV_HANDLE provider, NCRYPT_KEY_H
case
BCRYPT_RSAPRIVATE_MAGIC
:
case
BCRYPT_RSAPUBLIC_MAGIC
:
{
NTSTATUS
ret
;
NTSTATUS
status
;
BCRYPT_RSAKEY_BLOB
*
rsablob
=
(
BCRYPT_RSAKEY_BLOB
*
)
data
;
if
(
!
(
object
=
create_key_object
(
RSA
,
provider
)))
...
...
@@ -387,13 +389,13 @@ SECURITY_STATUS WINAPI NCryptImportKey(NCRYPT_PROV_HANDLE provider, NCRYPT_KEY_H
return
NTE_NO_MEMORY
;
}
ret
=
BCryptImportKeyPair
(
object
->
key
.
bcrypt_alg
,
NULL
,
type
,
&
object
->
key
.
bcrypt_key
,
data
,
datasize
,
0
);
if
(
ret
!=
ERROR
_SUCCESS
)
status
=
BCryptImportKeyPair
(
object
->
key
.
bcrypt_alg
,
NULL
,
type
,
&
object
->
key
.
bcrypt_key
,
data
,
datasize
,
0
);
if
(
status
!=
STATUS
_SUCCESS
)
{
WARN
(
"Error importing key pair
with bcrypt %#lx
\n
"
,
ret
);
WARN
(
"Error importing key pair
%#lx
\n
"
,
status
);
BCryptCloseAlgorithmProvider
(
object
->
key
.
bcrypt_alg
,
0
);
free
(
object
);
return
NTE_BAD_DATA
;
return
map_ntstatus
(
status
)
;
}
set_object_property
(
object
,
NCRYPT_LENGTH_PROPERTY
,
(
BYTE
*
)
&
rsablob
->
BitLength
,
sizeof
(
rsablob
->
BitLength
));
...
...
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