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
20aaf167
Commit
20aaf167
authored
Dec 08, 2017
by
Hans Leidekker
Committed by
Alexandre Julliard
Dec 08, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcrypt: Add support for AES encryption on macOS.
Signed-off-by:
Hans Leidekker
<
hans@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
72f3227d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
128 additions
and
19 deletions
+128
-19
configure
configure
+1
-1
configure.ac
configure.ac
+1
-1
bcrypt_main.c
dlls/bcrypt/bcrypt_main.c
+124
-15
config.h.in
include/config.h.in
+2
-2
No files found.
configure
View file @
20aaf167
...
...
@@ -6910,7 +6910,7 @@ for ac_header in \
AudioUnit/AudioComponent.h
\
CL/cl.h
\
Carbon/Carbon.h
\
CommonCrypto/Common
Digest
.h
\
CommonCrypto/Common
Cryptor
.h
\
CoreAudio/CoreAudio.h
\
CoreServices/CoreServices.h
\
DiskArbitration/DiskArbitration.h
\
...
...
configure.ac
View file @
20aaf167
...
...
@@ -396,7 +396,7 @@ AC_CHECK_HEADERS(\
AudioUnit/AudioComponent.h \
CL/cl.h \
Carbon/Carbon.h \
CommonCrypto/Common
Digest
.h \
CommonCrypto/Common
Cryptor
.h \
CoreAudio/CoreAudio.h \
CoreServices/CoreServices.h \
DiskArbitration/DiskArbitration.h \
...
...
dlls/bcrypt/bcrypt_main.c
View file @
20aaf167
...
...
@@ -21,9 +21,8 @@
#include "wine/port.h"
#include <stdarg.h>
#ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H
#include <CommonCrypto/CommonDigest.h>
#include <CommonCrypto/CommonHMAC.h>
#ifdef HAVE_COMMONCRYPTO_COMMONCRYPTOR_H
#include <CommonCrypto/CommonCryptor.h>
#elif defined(SONAME_LIBGNUTLS)
#include <gnutls/gnutls.h>
#include <gnutls/crypto.h>
...
...
@@ -46,7 +45,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(bcrypt);
static
HINSTANCE
instance
;
#if defined(HAVE_GNUTLS_CIPHER_INIT) && !defined(HAVE_COMMONCRYPTO_COMMON
DIGEST
_H)
#if defined(HAVE_GNUTLS_CIPHER_INIT) && !defined(HAVE_COMMONCRYPTO_COMMON
CRYPTOR
_H)
WINE_DECLARE_DEBUG_CHANNEL
(
winediag
);
static
void
*
libgnutls_handle
;
...
...
@@ -121,7 +120,7 @@ static void gnutls_uninitialize(void)
wine_dlclose
(
libgnutls_handle
,
NULL
,
0
);
libgnutls_handle
=
NULL
;
}
#endif
/* HAVE_GNUTLS_CIPHER_INIT && !HAVE_COMMONCRYPTO_COMMON
DIGEST
_H */
#endif
/* HAVE_GNUTLS_CIPHER_INIT && !HAVE_COMMONCRYPTO_COMMON
CRYPTOR
_H */
NTSTATUS
WINAPI
BCryptEnumAlgorithms
(
ULONG
dwAlgOperations
,
ULONG
*
pAlgCount
,
BCRYPT_ALGORITHM_IDENTIFIER
**
ppAlgList
,
ULONG
dwFlags
)
...
...
@@ -731,7 +730,16 @@ NTSTATUS WINAPI BCryptHash( BCRYPT_ALG_HANDLE algorithm, UCHAR *secret, ULONG se
return
BCryptDestroyHash
(
handle
);
}
#if defined(HAVE_GNUTLS_CIPHER_INIT) && !defined(HAVE_COMMONCRYPTO_COMMONDIGEST_H)
#if defined(HAVE_GNUTLS_CIPHER_INIT) || defined(HAVE_COMMONCRYPTO_COMMONCRYPTOR_H)
static
ULONG
get_block_size
(
enum
alg_id
alg
)
{
ULONG
ret
=
0
,
size
=
sizeof
(
ret
);
get_alg_property
(
alg
,
BCRYPT_BLOCK_LENGTH
,
(
UCHAR
*
)
&
ret
,
sizeof
(
ret
),
&
size
);
return
ret
;
}
#endif
#if defined(HAVE_GNUTLS_CIPHER_INIT) && !defined(HAVE_COMMONCRYPTO_COMMONCRYPTOR_H)
struct
key
{
struct
object
hdr
;
...
...
@@ -742,13 +750,6 @@ struct key
ULONG
secret_len
;
};
static
ULONG
get_block_size
(
enum
alg_id
alg
)
{
ULONG
ret
=
0
,
size
=
sizeof
(
ret
);
get_alg_property
(
alg
,
BCRYPT_BLOCK_LENGTH
,
(
UCHAR
*
)
&
ret
,
sizeof
(
ret
),
&
size
);
return
ret
;
}
static
NTSTATUS
key_init
(
struct
key
*
key
,
enum
alg_id
id
,
const
UCHAR
*
secret
,
ULONG
secret_len
)
{
UCHAR
*
buffer
;
...
...
@@ -858,6 +859,114 @@ static NTSTATUS key_destroy( struct key *key )
HeapFree
(
GetProcessHeap
(),
0
,
key
);
return
STATUS_SUCCESS
;
}
#elif defined(HAVE_COMMONCRYPTO_COMMONCRYPTOR_H)
struct
key
{
struct
object
hdr
;
enum
alg_id
alg_id
;
ULONG
block_size
;
CCCryptorRef
ref_encrypt
;
CCCryptorRef
ref_decrypt
;
UCHAR
*
secret
;
ULONG
secret_len
;
};
static
NTSTATUS
key_init
(
struct
key
*
key
,
enum
alg_id
id
,
const
UCHAR
*
secret
,
ULONG
secret_len
)
{
UCHAR
*
buffer
;
switch
(
id
)
{
case
ALG_ID_AES
:
break
;
default:
FIXME
(
"algorithm %u not supported
\n
"
,
id
);
return
STATUS_NOT_SUPPORTED
;
}
if
(
!
(
key
->
block_size
=
get_block_size
(
id
)))
return
STATUS_INVALID_PARAMETER
;
if
(
!
(
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
secret_len
)))
return
STATUS_NO_MEMORY
;
memcpy
(
buffer
,
secret
,
secret_len
);
key
->
alg_id
=
id
;
key
->
ref_encrypt
=
NULL
;
/* initialized on first use */
key
->
ref_decrypt
=
NULL
;
key
->
secret
=
buffer
;
key
->
secret_len
=
secret_len
;
return
STATUS_SUCCESS
;
}
static
NTSTATUS
key_set_params
(
struct
key
*
key
,
UCHAR
*
iv
,
ULONG
iv_len
)
{
CCCryptorStatus
status
;
if
(
key
->
ref_encrypt
)
{
CCCryptorRelease
(
key
->
ref_encrypt
);
key
->
ref_encrypt
=
NULL
;
}
if
(
key
->
ref_decrypt
)
{
CCCryptorRelease
(
key
->
ref_decrypt
);
key
->
ref_decrypt
=
NULL
;
}
if
((
status
=
CCCryptorCreateWithMode
(
kCCEncrypt
,
kCCModeCBC
,
kCCAlgorithmAES
,
ccNoPadding
,
iv
,
key
->
secret
,
key
->
secret_len
,
NULL
,
0
,
0
,
0
,
&
key
->
ref_encrypt
))
!=
kCCSuccess
)
{
WARN
(
"CCCryptorCreateWithMode failed %d
\n
"
,
status
);
return
STATUS_INTERNAL_ERROR
;
}
if
((
status
=
CCCryptorCreateWithMode
(
kCCDecrypt
,
kCCModeCBC
,
kCCAlgorithmAES
,
ccNoPadding
,
iv
,
key
->
secret
,
key
->
secret_len
,
NULL
,
0
,
0
,
0
,
&
key
->
ref_decrypt
))
!=
kCCSuccess
)
{
WARN
(
"CCCryptorCreateWithMode failed %d
\n
"
,
status
);
CCCryptorRelease
(
key
->
ref_encrypt
);
key
->
ref_encrypt
=
NULL
;
return
STATUS_INTERNAL_ERROR
;
}
return
STATUS_SUCCESS
;
}
static
NTSTATUS
key_encrypt
(
struct
key
*
key
,
const
UCHAR
*
input
,
ULONG
input_len
,
UCHAR
*
output
,
ULONG
output_len
)
{
CCCryptorStatus
status
;
if
((
status
=
CCCryptorUpdate
(
key
->
ref_encrypt
,
input
,
input_len
,
output
,
output_len
,
NULL
))
!=
kCCSuccess
)
{
WARN
(
"CCCryptorUpdate failed %d
\n
"
,
status
);
return
STATUS_INTERNAL_ERROR
;
}
return
STATUS_SUCCESS
;
}
static
NTSTATUS
key_decrypt
(
struct
key
*
key
,
const
UCHAR
*
input
,
ULONG
input_len
,
UCHAR
*
output
,
ULONG
output_len
)
{
CCCryptorStatus
status
;
if
((
status
=
CCCryptorUpdate
(
key
->
ref_decrypt
,
input
,
input_len
,
output
,
output_len
,
NULL
))
!=
kCCSuccess
)
{
WARN
(
"CCCryptorUpdate failed %d
\n
"
,
status
);
return
STATUS_INTERNAL_ERROR
;
}
return
STATUS_SUCCESS
;
}
static
NTSTATUS
key_destroy
(
struct
key
*
key
)
{
if
(
key
->
ref_encrypt
)
CCCryptorRelease
(
key
->
ref_encrypt
);
if
(
key
->
ref_decrypt
)
CCCryptorRelease
(
key
->
ref_decrypt
);
HeapFree
(
GetProcessHeap
(),
0
,
key
->
secret
);
HeapFree
(
GetProcessHeap
(),
0
,
key
);
return
STATUS_SUCCESS
;
}
#else
struct
key
{
...
...
@@ -1066,14 +1175,14 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
case
DLL_PROCESS_ATTACH
:
instance
=
hinst
;
DisableThreadLibraryCalls
(
hinst
);
#if defined(HAVE_GNUTLS_CIPHER_INIT) && !defined(HAVE_COMMONCRYPTO_COMMON
DIGEST
_H)
#if defined(HAVE_GNUTLS_CIPHER_INIT) && !defined(HAVE_COMMONCRYPTO_COMMON
CRYPTOR
_H)
gnutls_initialize
();
#endif
break
;
case
DLL_PROCESS_DETACH
:
if
(
reserved
)
break
;
#if defined(HAVE_GNUTLS_CIPHER_INIT) && !defined(HAVE_COMMONCRYPTO_COMMON
DIGEST
_H)
#if defined(HAVE_GNUTLS_CIPHER_INIT) && !defined(HAVE_COMMONCRYPTO_COMMON
CRYPTOR
_H)
gnutls_uninitialize
();
#endif
break
;
...
...
include/config.h.in
View file @
20aaf167
...
...
@@ -89,8 +89,8 @@
/* Define to 1 if you have the <CL/cl.h> header file. */
#undef HAVE_CL_CL_H
/* Define to 1 if you have the <CommonCrypto/Common
Digest
.h> header file. */
#undef HAVE_COMMONCRYPTO_COMMON
DIGEST
_H
/* Define to 1 if you have the <CommonCrypto/Common
Cryptor
.h> header file. */
#undef HAVE_COMMONCRYPTO_COMMON
CRYPTOR
_H
/* Define to 1 if you have the <CoreAudio/CoreAudio.h> header file. */
#undef HAVE_COREAUDIO_COREAUDIO_H
...
...
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