You've already forked wine-staging
mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-04-13 14:42:51 -07:00
Rebase against be0e05604a5560e26757d161708c2c3dae717834.
This commit is contained in:
@ -1,15 +1,15 @@
|
||||
From 489a67ec803b382248134be53f3449c206e208ff Mon Sep 17 00:00:00 2001
|
||||
From 6af9d620b8e766dbb45ac4237e392c752cd69f64 Mon Sep 17 00:00:00 2001
|
||||
From: Hans Leidekker <hans@codeweavers.com>
|
||||
Date: Mon, 19 Dec 2016 19:38:52 +0100
|
||||
Subject: bcrypt: Add AES provider.
|
||||
|
||||
---
|
||||
dlls/bcrypt/bcrypt.spec | 10 +-
|
||||
dlls/bcrypt/bcrypt_main.c | 347 ++++++++++++++++++++++++++++++++++++++++++++-
|
||||
dlls/bcrypt/bcrypt_main.c | 346 ++++++++++++++++++++++++++++++++++++++++++++-
|
||||
dlls/bcrypt/tests/bcrypt.c | 18 +--
|
||||
dlls/ncrypt/ncrypt.spec | 10 +-
|
||||
include/bcrypt.h | 3 +
|
||||
5 files changed, 357 insertions(+), 31 deletions(-)
|
||||
5 files changed, 357 insertions(+), 30 deletions(-)
|
||||
|
||||
diff --git a/dlls/bcrypt/bcrypt.spec b/dlls/bcrypt/bcrypt.spec
|
||||
index e299fe0cce8..962953e509b 100644
|
||||
@ -53,10 +53,10 @@ index e299fe0cce8..962953e509b 100644
|
||||
@ stub BCryptUnregisterConfigChangeNotify
|
||||
@ stub BCryptUnregisterProvider
|
||||
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
|
||||
index 6023c942e49..5867dbdc3fa 100644
|
||||
index cf4e3c6ccc3..b28699c26d5 100644
|
||||
--- a/dlls/bcrypt/bcrypt_main.c
|
||||
+++ b/dlls/bcrypt/bcrypt_main.c
|
||||
@@ -49,6 +49,10 @@ WINE_DECLARE_DEBUG_CHANNEL(winediag);
|
||||
@@ -51,6 +51,10 @@ WINE_DECLARE_DEBUG_CHANNEL(winediag);
|
||||
|
||||
static void *libgnutls_handle;
|
||||
#define MAKE_FUNCPTR(f) static typeof(f) * p##f
|
||||
@ -67,7 +67,7 @@ index 6023c942e49..5867dbdc3fa 100644
|
||||
MAKE_FUNCPTR(gnutls_global_deinit);
|
||||
MAKE_FUNCPTR(gnutls_global_init);
|
||||
MAKE_FUNCPTR(gnutls_global_set_log_function);
|
||||
@@ -84,6 +88,10 @@ static BOOL gnutls_initialize(void)
|
||||
@@ -80,6 +84,10 @@ static BOOL gnutls_initialize(void)
|
||||
goto fail; \
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ index 6023c942e49..5867dbdc3fa 100644
|
||||
LOAD_FUNCPTR(gnutls_global_deinit)
|
||||
LOAD_FUNCPTR(gnutls_global_init)
|
||||
LOAD_FUNCPTR(gnutls_global_set_log_function)
|
||||
@@ -138,6 +146,7 @@ NTSTATUS WINAPI BCryptEnumAlgorithms(ULONG dwAlgOperations, ULONG *pAlgCount,
|
||||
@@ -128,6 +136,7 @@ NTSTATUS WINAPI BCryptEnumAlgorithms(ULONG dwAlgOperations, ULONG *pAlgCount,
|
||||
|
||||
#define MAGIC_ALG (('A' << 24) | ('L' << 16) | ('G' << 8) | '0')
|
||||
#define MAGIC_HASH (('H' << 24) | ('A' << 16) | ('S' << 8) | 'H')
|
||||
@ -86,7 +86,7 @@ index 6023c942e49..5867dbdc3fa 100644
|
||||
struct object
|
||||
{
|
||||
ULONG magic;
|
||||
@@ -145,6 +154,7 @@ struct object
|
||||
@@ -135,6 +144,7 @@ struct object
|
||||
|
||||
enum alg_id
|
||||
{
|
||||
@ -94,15 +94,15 @@ index 6023c942e49..5867dbdc3fa 100644
|
||||
ALG_ID_MD5,
|
||||
ALG_ID_RNG,
|
||||
ALG_ID_SHA1,
|
||||
@@ -157,6 +167,7 @@ static const struct {
|
||||
ULONG hash_length;
|
||||
@@ -151,6 +161,7 @@ static const struct {
|
||||
ULONG block_bits;
|
||||
const WCHAR *alg_name;
|
||||
} alg_props[] = {
|
||||
+ /* ALG_ID_AES */ { 0, BCRYPT_AES_ALGORITHM },
|
||||
/* ALG_ID_MD5 */ { 16, BCRYPT_MD5_ALGORITHM },
|
||||
/* ALG_ID_RNG */ { 0, BCRYPT_RNG_ALGORITHM },
|
||||
/* ALG_ID_SHA1 */ { 20, BCRYPT_SHA1_ALGORITHM },
|
||||
@@ -215,11 +226,10 @@ NTSTATUS WINAPI BCryptGenRandom(BCRYPT_ALG_HANDLE handle, UCHAR *buffer, ULONG c
|
||||
+ /* ALG_ID_AES */ { 0, 0, BCRYPT_AES_ALGORITHM },
|
||||
/* ALG_ID_MD5 */ { 16, 512, BCRYPT_MD5_ALGORITHM },
|
||||
/* ALG_ID_RNG */ { 0, 0, BCRYPT_RNG_ALGORITHM },
|
||||
/* ALG_ID_SHA1 */ { 20, 512, BCRYPT_SHA1_ALGORITHM },
|
||||
@@ -209,11 +220,10 @@ NTSTATUS WINAPI BCryptGenRandom(BCRYPT_ALG_HANDLE handle, UCHAR *buffer, ULONG c
|
||||
|
||||
NTSTATUS WINAPI BCryptOpenAlgorithmProvider( BCRYPT_ALG_HANDLE *handle, LPCWSTR id, LPCWSTR implementation, DWORD flags )
|
||||
{
|
||||
@ -115,7 +115,7 @@ index 6023c942e49..5867dbdc3fa 100644
|
||||
TRACE( "%p, %s, %s, %08x\n", handle, wine_dbgstr_w(id), wine_dbgstr_w(implementation), flags );
|
||||
|
||||
if (!handle || !id) return STATUS_INVALID_PARAMETER;
|
||||
@@ -229,9 +239,10 @@ NTSTATUS WINAPI BCryptOpenAlgorithmProvider( BCRYPT_ALG_HANDLE *handle, LPCWSTR
|
||||
@@ -223,9 +233,10 @@ NTSTATUS WINAPI BCryptOpenAlgorithmProvider( BCRYPT_ALG_HANDLE *handle, LPCWSTR
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
@ -127,17 +127,9 @@ index 6023c942e49..5867dbdc3fa 100644
|
||||
else if (!strcmpW( id, BCRYPT_SHA256_ALGORITHM )) alg_id = ALG_ID_SHA256;
|
||||
else if (!strcmpW( id, BCRYPT_SHA384_ALGORITHM )) alg_id = ALG_ID_SHA384;
|
||||
else if (!strcmpW( id, BCRYPT_SHA512_ALGORITHM )) alg_id = ALG_ID_SHA512;
|
||||
@@ -430,7 +441,6 @@ static NTSTATUS hash_finish( struct hash *hash, UCHAR *output, ULONG size )
|
||||
static NTSTATUS hmac_finish( struct hash *hash, UCHAR *output, ULONG size )
|
||||
{
|
||||
CCHmacFinal( &hash->u.hmac_ctx, output );
|
||||
-
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
#elif defined(HAVE_GNUTLS_HASH)
|
||||
@@ -586,12 +596,19 @@ static NTSTATUS hmac_finish( struct hash *hash, UCHAR *output, ULONG size )
|
||||
}
|
||||
#endif
|
||||
@@ -387,12 +398,19 @@ struct hash
|
||||
struct hash_impl inner;
|
||||
};
|
||||
|
||||
+#ifdef _WIN64
|
||||
+#define OBJECT_LENGTH_AES 654
|
||||
@ -155,7 +147,7 @@ index 6023c942e49..5867dbdc3fa 100644
|
||||
static NTSTATUS generic_alg_property( enum alg_id id, const WCHAR *prop, UCHAR *buf, ULONG size, ULONG *ret_size )
|
||||
{
|
||||
if (!strcmpW( prop, BCRYPT_HASH_LENGTH ))
|
||||
@@ -628,6 +645,34 @@ static NTSTATUS get_alg_property( enum alg_id id, const WCHAR *prop, UCHAR *buf,
|
||||
@@ -429,6 +447,34 @@ static NTSTATUS get_alg_property( enum alg_id id, const WCHAR *prop, UCHAR *buf,
|
||||
|
||||
switch (id)
|
||||
{
|
||||
@ -190,7 +182,7 @@ index 6023c942e49..5867dbdc3fa 100644
|
||||
case ALG_ID_MD5:
|
||||
if (!strcmpW( prop, BCRYPT_OBJECT_LENGTH ))
|
||||
{
|
||||
@@ -731,6 +776,13 @@ NTSTATUS WINAPI BCryptGetProperty( BCRYPT_HANDLE handle, LPCWSTR prop, UCHAR *bu
|
||||
@@ -532,6 +578,13 @@ NTSTATUS WINAPI BCryptGetProperty( BCRYPT_HANDLE handle, LPCWSTR prop, UCHAR *bu
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,7 +196,7 @@ index 6023c942e49..5867dbdc3fa 100644
|
||||
NTSTATUS WINAPI BCryptCreateHash( BCRYPT_ALG_HANDLE algorithm, BCRYPT_HASH_HANDLE *handle, UCHAR *object, ULONG objectlen,
|
||||
UCHAR *secret, ULONG secretlen, ULONG flags )
|
||||
{
|
||||
@@ -854,6 +906,293 @@ NTSTATUS WINAPI BCryptHash( BCRYPT_ALG_HANDLE algorithm, UCHAR *secret, ULONG se
|
||||
@@ -670,6 +723,293 @@ NTSTATUS WINAPI BCryptHash( BCRYPT_ALG_HANDLE algorithm, UCHAR *secret, ULONG se
|
||||
return BCryptDestroyHash( handle );
|
||||
}
|
||||
|
||||
|
@ -1,469 +0,0 @@
|
||||
From f527689b793100c79654ac5d6c1376d128ca3175 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
||||
Date: Mon, 19 Dec 2016 23:58:52 +0100
|
||||
Subject: bcrypt: Directly implement hmac computation.
|
||||
|
||||
---
|
||||
dlls/bcrypt/bcrypt_main.c | 277 +++++++++++++++++-----------------------------
|
||||
1 file changed, 104 insertions(+), 173 deletions(-)
|
||||
|
||||
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
|
||||
index 937bdf7..af2314a 100644
|
||||
--- a/dlls/bcrypt/bcrypt_main.c
|
||||
+++ b/dlls/bcrypt/bcrypt_main.c
|
||||
@@ -60,9 +60,6 @@ MAKE_FUNCPTR(gnutls_global_set_log_level);
|
||||
MAKE_FUNCPTR(gnutls_hash);
|
||||
MAKE_FUNCPTR(gnutls_hash_deinit);
|
||||
MAKE_FUNCPTR(gnutls_hash_init);
|
||||
-MAKE_FUNCPTR(gnutls_hmac);
|
||||
-MAKE_FUNCPTR(gnutls_hmac_deinit);
|
||||
-MAKE_FUNCPTR(gnutls_hmac_init);
|
||||
MAKE_FUNCPTR(gnutls_perror);
|
||||
#undef MAKE_FUNCPTR
|
||||
|
||||
@@ -99,9 +96,6 @@ static BOOL gnutls_initialize(void)
|
||||
LOAD_FUNCPTR(gnutls_hash);
|
||||
LOAD_FUNCPTR(gnutls_hash_deinit);
|
||||
LOAD_FUNCPTR(gnutls_hash_init);
|
||||
- LOAD_FUNCPTR(gnutls_hmac);
|
||||
- LOAD_FUNCPTR(gnutls_hmac_deinit);
|
||||
- LOAD_FUNCPTR(gnutls_hmac_init);
|
||||
LOAD_FUNCPTR(gnutls_perror)
|
||||
#undef LOAD_FUNCPTR
|
||||
|
||||
@@ -163,6 +157,8 @@ enum alg_id
|
||||
ALG_ID_SHA512
|
||||
};
|
||||
|
||||
+#define MAX_HASH_OUTPUT_BYTES 64
|
||||
+
|
||||
static const struct {
|
||||
ULONG hash_length;
|
||||
const WCHAR *alg_name;
|
||||
@@ -183,6 +179,19 @@ struct algorithm
|
||||
BOOL hmac;
|
||||
};
|
||||
|
||||
+#define MAX_HASH_BLOCK_BITS 1024
|
||||
+
|
||||
+int alg_block_bits[] =
|
||||
+{
|
||||
+ /* ALG_ID_AES */ 0,
|
||||
+ /* ALG_ID_MD5 */ 512,
|
||||
+ /* ALG_ID_RNG */ 0,
|
||||
+ /* ALG_ID_SHA1 */ 512,
|
||||
+ /* ALG_ID_SHA256 */ 512,
|
||||
+ /* ALG_ID_SHA384 */ 1024,
|
||||
+ /* ALG_ID_SHA512 */ 1024
|
||||
+};
|
||||
+
|
||||
NTSTATUS WINAPI BCryptGenRandom(BCRYPT_ALG_HANDLE handle, UCHAR *buffer, ULONG count, ULONG flags)
|
||||
{
|
||||
const DWORD supported_flags = BCRYPT_USE_SYSTEM_PREFERRED_RNG;
|
||||
@@ -289,24 +298,20 @@ NTSTATUS WINAPI BCryptGetFipsAlgorithmMode(BOOLEAN *enabled)
|
||||
}
|
||||
|
||||
#ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H
|
||||
-struct hash
|
||||
+struct hash_impl
|
||||
{
|
||||
- struct object hdr;
|
||||
- enum alg_id alg_id;
|
||||
- BOOL hmac;
|
||||
union
|
||||
{
|
||||
CC_MD5_CTX md5_ctx;
|
||||
CC_SHA1_CTX sha1_ctx;
|
||||
CC_SHA256_CTX sha256_ctx;
|
||||
CC_SHA512_CTX sha512_ctx;
|
||||
- CCHmacContext hmac_ctx;
|
||||
} u;
|
||||
};
|
||||
|
||||
-static NTSTATUS hash_init( struct hash *hash )
|
||||
+static NTSTATUS hash_init( struct hash_impl *hash, enum alg_id alg_id )
|
||||
{
|
||||
- switch (hash->alg_id)
|
||||
+ switch (alg_id)
|
||||
{
|
||||
case ALG_ID_MD5:
|
||||
CC_MD5_Init( &hash->u.md5_ctx );
|
||||
@@ -329,50 +334,16 @@ static NTSTATUS hash_init( struct hash *hash )
|
||||
break;
|
||||
|
||||
default:
|
||||
- ERR( "unhandled id %u\n", hash->alg_id );
|
||||
+ ERR( "unhandled id %u\n", alg_id );
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
-static NTSTATUS hmac_init( struct hash *hash, UCHAR *key, ULONG key_size )
|
||||
+static NTSTATUS hash_update( struct hash_impl *hash, enum alg_id alg_id,
|
||||
+ UCHAR *input, ULONG size )
|
||||
{
|
||||
- CCHmacAlgorithm cc_algorithm;
|
||||
- switch (hash->alg_id)
|
||||
- {
|
||||
- case ALG_ID_MD5:
|
||||
- cc_algorithm = kCCHmacAlgMD5;
|
||||
- break;
|
||||
-
|
||||
- case ALG_ID_SHA1:
|
||||
- cc_algorithm = kCCHmacAlgSHA1;
|
||||
- break;
|
||||
-
|
||||
- case ALG_ID_SHA256:
|
||||
- cc_algorithm = kCCHmacAlgSHA256;
|
||||
- break;
|
||||
-
|
||||
- case ALG_ID_SHA384:
|
||||
- cc_algorithm = kCCHmacAlgSHA384;
|
||||
- break;
|
||||
-
|
||||
- case ALG_ID_SHA512:
|
||||
- cc_algorithm = kCCHmacAlgSHA512;
|
||||
- break;
|
||||
-
|
||||
- default:
|
||||
- ERR( "unhandled id %u\n", hash->alg_id );
|
||||
- return STATUS_NOT_IMPLEMENTED;
|
||||
- }
|
||||
-
|
||||
- CCHmacInit( &hash->u.hmac_ctx, cc_algorithm, key, key_size );
|
||||
- return STATUS_SUCCESS;
|
||||
-}
|
||||
-
|
||||
-
|
||||
-static NTSTATUS hash_update( struct hash *hash, UCHAR *input, ULONG size )
|
||||
-{
|
||||
- switch (hash->alg_id)
|
||||
+ switch (alg_id)
|
||||
{
|
||||
case ALG_ID_MD5:
|
||||
CC_MD5_Update( &hash->u.md5_ctx, input, size );
|
||||
@@ -395,21 +366,16 @@ static NTSTATUS hash_update( struct hash *hash, UCHAR *input, ULONG size )
|
||||
break;
|
||||
|
||||
default:
|
||||
- ERR( "unhandled id %u\n", hash->alg_id );
|
||||
+ ERR( "unhandled id %u\n", alg_id );
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
-static NTSTATUS hmac_update( struct hash *hash, UCHAR *input, ULONG size )
|
||||
-{
|
||||
- CCHmacUpdate( &hash->u.hmac_ctx, input, size );
|
||||
- return STATUS_SUCCESS;
|
||||
-}
|
||||
-
|
||||
-static NTSTATUS hash_finish( struct hash *hash, UCHAR *output, ULONG size )
|
||||
+static NTSTATUS hash_finish( struct hash_impl *hash, enum alg_id alg_id,
|
||||
+ UCHAR *output, ULONG size )
|
||||
{
|
||||
- switch (hash->alg_id)
|
||||
+ switch (alg_id)
|
||||
{
|
||||
case ALG_ID_MD5:
|
||||
CC_MD5_Final( output, &hash->u.md5_ctx );
|
||||
@@ -432,37 +398,25 @@ static NTSTATUS hash_finish( struct hash *hash, UCHAR *output, ULONG size )
|
||||
break;
|
||||
|
||||
default:
|
||||
- ERR( "unhandled id %u\n", hash->alg_id );
|
||||
+ ERR( "unhandled id %u\n", alg_id );
|
||||
break;
|
||||
}
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
-static NTSTATUS hmac_finish( struct hash *hash, UCHAR *output, ULONG size )
|
||||
-{
|
||||
- CCHmacFinal( &hash->u.hmac_ctx, output );
|
||||
- return STATUS_SUCCESS;
|
||||
-}
|
||||
#elif defined(HAVE_GNUTLS_HASH)
|
||||
-struct hash
|
||||
+struct hash_impl
|
||||
{
|
||||
- struct object hdr;
|
||||
- enum alg_id alg_id;
|
||||
- BOOL hmac;
|
||||
- union
|
||||
- {
|
||||
- gnutls_hash_hd_t hash_handle;
|
||||
- gnutls_hmac_hd_t hmac_handle;
|
||||
- } u;
|
||||
+ gnutls_hash_hd_t hash_handle;
|
||||
};
|
||||
|
||||
-static NTSTATUS hash_init( struct hash *hash )
|
||||
+static NTSTATUS hash_init( struct hash_impl *hash, enum alg_id alg_id )
|
||||
{
|
||||
gnutls_digest_algorithm_t alg;
|
||||
|
||||
if (!libgnutls_handle) return STATUS_INTERNAL_ERROR;
|
||||
|
||||
- switch (hash->alg_id)
|
||||
+ switch (alg_id)
|
||||
{
|
||||
case ALG_ID_MD5:
|
||||
alg = GNUTLS_DIG_MD5;
|
||||
@@ -484,117 +438,63 @@ static NTSTATUS hash_init( struct hash *hash )
|
||||
break;
|
||||
|
||||
default:
|
||||
- ERR( "unhandled id %u\n", hash->alg_id );
|
||||
- return STATUS_NOT_IMPLEMENTED;
|
||||
- }
|
||||
-
|
||||
- if (pgnutls_hash_init( &hash->u.hash_handle, alg )) return STATUS_INTERNAL_ERROR;
|
||||
- return STATUS_SUCCESS;
|
||||
-}
|
||||
-
|
||||
-static NTSTATUS hmac_init( struct hash *hash, UCHAR *key, ULONG key_size )
|
||||
-{
|
||||
- gnutls_mac_algorithm_t alg;
|
||||
-
|
||||
- if (!libgnutls_handle) return STATUS_INTERNAL_ERROR;
|
||||
-
|
||||
- switch (hash->alg_id)
|
||||
- {
|
||||
- case ALG_ID_MD5:
|
||||
- alg = GNUTLS_MAC_MD5;
|
||||
- break;
|
||||
- case ALG_ID_SHA1:
|
||||
- alg = GNUTLS_MAC_SHA1;
|
||||
- break;
|
||||
-
|
||||
- case ALG_ID_SHA256:
|
||||
- alg = GNUTLS_MAC_SHA256;
|
||||
- break;
|
||||
-
|
||||
- case ALG_ID_SHA384:
|
||||
- alg = GNUTLS_MAC_SHA384;
|
||||
- break;
|
||||
-
|
||||
- case ALG_ID_SHA512:
|
||||
- alg = GNUTLS_MAC_SHA512;
|
||||
- break;
|
||||
-
|
||||
- default:
|
||||
- ERR( "unhandled id %u\n", hash->alg_id );
|
||||
+ ERR( "unhandled id %u\n", alg_id );
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
- if (pgnutls_hmac_init( &hash->u.hmac_handle, alg, key, key_size )) return STATUS_INTERNAL_ERROR;
|
||||
- return STATUS_SUCCESS;
|
||||
-}
|
||||
-
|
||||
-static NTSTATUS hash_update( struct hash *hash, UCHAR *input, ULONG size )
|
||||
-{
|
||||
- if (pgnutls_hash( hash->u.hash_handle, input, size )) return STATUS_INTERNAL_ERROR;
|
||||
+ if (pgnutls_hash_init( &hash->hash_handle, alg )) return STATUS_INTERNAL_ERROR;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
-static NTSTATUS hmac_update( struct hash *hash, UCHAR *input, ULONG size )
|
||||
+static NTSTATUS hash_update( struct hash_impl *hash, enum alg_id alg_id,
|
||||
+ UCHAR *input, ULONG size )
|
||||
{
|
||||
- if (pgnutls_hmac( hash->u.hmac_handle, input, size )) return STATUS_INTERNAL_ERROR;
|
||||
+ if (pgnutls_hash( hash->hash_handle, input, size )) return STATUS_INTERNAL_ERROR;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
-static NTSTATUS hash_finish( struct hash *hash, UCHAR *output, ULONG size )
|
||||
+static NTSTATUS hash_finish( struct hash_impl *hash, enum alg_id alg_id,
|
||||
+ UCHAR *output, ULONG size )
|
||||
{
|
||||
- pgnutls_hash_deinit( hash->u.hash_handle, output );
|
||||
+ pgnutls_hash_deinit( hash->hash_handle, output );
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
-static NTSTATUS hmac_finish( struct hash *hash, UCHAR *output, ULONG size )
|
||||
-{
|
||||
- pgnutls_hmac_deinit( hash->u.hmac_handle, output );
|
||||
- return STATUS_SUCCESS;
|
||||
-}
|
||||
#else
|
||||
-struct hash
|
||||
+struct hash_impl
|
||||
{
|
||||
- struct object hdr;
|
||||
- BOOL hmac;
|
||||
- enum alg_id alg_id;
|
||||
-};
|
||||
|
||||
-static NTSTATUS hash_init( struct hash *hash )
|
||||
-{
|
||||
- ERR( "support for hashes not available at build time\n" );
|
||||
- return STATUS_NOT_IMPLEMENTED;
|
||||
-}
|
||||
-
|
||||
-static NTSTATUS hmac_init( struct hash *hash, UCHAR *key, ULONG key_size )
|
||||
-{
|
||||
- ERR( "support for hashes not available at build time\n" );
|
||||
- return STATUS_NOT_IMPLEMENTED;
|
||||
-}
|
||||
+};
|
||||
|
||||
-static NTSTATUS hash_update( struct hash *hash, UCHAR *input, ULONG size )
|
||||
+static NTSTATUS hash_init( struct hash_impl *hash, enum alg_id alg_id )
|
||||
{
|
||||
ERR( "support for hashes not available at build time\n" );
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
-static NTSTATUS hmac_update( struct hash *hash, UCHAR *input, ULONG size )
|
||||
+static NTSTATUS hash_update( struct hash_impl *hash, enum alg_id alg_id,
|
||||
+ UCHAR *input, ULONG size )
|
||||
{
|
||||
ERR( "support for hashes not available at build time\n" );
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
-static NTSTATUS hash_finish( struct hash *hash, UCHAR *output, ULONG size )
|
||||
+static NTSTATUS hash_finish( struct hash_impl *hash, enum alg_id alg_id,
|
||||
+ UCHAR *output, ULONG size )
|
||||
{
|
||||
ERR( "support for hashes not available at build time\n" );
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
+#endif
|
||||
|
||||
-static NTSTATUS hmac_finish( struct hash *hash, UCHAR *output, ULONG size )
|
||||
+struct hash
|
||||
{
|
||||
- ERR( "support for hashes not available at build time\n" );
|
||||
- return STATUS_NOT_IMPLEMENTED;
|
||||
-}
|
||||
-#endif
|
||||
+ struct object hdr;
|
||||
+ enum alg_id alg_id;
|
||||
+ BOOL hmac;
|
||||
+ struct hash_impl outer;
|
||||
+ struct hash_impl inner;
|
||||
+};
|
||||
|
||||
#ifdef _WIN64
|
||||
#define OBJECT_LENGTH_AES 654
|
||||
@@ -787,8 +687,11 @@ NTSTATUS WINAPI BCryptCreateHash( BCRYPT_ALG_HANDLE algorithm, BCRYPT_HASH_HANDL
|
||||
UCHAR *secret, ULONG secretlen, ULONG flags )
|
||||
{
|
||||
struct algorithm *alg = algorithm;
|
||||
+ UCHAR buffer[MAX_HASH_BLOCK_BITS / 8];
|
||||
struct hash *hash;
|
||||
+ int block_bytes;
|
||||
NTSTATUS status;
|
||||
+ int i;
|
||||
|
||||
TRACE( "%p, %p, %p, %u, %p, %u, %08x - stub\n", algorithm, handle, object, objectlen,
|
||||
secret, secretlen, flags );
|
||||
@@ -806,17 +709,45 @@ NTSTATUS WINAPI BCryptCreateHash( BCRYPT_ALG_HANDLE algorithm, BCRYPT_HASH_HANDL
|
||||
hash->alg_id = alg->id;
|
||||
hash->hmac = alg->hmac;
|
||||
|
||||
- if (hash->hmac)
|
||||
+ status = hash_init( &hash->inner, hash->alg_id );
|
||||
+ if (status || !hash->hmac) goto end;
|
||||
+ status = hash_init( &hash->outer, hash->alg_id );
|
||||
+ if (status) goto end;
|
||||
+
|
||||
+ /* reduce key size if too big */
|
||||
+ block_bytes = alg_block_bits[hash->alg_id] / 8;
|
||||
+ if (secretlen > block_bytes)
|
||||
{
|
||||
- status = hmac_init( hash, secret, secretlen );
|
||||
+ struct hash_impl temp;
|
||||
+ status = hash_init( &temp, hash->alg_id );
|
||||
+ if (status) goto end;
|
||||
+ status = hash_update( &temp, hash->alg_id, secret, secretlen );
|
||||
+ if (status) goto end;
|
||||
+ memset( buffer, 0, block_bytes );
|
||||
+ status = hash_finish( &temp, hash->alg_id, buffer, alg_props[hash->alg_id].hash_length );
|
||||
+ if (status) goto end;
|
||||
}
|
||||
else
|
||||
{
|
||||
- status = hash_init( hash );
|
||||
+ memset( buffer, 0, block_bytes );
|
||||
+ memcpy( buffer, secret, secretlen );
|
||||
}
|
||||
|
||||
+ /* initialize outer hash */
|
||||
+ for (i = 0; i < block_bytes; i++)
|
||||
+ buffer[i] ^= 0x5c;
|
||||
+ status = hash_update( &hash->outer, hash->alg_id, buffer, block_bytes );
|
||||
+ if (status) goto end;
|
||||
+
|
||||
+ /* initialize inner hash */
|
||||
+ for (i = 0; i < block_bytes; i++)
|
||||
+ buffer[i] ^= (0x5c ^ 0x36);
|
||||
+ status = hash_update( &hash->inner, hash->alg_id, buffer, block_bytes );
|
||||
+
|
||||
+end:
|
||||
if (status != STATUS_SUCCESS)
|
||||
{
|
||||
+ /* FIXME: call hash_finish to release resources */
|
||||
HeapFree( GetProcessHeap(), 0, hash );
|
||||
return status;
|
||||
}
|
||||
@@ -845,33 +776,33 @@ NTSTATUS WINAPI BCryptHashData( BCRYPT_HASH_HANDLE handle, UCHAR *input, ULONG s
|
||||
if (!hash || hash->hdr.magic != MAGIC_HASH) return STATUS_INVALID_HANDLE;
|
||||
if (!input) return STATUS_SUCCESS;
|
||||
|
||||
- if (hash->hmac)
|
||||
- {
|
||||
- return hmac_update( hash, input, size );
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- return hash_update( hash, input, size );
|
||||
- }
|
||||
+ return hash_update( &hash->inner, hash->alg_id, input, size );
|
||||
}
|
||||
|
||||
NTSTATUS WINAPI BCryptFinishHash( BCRYPT_HASH_HANDLE handle, UCHAR *output, ULONG size, ULONG flags )
|
||||
{
|
||||
+ UCHAR buffer[MAX_HASH_OUTPUT_BYTES];
|
||||
struct hash *hash = handle;
|
||||
+ NTSTATUS status;
|
||||
+ int hash_size;
|
||||
|
||||
TRACE( "%p, %p, %u, %08x\n", handle, output, size, flags );
|
||||
|
||||
if (!hash || hash->hdr.magic != MAGIC_HASH) return STATUS_INVALID_HANDLE;
|
||||
if (!output) return STATUS_INVALID_PARAMETER;
|
||||
|
||||
- if (hash->hmac)
|
||||
- {
|
||||
- return hmac_finish( hash, output, size );
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- return hash_finish( hash, output, size );
|
||||
- }
|
||||
+ if (!hash->hmac)
|
||||
+ return hash_finish( &hash->inner, hash->alg_id, output, size );
|
||||
+
|
||||
+ hash_size = alg_props[hash->alg_id].hash_length;
|
||||
+
|
||||
+ status = hash_finish( &hash->inner, hash->alg_id, buffer, hash_size);
|
||||
+ if (status) return status;
|
||||
+
|
||||
+ status = hash_update( &hash->outer, hash->alg_id, buffer, hash_size);
|
||||
+ if (status) return status;
|
||||
+
|
||||
+ return hash_finish( &hash->outer, hash->alg_id, output, size);
|
||||
}
|
||||
|
||||
NTSTATUS WINAPI BCryptHash( BCRYPT_ALG_HANDLE algorithm, UCHAR *secret, ULONG secretlen,
|
||||
--
|
||||
2.9.0
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,216 +0,0 @@
|
||||
From ae04ece5f64a29a67e187d5aa32c6b8d3e399d61 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
||||
Date: Tue, 20 Dec 2016 02:39:26 +0100
|
||||
Subject: bcrypt: Use hash fallback implementation as default and remove gnutls
|
||||
/ commoncrypto hash implemetation.
|
||||
|
||||
---
|
||||
dlls/bcrypt/bcrypt_main.c | 171 ----------------------------------------------
|
||||
1 file changed, 171 deletions(-)
|
||||
|
||||
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
|
||||
index 9441cf0..3e2b22d 100644
|
||||
--- a/dlls/bcrypt/bcrypt_main.c
|
||||
+++ b/dlls/bcrypt/bcrypt_main.c
|
||||
@@ -59,9 +59,6 @@ MAKE_FUNCPTR(gnutls_global_deinit);
|
||||
MAKE_FUNCPTR(gnutls_global_init);
|
||||
MAKE_FUNCPTR(gnutls_global_set_log_function);
|
||||
MAKE_FUNCPTR(gnutls_global_set_log_level);
|
||||
-MAKE_FUNCPTR(gnutls_hash);
|
||||
-MAKE_FUNCPTR(gnutls_hash_deinit);
|
||||
-MAKE_FUNCPTR(gnutls_hash_init);
|
||||
MAKE_FUNCPTR(gnutls_perror);
|
||||
#undef MAKE_FUNCPTR
|
||||
|
||||
@@ -95,9 +92,6 @@ static BOOL gnutls_initialize(void)
|
||||
LOAD_FUNCPTR(gnutls_global_init)
|
||||
LOAD_FUNCPTR(gnutls_global_set_log_function)
|
||||
LOAD_FUNCPTR(gnutls_global_set_log_level)
|
||||
- LOAD_FUNCPTR(gnutls_hash);
|
||||
- LOAD_FUNCPTR(gnutls_hash_deinit);
|
||||
- LOAD_FUNCPTR(gnutls_hash_init);
|
||||
LOAD_FUNCPTR(gnutls_perror)
|
||||
#undef LOAD_FUNCPTR
|
||||
|
||||
@@ -299,170 +293,6 @@ NTSTATUS WINAPI BCryptGetFipsAlgorithmMode(BOOLEAN *enabled)
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
-#ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H
|
||||
-struct hash_impl
|
||||
-{
|
||||
- union
|
||||
- {
|
||||
- CC_MD5_CTX md5_ctx;
|
||||
- CC_SHA1_CTX sha1_ctx;
|
||||
- CC_SHA256_CTX sha256_ctx;
|
||||
- CC_SHA512_CTX sha512_ctx;
|
||||
- } u;
|
||||
-};
|
||||
-
|
||||
-static NTSTATUS hash_init( struct hash_impl *hash, enum alg_id alg_id )
|
||||
-{
|
||||
- switch (alg_id)
|
||||
- {
|
||||
- case ALG_ID_MD5:
|
||||
- CC_MD5_Init( &hash->u.md5_ctx );
|
||||
- break;
|
||||
-
|
||||
- case ALG_ID_SHA1:
|
||||
- CC_SHA1_Init( &hash->u.sha1_ctx );
|
||||
- break;
|
||||
-
|
||||
- case ALG_ID_SHA256:
|
||||
- CC_SHA256_Init( &hash->u.sha256_ctx );
|
||||
- break;
|
||||
-
|
||||
- case ALG_ID_SHA384:
|
||||
- CC_SHA384_Init( &hash->u.sha512_ctx );
|
||||
- break;
|
||||
-
|
||||
- case ALG_ID_SHA512:
|
||||
- CC_SHA512_Init( &hash->u.sha512_ctx );
|
||||
- break;
|
||||
-
|
||||
- default:
|
||||
- ERR( "unhandled id %u\n", alg_id );
|
||||
- return STATUS_NOT_IMPLEMENTED;
|
||||
- }
|
||||
- return STATUS_SUCCESS;
|
||||
-}
|
||||
-
|
||||
-static NTSTATUS hash_update( struct hash_impl *hash, enum alg_id alg_id,
|
||||
- UCHAR *input, ULONG size )
|
||||
-{
|
||||
- switch (alg_id)
|
||||
- {
|
||||
- case ALG_ID_MD5:
|
||||
- CC_MD5_Update( &hash->u.md5_ctx, input, size );
|
||||
- break;
|
||||
-
|
||||
- case ALG_ID_SHA1:
|
||||
- CC_SHA1_Update( &hash->u.sha1_ctx, input, size );
|
||||
- break;
|
||||
-
|
||||
- case ALG_ID_SHA256:
|
||||
- CC_SHA256_Update( &hash->u.sha256_ctx, input, size );
|
||||
- break;
|
||||
-
|
||||
- case ALG_ID_SHA384:
|
||||
- CC_SHA384_Update( &hash->u.sha512_ctx, input, size );
|
||||
- break;
|
||||
-
|
||||
- case ALG_ID_SHA512:
|
||||
- CC_SHA512_Update( &hash->u.sha512_ctx, input, size );
|
||||
- break;
|
||||
-
|
||||
- default:
|
||||
- ERR( "unhandled id %u\n", alg_id );
|
||||
- return STATUS_NOT_IMPLEMENTED;
|
||||
- }
|
||||
- return STATUS_SUCCESS;
|
||||
-}
|
||||
-
|
||||
-static NTSTATUS hash_finish( struct hash_impl *hash, enum alg_id alg_id,
|
||||
- UCHAR *output, ULONG size )
|
||||
-{
|
||||
- switch (alg_id)
|
||||
- {
|
||||
- case ALG_ID_MD5:
|
||||
- CC_MD5_Final( output, &hash->u.md5_ctx );
|
||||
- break;
|
||||
-
|
||||
- case ALG_ID_SHA1:
|
||||
- CC_SHA1_Final( output, &hash->u.sha1_ctx );
|
||||
- break;
|
||||
-
|
||||
- case ALG_ID_SHA256:
|
||||
- CC_SHA256_Final( output, &hash->u.sha256_ctx );
|
||||
- break;
|
||||
-
|
||||
- case ALG_ID_SHA384:
|
||||
- CC_SHA384_Final( output, &hash->u.sha512_ctx );
|
||||
- break;
|
||||
-
|
||||
- case ALG_ID_SHA512:
|
||||
- CC_SHA512_Final( output, &hash->u.sha512_ctx );
|
||||
- break;
|
||||
-
|
||||
- default:
|
||||
- ERR( "unhandled id %u\n", alg_id );
|
||||
- break;
|
||||
- }
|
||||
- return STATUS_SUCCESS;
|
||||
-}
|
||||
-
|
||||
-#elif defined(HAVE_GNUTLS_HASH)
|
||||
-struct hash_impl
|
||||
-{
|
||||
- gnutls_hash_hd_t hash_handle;
|
||||
-};
|
||||
-
|
||||
-static NTSTATUS hash_init( struct hash_impl *hash, enum alg_id alg_id )
|
||||
-{
|
||||
- gnutls_digest_algorithm_t alg;
|
||||
-
|
||||
- if (!libgnutls_handle) return STATUS_INTERNAL_ERROR;
|
||||
-
|
||||
- switch (alg_id)
|
||||
- {
|
||||
- case ALG_ID_MD5:
|
||||
- alg = GNUTLS_DIG_MD5;
|
||||
- break;
|
||||
- case ALG_ID_SHA1:
|
||||
- alg = GNUTLS_DIG_SHA1;
|
||||
- break;
|
||||
-
|
||||
- case ALG_ID_SHA256:
|
||||
- alg = GNUTLS_DIG_SHA256;
|
||||
- break;
|
||||
-
|
||||
- case ALG_ID_SHA384:
|
||||
- alg = GNUTLS_DIG_SHA384;
|
||||
- break;
|
||||
-
|
||||
- case ALG_ID_SHA512:
|
||||
- alg = GNUTLS_DIG_SHA512;
|
||||
- break;
|
||||
-
|
||||
- default:
|
||||
- ERR( "unhandled id %u\n", alg_id );
|
||||
- return STATUS_NOT_IMPLEMENTED;
|
||||
- }
|
||||
-
|
||||
- if (pgnutls_hash_init( &hash->hash_handle, alg )) return STATUS_INTERNAL_ERROR;
|
||||
- return STATUS_SUCCESS;
|
||||
-}
|
||||
-
|
||||
-static NTSTATUS hash_update( struct hash_impl *hash, enum alg_id alg_id,
|
||||
- UCHAR *input, ULONG size )
|
||||
-{
|
||||
- if (pgnutls_hash( hash->hash_handle, input, size )) return STATUS_INTERNAL_ERROR;
|
||||
- return STATUS_SUCCESS;
|
||||
-}
|
||||
-
|
||||
-static NTSTATUS hash_finish( struct hash_impl *hash, enum alg_id alg_id,
|
||||
- UCHAR *output, ULONG size )
|
||||
-{
|
||||
- pgnutls_hash_deinit( hash->hash_handle, output );
|
||||
- return STATUS_SUCCESS;
|
||||
-}
|
||||
-
|
||||
-#else
|
||||
struct hash_impl
|
||||
{
|
||||
union
|
||||
@@ -572,7 +402,6 @@ static NTSTATUS hash_finish( struct hash_impl *hash, enum alg_id alg_id,
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
-#endif
|
||||
|
||||
struct hash
|
||||
{
|
||||
--
|
||||
2.9.0
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 5313398cdabe97a17b21e2d9f25a191da7bd9434 Mon Sep 17 00:00:00 2001
|
||||
From 03131f461a6650b1fa04aec9cbeaba225b42653d Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
||||
Date: Mon, 26 Dec 2016 06:08:33 +0100
|
||||
Subject: bcrypt: Implement BCryptSetProperty for algorithms.
|
||||
@ -9,7 +9,7 @@ Subject: bcrypt: Implement BCryptSetProperty for algorithms.
|
||||
2 files changed, 67 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
|
||||
index 8a5161b..4757878 100644
|
||||
index eb89af3757c..2885c5101ed 100644
|
||||
--- a/dlls/bcrypt/bcrypt_main.c
|
||||
+++ b/dlls/bcrypt/bcrypt_main.c
|
||||
@@ -153,6 +153,12 @@ enum alg_id
|
||||
@ -23,9 +23,9 @@ index 8a5161b..4757878 100644
|
||||
+};
|
||||
+
|
||||
#define MAX_HASH_OUTPUT_BYTES 64
|
||||
#define MAX_HASH_BLOCK_BITS 1024
|
||||
|
||||
static const struct {
|
||||
@@ -172,6 +178,7 @@ struct algorithm
|
||||
@@ -174,6 +180,7 @@ struct algorithm
|
||||
{
|
||||
struct object hdr;
|
||||
enum alg_id id;
|
||||
@ -33,7 +33,7 @@ index 8a5161b..4757878 100644
|
||||
BOOL hmac;
|
||||
};
|
||||
|
||||
@@ -265,6 +272,7 @@ NTSTATUS WINAPI BCryptOpenAlgorithmProvider( BCRYPT_ALG_HANDLE *handle, LPCWSTR
|
||||
@@ -254,6 +261,7 @@ NTSTATUS WINAPI BCryptOpenAlgorithmProvider( BCRYPT_ALG_HANDLE *handle, LPCWSTR
|
||||
if (!(alg = HeapAlloc( GetProcessHeap(), 0, sizeof(*alg) ))) return STATUS_NO_MEMORY;
|
||||
alg->hdr.magic = MAGIC_ALG;
|
||||
alg->id = alg_id;
|
||||
@ -41,7 +41,7 @@ index 8a5161b..4757878 100644
|
||||
alg->hmac = flags & BCRYPT_ALG_HANDLE_HMAC_FLAG;
|
||||
|
||||
*handle = alg;
|
||||
@@ -555,6 +563,40 @@ static NTSTATUS get_alg_property( const struct algorithm *alg, const WCHAR *prop
|
||||
@@ -541,6 +549,40 @@ static NTSTATUS get_alg_property( const struct algorithm *alg, const WCHAR *prop
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ index 8a5161b..4757878 100644
|
||||
static NTSTATUS get_hash_property( const struct hash *hash, const WCHAR *prop, UCHAR *buf, ULONG size, ULONG *ret_size )
|
||||
{
|
||||
NTSTATUS status;
|
||||
@@ -595,8 +637,28 @@ NTSTATUS WINAPI BCryptGetProperty( BCRYPT_HANDLE handle, LPCWSTR prop, UCHAR *bu
|
||||
@@ -581,8 +623,28 @@ NTSTATUS WINAPI BCryptGetProperty( BCRYPT_HANDLE handle, LPCWSTR prop, UCHAR *bu
|
||||
NTSTATUS WINAPI BCryptSetProperty( BCRYPT_HANDLE handle, const WCHAR *prop, UCHAR *value,
|
||||
ULONG size, ULONG flags )
|
||||
{
|
||||
@ -114,10 +114,10 @@ index 8a5161b..4757878 100644
|
||||
|
||||
NTSTATUS WINAPI BCryptCreateHash( BCRYPT_ALG_HANDLE algorithm, BCRYPT_HASH_HANDLE *handle, UCHAR *object, ULONG objectlen,
|
||||
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
|
||||
index 699a995..d850738 100644
|
||||
index a363da16f55..58faf47ea96 100644
|
||||
--- a/dlls/bcrypt/tests/bcrypt.c
|
||||
+++ b/dlls/bcrypt/tests/bcrypt.c
|
||||
@@ -889,7 +889,7 @@ static void test_BCryptGenerateSymmetricKey(void)
|
||||
@@ -875,7 +875,7 @@ static void test_BCryptGenerateSymmetricKey(void)
|
||||
|
||||
ret = pBCryptSetProperty(aes, BCRYPT_CHAINING_MODE, (UCHAR *)BCRYPT_CHAIN_MODE_CBC,
|
||||
sizeof(BCRYPT_CHAIN_MODE_CBC), 0);
|
||||
@ -126,7 +126,7 @@ index 699a995..d850738 100644
|
||||
|
||||
size = 0xdeadbeef;
|
||||
ret = pBCryptEncrypt(key, NULL, 0, NULL, NULL, 0, NULL, 0, &size, 0);
|
||||
@@ -1078,7 +1078,7 @@ static void test_BCryptEncrypt(void)
|
||||
@@ -1064,7 +1064,7 @@ static void test_BCryptEncrypt(void)
|
||||
todo_wine ok(ret == STATUS_NOT_SUPPORTED, "got %08x\n", ret);
|
||||
|
||||
ret = BCryptSetProperty(aes, BCRYPT_CHAINING_MODE, (UCHAR*)BCRYPT_CHAIN_MODE_GCM, sizeof(BCRYPT_CHAIN_MODE_GCM), 0);
|
||||
@ -135,7 +135,7 @@ index 699a995..d850738 100644
|
||||
|
||||
size = 0;
|
||||
ret = BCryptGetProperty(aes, BCRYPT_AUTH_TAG_LENGTH, NULL, 0, &size, 0);
|
||||
@@ -1306,7 +1306,7 @@ static void test_BCryptDecrypt(void)
|
||||
@@ -1292,7 +1292,7 @@ static void test_BCryptDecrypt(void)
|
||||
******************/
|
||||
|
||||
ret = BCryptSetProperty(aes, BCRYPT_CHAINING_MODE, (UCHAR*)BCRYPT_CHAIN_MODE_GCM, sizeof(BCRYPT_CHAIN_MODE_GCM), 0);
|
||||
@ -145,5 +145,5 @@ index 699a995..d850738 100644
|
||||
buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
|
||||
ret = pBCryptGenerateSymmetricKey(aes, &key, buf, len, secret, sizeof(secret), 0);
|
||||
--
|
||||
2.9.0
|
||||
2.11.0
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 85c7ad0c67aa6cc57e93f2160922305f80d49b4c Mon Sep 17 00:00:00 2001
|
||||
From bdebe07119a6ab2d3d3ba87f1d31ab0c4d998417 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
||||
Date: Mon, 26 Dec 2016 08:41:31 +0100
|
||||
Subject: bcrypt: Allow to call BCryptSetProperty on key objects.
|
||||
@ -9,11 +9,11 @@ Subject: bcrypt: Allow to call BCryptSetProperty on key objects.
|
||||
2 files changed, 40 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
|
||||
index a07250e..3638c77 100644
|
||||
index 5ca0c85e9ee..75b9765a602 100644
|
||||
--- a/dlls/bcrypt/bcrypt_main.c
|
||||
+++ b/dlls/bcrypt/bcrypt_main.c
|
||||
@@ -215,6 +215,9 @@ int alg_block_bits[] =
|
||||
/* ALG_ID_SHA512 */ 1024
|
||||
@@ -204,6 +204,9 @@ struct algorithm
|
||||
BOOL hmac;
|
||||
};
|
||||
|
||||
+struct key;
|
||||
@ -22,7 +22,7 @@ index a07250e..3638c77 100644
|
||||
NTSTATUS WINAPI BCryptGenRandom(BCRYPT_ALG_HANDLE handle, UCHAR *buffer, ULONG count, ULONG flags)
|
||||
{
|
||||
const DWORD supported_flags = BCRYPT_USE_SYSTEM_PREFERRED_RNG;
|
||||
@@ -685,8 +688,8 @@ NTSTATUS WINAPI BCryptSetProperty( BCRYPT_HANDLE handle, const WCHAR *prop, UCHA
|
||||
@@ -671,8 +674,8 @@ NTSTATUS WINAPI BCryptSetProperty( BCRYPT_HANDLE handle, const WCHAR *prop, UCHA
|
||||
}
|
||||
case MAGIC_KEY:
|
||||
{
|
||||
@ -33,7 +33,7 @@ index a07250e..3638c77 100644
|
||||
}
|
||||
default:
|
||||
WARN( "unknown magic %08x\n", object->magic );
|
||||
@@ -933,6 +936,31 @@ static NTSTATUS key_duplicate( struct key *key_orig, struct key *key_copy )
|
||||
@@ -903,6 +906,31 @@ static NTSTATUS key_duplicate( struct key *key_orig, struct key *key_copy )
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ index a07250e..3638c77 100644
|
||||
static gnutls_cipher_algorithm_t get_gnutls_cipher( const struct key *key )
|
||||
{
|
||||
switch (key->alg_id)
|
||||
@@ -1050,6 +1078,12 @@ static NTSTATUS key_duplicate( struct key *key_orig, struct key *key_copy )
|
||||
@@ -1023,6 +1051,12 @@ static NTSTATUS key_duplicate( struct key *key_orig, struct key *key_copy )
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
@ -79,10 +79,10 @@ index a07250e..3638c77 100644
|
||||
{
|
||||
ERR( "support for keys not available at build time\n" );
|
||||
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
|
||||
index a55d9a9..62f0ca7 100644
|
||||
index f458ab5ce56..e00245556f4 100644
|
||||
--- a/dlls/bcrypt/tests/bcrypt.c
|
||||
+++ b/dlls/bcrypt/tests/bcrypt.c
|
||||
@@ -903,6 +903,10 @@ static void test_BCryptGenerateSymmetricKey(void)
|
||||
@@ -889,6 +889,10 @@ static void test_BCryptGenerateSymmetricKey(void)
|
||||
sizeof(BCRYPT_CHAIN_MODE_CBC), 0);
|
||||
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
|
||||
|
||||
@ -94,5 +94,5 @@ index a55d9a9..62f0ca7 100644
|
||||
ret = pBCryptEncrypt(key, NULL, 0, NULL, NULL, 0, NULL, 0, &size, 0);
|
||||
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
|
||||
--
|
||||
2.9.0
|
||||
2.11.0
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 336cf41969e853ca0044261f00ed55ac6f668ff1 Mon Sep 17 00:00:00 2001
|
||||
From dd12a2be3d035d72a3e08573849cdb457b9ec1e7 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
||||
Date: Fri, 4 Mar 2016 22:22:42 +0100
|
||||
Subject: ddraw: Set ddsOldCaps correctly in ddraw7_GetCaps.
|
||||
@ -12,7 +12,7 @@ Subject: ddraw: Set ddsOldCaps correctly in ddraw7_GetCaps.
|
||||
5 files changed, 106 insertions(+)
|
||||
|
||||
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
|
||||
index fb91722943e..4b9d9fbf876 100644
|
||||
index 8a33ccd4c77..3330b9ce321 100644
|
||||
--- a/dlls/ddraw/ddraw.c
|
||||
+++ b/dlls/ddraw/ddraw.c
|
||||
@@ -1554,6 +1554,8 @@ static HRESULT WINAPI ddraw7_GetCaps(IDirectDraw7 *iface, DDCAPS *DriverCaps, DD
|
||||
@ -25,10 +25,10 @@ index fb91722943e..4b9d9fbf876 100644
|
||||
|
||||
if(DriverCaps)
|
||||
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
|
||||
index 278b9c60069..e1a7a1a4d1c 100644
|
||||
index da01bd2ef6d..b81f858ad46 100644
|
||||
--- a/dlls/ddraw/tests/ddraw1.c
|
||||
+++ b/dlls/ddraw/tests/ddraw1.c
|
||||
@@ -10163,6 +10163,31 @@ static void test_texture_load(void)
|
||||
@@ -10683,6 +10683,31 @@ done:
|
||||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
@ -60,18 +60,18 @@ index 278b9c60069..e1a7a1a4d1c 100644
|
||||
START_TEST(ddraw1)
|
||||
{
|
||||
IDirectDraw *ddraw;
|
||||
@@ -10249,4 +10274,5 @@ START_TEST(ddraw1)
|
||||
test_display_mode_surface_pixel_format();
|
||||
@@ -10770,4 +10795,5 @@ START_TEST(ddraw1)
|
||||
test_surface_desc_size();
|
||||
test_texture_load();
|
||||
test_ck_operation();
|
||||
+ test_caps();
|
||||
}
|
||||
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
|
||||
index db09e5d8975..53279059105 100644
|
||||
index 0c2c00f2af7..c26e2cd9b12 100644
|
||||
--- a/dlls/ddraw/tests/ddraw2.c
|
||||
+++ b/dlls/ddraw/tests/ddraw2.c
|
||||
@@ -11487,6 +11487,31 @@ static void test_surface_desc_size(void)
|
||||
ok(!refcount, "DirectDraw has %u references left.\n", refcount);
|
||||
@@ -12021,6 +12021,31 @@ done:
|
||||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
+static void test_caps(void)
|
||||
@ -102,17 +102,17 @@ index db09e5d8975..53279059105 100644
|
||||
START_TEST(ddraw2)
|
||||
{
|
||||
IDirectDraw2 *ddraw;
|
||||
@@ -11581,4 +11606,5 @@ START_TEST(ddraw2)
|
||||
test_transform_vertices();
|
||||
@@ -12116,4 +12141,5 @@ START_TEST(ddraw2)
|
||||
test_display_mode_surface_pixel_format();
|
||||
test_surface_desc_size();
|
||||
test_ck_operation();
|
||||
+ test_caps();
|
||||
}
|
||||
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
|
||||
index 830da89bba2..7ba77be3406 100644
|
||||
index 4c15e0b3a09..af3c145122f 100644
|
||||
--- a/dlls/ddraw/tests/ddraw4.c
|
||||
+++ b/dlls/ddraw/tests/ddraw4.c
|
||||
@@ -12885,6 +12885,31 @@ static void test_get_surface_from_dc(void)
|
||||
@@ -13386,6 +13386,31 @@ done:
|
||||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
@ -144,17 +144,17 @@ index 830da89bba2..7ba77be3406 100644
|
||||
START_TEST(ddraw4)
|
||||
{
|
||||
IDirectDraw4 *ddraw;
|
||||
@@ -12988,4 +13013,5 @@ START_TEST(ddraw4)
|
||||
test_display_mode_surface_pixel_format();
|
||||
@@ -13490,4 +13515,5 @@ START_TEST(ddraw4)
|
||||
test_surface_desc_size();
|
||||
test_get_surface_from_dc();
|
||||
test_ck_operation();
|
||||
+ test_caps();
|
||||
}
|
||||
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
|
||||
index ba0e4a96e0f..be70456555e 100644
|
||||
index 4828aa46d6f..d5244625d96 100644
|
||||
--- a/dlls/ddraw/tests/ddraw7.c
|
||||
+++ b/dlls/ddraw/tests/ddraw7.c
|
||||
@@ -12576,6 +12576,31 @@ static void test_get_surface_from_dc(void)
|
||||
@@ -13077,6 +13077,31 @@ done:
|
||||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
@ -186,10 +186,10 @@ index ba0e4a96e0f..be70456555e 100644
|
||||
START_TEST(ddraw7)
|
||||
{
|
||||
HMODULE module = GetModuleHandleA("ddraw.dll");
|
||||
@@ -12689,4 +12714,5 @@ START_TEST(ddraw7)
|
||||
test_display_mode_surface_pixel_format();
|
||||
@@ -13191,4 +13216,5 @@ START_TEST(ddraw7)
|
||||
test_surface_desc_size();
|
||||
test_get_surface_from_dc();
|
||||
test_ck_operation();
|
||||
+ test_caps();
|
||||
}
|
||||
--
|
||||
|
@ -52,7 +52,7 @@ usage()
|
||||
# Get the upstream commit sha
|
||||
upstream_commit()
|
||||
{
|
||||
echo "1ddf2b4db8c42da36bdccd43dc336eee6ba03cce"
|
||||
echo "be0e05604a5560e26757d161708c2c3dae717834"
|
||||
}
|
||||
|
||||
# Show version information
|
||||
@ -2848,15 +2848,11 @@ fi
|
||||
# | * [#42553] Implement BCrypt ECB chaining mode
|
||||
# |
|
||||
# | Modified files:
|
||||
# | * dlls/bcrypt/Makefile.in, dlls/bcrypt/bcrypt.spec, dlls/bcrypt/bcrypt_internal.h, dlls/bcrypt/bcrypt_main.c,
|
||||
# | dlls/bcrypt/sha256.c, dlls/bcrypt/sha384.c, dlls/bcrypt/sha512.c, dlls/bcrypt/tests/bcrypt.c, dlls/ncrypt/ncrypt.spec,
|
||||
# | * dlls/bcrypt/bcrypt.spec, dlls/bcrypt/bcrypt_main.c, dlls/bcrypt/tests/bcrypt.c, dlls/ncrypt/ncrypt.spec,
|
||||
# | include/bcrypt.h, include/ntstatus.h
|
||||
# |
|
||||
if test "$enable_bcrypt_Improvements" -eq 1; then
|
||||
patch_apply bcrypt-Improvements/0001-bcrypt-Add-AES-provider.patch
|
||||
patch_apply bcrypt-Improvements/0002-bcrypt-Directly-implement-hmac-computation.patch
|
||||
patch_apply bcrypt-Improvements/0003-bcrypt-Add-internal-fallback-implementation-for-hash.patch
|
||||
patch_apply bcrypt-Improvements/0004-bcrypt-Use-hash-fallback-implementation-as-default-a.patch
|
||||
patch_apply bcrypt-Improvements/0005-bcrypt-Implement-BCryptDuplicateHash.patch
|
||||
patch_apply bcrypt-Improvements/0006-bcrypt-Fix-handling-of-padding-when-input-size-equal.patch
|
||||
patch_apply bcrypt-Improvements/0007-bcrypt-Properly-handle-padding-in-AES-decryption.patch
|
||||
@ -2881,9 +2877,6 @@ if test "$enable_bcrypt_Improvements" -eq 1; then
|
||||
patch_apply bcrypt-Improvements/0026-bcrypt-Implement-support-for-ECB-chain-mode.patch
|
||||
(
|
||||
printf '%s\n' '+ { "Hans Leidekker", "bcrypt: Add AES provider.", 1 },';
|
||||
printf '%s\n' '+ { "Michael Müller", "bcrypt: Directly implement hmac computation.", 1 },';
|
||||
printf '%s\n' '+ { "Michael Müller", "bcrypt: Add internal fallback implementation for hash calculations.", 1 },';
|
||||
printf '%s\n' '+ { "Michael Müller", "bcrypt: Use hash fallback implementation as default and remove gnutls / commoncrypto hash implemetation.", 1 },';
|
||||
printf '%s\n' '+ { "Michael Müller", "bcrypt: Implement BCryptDuplicateHash.", 1 },';
|
||||
printf '%s\n' '+ { "Michael Müller", "bcrypt: Fix handling of padding when input size equals block size for AES.", 1 },';
|
||||
printf '%s\n' '+ { "Michael Müller", "bcrypt: Properly handle padding in AES decryption.", 1 },';
|
||||
|
Reference in New Issue
Block a user