2020-12-16 05:23:52 -08:00
|
|
|
From 3478a4e41c07a66e7e913c54bcf5ad52e16a8fee Mon Sep 17 00:00:00 2001
|
2020-10-03 01:48:06 -07:00
|
|
|
From: Derek Lesho <dlesho@codeweavers.com>
|
|
|
|
Date: Fri, 2 Oct 2020 11:29:24 -0500
|
|
|
|
Subject: [PATCH] bcrypt: Allow multiple backends to coexist.
|
|
|
|
|
|
|
|
Signed-off-by: Derek Lesho <dlesho@codeweavers.com>
|
|
|
|
---
|
|
|
|
dlls/bcrypt/Makefile.in | 3 +-
|
|
|
|
dlls/bcrypt/bcrypt_internal.h | 3 +
|
2020-10-14 14:48:35 -07:00
|
|
|
dlls/bcrypt/gnutls.c | 32 ++++--
|
2020-12-16 05:23:52 -08:00
|
|
|
dlls/bcrypt/macos.c | 18 ++-
|
|
|
|
dlls/bcrypt/unixlib.c | 211 ++++++++++++++++++++++++++++++++++
|
|
|
|
5 files changed, 252 insertions(+), 15 deletions(-)
|
2020-10-03 01:48:06 -07:00
|
|
|
create mode 100644 dlls/bcrypt/unixlib.c
|
|
|
|
|
|
|
|
diff --git a/dlls/bcrypt/Makefile.in b/dlls/bcrypt/Makefile.in
|
2020-12-15 13:30:41 -08:00
|
|
|
index 24803fb2d7cb..46a20d473dd7 100644
|
2020-10-03 01:48:06 -07:00
|
|
|
--- a/dlls/bcrypt/Makefile.in
|
|
|
|
+++ b/dlls/bcrypt/Makefile.in
|
|
|
|
@@ -11,6 +11,7 @@ C_SRCS = \
|
|
|
|
macos.c \
|
|
|
|
md2.c \
|
|
|
|
sha256.c \
|
|
|
|
- sha512.c
|
|
|
|
+ sha512.c \
|
|
|
|
+ unixlib.c
|
|
|
|
|
|
|
|
RC_SRCS = version.rc
|
|
|
|
diff --git a/dlls/bcrypt/bcrypt_internal.h b/dlls/bcrypt/bcrypt_internal.h
|
2020-12-15 13:30:41 -08:00
|
|
|
index eb1361115093..3c7110d05f84 100644
|
2020-10-03 01:48:06 -07:00
|
|
|
--- a/dlls/bcrypt/bcrypt_internal.h
|
|
|
|
+++ b/dlls/bcrypt/bcrypt_internal.h
|
2020-12-15 13:30:41 -08:00
|
|
|
@@ -218,4 +218,7 @@ struct key_funcs
|
2020-12-03 15:53:09 -08:00
|
|
|
NTSTATUS (CDECL *key_import_rsa)( struct key *, UCHAR *, ULONG );
|
2020-10-03 01:48:06 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
+struct key_funcs *gnutls_lib_init(DWORD reason);
|
|
|
|
+struct key_funcs *macos_lib_init(DWORD reason);
|
|
|
|
+
|
|
|
|
#endif /* __BCRYPT_INTERNAL_H */
|
|
|
|
diff --git a/dlls/bcrypt/gnutls.c b/dlls/bcrypt/gnutls.c
|
2020-12-15 13:30:41 -08:00
|
|
|
index c065ac31fba3..9490ea8612a8 100644
|
2020-10-03 01:48:06 -07:00
|
|
|
--- a/dlls/bcrypt/gnutls.c
|
|
|
|
+++ b/dlls/bcrypt/gnutls.c
|
2020-12-15 13:30:41 -08:00
|
|
|
@@ -371,9 +371,12 @@ fail:
|
2020-10-03 01:48:06 -07:00
|
|
|
|
|
|
|
static void gnutls_uninitialize(void)
|
|
|
|
{
|
|
|
|
- pgnutls_global_deinit();
|
|
|
|
- dlclose( libgnutls_handle );
|
|
|
|
- libgnutls_handle = NULL;
|
|
|
|
+ if (libgnutls_handle)
|
|
|
|
+ {
|
|
|
|
+ pgnutls_global_deinit();
|
|
|
|
+ dlclose( libgnutls_handle );
|
|
|
|
+ libgnutls_handle = NULL;
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
|
|
|
struct buffer
|
2020-12-15 13:30:41 -08:00
|
|
|
@@ -1949,19 +1952,28 @@ static const struct key_funcs key_funcs =
|
2020-12-03 15:53:09 -08:00
|
|
|
key_import_rsa
|
2020-10-03 01:48:06 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
-NTSTATUS CDECL __wine_init_unix_lib( HMODULE module, DWORD reason, const void *ptr_in, void *ptr_out )
|
|
|
|
+struct key_funcs * gnutls_lib_init( DWORD reason )
|
|
|
|
{
|
|
|
|
switch (reason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
- if (!gnutls_initialize()) return STATUS_DLL_NOT_FOUND;
|
|
|
|
- *(const struct key_funcs **)ptr_out = &key_funcs;
|
|
|
|
- break;
|
|
|
|
+ if (!gnutls_initialize()) return NULL;
|
|
|
|
+ return &key_funcs;
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
gnutls_uninitialize();
|
|
|
|
- break;
|
|
|
|
}
|
|
|
|
- return STATUS_SUCCESS;
|
|
|
|
+ return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
-#endif /* HAVE_GNUTLS_CIPHER_INIT */
|
|
|
|
+#else /* HAVE_GNUTLS_CIPHER_INIT */
|
|
|
|
+#include "ntstatus.h"
|
|
|
|
+#define WIN32_NO_STATUS
|
|
|
|
+#include "windef.h"
|
|
|
|
+#include "winbase.h"
|
|
|
|
+#include "winternl.h"
|
|
|
|
+
|
|
|
|
+struct key_funcs * gnutls_lib_init( DWORD reason )
|
|
|
|
+{
|
|
|
|
+ return NULL;
|
|
|
|
+}
|
|
|
|
+#endif
|
|
|
|
diff --git a/dlls/bcrypt/macos.c b/dlls/bcrypt/macos.c
|
2020-12-15 13:30:41 -08:00
|
|
|
index 44906519cef0..2a88aec8362c 100644
|
2020-10-03 01:48:06 -07:00
|
|
|
--- a/dlls/bcrypt/macos.c
|
|
|
|
+++ b/dlls/bcrypt/macos.c
|
2020-12-15 13:30:41 -08:00
|
|
|
@@ -302,11 +302,21 @@ static const struct key_funcs key_funcs =
|
2020-12-03 15:53:09 -08:00
|
|
|
key_import_rsa
|
2020-10-03 01:48:06 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
-NTSTATUS CDECL __wine_init_unix_lib( HMODULE module, DWORD reason, const void *ptr_in, void *ptr_out )
|
|
|
|
+struct key_funcs * macos_lib_init( DWORD reason )
|
|
|
|
{
|
|
|
|
- if (reason != DLL_PROCESS_ATTACH) return STATUS_SUCCESS;
|
|
|
|
- *(const struct key_funcs **)ptr_out = &key_funcs;
|
|
|
|
- return STATUS_SUCCESS;
|
|
|
|
+ if (reason != DLL_PROCESS_ATTACH) return NULL;
|
|
|
|
+ return &key_funcs;
|
|
|
|
}
|
|
|
|
|
|
|
|
+#else
|
|
|
|
+#include "ntstatus.h"
|
|
|
|
+#define WIN32_NO_STATUS
|
|
|
|
+#include "windef.h"
|
|
|
|
+#include "winbase.h"
|
|
|
|
+#include "winternl.h"
|
|
|
|
+
|
|
|
|
+struct key_funcs * macos_lib_init( DWORD reason )
|
|
|
|
+{
|
|
|
|
+ return NULL;
|
|
|
|
+}
|
|
|
|
#endif
|
|
|
|
diff --git a/dlls/bcrypt/unixlib.c b/dlls/bcrypt/unixlib.c
|
|
|
|
new file mode 100644
|
2020-12-16 05:23:52 -08:00
|
|
|
index 000000000000..9cbb25f5740c
|
2020-10-03 01:48:06 -07:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/dlls/bcrypt/unixlib.c
|
2020-12-16 05:23:52 -08:00
|
|
|
@@ -0,0 +1,211 @@
|
2020-10-03 01:48:06 -07:00
|
|
|
+#if 0
|
|
|
|
+#pragma makedep unix
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+#include "config.h"
|
|
|
|
+#include "wine/port.h"
|
|
|
|
+
|
|
|
|
+#include <stdarg.h>
|
|
|
|
+
|
|
|
|
+#include "ntstatus.h"
|
|
|
|
+#define WIN32_NO_STATUS
|
|
|
|
+#include "windef.h"
|
|
|
|
+#include "winbase.h"
|
|
|
|
+#include "ntsecapi.h"
|
|
|
|
+#include "bcrypt.h"
|
|
|
|
+
|
|
|
|
+#include "bcrypt_internal.h"
|
|
|
|
+
|
|
|
|
+#include "wine/debug.h"
|
|
|
|
+#include "wine/unicode.h"
|
|
|
|
+
|
|
|
|
+#if defined(HAVE_COMMONCRYPTO_COMMONCRYPTOR_H) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 || defined(HAVE_GNUTLS_CIPHER_INIT)
|
|
|
|
+WINE_DEFAULT_DEBUG_CHANNEL(bcrypt);
|
|
|
|
+
|
|
|
|
+static NTSTATUS CDECL key_set_property( struct key *key, const WCHAR *prop, UCHAR *value, ULONG size, ULONG flags )
|
|
|
|
+{
|
|
|
|
+ FIXME( "not implemented\n" );
|
|
|
|
+ return STATUS_NOT_IMPLEMENTED;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static NTSTATUS CDECL key_symmetric_init( struct key *key )
|
|
|
|
+{
|
|
|
|
+ FIXME( "not implemented\n" );
|
|
|
|
+ return STATUS_NOT_IMPLEMENTED;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void CDECL key_symmetric_vector_reset( struct key *key )
|
|
|
|
+{
|
|
|
|
+ FIXME( "not implemented\n" );
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static NTSTATUS CDECL key_symmetric_set_auth_data( struct key *key, UCHAR *auth_data, ULONG len )
|
|
|
|
+{
|
|
|
|
+ FIXME( "not implemented\n" );
|
|
|
|
+ return STATUS_NOT_IMPLEMENTED;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static NTSTATUS CDECL key_symmetric_encrypt( struct key *key, const UCHAR *input, ULONG input_len, UCHAR *output, ULONG output_len )
|
|
|
|
+{
|
|
|
|
+ FIXME( "not implemented\n" );
|
|
|
|
+ return STATUS_NOT_IMPLEMENTED;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static NTSTATUS CDECL key_symmetric_decrypt( struct key *key, const UCHAR *input, ULONG input_len, UCHAR *output, ULONG output_len )
|
|
|
|
+{
|
|
|
|
+ FIXME( "not implemented\n" );
|
|
|
|
+ return STATUS_NOT_IMPLEMENTED;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static NTSTATUS CDECL key_symmetric_get_tag( struct key *key, UCHAR *tag, ULONG len )
|
|
|
|
+{
|
|
|
|
+ FIXME( "not implemented\n" );
|
|
|
|
+ return STATUS_NOT_IMPLEMENTED;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void CDECL key_symmetric_destroy( struct key *key )
|
|
|
|
+{
|
|
|
|
+ FIXME( "not implemented\n" );
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static NTSTATUS CDECL key_asymmetric_init( struct key *key )
|
|
|
|
+{
|
|
|
|
+ FIXME( "not implemented\n" );
|
|
|
|
+ return STATUS_NOT_IMPLEMENTED;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static NTSTATUS CDECL key_asymmetric_sign( struct key *key, void *padding, UCHAR *input, ULONG input_len, UCHAR *output,
|
|
|
|
+ ULONG output_len, ULONG *ret_len, ULONG flags )
|
|
|
|
+{
|
|
|
|
+ FIXME( "not implemented\n" );
|
|
|
|
+ return STATUS_NOT_IMPLEMENTED;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static NTSTATUS CDECL key_asymmetric_verify( struct key *key, void *padding, UCHAR *hash, ULONG hash_len,
|
|
|
|
+ UCHAR *signature, ULONG signature_len, DWORD flags )
|
|
|
|
+{
|
|
|
|
+ FIXME( "not implemented\n" );
|
|
|
|
+ return STATUS_NOT_IMPLEMENTED;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static NTSTATUS CDECL key_export_dsa_capi( struct key *key, UCHAR *buf, ULONG len, ULONG *ret_len )
|
|
|
|
+{
|
|
|
|
+ FIXME( "not implemented\n" );
|
|
|
|
+ return STATUS_NOT_IMPLEMENTED;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static NTSTATUS CDECL key_export_ecc( struct key *key, UCHAR *output, ULONG len, ULONG *ret_len )
|
|
|
|
+{
|
|
|
|
+ FIXME( "not implemented\n" );
|
|
|
|
+ return STATUS_NOT_IMPLEMENTED;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static NTSTATUS CDECL key_import_dsa_capi( struct key *key, UCHAR *buf, ULONG len )
|
|
|
|
+{
|
|
|
|
+ FIXME( "not implemented\n" );
|
|
|
|
+ return STATUS_NOT_IMPLEMENTED;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static NTSTATUS CDECL key_import_ecc( struct key *key, UCHAR *input, ULONG len )
|
|
|
|
+{
|
|
|
|
+ FIXME( "not implemented\n" );
|
|
|
|
+ return STATUS_NOT_IMPLEMENTED;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static NTSTATUS CDECL key_asymmetric_generate( struct key *key )
|
|
|
|
+{
|
|
|
|
+ FIXME( "not implemented\n" );
|
|
|
|
+ return STATUS_NOT_IMPLEMENTED;
|
|
|
|
+}
|
|
|
|
+
|
2020-10-26 16:38:43 -07:00
|
|
|
+static NTSTATUS CDECL key_asymmetric_duplicate( struct key *key_orig, struct key *key_copy )
|
|
|
|
+{
|
|
|
|
+ FIXME( "not implemented\n" );
|
|
|
|
+ return STATUS_NOT_IMPLEMENTED;
|
|
|
|
+}
|
|
|
|
+
|
2020-10-03 01:48:06 -07:00
|
|
|
+static void CDECL key_asymmetric_destroy( struct key *key )
|
|
|
|
+{
|
|
|
|
+ FIXME( "not implemented\n" );
|
|
|
|
+}
|
|
|
|
+
|
2020-12-16 05:23:52 -08:00
|
|
|
+static NTSTATUS CDECL key_asymmetric_decrypt( struct key *key, UCHAR *input, ULONG input_len,
|
|
|
|
+ UCHAR *output, ULONG *output_len )
|
|
|
|
+{
|
|
|
|
+ FIXME( "not implemented\n" );
|
|
|
|
+ return STATUS_NOT_IMPLEMENTED;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static NTSTATUS CDECL key_import_rsa( struct key *key, UCHAR *input, ULONG input_len )
|
|
|
|
+{
|
|
|
|
+ FIXME( "not implemented\n" );
|
|
|
|
+ return STATUS_NOT_IMPLEMENTED;
|
|
|
|
+}
|
|
|
|
+
|
2020-10-03 01:48:06 -07:00
|
|
|
+static struct key_funcs key_funcs =
|
|
|
|
+{
|
|
|
|
+ key_set_property,
|
|
|
|
+ key_symmetric_init,
|
|
|
|
+ key_symmetric_vector_reset,
|
|
|
|
+ key_symmetric_set_auth_data,
|
|
|
|
+ key_symmetric_encrypt,
|
|
|
|
+ key_symmetric_decrypt,
|
|
|
|
+ key_symmetric_get_tag,
|
|
|
|
+ key_symmetric_destroy,
|
|
|
|
+ key_asymmetric_init,
|
|
|
|
+ key_asymmetric_generate,
|
2020-12-16 05:23:52 -08:00
|
|
|
+ key_asymmetric_decrypt,
|
2020-10-26 16:38:43 -07:00
|
|
|
+ key_asymmetric_duplicate,
|
2020-10-03 01:48:06 -07:00
|
|
|
+ key_asymmetric_sign,
|
|
|
|
+ key_asymmetric_verify,
|
|
|
|
+ key_asymmetric_destroy,
|
|
|
|
+ key_export_dsa_capi,
|
|
|
|
+ key_export_ecc,
|
|
|
|
+ key_import_dsa_capi,
|
2020-12-16 05:23:52 -08:00
|
|
|
+ key_import_ecc,
|
|
|
|
+ key_import_rsa,
|
2020-10-03 01:48:06 -07:00
|
|
|
+};
|
|
|
|
+
|
|
|
|
+NTSTATUS CDECL __wine_init_unix_lib( HMODULE module, DWORD reason, const void *ptr_in, void *ptr_out )
|
|
|
|
+{
|
|
|
|
+ struct key_funcs *gnutls_funcs = gnutls_lib_init(reason);
|
|
|
|
+ struct key_funcs *macos_funcs = macos_lib_init(reason);
|
|
|
|
+
|
|
|
|
+ if (reason == DLL_PROCESS_ATTACH)
|
|
|
|
+ {
|
|
|
|
+#define RESOLVE_FUNC(name) \
|
|
|
|
+ if (macos_funcs && macos_funcs->key_##name) \
|
|
|
|
+ key_funcs.key_##name = macos_funcs->key_##name; \
|
|
|
|
+ if (gnutls_funcs && gnutls_funcs->key_##name) \
|
|
|
|
+ key_funcs.key_##name = gnutls_funcs->key_##name;
|
|
|
|
+
|
|
|
|
+ RESOLVE_FUNC(set_property)
|
|
|
|
+ RESOLVE_FUNC(symmetric_init)
|
|
|
|
+ RESOLVE_FUNC(symmetric_vector_reset)
|
|
|
|
+ RESOLVE_FUNC(symmetric_set_auth_data)
|
|
|
|
+ RESOLVE_FUNC(symmetric_encrypt)
|
|
|
|
+ RESOLVE_FUNC(symmetric_decrypt)
|
|
|
|
+ RESOLVE_FUNC(symmetric_get_tag)
|
|
|
|
+ RESOLVE_FUNC(symmetric_destroy)
|
|
|
|
+ RESOLVE_FUNC(asymmetric_init)
|
|
|
|
+ RESOLVE_FUNC(asymmetric_generate)
|
2020-12-16 05:23:52 -08:00
|
|
|
+ RESOLVE_FUNC(asymmetric_decrypt)
|
2020-10-27 08:42:57 -07:00
|
|
|
+ RESOLVE_FUNC(asymmetric_duplicate)
|
2020-10-03 01:48:06 -07:00
|
|
|
+ RESOLVE_FUNC(asymmetric_sign)
|
|
|
|
+ RESOLVE_FUNC(asymmetric_verify)
|
|
|
|
+ RESOLVE_FUNC(asymmetric_destroy)
|
|
|
|
+ RESOLVE_FUNC(export_dsa_capi)
|
|
|
|
+ RESOLVE_FUNC(export_ecc)
|
|
|
|
+ RESOLVE_FUNC(import_dsa_capi)
|
|
|
|
+ RESOLVE_FUNC(import_ecc)
|
2020-12-16 05:23:52 -08:00
|
|
|
+ RESOLVE_FUNC(import_rsa)
|
2020-10-03 01:48:06 -07:00
|
|
|
+
|
|
|
|
+#undef RESOLVE_FUNC
|
|
|
|
+
|
|
|
|
+ *(struct key_funcs **)ptr_out = &key_funcs;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return STATUS_SUCCESS;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#endif
|
|
|
|
--
|
2020-12-03 15:53:09 -08:00
|
|
|
2.29.2
|
2020-10-03 01:48:06 -07:00
|
|
|
|