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
27cdb54b
Commit
27cdb54b
authored
Jul 31, 2022
by
Santino Mazza
Committed by
Alexandre Julliard
Aug 03, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ncrypt: Initial implementation for NCryptEncrypt.
Signed-off-by:
Santino Mazza
<
mazzasantino1206@gmail.com
>
parent
dd61c563
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
3 deletions
+25
-3
main.c
dlls/ncrypt/main.c
+21
-1
ncrypt.c
dlls/ncrypt/tests/ncrypt.c
+4
-2
No files found.
dlls/ncrypt/main.c
View file @
27cdb54b
...
@@ -43,6 +43,7 @@ static SECURITY_STATUS map_ntstatus(NTSTATUS status)
...
@@ -43,6 +43,7 @@ static SECURITY_STATUS map_ntstatus(NTSTATUS status)
case
STATUS_NO_MEMORY
:
return
NTE_NO_MEMORY
;
case
STATUS_NO_MEMORY
:
return
NTE_NO_MEMORY
;
case
STATUS_NOT_SUPPORTED
:
return
NTE_NOT_SUPPORTED
;
case
STATUS_NOT_SUPPORTED
:
return
NTE_NOT_SUPPORTED
;
case
NTE_BAD_DATA
:
return
NTE_BAD_DATA
;
case
NTE_BAD_DATA
:
return
NTE_BAD_DATA
;
case
STATUS_BUFFER_TOO_SMALL
:
return
NTE_BUFFER_TOO_SMALL
;
default:
default:
FIXME
(
"unhandled status %#lx
\n
"
,
status
);
FIXME
(
"unhandled status %#lx
\n
"
,
status
);
return
NTE_INTERNAL_ERROR
;
return
NTE_INTERNAL_ERROR
;
...
@@ -227,9 +228,28 @@ SECURITY_STATUS WINAPI NCryptDeleteKey(NCRYPT_KEY_HANDLE key, DWORD flags)
...
@@ -227,9 +228,28 @@ SECURITY_STATUS WINAPI NCryptDeleteKey(NCRYPT_KEY_HANDLE key, DWORD flags)
SECURITY_STATUS
WINAPI
NCryptEncrypt
(
NCRYPT_KEY_HANDLE
key
,
BYTE
*
input
,
DWORD
insize
,
void
*
padding
,
SECURITY_STATUS
WINAPI
NCryptEncrypt
(
NCRYPT_KEY_HANDLE
key
,
BYTE
*
input
,
DWORD
insize
,
void
*
padding
,
BYTE
*
output
,
DWORD
outsize
,
DWORD
*
result
,
DWORD
flags
)
BYTE
*
output
,
DWORD
outsize
,
DWORD
*
result
,
DWORD
flags
)
{
{
FIXME
(
"(%#Ix, %p, %lu, %p, %p, %lu, %p, %#lx): stub
\n
"
,
key
,
input
,
insize
,
padding
,
struct
object
*
key_object
=
(
struct
object
*
)
key
;
TRACE
(
"(%#Ix, %p, %lu, %p, %p, %lu, %p, %#lx)
\n
"
,
key
,
input
,
insize
,
padding
,
output
,
outsize
,
result
,
flags
);
output
,
outsize
,
result
,
flags
);
if
(
flags
&
~
(
NCRYPT_NO_PADDING_FLAG
|
NCRYPT_PAD_OAEP_FLAG
|
NCRYPT_PAD_PKCS1_FLAG
|
NCRYPT_SILENT_FLAG
))
{
FIXME
(
"Flags %lx not supported
\n
"
,
flags
);
return
NTE_BAD_FLAGS
;
}
if
(
flags
&
NCRYPT_NO_PADDING_FLAG
||
flags
&
NCRYPT_PAD_OAEP_FLAG
)
{
FIXME
(
"No padding and oaep padding not supported
\n
"
);
return
NTE_NOT_SUPPORTED
;
return
NTE_NOT_SUPPORTED
;
}
if
(
key_object
->
type
!=
KEY
)
return
NTE_INVALID_HANDLE
;
return
map_ntstatus
(
BCryptEncrypt
(
key_object
->
key
.
bcrypt_key
,
input
,
insize
,
padding
,
NULL
,
0
,
output
,
outsize
,
result
,
flags
));
}
}
SECURITY_STATUS
WINAPI
NCryptEnumAlgorithms
(
NCRYPT_PROV_HANDLE
provider
,
DWORD
alg_ops
,
SECURITY_STATUS
WINAPI
NCryptEnumAlgorithms
(
NCRYPT_PROV_HANDLE
provider
,
DWORD
alg_ops
,
...
...
dlls/ncrypt/tests/ncrypt.c
View file @
27cdb54b
...
@@ -550,7 +550,6 @@ static void test_NCryptEncrypt(void)
...
@@ -550,7 +550,6 @@ static void test_NCryptEncrypt(void)
BYTE
*
output_b
;
BYTE
*
output_b
;
DWORD
output_size
;
DWORD
output_size
;
todo_wine
{
NCryptOpenStorageProvider
(
&
prov
,
NULL
,
0
);
NCryptOpenStorageProvider
(
&
prov
,
NULL
,
0
);
NCryptCreatePersistedKey
(
prov
,
&
key
,
BCRYPT_RSA_ALGORITHM
,
NULL
,
0
,
0
);
NCryptCreatePersistedKey
(
prov
,
&
key
,
BCRYPT_RSA_ALGORITHM
,
NULL
,
0
,
0
);
...
@@ -562,6 +561,7 @@ static void test_NCryptEncrypt(void)
...
@@ -562,6 +561,7 @@ static void test_NCryptEncrypt(void)
/* Test encrypt with a non finalized key */
/* Test encrypt with a non finalized key */
ret
=
NCryptEncrypt
(
key
,
data_to_encrypt
,
sizeof
(
data_to_encrypt
),
NULL
,
NULL
,
0
,
ret
=
NCryptEncrypt
(
key
,
data_to_encrypt
,
sizeof
(
data_to_encrypt
),
NULL
,
NULL
,
0
,
&
output_size
,
NCRYPT_PAD_PKCS1_FLAG
);
&
output_size
,
NCRYPT_PAD_PKCS1_FLAG
);
todo_wine
ok
(
ret
==
NTE_BAD_KEY_STATE
,
"got %lx
\n
"
,
ret
);
ok
(
ret
==
NTE_BAD_KEY_STATE
,
"got %lx
\n
"
,
ret
);
NCryptFinalizeKey
(
key
,
0
);
NCryptFinalizeKey
(
key
,
0
);
...
@@ -572,6 +572,8 @@ static void test_NCryptEncrypt(void)
...
@@ -572,6 +572,8 @@ static void test_NCryptEncrypt(void)
ok
(
ret
==
NTE_BAD_FLAGS
,
"got %lx
\n
"
,
ret
);
ok
(
ret
==
NTE_BAD_FLAGS
,
"got %lx
\n
"
,
ret
);
/* Test no padding with RSA */
/* Test no padding with RSA */
todo_wine
{
ret
=
NCryptEncrypt
(
key
,
data_to_encrypt
,
sizeof
(
data_to_encrypt
),
NULL
,
NULL
,
0
,
&
output_size
,
ret
=
NCryptEncrypt
(
key
,
data_to_encrypt
,
sizeof
(
data_to_encrypt
),
NULL
,
NULL
,
0
,
&
output_size
,
NCRYPT_NO_PADDING_FLAG
);
NCRYPT_NO_PADDING_FLAG
);
ok
(
ret
==
ERROR_SUCCESS
,
"got %lx
\n
"
,
ret
);
ok
(
ret
==
ERROR_SUCCESS
,
"got %lx
\n
"
,
ret
);
...
@@ -582,6 +584,7 @@ static void test_NCryptEncrypt(void)
...
@@ -582,6 +584,7 @@ static void test_NCryptEncrypt(void)
&
output_size
,
NCRYPT_NO_PADDING_FLAG
);
&
output_size
,
NCRYPT_NO_PADDING_FLAG
);
ok
(
ret
==
NTE_INVALID_PARAMETER
,
"got %lx
\n
"
,
ret
);
ok
(
ret
==
NTE_INVALID_PARAMETER
,
"got %lx
\n
"
,
ret
);
free
(
output_a
);
free
(
output_a
);
}
/* Test output RSA with PKCS1. PKCS1 should append a random padding to the data, so the output should be different
/* Test output RSA with PKCS1. PKCS1 should append a random padding to the data, so the output should be different
* with each call. */
* with each call. */
...
@@ -611,7 +614,6 @@ static void test_NCryptEncrypt(void)
...
@@ -611,7 +614,6 @@ static void test_NCryptEncrypt(void)
free
(
output_b
);
free
(
output_b
);
NCryptFreeObject
(
prov
);
NCryptFreeObject
(
prov
);
}
}
}
START_TEST
(
ncrypt
)
START_TEST
(
ncrypt
)
...
...
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