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
4918be2c
Commit
4918be2c
authored
Sep 12, 2022
by
Hans Leidekker
Committed by
Alexandre Julliard
Sep 13, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ncrypt: Use BCrypt algorithm pseudo-handles.
parent
ba1631ad
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
28 deletions
+5
-28
main.c
dlls/ncrypt/main.c
+5
-27
ncrypt_internal.h
dlls/ncrypt/ncrypt_internal.h
+0
-1
No files found.
dlls/ncrypt/main.c
View file @
4918be2c
...
...
@@ -130,38 +130,21 @@ 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
status
;
if
(
!
(
object
=
allocate_object
(
KEY
)))
{
ERR
(
"Error allocating memory
\n
"
);
return
NULL
;
}
switch
(
algid
)
{
case
RSA
:
{
status
=
BCryptOpenAlgorithmProvider
(
&
object
->
key
.
bcrypt_alg
,
BCRYPT_RSA_ALGORITHM
,
NULL
,
0
);
if
(
status
!=
STATUS_SUCCESS
)
{
ERR
(
"Error opening algorithm provider %#lx
\n
"
,
status
);
free
(
object
);
return
NULL
;
}
if
(
!
(
object
=
allocate_object
(
KEY
)))
return
NULL
;
object
->
key
.
algid
=
RSA
;
set_object_property
(
object
,
NCRYPT_ALGORITHM_GROUP_PROPERTY
,
(
BYTE
*
)
BCRYPT_RSA_ALGORITHM
,
sizeof
(
BCRYPT_RSA_ALGORITHM
));
break
;
}
default:
{
ERR
(
"Invalid algid %#x
\n
"
,
algid
);
free
(
object
);
return
NULL
;
}
}
set_object_property
(
object
,
NCRYPT_PROVIDER_HANDLE_PROPERTY
,
(
BYTE
*
)
&
provider
,
sizeof
(
provider
));
return
object
;
...
...
@@ -190,11 +173,10 @@ SECURITY_STATUS WINAPI NCryptCreatePersistedKey(NCRYPT_PROV_HANDLE provider, NCR
return
NTE_NO_MEMORY
;
}
status
=
BCryptGenerateKeyPair
(
object
->
key
.
bcrypt_alg
,
&
object
->
key
.
bcrypt_key
,
default_bitlen
,
0
);
status
=
BCryptGenerateKeyPair
(
BCRYPT_RSA_ALG_HANDLE
,
&
object
->
key
.
bcrypt_key
,
default_bitlen
,
0
);
if
(
status
!=
STATUS_SUCCESS
)
{
ERR
(
"Error generating key pair %#lx
\n
"
,
status
);
BCryptCloseAlgorithmProvider
(
object
->
key
.
bcrypt_alg
,
0
);
free
(
object
);
return
map_ntstatus
(
status
);
}
...
...
@@ -304,10 +286,7 @@ SECURITY_STATUS WINAPI NCryptFreeBuffer(PVOID buf)
static
SECURITY_STATUS
free_key_object
(
struct
key
*
key
)
{
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
;
return
map_ntstatus
(
BCryptDestroyKey
(
key
->
bcrypt_key
)
);
}
SECURITY_STATUS
WINAPI
NCryptFreeObject
(
NCRYPT_HANDLE
handle
)
...
...
@@ -414,11 +393,10 @@ SECURITY_STATUS WINAPI NCryptImportKey(NCRYPT_PROV_HANDLE provider, NCRYPT_KEY_H
return
NTE_NO_MEMORY
;
}
status
=
BCryptImportKeyPair
(
object
->
key
.
bcrypt_alg
,
NULL
,
type
,
&
object
->
key
.
bcrypt_key
,
data
,
datasize
,
0
);
status
=
BCryptImportKeyPair
(
BCRYPT_RSA_ALG_HANDLE
,
NULL
,
type
,
&
object
->
key
.
bcrypt_key
,
data
,
datasize
,
0
);
if
(
status
!=
STATUS_SUCCESS
)
{
WARN
(
"Error importing key pair %#lx
\n
"
,
status
);
BCryptCloseAlgorithmProvider
(
object
->
key
.
bcrypt_alg
,
0
);
free
(
object
);
return
map_ntstatus
(
status
);
}
...
...
dlls/ncrypt/ncrypt_internal.h
View file @
4918be2c
...
...
@@ -31,7 +31,6 @@ enum algid
struct
key
{
enum
algid
algid
;
BCRYPT_ALG_HANDLE
bcrypt_alg
;
BCRYPT_KEY_HANDLE
bcrypt_key
;
};
...
...
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