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
5c2ac77a
Commit
5c2ac77a
authored
Feb 13, 2019
by
Hans Leidekker
Committed by
Alexandre Julliard
Feb 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcrypt: Add support for importing and exporting ECC public keys.
Signed-off-by:
Hans Leidekker
<
hans@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
73b695f0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
1 deletion
+37
-1
bcrypt_main.c
dlls/bcrypt/bcrypt_main.c
+15
-1
bcrypt.c
dlls/bcrypt/tests/bcrypt.c
+22
-0
No files found.
dlls/bcrypt/bcrypt_main.c
View file @
5c2ac77a
...
...
@@ -813,6 +813,14 @@ static NTSTATUS key_export( struct key *key, const WCHAR *type, UCHAR *output, U
memcpy
(
output
+
sizeof
(
len
),
key
->
u
.
s
.
secret
,
key
->
u
.
s
.
secret_len
);
return
STATUS_SUCCESS
;
}
else
if
(
!
strcmpW
(
type
,
BCRYPT_ECCPUBLIC_BLOB
))
{
*
size
=
key
->
u
.
a
.
pubkey_len
;
if
(
output_len
<
key
->
u
.
a
.
pubkey_len
)
return
STATUS_SUCCESS
;
memcpy
(
output
,
key
->
u
.
a
.
pubkey
,
key
->
u
.
a
.
pubkey_len
);
return
STATUS_SUCCESS
;
}
FIXME
(
"unsupported key type %s
\n
"
,
debugstr_w
(
type
)
);
return
STATUS_NOT_IMPLEMENTED
;
...
...
@@ -1012,6 +1020,11 @@ static NTSTATUS key_import_pair( struct algorithm *alg, const WCHAR *type, BCRYP
switch
(
alg
->
id
)
{
case
ALG_ID_ECDH_P256
:
key_size
=
32
;
magic
=
BCRYPT_ECDH_PUBLIC_P256_MAGIC
;
break
;
case
ALG_ID_ECDSA_P256
:
key_size
=
32
;
magic
=
BCRYPT_ECDSA_PUBLIC_P256_MAGIC
;
...
...
@@ -1028,7 +1041,8 @@ static NTSTATUS key_import_pair( struct algorithm *alg, const WCHAR *type, BCRYP
}
if
(
ecc_blob
->
dwMagic
!=
magic
)
return
STATUS_NOT_SUPPORTED
;
if
(
ecc_blob
->
cbKey
!=
key_size
)
return
STATUS_INVALID_PARAMETER
;
if
(
ecc_blob
->
cbKey
!=
key_size
||
input_len
<
sizeof
(
*
ecc_blob
)
+
ecc_blob
->
cbKey
*
2
)
return
STATUS_INVALID_PARAMETER
;
if
(
!
(
key
=
heap_alloc_zero
(
sizeof
(
*
key
)
)))
return
STATUS_NO_MEMORY
;
key
->
hdr
.
magic
=
MAGIC_KEY
;
...
...
dlls/bcrypt/tests/bcrypt.c
View file @
5c2ac77a
...
...
@@ -1659,9 +1659,12 @@ static void test_RSA(void)
static
void
test_ECDH
(
void
)
{
BYTE
*
buf
;
BCRYPT_ECCKEY_BLOB
*
ecckey
;
BCRYPT_ALG_HANDLE
alg
;
BCRYPT_KEY_HANDLE
key
;
NTSTATUS
status
;
ULONG
size
;
status
=
pBCryptOpenAlgorithmProvider
(
&
alg
,
BCRYPT_ECDH_P256_ALGORITHM
,
NULL
,
0
);
if
(
status
)
...
...
@@ -1678,6 +1681,25 @@ static void test_ECDH(void)
status
=
pBCryptFinalizeKeyPair
(
key
,
0
);
ok
(
status
==
STATUS_SUCCESS
,
"got %08x
\n
"
,
status
);
size
=
0
;
SetLastError
(
0xdeadbeef
);
status
=
pBCryptExportKey
(
key
,
NULL
,
BCRYPT_ECCPUBLIC_BLOB
,
NULL
,
0
,
&
size
,
0
);
ok
(
status
==
STATUS_SUCCESS
,
"got %08x
\n
"
,
status
);
ok
(
size
,
"size not set
\n
"
);
buf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
status
=
pBCryptExportKey
(
key
,
NULL
,
BCRYPT_ECCPUBLIC_BLOB
,
buf
,
size
,
&
size
,
0
);
ok
(
status
==
STATUS_SUCCESS
,
"got %08x
\n
"
,
status
);
ecckey
=
(
BCRYPT_ECCKEY_BLOB
*
)
buf
;
ok
(
ecckey
->
dwMagic
==
BCRYPT_ECDH_PUBLIC_P256_MAGIC
,
"got %08x
\n
"
,
ecckey
->
dwMagic
);
ok
(
ecckey
->
cbKey
==
32
,
"got %u
\n
"
,
ecckey
->
cbKey
);
ok
(
size
==
sizeof
(
*
ecckey
)
+
ecckey
->
cbKey
*
2
,
"got %u
\n
"
,
size
);
pBCryptDestroyKey
(
key
);
status
=
pBCryptImportKeyPair
(
alg
,
NULL
,
BCRYPT_ECCPUBLIC_BLOB
,
&
key
,
buf
,
size
,
0
);
ok
(
status
==
STATUS_SUCCESS
,
"got %08x
\n
"
,
status
);
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
pBCryptDestroyKey
(
key
);
pBCryptCloseAlgorithmProvider
(
alg
,
0
);
}
...
...
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