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
d17b118f
Commit
d17b118f
authored
Jul 29, 2020
by
Hans Leidekker
Committed by
Alexandre Julliard
Jul 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcrypt: Allow importing private ECDSA keys.
Based on a patch by Derek Lesho. Signed-off-by:
Hans Leidekker
<
hans@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
4401d460
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
6 deletions
+38
-6
bcrypt_main.c
dlls/bcrypt/bcrypt_main.c
+4
-0
gnutls.c
dlls/bcrypt/gnutls.c
+1
-0
bcrypt.c
dlls/bcrypt/tests/bcrypt.c
+33
-6
No files found.
dlls/bcrypt/bcrypt_main.c
View file @
d17b118f
...
...
@@ -1201,6 +1201,10 @@ static NTSTATUS key_import_pair( struct algorithm *alg, const WCHAR *type, BCRYP
key_size
=
32
;
magic
=
BCRYPT_ECDH_PRIVATE_P256_MAGIC
;
break
;
case
ALG_ID_ECDSA_P256
:
key_size
=
32
;
magic
=
BCRYPT_ECDSA_PRIVATE_P256_MAGIC
;
break
;
default:
FIXME
(
"algorithm %u does not yet support importing blob of type %s
\n
"
,
alg
->
id
,
debugstr_w
(
type
)
);
...
...
dlls/bcrypt/gnutls.c
View file @
d17b118f
...
...
@@ -952,6 +952,7 @@ NTSTATUS key_import_ecc( struct key *key, UCHAR *buf, ULONG len )
switch
(
key
->
alg_id
)
{
case
ALG_ID_ECDH_P256
:
case
ALG_ID_ECDSA_P256
:
curve
=
GNUTLS_ECC_CURVE_SECP256R1
;
break
;
...
...
dlls/bcrypt/tests/bcrypt.c
View file @
d17b118f
...
...
@@ -1670,6 +1670,18 @@ static void test_key_import_export(void)
ok
(
ret
==
STATUS_SUCCESS
,
"got %08x
\n
"
,
ret
);
}
static
BYTE
eccPrivkey
[]
=
{
/* X */
0x26
,
0xff
,
0x0e
,
0xf9
,
0x71
,
0x93
,
0xf8
,
0xed
,
0x59
,
0xfa
,
0x24
,
0xec
,
0x18
,
0x13
,
0xfe
,
0xf5
,
0x0b
,
0x4a
,
0xb1
,
0x27
,
0xb7
,
0xab
,
0x3e
,
0x4f
,
0xc5
,
0x5a
,
0x91
,
0xa3
,
0x6e
,
0x21
,
0x61
,
0x65
,
/* Y */
0x62
,
0x7b
,
0x8b
,
0x30
,
0x7a
,
0x63
,
0x4c
,
0x1a
,
0xf4
,
0x54
,
0x54
,
0xbb
,
0x75
,
0x59
,
0x68
,
0x36
,
0xfe
,
0x49
,
0x95
,
0x75
,
0x9e
,
0x20
,
0x3e
,
0x69
,
0x58
,
0xb9
,
0x7a
,
0x84
,
0x03
,
0x45
,
0x5c
,
0x10
,
/* d */
0xb9
,
0xcd
,
0xbe
,
0xd4
,
0x75
,
0x5d
,
0x05
,
0xe5
,
0x83
,
0x0c
,
0xd3
,
0x37
,
0x34
,
0x15
,
0xe3
,
0x2c
,
0xe5
,
0x85
,
0x15
,
0xa9
,
0xee
,
0xba
,
0x94
,
0x03
,
0x03
,
0x0b
,
0x86
,
0xea
,
0x85
,
0x40
,
0xbd
,
0x35
,
};
static
BYTE
eccPubkey
[]
=
{
/* X */
...
...
@@ -1696,11 +1708,12 @@ static BYTE certSignature[] =
static
void
test_ECDSA
(
void
)
{
BYTE
buffer
[
sizeof
(
BCRYPT_ECCKEY_BLOB
)
+
sizeof
(
eccP
ub
key
)];
BYTE
buffer
[
sizeof
(
BCRYPT_ECCKEY_BLOB
)
+
sizeof
(
eccP
riv
key
)];
BCRYPT_ECCKEY_BLOB
*
ecckey
=
(
void
*
)
buffer
;
BCRYPT_ALG_HANDLE
alg
=
NULL
;
BCRYPT_KEY_HANDLE
key
=
NULL
;
BCRYPT_ALG_HANDLE
alg
;
BCRYPT_KEY_HANDLE
key
;
NTSTATUS
status
;
ULONG
size
;
status
=
pBCryptOpenAlgorithmProvider
(
&
alg
,
BCRYPT_ECDSA_P256_ALGORITHM
,
NULL
,
0
);
if
(
status
)
...
...
@@ -1713,11 +1726,12 @@ static void test_ECDSA(void)
memcpy
(
ecckey
+
1
,
eccPubkey
,
sizeof
(
eccPubkey
));
ecckey
->
cbKey
=
2
;
status
=
pBCryptImportKeyPair
(
alg
,
NULL
,
BCRYPT_ECCPUBLIC_BLOB
,
&
key
,
buffer
,
sizeof
(
buffer
),
0
);
size
=
sizeof
(
BCRYPT_ECCKEY_BLOB
)
+
sizeof
(
eccPubkey
);
status
=
pBCryptImportKeyPair
(
alg
,
NULL
,
BCRYPT_ECCPUBLIC_BLOB
,
&
key
,
buffer
,
size
,
0
);
ok
(
status
==
STATUS_INVALID_PARAMETER
,
"Expected STATUS_INVALID_PARAMETER, got %08x
\n
"
,
status
);
ecckey
->
cbKey
=
sizeof
(
eccPubkey
)
/
2
;
status
=
pBCryptImportKeyPair
(
alg
,
NULL
,
BCRYPT_ECCPUBLIC_BLOB
,
&
key
,
buffer
,
size
of
(
buffer
)
,
0
);
ecckey
->
cbKey
=
3
2
;
status
=
pBCryptImportKeyPair
(
alg
,
NULL
,
BCRYPT_ECCPUBLIC_BLOB
,
&
key
,
buffer
,
size
,
0
);
ok
(
!
status
,
"BCryptImportKeyPair failed: %08x
\n
"
,
status
);
status
=
pBCryptVerifySignature
(
key
,
NULL
,
certHash
,
sizeof
(
certHash
)
-
1
,
certSignature
,
sizeof
(
certSignature
),
0
);
...
...
@@ -1725,6 +1739,19 @@ static void test_ECDSA(void)
status
=
pBCryptVerifySignature
(
key
,
NULL
,
certHash
,
sizeof
(
certHash
),
certSignature
,
sizeof
(
certSignature
),
0
);
ok
(
!
status
,
"BCryptVerifySignature failed: %08x
\n
"
,
status
);
pBCryptDestroyKey
(
key
);
ecckey
->
dwMagic
=
BCRYPT_ECDSA_PRIVATE_P256_MAGIC
;
memcpy
(
ecckey
+
1
,
eccPrivkey
,
sizeof
(
eccPrivkey
));
ecckey
->
cbKey
=
2
;
size
=
sizeof
(
BCRYPT_ECCKEY_BLOB
)
+
sizeof
(
eccPrivkey
);
status
=
pBCryptImportKeyPair
(
alg
,
NULL
,
BCRYPT_ECCPRIVATE_BLOB
,
&
key
,
buffer
,
size
,
0
);
ok
(
status
==
STATUS_INVALID_PARAMETER
,
"Expected STATUS_INVALID_PARAMETER, got %08x
\n
"
,
status
);
ecckey
->
cbKey
=
32
;
status
=
pBCryptImportKeyPair
(
alg
,
NULL
,
BCRYPT_ECCPRIVATE_BLOB
,
&
key
,
buffer
,
size
,
0
);
ok
(
!
status
,
"BCryptImportKeyPair failed: %08x
\n
"
,
status
);
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