Updated bcrypt-ECDHSecretAgreement patchset.

Update key_funcs[] in gcrypt.c and thus fix the crash
on attempt to compute ECDH secret agreement.
This commit is contained in:
Paul Gofman 2020-12-16 00:30:41 +03:00
parent fe5b02cbbc
commit 53bbade133
3 changed files with 40 additions and 38 deletions

View File

@ -1,4 +1,4 @@
From eaab7eaeb7533445473bc19d947c34bdc360566e Mon Sep 17 00:00:00 2001
From e2d88702bb88b9f4e2531d5c1c634553b2928554 Mon Sep 17 00:00:00 2001
From: Derek Lesho <dlesho@codeweavers.com>
Date: Fri, 2 Oct 2020 11:29:24 -0500
Subject: [PATCH] bcrypt: Allow multiple backends to coexist.
@ -14,7 +14,7 @@ Signed-off-by: Derek Lesho <dlesho@codeweavers.com>
create mode 100644 dlls/bcrypt/unixlib.c
diff --git a/dlls/bcrypt/Makefile.in b/dlls/bcrypt/Makefile.in
index 24803fb2d7c..46a20d473dd 100644
index 24803fb2d7cb..46a20d473dd7 100644
--- a/dlls/bcrypt/Makefile.in
+++ b/dlls/bcrypt/Makefile.in
@@ -11,6 +11,7 @@ C_SRCS = \
@ -27,10 +27,10 @@ index 24803fb2d7c..46a20d473dd 100644
RC_SRCS = version.rc
diff --git a/dlls/bcrypt/bcrypt_internal.h b/dlls/bcrypt/bcrypt_internal.h
index e1777ed130b..86b1e3d28c3 100644
index eb1361115093..3c7110d05f84 100644
--- a/dlls/bcrypt/bcrypt_internal.h
+++ b/dlls/bcrypt/bcrypt_internal.h
@@ -217,4 +217,7 @@ struct key_funcs
@@ -218,4 +218,7 @@ struct key_funcs
NTSTATUS (CDECL *key_import_rsa)( struct key *, UCHAR *, ULONG );
};
@ -39,10 +39,10 @@ index e1777ed130b..86b1e3d28c3 100644
+
#endif /* __BCRYPT_INTERNAL_H */
diff --git a/dlls/bcrypt/gnutls.c b/dlls/bcrypt/gnutls.c
index 162ac9ea732..a7fd8428dec 100644
index c065ac31fba3..9490ea8612a8 100644
--- a/dlls/bcrypt/gnutls.c
+++ b/dlls/bcrypt/gnutls.c
@@ -358,9 +358,12 @@ fail:
@@ -371,9 +371,12 @@ fail:
static void gnutls_uninitialize(void)
{
@ -58,7 +58,7 @@ index 162ac9ea732..a7fd8428dec 100644
}
struct buffer
@@ -1906,19 +1909,28 @@ static const struct key_funcs key_funcs =
@@ -1949,19 +1952,28 @@ static const struct key_funcs key_funcs =
key_import_rsa
};
@ -95,10 +95,10 @@ index 162ac9ea732..a7fd8428dec 100644
+}
+#endif
diff --git a/dlls/bcrypt/macos.c b/dlls/bcrypt/macos.c
index 57edc3e262b..55dca5dde34 100644
index 44906519cef0..2a88aec8362c 100644
--- a/dlls/bcrypt/macos.c
+++ b/dlls/bcrypt/macos.c
@@ -294,11 +294,21 @@ static const struct key_funcs key_funcs =
@@ -302,11 +302,21 @@ static const struct key_funcs key_funcs =
key_import_rsa
};
@ -126,7 +126,7 @@ index 57edc3e262b..55dca5dde34 100644
#endif
diff --git a/dlls/bcrypt/unixlib.c b/dlls/bcrypt/unixlib.c
new file mode 100644
index 00000000000..a158ec1630a
index 000000000000..a158ec1630a6
--- /dev/null
+++ b/dlls/bcrypt/unixlib.c
@@ -0,0 +1,194 @@

View File

@ -1,4 +1,4 @@
From 6a38df1250c4bab1fab1a72e06fc347586a7c535 Mon Sep 17 00:00:00 2001
From 71de99f0e405cc39e819421ccc470b1085dbe8a1 Mon Sep 17 00:00:00 2001
From: Derek Lesho <dlesho@codeweavers.com>
Date: Fri, 2 Oct 2020 12:11:49 -0500
Subject: [PATCH] bcrypt: Implement BCryptSecretAgreement with libgcrypt.
@ -9,19 +9,19 @@ Signed-off-by: Derek Lesho <dlesho@codeweavers.com>
dlls/bcrypt/Makefile.in | 1 +
dlls/bcrypt/bcrypt_internal.h | 4 +
dlls/bcrypt/bcrypt_main.c | 55 ++++++-
dlls/bcrypt/gcrypt.c | 290 ++++++++++++++++++++++++++++++++++
dlls/bcrypt/gcrypt.c | 292 ++++++++++++++++++++++++++++++++++
dlls/bcrypt/gnutls.c | 3 +-
dlls/bcrypt/macos.c | 3 +-
dlls/bcrypt/tests/bcrypt.c | 2 +-
dlls/bcrypt/unixlib.c | 15 +-
9 files changed, 377 insertions(+), 10 deletions(-)
9 files changed, 379 insertions(+), 10 deletions(-)
create mode 100644 dlls/bcrypt/gcrypt.c
diff --git a/configure.ac b/configure.ac
index 029dcd45187..a18e271dd4c 100644
index b6b8d49342f3..7c1c8a7ddaf4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -45,6 +45,7 @@ AC_ARG_WITH(faudio, AS_HELP_STRING([--without-faudio],[do not use FAudio (XAu
@@ -46,6 +46,7 @@ AC_ARG_WITH(faudio, AS_HELP_STRING([--without-faudio],[do not use FAudio (XAu
AC_ARG_WITH(float-abi, AS_HELP_STRING([--with-float-abi=abi],[specify the ABI (soft|softfp|hard) for ARM platforms]))
AC_ARG_WITH(fontconfig,AS_HELP_STRING([--without-fontconfig],[do not use fontconfig]))
AC_ARG_WITH(freetype, AS_HELP_STRING([--without-freetype],[do not use the FreeType library]))
@ -29,7 +29,7 @@ index 029dcd45187..a18e271dd4c 100644
AC_ARG_WITH(gettext, AS_HELP_STRING([--without-gettext],[do not use gettext]))
AC_ARG_WITH(gettextpo, AS_HELP_STRING([--with-gettextpo],[use the GetTextPO library to rebuild po files]),
[if test "x$withval" = "xno"; then ac_cv_header_gettext_po_h=no; fi])
@@ -1988,6 +1989,19 @@ WINE_NOTICE_WITH(vkd3d,[test "x$ac_cv_lib_soname_vkd3d" = "x"],
@@ -1989,6 +1990,19 @@ WINE_NOTICE_WITH(vkd3d,[test "x$ac_cv_lib_soname_vkd3d" = "x"],
[vkd3d ${notice_platform}development files not found (or too old), Direct3D 12 won't be supported.])
test "x$ac_cv_lib_soname_vkd3d" != "x" || enable_d3d12=${enable_d3d12:-no}
@ -50,7 +50,7 @@ index 029dcd45187..a18e271dd4c 100644
AC_SUBST(EXTRACFLAGS,"")
diff --git a/dlls/bcrypt/Makefile.in b/dlls/bcrypt/Makefile.in
index 46a20d473dd..4a3016784af 100644
index 46a20d473dd7..4a3016784af3 100644
--- a/dlls/bcrypt/Makefile.in
+++ b/dlls/bcrypt/Makefile.in
@@ -7,6 +7,7 @@ EXTRADLLFLAGS = -mno-cygwin
@ -62,7 +62,7 @@ index 46a20d473dd..4a3016784af 100644
macos.c \
md2.c \
diff --git a/dlls/bcrypt/bcrypt_internal.h b/dlls/bcrypt/bcrypt_internal.h
index 86b1e3d28c3..5d969b13dc3 100644
index 3c7110d05f84..e7991eac077a 100644
--- a/dlls/bcrypt/bcrypt_internal.h
+++ b/dlls/bcrypt/bcrypt_internal.h
@@ -192,6 +192,8 @@ struct key
@ -74,7 +74,7 @@ index 86b1e3d28c3..5d969b13dc3 100644
};
struct key_funcs
@@ -215,9 +217,11 @@ struct key_funcs
@@ -216,9 +218,11 @@ struct key_funcs
NTSTATUS (CDECL *key_import_dsa_capi)( struct key *, UCHAR *, ULONG );
NTSTATUS (CDECL *key_import_ecc)( struct key *, UCHAR *, ULONG );
NTSTATUS (CDECL *key_import_rsa)( struct key *, UCHAR *, ULONG );
@ -87,10 +87,10 @@ index 86b1e3d28c3..5d969b13dc3 100644
#endif /* __BCRYPT_INTERNAL_H */
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index 591c01c710c..f2c344f3275 100644
index a1423dcd8368..0655c5dcfe81 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -1914,9 +1914,12 @@ NTSTATUS WINAPI BCryptSecretAgreement(BCRYPT_KEY_HANDLE privatekey, BCRYPT_KEY_H
@@ -1932,9 +1932,12 @@ NTSTATUS WINAPI BCryptSecretAgreement(BCRYPT_KEY_HANDLE privatekey, BCRYPT_KEY_H
{
struct key *privkey = privatekey;
struct key *pubkey = publickey;
@ -104,7 +104,7 @@ index 591c01c710c..f2c344f3275 100644
if (!privkey || privkey->hdr.magic != MAGIC_KEY) return STATUS_INVALID_HANDLE;
if (!pubkey || pubkey->hdr.magic != MAGIC_KEY) return STATUS_INVALID_HANDLE;
@@ -1925,18 +1928,39 @@ NTSTATUS WINAPI BCryptSecretAgreement(BCRYPT_KEY_HANDLE privatekey, BCRYPT_KEY_H
@@ -1943,18 +1946,39 @@ NTSTATUS WINAPI BCryptSecretAgreement(BCRYPT_KEY_HANDLE privatekey, BCRYPT_KEY_H
if (!(secret = heap_alloc_zero( sizeof(*secret) ))) return STATUS_NO_MEMORY;
secret->hdr.magic = MAGIC_SECRET;
@ -146,7 +146,7 @@ index 591c01c710c..f2c344f3275 100644
heap_free( secret );
return STATUS_SUCCESS;
}
@@ -1946,12 +1970,33 @@ NTSTATUS WINAPI BCryptDeriveKey(BCRYPT_SECRET_HANDLE handle, LPCWSTR kdf, BCrypt
@@ -1964,12 +1988,33 @@ NTSTATUS WINAPI BCryptDeriveKey(BCRYPT_SECRET_HANDLE handle, LPCWSTR kdf, BCrypt
{
struct secret *secret = handle;
@ -184,10 +184,10 @@ index 591c01c710c..f2c344f3275 100644
BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
diff --git a/dlls/bcrypt/gcrypt.c b/dlls/bcrypt/gcrypt.c
new file mode 100644
index 00000000000..00849358c68
index 000000000000..e72c27feb519
--- /dev/null
+++ b/dlls/bcrypt/gcrypt.c
@@ -0,0 +1,290 @@
@@ -0,0 +1,292 @@
+#if 0
+#pragma makedep unix
+#endif
@ -450,6 +450,8 @@ index 00000000000..00849358c68
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ key_compute_secret_ecc
+};
+
@ -479,10 +481,10 @@ index 00000000000..00849358c68
+}
+#endif
diff --git a/dlls/bcrypt/gnutls.c b/dlls/bcrypt/gnutls.c
index a7fd8428dec..575aaa21309 100644
index 9490ea8612a8..78d0f2d95966 100644
--- a/dlls/bcrypt/gnutls.c
+++ b/dlls/bcrypt/gnutls.c
@@ -1906,7 +1906,8 @@ static const struct key_funcs key_funcs =
@@ -1949,7 +1949,8 @@ static const struct key_funcs key_funcs =
key_export_ecc,
key_import_dsa_capi,
key_import_ecc,
@ -493,10 +495,10 @@ index a7fd8428dec..575aaa21309 100644
struct key_funcs * gnutls_lib_init( DWORD reason )
diff --git a/dlls/bcrypt/macos.c b/dlls/bcrypt/macos.c
index 55dca5dde34..fd7aeae9ec2 100644
index 2a88aec8362c..3ee3515f9de2 100644
--- a/dlls/bcrypt/macos.c
+++ b/dlls/bcrypt/macos.c
@@ -291,7 +291,8 @@ static const struct key_funcs key_funcs =
@@ -299,7 +299,8 @@ static const struct key_funcs key_funcs =
key_export_ecc,
key_import_dsa_capi,
key_import_ecc,
@ -507,7 +509,7 @@ index 55dca5dde34..fd7aeae9ec2 100644
struct key_funcs * macos_lib_init( DWORD reason )
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
index 456727d04a9..6be406dee21 100644
index 456727d04a96..6be406dee21f 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -2163,7 +2163,7 @@ static void test_ECDH(void)
@ -520,7 +522,7 @@ index 456727d04a9..6be406dee21 100644
if (status != STATUS_SUCCESS)
{
diff --git a/dlls/bcrypt/unixlib.c b/dlls/bcrypt/unixlib.c
index a158ec1630a..a01e2ad02ed 100644
index a158ec1630a6..a01e2ad02ed9 100644
--- a/dlls/bcrypt/unixlib.c
+++ b/dlls/bcrypt/unixlib.c
@@ -129,6 +129,12 @@ static void CDECL key_asymmetric_destroy( struct key *key )

View File

@ -1,4 +1,4 @@
From 01530fae68970b0c0af8811c5f6c5ea85c14372c Mon Sep 17 00:00:00 2001
From 718b9e52a3f66ad18da55c32ba6583e10751c87a Mon Sep 17 00:00:00 2001
From: Derek Lesho <dlesho@codeweavers.com>
Date: Tue, 7 Jan 2020 14:22:49 -0600
Subject: [PATCH] bcrypt: Implement BCRYPT_KDF_HASH.
@ -11,10 +11,10 @@ Signed-off-by: Derek Lesho <dlesho at codeweavers.com>
2 files changed, 108 insertions(+), 3 deletions(-)
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index 8dae41a2e2e..67be417aa61 100644
index 0655c5dcfe81..70e914bd41f1 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -1837,7 +1837,113 @@ NTSTATUS WINAPI BCryptDeriveKey(BCRYPT_SECRET_HANDLE handle, LPCWSTR kdf, BCrypt
@@ -1993,7 +1993,113 @@ NTSTATUS WINAPI BCryptDeriveKey(BCRYPT_SECRET_HANDLE handle, LPCWSTR kdf, BCrypt
if (!secret || secret->hdr.magic != MAGIC_SECRET) return STATUS_INVALID_HANDLE;
if (!kdf) return STATUS_INVALID_PARAMETER;
@ -130,10 +130,10 @@ index 8dae41a2e2e..67be417aa61 100644
ULONG n;
ULONG secret_length = secret->len;
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
index 5701a0a30ce..d4ffb3fe69c 100644
index 6be406dee21f..b13432523d15 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -2132,7 +2132,7 @@ static void test_ECDH(void)
@@ -2180,7 +2180,7 @@ static void test_ECDH(void)
raw_secret_end:
status = pBCryptDeriveKey(secret, BCRYPT_KDF_HASH, &hash_params, NULL, 0, &size, 0);
@ -142,7 +142,7 @@ index 5701a0a30ce..d4ffb3fe69c 100644
if (status != STATUS_SUCCESS)
{
@@ -2666,7 +2666,6 @@ static void test_SecretAgreement(void)
@@ -2716,7 +2716,6 @@ static void test_SecretAgreement(void)
ok(status == STATUS_INVALID_PARAMETER, "got %08x\n", status);
status = pBCryptDeriveKey(secret, L"HASH", NULL, NULL, 0, &size, 0);
@ -151,5 +151,5 @@ index 5701a0a30ce..d4ffb3fe69c 100644
status = pBCryptDestroyHash(secret);
--
2.28.0
2.29.2