Rebase against 0a72708126f5b8fc06698172d973bb529944c3bf

This commit is contained in:
Alistair Leslie-Hughes
2018-03-01 12:28:01 +11:00
parent d3bcb61436
commit 9999806838
39 changed files with 695 additions and 1116 deletions

View File

@@ -1,29 +0,0 @@
From 73d73983bcb5d63470998096e502fabbf82bc06d Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Mon, 26 Dec 2016 04:38:15 +0100
Subject: [PATCH] bcrypt/tests: Add test for bugs in BCryptGetProperty.
---
dlls/bcrypt/tests/bcrypt.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
index 6fa04b0..8fd6c6a 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -452,6 +452,12 @@ static void test_aes(void)
ok(size == 64, "got %u\n", size);
size = 0;
+ ret = pBCryptGetProperty(alg, BCRYPT_CHAINING_MODE, mode, sizeof(mode) - 1, &size, 0);
+ todo_wine ok(ret == STATUS_BUFFER_TOO_SMALL, "got %08x\n", ret);
+ ok(size == 64, "got %u\n", size);
+
+ size = 0;
+ memset(mode, 0, sizeof(mode));
ret = pBCryptGetProperty(alg, BCRYPT_CHAINING_MODE, mode, sizeof(mode), &size, 0);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
ok(!lstrcmpW((const WCHAR *)mode, BCRYPT_CHAIN_MODE_CBC), "got %s\n", mode);
--
1.9.1

View File

@@ -1,7 +1,7 @@
From f7f71658aa091abc71f4dff1449a2ef4db396590 Mon Sep 17 00:00:00 2001
From a19e65b706a6dc0ca59454375d8b33bcca0265ea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Mon, 26 Dec 2016 05:37:02 +0100
Subject: [PATCH] bcrypt/tests: Add tests for AES GCM mode.
Subject: [PATCH 11/36] bcrypt/tests: Add tests for AES GCM mode.
---
dlls/bcrypt/tests/bcrypt.c | 155 ++++++++++++++++++++++++++++++++++++++++++++-
@@ -10,10 +10,10 @@ Subject: [PATCH] bcrypt/tests: Add tests for AES GCM mode.
3 files changed, 179 insertions(+), 2 deletions(-)
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
index 8fd6c6a..517baf2 100644
index 6e283487b5..6cefe13226 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -561,6 +561,8 @@ static void test_BCryptGenerateSymmetricKey(void)
@@ -564,6 +564,8 @@ static void test_BCryptGenerateSymmetricKey(void)
static void test_BCryptEncrypt(void)
{
@@ -22,7 +22,7 @@ index 8fd6c6a..517baf2 100644
static UCHAR secret[] =
{0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f};
static UCHAR iv[] =
@@ -579,15 +581,28 @@ static void test_BCryptEncrypt(void)
@@ -582,15 +584,28 @@ static void test_BCryptEncrypt(void)
{0xc6,0xa1,0x3b,0x37,0x87,0x8f,0x5b,0x82,0x6f,0x4f,0x81,0x62,0xa1,0xc8,0xd8,0x79,
0xb1,0xa2,0x92,0x73,0xbe,0x2c,0x42,0x07,0xa5,0xac,0xe3,0x93,0x39,0x8c,0xb6,0xfb,
0x87,0x5d,0xea,0xa3,0x7e,0x0f,0xde,0xfa,0xd9,0xec,0x6c,0x4e,0x3c,0x76,0x86,0xe4};
@@ -52,7 +52,7 @@ index 8fd6c6a..517baf2 100644
len = 0xdeadbeef;
size = sizeof(len);
ret = pBCryptGetProperty(aes, BCRYPT_OBJECT_LENGTH, (UCHAR *)&len, sizeof(len), &size, 0);
@@ -674,12 +689,101 @@ static void test_BCryptEncrypt(void)
@@ -677,12 +692,101 @@ static void test_BCryptEncrypt(void)
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
HeapFree(GetProcessHeap(), 0, buf);
@@ -154,7 +154,7 @@ index 8fd6c6a..517baf2 100644
static UCHAR secret[] =
{0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f};
static UCHAR iv[] =
@@ -701,6 +805,12 @@ static void test_BCryptDecrypt(void)
@@ -704,6 +808,12 @@ static void test_BCryptDecrypt(void)
{0xc6,0xa1,0x3b,0x37,0x87,0x8f,0x5b,0x82,0x6f,0x4f,0x81,0x62,0xa1,0xc8,0xd8,0x79,
0xb1,0xa2,0x92,0x73,0xbe,0x2c,0x42,0x07,0xa5,0xac,0xe3,0x93,0x39,0x8c,0xb6,0xfb,
0x87,0x5d,0xea,0xa3,0x7e,0x0f,0xde,0xfa,0xd9,0xec,0x6c,0x4e,0x3c,0x76,0x86,0xe4};
@@ -167,7 +167,7 @@ index 8fd6c6a..517baf2 100644
BCRYPT_KEY_LENGTHS_STRUCT key_lengths;
BCRYPT_ALG_HANDLE aes;
BCRYPT_KEY_HANDLE key;
@@ -720,6 +830,10 @@ static void test_BCryptDecrypt(void)
@@ -723,6 +833,10 @@ static void test_BCryptDecrypt(void)
ok(key_lengths.dwMaxLength == 256, "Expected 256, got %d\n", key_lengths.dwMaxLength);
ok(key_lengths.dwIncrement == 64, "Expected 64, got %d\n", key_lengths.dwIncrement);
@@ -178,7 +178,7 @@ index 8fd6c6a..517baf2 100644
len = 0xdeadbeef;
size = sizeof(len);
ret = pBCryptGetProperty(aes, BCRYPT_OBJECT_LENGTH, (UCHAR *)&len, sizeof(len), &size, 0);
@@ -817,6 +931,45 @@ static void test_BCryptDecrypt(void)
@@ -820,6 +934,45 @@ static void test_BCryptDecrypt(void)
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
HeapFree(GetProcessHeap(), 0, buf);
@@ -225,10 +225,10 @@ index 8fd6c6a..517baf2 100644
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
}
diff --git a/include/bcrypt.h b/include/bcrypt.h
index 1f7093c..1e468a3 100644
index 1be9b8533e..d0b29c7cdd 100644
--- a/include/bcrypt.h
+++ b/include/bcrypt.h
@@ -92,7 +92,29 @@ typedef struct __BCRYPT_KEY_LENGTHS_STRUCT
@@ -96,7 +96,29 @@ typedef struct __BCRYPT_KEY_LENGTHS_STRUCT
ULONG dwMinLength;
ULONG dwMaxLength;
ULONG dwIncrement;
@@ -260,7 +260,7 @@ index 1f7093c..1e468a3 100644
typedef struct _CRYPT_INTERFACE_REG
{
diff --git a/include/ntstatus.h b/include/ntstatus.h
index 86dad85..7026de7 100644
index 86dad85b43..7026de7f85 100644
--- a/include/ntstatus.h
+++ b/include/ntstatus.h
@@ -990,6 +990,8 @@
@@ -273,5 +273,5 @@ index 86dad85..7026de7 100644
#define RPC_NT_WRONG_KIND_OF_BINDING ((NTSTATUS) 0xC0020002)
#define RPC_NT_INVALID_BINDING ((NTSTATUS) 0xC0020003)
--
1.9.1
2.16.1

View File

@@ -1,15 +1,15 @@
From 96fcffc63b4777700544f938f10e868acf71a177 Mon Sep 17 00:00:00 2001
From a6e56ac8c6a42f4cf6008564c3b91c5868314b6b Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Mon, 26 Dec 2016 06:18:01 +0100
Subject: [PATCH] bcrypt: Pass object to get_{alg,hash}_property instead of
alg_id.
Subject: [PATCH 12/36] bcrypt: Pass object to get_{alg,hash}_property instead
of alg_id.
---
dlls/bcrypt/bcrypt_main.c | 40 ++++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)
dlls/bcrypt/bcrypt_main.c | 42 ++++++++++++++++++++++--------------------
1 file changed, 22 insertions(+), 20 deletions(-)
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index 72b5df2..7b37e1b 100644
index 6e47349de4..73a5c36fed 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -510,15 +510,15 @@ static NTSTATUS generic_alg_property( enum alg_id id, const WCHAR *prop, UCHAR *
@@ -60,8 +60,14 @@ index 72b5df2..7b37e1b 100644
}
default:
WARN( "unknown magic %08x\n", object->magic );
@@ -769,7 +769,7 @@ NTSTATUS WINAPI BCryptHash( BCRYPT_ALG_HANDLE algorithm, UCHAR *secret, ULONG se
}
@@ -794,11 +794,13 @@ struct key
{
struct object hdr;
ULONG block_size;
+ UCHAR *secret;
+ ULONG secret_len;
};
#endif
#if defined(HAVE_GNUTLS_CIPHER_INIT) || defined(HAVE_COMMONCRYPTO_COMMONCRYPTOR_H) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
-static ULONG get_block_size( enum alg_id alg )
@@ -69,10 +75,10 @@ index 72b5df2..7b37e1b 100644
{
ULONG ret = 0, size = sizeof(ret);
get_alg_property( alg, BCRYPT_BLOCK_LENGTH, (UCHAR *)&ret, sizeof(ret), &size );
@@ -788,27 +788,27 @@ struct key
ULONG secret_len;
};
@@ -827,27 +829,27 @@ static NTSTATUS key_export( struct key *key, const WCHAR *type, UCHAR *output, U
#endif
#if defined(HAVE_GNUTLS_CIPHER_INIT) && !defined(HAVE_COMMONCRYPTO_COMMONCRYPTOR_H)
-static NTSTATUS key_init( struct key *key, enum alg_id id, const UCHAR *secret, ULONG secret_len )
+static NTSTATUS key_init( struct key *key, struct algorithm *alg, const UCHAR *secret, ULONG secret_len )
{
@@ -102,10 +108,10 @@ index 72b5df2..7b37e1b 100644
key->handle = 0; /* initialized on first use */
key->secret = buffer;
key->secret_len = secret_len;
@@ -909,25 +909,25 @@ struct key
ULONG secret_len;
};
@@ -937,25 +939,25 @@ static NTSTATUS key_destroy( struct key *key )
return STATUS_SUCCESS;
}
#elif defined(HAVE_COMMONCRYPTO_COMMONCRYPTOR_H) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
-static NTSTATUS key_init( struct key *key, enum alg_id id, const UCHAR *secret, ULONG secret_len )
+static NTSTATUS key_init( struct key *key, struct algorithm *alg, const UCHAR *secret, ULONG secret_len )
{
@@ -124,7 +130,7 @@ index 72b5df2..7b37e1b 100644
}
- if (!(key->block_size = get_block_size( id ))) return STATUS_INVALID_PARAMETER;
+ if (!(key->block_size = get_block_size( alg ))) return STATUS_INVALID_PARAMETER;
+ if (!(key->block_size = get_block_size( arg ))) return STATUS_INVALID_PARAMETER;
if (!(buffer = heap_alloc( secret_len ))) return STATUS_NO_MEMORY;
memcpy( buffer, secret, secret_len );
@@ -133,16 +139,16 @@ index 72b5df2..7b37e1b 100644
key->ref_encrypt = NULL; /* initialized on first use */
key->ref_decrypt = NULL;
key->secret = buffer;
@@ -1012,7 +1012,7 @@ struct key
ULONG block_size;
};
@@ -1034,7 +1036,7 @@ static NTSTATUS key_destroy( struct key *key )
return STATUS_SUCCESS;
}
#else
-static NTSTATUS key_init( struct key *key, enum alg_id id, const UCHAR *secret, ULONG secret_len )
+static NTSTATUS key_init( struct key *key, struct algorithm *alg, UCHAR *secret, ULONG secret_len )
+static NTSTATUS key_init( struct key *key, struct algorithm *alg, const UCHAR *secret, ULONG secret_len )
{
ERR( "support for keys not available at build time\n" );
return STATUS_NOT_IMPLEMENTED;
@@ -1061,7 +1061,7 @@ NTSTATUS WINAPI BCryptGenerateSymmetricKey( BCRYPT_ALG_HANDLE algorithm, BCRYPT_
@@ -1089,7 +1091,7 @@ NTSTATUS WINAPI BCryptGenerateSymmetricKey( BCRYPT_ALG_HANDLE algorithm, BCRYPT_
if (!(key = heap_alloc( sizeof(*key) ))) return STATUS_NO_MEMORY;
key->hdr.magic = MAGIC_KEY;
@@ -152,5 +158,5 @@ index 72b5df2..7b37e1b 100644
heap_free( key );
return status;
--
1.9.1
2.16.1

View File

@@ -1,7 +1,7 @@
From 1d2d95c30925b24b337978b0ad203ff4353f7ec1 Mon Sep 17 00:00:00 2001
From b27eaf2a7d4ca0811a7b8a7665b44a1b897ddbe3 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: [PATCH] bcrypt: Implement BCryptSetProperty for algorithms.
Subject: [PATCH 13/36] bcrypt: Implement BCryptSetProperty for algorithms.
---
dlls/bcrypt/bcrypt_main.c | 66 ++++++++++++++++++++++++++++++++++++++++++++--
@@ -9,7 +9,7 @@ Subject: [PATCH] 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 7b37e1b..1db0a16 100644
index 73a5c36fed..cbf7576860 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -192,6 +192,12 @@ enum alg_id
@@ -114,10 +114,10 @@ index 7b37e1b..1db0a16 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 517baf2..4522505 100644
index 6cefe13226..75c25d0929 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -509,7 +509,7 @@ static void test_BCryptGenerateSymmetricKey(void)
@@ -512,7 +512,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 517baf2..4522505 100644
size = 0xdeadbeef;
ret = pBCryptEncrypt(key, NULL, 0, NULL, NULL, 0, NULL, 0, &size, 0);
@@ -698,7 +698,7 @@ static void test_BCryptEncrypt(void)
@@ -701,7 +701,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 517baf2..4522505 100644
size = 0;
ret = BCryptGetProperty(aes, BCRYPT_AUTH_TAG_LENGTH, NULL, 0, &size, 0);
@@ -936,7 +936,7 @@ static void test_BCryptDecrypt(void)
@@ -939,7 +939,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 517baf2..4522505 100644
buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
ret = pBCryptGenerateSymmetricKey(aes, &key, buf, len, secret, sizeof(secret), 0);
--
1.9.1
2.16.1

View File

@@ -1,22 +1,22 @@
From 049fa305cf5b74336cac77ebaaef109aeb94364f Mon Sep 17 00:00:00 2001
From 03f5aab7ed244185ec6af90d14213ffff3241536 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:46:11 +0100
Subject: [PATCH] bcrypt: Implement BCryptGetProperty for BCRYPT_CHAINING_MODE.
Subject: [PATCH 14/36] bcrypt: Implement BCryptGetProperty for
BCRYPT_CHAINING_MODE.
---
dlls/bcrypt/bcrypt_main.c | 19 ++++++++++---------
dlls/bcrypt/tests/bcrypt.c | 2 +-
2 files changed, 11 insertions(+), 10 deletions(-)
dlls/bcrypt/bcrypt_main.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index 1db0a16..f55c7d4 100644
index cbf7576860..186e619d5f 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -540,17 +540,18 @@ static NTSTATUS get_alg_property( const struct algorithm *alg, const WCHAR *prop
}
if (!strcmpW( prop, BCRYPT_CHAINING_MODE ))
{
- if (size >= sizeof(BCRYPT_CHAIN_MODE_CBC))
- if (size >= sizeof(BCRYPT_CHAIN_MODE_CBC) * sizeof(WCHAR))
+ const WCHAR *mode;
+ switch (alg->mode)
{
@@ -40,19 +40,6 @@ index 1db0a16..f55c7d4 100644
}
if (!strcmpW( prop, BCRYPT_KEY_LENGTHS ))
{
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
index 4522505..d1633a8 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -453,7 +453,7 @@ static void test_aes(void)
size = 0;
ret = pBCryptGetProperty(alg, BCRYPT_CHAINING_MODE, mode, sizeof(mode) - 1, &size, 0);
- todo_wine ok(ret == STATUS_BUFFER_TOO_SMALL, "got %08x\n", ret);
+ ok(ret == STATUS_BUFFER_TOO_SMALL, "got %08x\n", ret);
ok(size == 64, "got %u\n", size);
size = 0;
--
1.9.1
2.16.1

View File

@@ -1,7 +1,7 @@
From 943d83df3c24ff415863425287e6ba5434bfe927 Mon Sep 17 00:00:00 2001
From 744b3c49bafcff56b8780666ed0da8cec97f4866 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:50:28 +0100
Subject: [PATCH] bcrypt: Implement BCryptGetProperty for
Subject: [PATCH 15/36] bcrypt: Implement BCryptGetProperty for
BCRYPT_AUTH_TAG_LENGTH.
---
@@ -10,7 +10,7 @@ Subject: [PATCH] bcrypt: Implement BCryptGetProperty for
2 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index f55c7d4..089ef45 100644
index 186e619d5f..47ed8e0533 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -566,6 +566,20 @@ static NTSTATUS get_alg_property( const struct algorithm *alg, const WCHAR *prop
@@ -35,10 +35,10 @@ index f55c7d4..089ef45 100644
default:
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
index d1633a8..14f9eaa 100644
index 75c25d0929..27feabb5f4 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -695,24 +695,24 @@ static void test_BCryptEncrypt(void)
@@ -698,24 +698,24 @@ static void test_BCryptEncrypt(void)
size = 0;
ret = BCryptGetProperty(aes, BCRYPT_AUTH_TAG_LENGTH, NULL, 0, &size, 0);
@@ -72,5 +72,5 @@ index d1633a8..14f9eaa 100644
len = 0xdeadbeef;
size = sizeof(len);
--
1.9.1
2.16.1

View File

@@ -1,7 +1,7 @@
From 2987f2d44eec9ab8269e0af331cdc7bf16d6383e Mon Sep 17 00:00:00 2001
From 3ef6086a7db8a9d101ea763b3415a727ce2cf6a8 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Mon, 26 Dec 2016 07:21:27 +0100
Subject: [PATCH] bcrypt: Fix string comparison in set_alg_property.
Subject: [PATCH 16/36] bcrypt: Fix string comparison in set_alg_property.
---
dlls/bcrypt/bcrypt_main.c | 6 ++----
@@ -9,7 +9,7 @@ Subject: [PATCH] bcrypt: Fix string comparison in set_alg_property.
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index 089ef45..9cd58c6 100644
index 47ed8e0533..9e9e357634 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -597,14 +597,12 @@ static NTSTATUS set_alg_property( struct algorithm *alg, const WCHAR *prop, UCHA
@@ -30,10 +30,10 @@ index 089ef45..9cd58c6 100644
alg->mode = MODE_ID_GCM;
return STATUS_SUCCESS;
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
index 14f9eaa..c4b411d 100644
index 27feabb5f4..70d9e0c246 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -472,6 +472,17 @@ static void test_aes(void)
@@ -475,6 +475,17 @@ static void test_aes(void)
ok(key_lengths.dwMaxLength == 256, "Expected 256, got %d\n", key_lengths.dwMaxLength);
ok(key_lengths.dwIncrement == 64, "Expected 64, got %d\n", key_lengths.dwIncrement);
@@ -52,5 +52,5 @@ index 14f9eaa..c4b411d 100644
ret = pBCryptCloseAlgorithmProvider(alg, 0);
--
1.9.1
2.16.1

View File

@@ -1,15 +1,15 @@
From fe6fae656c8755b7eb96f7cba4828bd45e7efaec Mon Sep 17 00:00:00 2001
From ae6849dde0d3c7e125c9913f7bcde27e5c514304 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Mon, 26 Dec 2016 07:46:57 +0100
Subject: [PATCH] bcrypt: Implement BCryptEncrypt for AES GCM mode.
Subject: [PATCH 17/36] bcrypt: Implement BCryptEncrypt for AES GCM mode.
---
dlls/bcrypt/bcrypt_main.c | 50 ++++++++++++++++++++++++++++++++++++++--------
dlls/bcrypt/bcrypt_main.c | 48 ++++++++++++++++++++++++++++++++++++++--------
dlls/bcrypt/tests/bcrypt.c | 18 ++++++++---------
2 files changed, 51 insertions(+), 17 deletions(-)
2 files changed, 49 insertions(+), 17 deletions(-)
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index 9cd58c6..88f3ef2 100644
index 9e9e357634..387f448516 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -63,6 +63,12 @@ MAKE_FUNCPTR(gnutls_global_set_log_level);
@@ -25,7 +25,7 @@ index 9cd58c6..88f3ef2 100644
static void gnutls_log( int level, const char *msg )
{
TRACE( "<%d> %s", level, msg );
@@ -857,6 +863,7 @@ struct key
@@ -848,6 +854,7 @@ struct key
{
struct object hdr;
enum alg_id alg_id;
@@ -33,7 +33,7 @@ index 9cd58c6..88f3ef2 100644
ULONG block_size;
gnutls_cipher_hd_t handle;
UCHAR *secret;
@@ -884,6 +891,7 @@ static NTSTATUS key_init( struct key *key, struct algorithm *alg, const UCHAR *s
@@ -925,6 +932,7 @@ static NTSTATUS key_init( struct key *key, struct algorithm *alg, const UCHAR *s
memcpy( buffer, secret, secret_len );
key->alg_id = alg->id;
@@ -41,7 +41,7 @@ index 9cd58c6..88f3ef2 100644
key->handle = 0; /* initialized on first use */
key->secret = buffer;
key->secret_len = secret_len;
@@ -896,9 +904,13 @@ static gnutls_cipher_algorithm_t get_gnutls_cipher( const struct key *key )
@@ -937,9 +945,13 @@ static gnutls_cipher_algorithm_t get_gnutls_cipher( const struct key *key )
switch (key->alg_id)
{
case ALG_ID_AES:
@@ -58,22 +58,7 @@ index 9cd58c6..88f3ef2 100644
default:
FIXME( "algorithm %u not supported\n", key->alg_id );
return GNUTLS_CIPHER_UNKNOWN;
@@ -1084,12 +1096,14 @@ static NTSTATUS key_destroy( struct key *key )
struct key
{
struct object hdr;
+ enum mode_id mode;
ULONG block_size;
};
static NTSTATUS key_init( struct key *key, struct algorithm *alg, UCHAR *secret, ULONG secret_len )
{
ERR( "support for keys not available at build time\n" );
+ key->mode = MODE_ID_CBC;
return STATUS_NOT_IMPLEMENTED;
}
@@ -1169,17 +1183,37 @@ NTSTATUS WINAPI BCryptEncrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG inp
@@ -1262,17 +1274,37 @@ NTSTATUS WINAPI BCryptEncrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG inp
padding, iv, iv_len, output, output_len, ret_len, flags );
if (!key || key->hdr.magic != MAGIC_KEY) return STATUS_INVALID_HANDLE;
@@ -117,10 +102,10 @@ index 9cd58c6..88f3ef2 100644
*ret_len = input_len;
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
index c4b411d..2721d7d 100644
index 70d9e0c246..355a414bca 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -748,12 +748,12 @@ static void test_BCryptEncrypt(void)
@@ -751,12 +751,12 @@ static void test_BCryptEncrypt(void)
memset(ciphertext, 0xff, sizeof(ciphertext));
memset(tag, 0xff, sizeof(tag));
ret = pBCryptEncrypt(key, data2, 32, &auth_info, ivbuf, 16, ciphertext, 32, &size, 0);
@@ -137,7 +122,7 @@ index c4b411d..2721d7d 100644
for (i = 0; i < 16; i++)
todo_wine ok(tag[i] == expected_tag[i], "%u: %02x != %02x\n", i, tag[i], expected_tag[i]);
@@ -763,12 +763,12 @@ static void test_BCryptEncrypt(void)
@@ -766,12 +766,12 @@ static void test_BCryptEncrypt(void)
memset(ciphertext, 0xff, sizeof(ciphertext));
memset(tag, 0xff, sizeof(tag));
ret = pBCryptEncrypt(key, data2, 24, &auth_info, ivbuf, 16, ciphertext, 24, &size, 0);
@@ -154,7 +139,7 @@ index c4b411d..2721d7d 100644
for (i = 0; i < 16; i++)
todo_wine ok(tag[i] == expected_tag2[i], "%u: %02x != %02x\n", i, tag[i], expected_tag2[i]);
@@ -781,7 +781,7 @@ static void test_BCryptEncrypt(void)
@@ -784,7 +784,7 @@ static void test_BCryptEncrypt(void)
memcpy(ivbuf, iv, sizeof(iv));
memset(ciphertext, 0, sizeof(ciphertext));
ret = pBCryptEncrypt(key, data2, 32, &auth_info, ivbuf, 16, ciphertext, 48, &size, BCRYPT_BLOCK_PADDING);
@@ -164,5 +149,5 @@ index c4b411d..2721d7d 100644
ret = pBCryptDestroyKey(key);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
--
1.9.1
2.16.1

View File

@@ -1,7 +1,7 @@
From 9fdb049ba640b416515052670a2c2f7cdc285190 Mon Sep 17 00:00:00 2001
From 94a36fa538e9ac90ba19e76a0be3f616b53e02fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Mon, 26 Dec 2016 07:53:10 +0100
Subject: [PATCH] bcrypt: Implement BCryptDecrypt for AES GCM mode.
Subject: [PATCH 18/36] bcrypt: Implement BCryptDecrypt for AES GCM mode.
---
dlls/bcrypt/bcrypt_main.c | 28 +++++++++++++++++++++++-----
@@ -9,10 +9,10 @@ Subject: [PATCH] bcrypt: Implement BCryptDecrypt for AES GCM mode.
2 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index 88f3ef2..533344b 100644
index 387f448516..17cc92dded 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -1261,17 +1261,35 @@ NTSTATUS WINAPI BCryptDecrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG inp
@@ -1352,17 +1352,35 @@ NTSTATUS WINAPI BCryptDecrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG inp
padding, iv, iv_len, output, output_len, ret_len, flags );
if (!key || key->hdr.magic != MAGIC_KEY) return STATUS_INVALID_HANDLE;
@@ -54,10 +54,10 @@ index 88f3ef2..533344b 100644
*ret_len = input_len;
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
index 2721d7d..2a646e8 100644
index 355a414bca..89a3c40850 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -966,16 +966,16 @@ static void test_BCryptDecrypt(void)
@@ -969,16 +969,16 @@ static void test_BCryptDecrypt(void)
memcpy(ivbuf, iv, sizeof(iv));
memset(plaintext, 0, sizeof(plaintext));
ret = pBCryptDecrypt(key, ciphertext4, 32, &auth_info, ivbuf, 16, plaintext, 32, &size, 0);
@@ -79,5 +79,5 @@ index 2721d7d..2a646e8 100644
ret = pBCryptDestroyKey(key);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
--
1.9.1
2.16.1

View File

@@ -1,7 +1,7 @@
From d28a934a7013ac3ab6b97c333ff404d2e76e829a Mon Sep 17 00:00:00 2001
From c7ce0b85b9d54ee608e0c2e70e6376c2f68d188e 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:02:36 +0100
Subject: [PATCH] bcrypt: Add support for computing/comparing cipher tag.
Subject: [PATCH 19/36] bcrypt: Add support for computing/comparing cipher tag.
---
dlls/bcrypt/bcrypt_main.c | 41 ++++++++++++++++++++++++++++++++++++++++-
@@ -9,7 +9,7 @@ Subject: [PATCH] bcrypt: Add support for computing/comparing cipher tag.
2 files changed, 45 insertions(+), 6 deletions(-)
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index 533344b..0ea8c68 100644
index 17cc92dded..bdf02ca375 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -50,6 +50,9 @@ static HINSTANCE instance;
@@ -47,7 +47,7 @@ index 533344b..0ea8c68 100644
if ((ret = pgnutls_global_init()) != GNUTLS_E_SUCCESS)
{
pgnutls_perror( ret );
@@ -977,6 +991,19 @@ static NTSTATUS key_decrypt( struct key *key, const UCHAR *input, ULONG input_le
@@ -1018,6 +1032,19 @@ static NTSTATUS key_decrypt( struct key *key, const UCHAR *input, ULONG input_le
return STATUS_SUCCESS;
}
@@ -67,7 +67,7 @@ index 533344b..0ea8c68 100644
static NTSTATUS key_destroy( struct key *key )
{
if (key->handle) pgnutls_cipher_deinit( key->handle );
@@ -1127,6 +1154,12 @@ static NTSTATUS key_decrypt( struct key *key, const UCHAR *input, ULONG input_le
@@ -1149,6 +1176,12 @@ static NTSTATUS key_decrypt( struct key *key, const UCHAR *input, ULONG input_le
return STATUS_NOT_IMPLEMENTED;
}
@@ -80,7 +80,15 @@ index 533344b..0ea8c68 100644
static NTSTATUS key_destroy( struct key *key )
{
ERR( "support for keys not available at build time\n" );
@@ -1211,7 +1244,7 @@ NTSTATUS WINAPI BCryptEncrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG inp
@@ -1283,6 +1316,7 @@ NTSTATUS WINAPI BCryptEncrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG inp
if (key->mode == MODE_ID_GCM)
{
BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO *auth_info = padding;
+ UCHAR tag[16];
if (!auth_info) return STATUS_INVALID_PARAMETER;
if (!auth_info->pbNonce) return STATUS_INVALID_PARAMETER;
@@ -1302,7 +1336,7 @@ NTSTATUS WINAPI BCryptEncrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG inp
if ((status = key_encrypt( key, input, input_len, output, output_len )))
return status;
@@ -89,15 +97,7 @@ index 533344b..0ea8c68 100644
}
if ((status = key_set_params( key, iv, iv_len ))) return status;
@@ -1270,6 +1303,7 @@ NTSTATUS WINAPI BCryptDecrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG inp
if (key->mode == MODE_ID_GCM)
{
BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO *auth_info = padding;
+ UCHAR tag[16];
if (!auth_info) return STATUS_INVALID_PARAMETER;
if (!auth_info->pbNonce) return STATUS_INVALID_PARAMETER;
@@ -1287,6 +1321,11 @@ NTSTATUS WINAPI BCryptDecrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG inp
@@ -1378,6 +1412,11 @@ NTSTATUS WINAPI BCryptDecrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG inp
if ((status = key_decrypt( key, input, input_len, output, output_len )))
return status;
@@ -110,10 +110,10 @@ index 533344b..0ea8c68 100644
}
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
index 2a646e8..887fe85 100644
index 89a3c40850..18cd2a2713 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -751,11 +751,11 @@ static void test_BCryptEncrypt(void)
@@ -754,11 +754,11 @@ static void test_BCryptEncrypt(void)
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
ok(size == 32, "got %u\n", size);
ok(!memcmp(ciphertext, expected4, sizeof(expected4)), "wrong data\n");
@@ -127,7 +127,7 @@ index 2a646e8..887fe85 100644
/* input size is not multiple of block size */
size = 0;
@@ -766,11 +766,11 @@ static void test_BCryptEncrypt(void)
@@ -769,11 +769,11 @@ static void test_BCryptEncrypt(void)
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
ok(size == 24, "got %u\n", size);
ok(!memcmp(ciphertext, expected4, 24), "wrong data\n");
@@ -141,7 +141,7 @@ index 2a646e8..887fe85 100644
/* test with padding */
memcpy(ivbuf, iv, sizeof(iv));
@@ -974,7 +974,7 @@ static void test_BCryptDecrypt(void)
@@ -977,7 +977,7 @@ static void test_BCryptDecrypt(void)
memcpy(ivbuf, iv, sizeof(iv));
auth_info.pbTag = iv; /* wrong tag */
ret = pBCryptDecrypt(key, ciphertext4, 32, &auth_info, ivbuf, 16, plaintext, 32, &size, 0);
@@ -151,5 +151,5 @@ index 2a646e8..887fe85 100644
ret = pBCryptDestroyKey(key);
--
1.9.1
2.16.1

View File

@@ -1,7 +1,7 @@
From c529d8ff61ab26fcd3d558f96f86196af037290f Mon Sep 17 00:00:00 2001
From 790c773742b2a0a4b4a8672de3bdfcbf539dc046 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:28:24 +0100
Subject: [PATCH] bcrypt: Implement BCryptDuplicateKey.
Subject: [PATCH 20/36] bcrypt: Implement BCryptDuplicateKey.
---
dlls/bcrypt/bcrypt.spec | 2 +-
@@ -10,7 +10,7 @@ Subject: [PATCH] bcrypt: Implement BCryptDuplicateKey.
3 files changed, 51 insertions(+), 2 deletions(-)
diff --git a/dlls/bcrypt/bcrypt.spec b/dlls/bcrypt/bcrypt.spec
index f00f55c..fcd0f6d 100644
index 21b54b4934..28c2394ce4 100644
--- a/dlls/bcrypt/bcrypt.spec
+++ b/dlls/bcrypt/bcrypt.spec
@@ -12,7 +12,7 @@
@@ -23,10 +23,10 @@ index f00f55c..fcd0f6d 100644
@ stdcall BCryptEnumAlgorithms(long ptr ptr long)
@ stub BCryptEnumContextFunctionProviders
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index 0ea8c68..5f7f86a 100644
index bdf02ca375..8d4b5ade64 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -913,6 +913,24 @@ static NTSTATUS key_init( struct key *key, struct algorithm *alg, const UCHAR *s
@@ -954,6 +954,24 @@ static NTSTATUS key_init( struct key *key, struct algorithm *alg, const UCHAR *s
return STATUS_SUCCESS;
}
@@ -51,7 +51,7 @@ index 0ea8c68..5f7f86a 100644
static gnutls_cipher_algorithm_t get_gnutls_cipher( const struct key *key )
{
switch (key->alg_id)
@@ -1134,6 +1152,13 @@ static NTSTATUS key_init( struct key *key, struct algorithm *alg, UCHAR *secret,
@@ -1156,6 +1174,13 @@ static NTSTATUS key_init( struct key *key, struct algorithm *alg, const UCHAR *s
return STATUS_NOT_IMPLEMENTED;
}
@@ -65,8 +65,8 @@ index 0ea8c68..5f7f86a 100644
static NTSTATUS key_set_params( struct key *key, UCHAR *iv, ULONG iv_len )
{
ERR( "support for keys not available at build time\n" );
@@ -1193,6 +1218,30 @@ NTSTATUS WINAPI BCryptGenerateSymmetricKey( BCRYPT_ALG_HANDLE algorithm, BCRYPT_
return STATUS_SUCCESS;
@@ -1284,6 +1309,30 @@ NTSTATUS WINAPI BCryptExportKey(BCRYPT_KEY_HANDLE export_key, BCRYPT_KEY_HANDLE
return key_export( key, type, output, output_len, size );
}
+NTSTATUS WINAPI BCryptDuplicateKey( BCRYPT_KEY_HANDLE handle, BCRYPT_KEY_HANDLE *handle_copy,
@@ -97,7 +97,7 @@ index 0ea8c68..5f7f86a 100644
{
struct key *key = handle;
diff --git a/dlls/ncrypt/ncrypt.spec b/dlls/ncrypt/ncrypt.spec
index 5d37121..68735eb 100644
index 5d5fae0b5c..d0f0f56cc4 100644
--- a/dlls/ncrypt/ncrypt.spec
+++ b/dlls/ncrypt/ncrypt.spec
@@ -14,7 +14,7 @@
@@ -110,5 +110,5 @@ index 5d37121..68735eb 100644
@ stdcall BCryptEnumAlgorithms(long ptr ptr long) bcrypt.BCryptEnumAlgorithms
@ stub BCryptEnumContextFunctionProviders
--
1.9.1
2.16.1

View File

@@ -1,14 +1,14 @@
From c8e9ffd4e5bcc6de9b8e59ff9eb98fb316970363 Mon Sep 17 00:00:00 2001
From cf71e3c1c9bd50a1e1d3f9310c526844f65510c9 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Mon, 26 Dec 2016 08:30:43 +0100
Subject: [PATCH] bcrypt/tests: Add tests for BCryptDuplicateKey.
Subject: [PATCH 21/36] bcrypt/tests: Add tests for BCryptDuplicateKey.
---
dlls/bcrypt/tests/bcrypt.c | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
index 887fe85..e33dcd3 100644
index 18cd2a2713..6ec429e309 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -45,6 +45,7 @@ static NTSTATUS (WINAPI *pBCryptEncrypt)(BCRYPT_KEY_HANDLE, PUCHAR, ULONG, VOID
@@ -17,9 +17,9 @@ index 887fe85..e33dcd3 100644
ULONG *, ULONG);
+static NTSTATUS (WINAPI *pBCryptDuplicateKey)(BCRYPT_KEY_HANDLE, BCRYPT_KEY_HANDLE *, UCHAR *, ULONG, ULONG);
static NTSTATUS (WINAPI *pBCryptDestroyKey)(BCRYPT_KEY_HANDLE);
static void test_BCryptGenRandom(void)
@@ -500,7 +501,7 @@ static void test_BCryptGenerateSymmetricKey(void)
static NTSTATUS (WINAPI *pBCryptImportKey)(BCRYPT_ALG_HANDLE, BCRYPT_KEY_HANDLE, LPCWSTR, BCRYPT_KEY_HANDLE *,
PUCHAR, ULONG, PUCHAR, ULONG, ULONG);
@@ -503,7 +504,7 @@ static void test_BCryptGenerateSymmetricKey(void)
static UCHAR expected[] =
{0xc6,0xa1,0x3b,0x37,0x87,0x8f,0x5b,0x82,0x6f,0x4f,0x81,0x62,0xa1,0xc8,0xd8,0x79};
BCRYPT_ALG_HANDLE aes;
@@ -28,7 +28,7 @@ index 887fe85..e33dcd3 100644
UCHAR *buf, ciphertext[16], plaintext[16], ivbuf[16];
ULONG size, len, i;
NTSTATUS ret;
@@ -543,6 +544,35 @@ static void test_BCryptGenerateSymmetricKey(void)
@@ -546,6 +547,35 @@ static void test_BCryptGenerateSymmetricKey(void)
for (i = 0; i < 16; i++)
ok(ciphertext[i] == expected[i], "%u: %02x != %02x\n", i, ciphertext[i], expected[i]);
@@ -64,14 +64,14 @@ index 887fe85..e33dcd3 100644
size = 0xdeadbeef;
ret = pBCryptDecrypt(key, NULL, 0, NULL, NULL, 0, NULL, 0, &size, 0);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
@@ -1011,6 +1041,7 @@ START_TEST(bcrypt)
@@ -1059,6 +1089,7 @@ START_TEST(bcrypt)
pBCryptGenerateSymmetricKey = (void *)GetProcAddress(module, "BCryptGenerateSymmetricKey");
pBCryptEncrypt = (void *)GetProcAddress(module, "BCryptEncrypt");
pBCryptDecrypt = (void *)GetProcAddress(module, "BCryptDecrypt");
+ pBCryptDuplicateKey = (void *)GetProcAddress(module, "BCryptDuplicateKey");
pBCryptDestroyKey = (void *)GetProcAddress(module, "BCryptDestroyKey");
test_BCryptGenRandom();
pBCryptImportKey = (void *)GetProcAddress(module, "BCryptImportKey");
pBCryptExportKey = (void *)GetProcAddress(module, "BCryptExportKey");
--
1.9.1
2.16.1

View File

@@ -1,7 +1,7 @@
From c625100431c570195863b2ed7e3c17c160426f26 Mon Sep 17 00:00:00 2001
From 99c36c1642f054366532902bb9a41bc264d06df6 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: [PATCH] bcrypt: Allow to call BCryptSetProperty on key objects.
Subject: [PATCH 22/36] bcrypt: Allow to call BCryptSetProperty on key objects.
---
dlls/bcrypt/bcrypt_main.c | 38 ++++++++++++++++++++++++++++++++++++--
@@ -9,7 +9,7 @@ Subject: [PATCH] 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 5f7f86a..d57cc6f 100644
index 8d4b5ade64..5913d1283e 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -246,6 +246,9 @@ struct algorithm
@@ -33,7 +33,7 @@ index 5f7f86a..d57cc6f 100644
}
default:
WARN( "unknown magic %08x\n", object->magic );
@@ -931,6 +934,31 @@ static NTSTATUS key_duplicate( struct key *key_orig, struct key *key_copy )
@@ -972,6 +975,31 @@ static NTSTATUS key_duplicate( struct key *key_orig, struct key *key_copy )
return STATUS_SUCCESS;
}
@@ -65,7 +65,7 @@ index 5f7f86a..d57cc6f 100644
static gnutls_cipher_algorithm_t get_gnutls_cipher( const struct key *key )
{
switch (key->alg_id)
@@ -1159,6 +1187,12 @@ static NTSTATUS key_duplicate( struct key *key_orig, struct key *key_copy )
@@ -1181,6 +1209,12 @@ static NTSTATUS key_duplicate( struct key *key_orig, struct key *key_copy )
return STATUS_NOT_IMPLEMENTED;
}
@@ -79,10 +79,10 @@ index 5f7f86a..d57cc6f 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 e33dcd3..c826697 100644
index 6ec429e309..baf5b638f9 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -523,6 +523,10 @@ static void test_BCryptGenerateSymmetricKey(void)
@@ -526,6 +526,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 e33dcd3..c826697 100644
ret = pBCryptEncrypt(key, NULL, 0, NULL, NULL, 0, NULL, 0, &size, 0);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
--
1.9.1
2.16.1

View File

@@ -1,53 +1,62 @@
From 819a2d3c4c10b2512760e554f7f1c142ec9fc07a Mon Sep 17 00:00:00 2001
From 71875d0a5fa90536bb48d83c3e9cf6163df370de Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Mon, 26 Dec 2016 15:01:19 +0100
Subject: [PATCH] bcrypt: Add support for auth data in AES GCM mode.
Subject: [PATCH 23/36] bcrypt: Add support for auth data in AES GCM mode.
---
dlls/bcrypt/bcrypt_main.c | 38 ++++++++++++++++++++++++++++++++++++--
1 file changed, 36 insertions(+), 2 deletions(-)
dlls/bcrypt/bcrypt_main.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index d57cc6f..506ed70 100644
index 5913d1283e..a9dfb00ab4 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -51,7 +51,8 @@ static HINSTANCE instance;
WINE_DECLARE_DEBUG_CHANNEL(winediag);
@@ -53,6 +53,10 @@ WINE_DECLARE_DEBUG_CHANNEL(winediag);
/* Not present in gnutls version < 3.0 */
-static int (*pgnutls_cipher_tag)(gnutls_cipher_hd_t handle, void * tag, size_t tag_size);
static int (*pgnutls_cipher_tag)(gnutls_cipher_hd_t handle, void * tag, size_t tag_size);
+/* Not present in gnutls version < 3.0 */
+static int (*pgnutls_cipher_tag)(gnutls_cipher_hd_t handle, void *tag, size_t tag_size);
+static int (*pgnutls_cipher_add_auth)(gnutls_cipher_hd_t handle, const void *ptext, size_t ptext_size);
+
static void *libgnutls_handle;
#define MAKE_FUNCPTR(f) static typeof(f) * p##f
@@ -72,7 +73,12 @@ MAKE_FUNCPTR(gnutls_perror);
#define GNUTLS_CIPHER_AES_256_GCM 94
#endif
MAKE_FUNCPTR(gnutls_cipher_decrypt2);
@@ -77,6 +81,16 @@ static int compat_gnutls_cipher_tag(gnutls_cipher_hd_t handle, void * tag, size_
return GNUTLS_E_UNKNOWN_CIPHER_TYPE;
}
-static int compat_gnutls_cipher_tag(gnutls_cipher_hd_t handle, void * tag, size_t tag_size)
+static int compat_gnutls_cipher_tag(gnutls_cipher_hd_t handle, void *tag, size_t tag_size)
+{
+ return GNUTLS_E_UNKNOWN_CIPHER_TYPE;
+}
+
+static int compat_gnutls_cipher_add_auth(gnutls_cipher_hd_t handle, const void *ptext, size_t ptext_size)
+{
+ return GNUTLS_E_UNKNOWN_CIPHER_TYPE;
+}
+
static void gnutls_log( int level, const char *msg )
{
return GNUTLS_E_UNKNOWN_CIPHER_TYPE;
}
@@ -115,6 +121,11 @@ static BOOL gnutls_initialize(void)
WARN("gnutls_cipher_tag not found\n");
pgnutls_cipher_tag = compat_gnutls_cipher_tag;
TRACE( "<%d> %s", level, msg );
@@ -127,6 +141,16 @@ static BOOL gnutls_initialize(void)
pgnutls_global_set_log_level( 4 );
pgnutls_global_set_log_function( gnutls_log );
}
+ if (!(pgnutls_cipher_tag = wine_dlsym( libgnutls_handle, "gnutls_cipher_tag", NULL, 0 )))
+ {
+ WARN("gnutls_cipher_tag not found\n");
+ pgnutls_cipher_tag = compat_gnutls_cipher_tag;
+ }
+ if (!(pgnutls_cipher_add_auth = wine_dlsym( libgnutls_handle, "gnutls_cipher_add_auth", NULL, 0 )))
+ {
+ WARN("gnutls_cipher_add_auth not found\n");
+ pgnutls_cipher_add_auth = compat_gnutls_cipher_add_auth;
+ }
if ((ret = pgnutls_global_init()) != GNUTLS_E_SUCCESS)
{
@@ -1009,6 +1020,19 @@ static NTSTATUS key_set_params( struct key *key, UCHAR *iv, ULONG iv_len )
return TRUE;
@@ -1050,6 +1074,19 @@ static NTSTATUS key_set_params( struct key *key, UCHAR *iv, ULONG iv_len )
return STATUS_SUCCESS;
}
@@ -67,7 +76,7 @@ index d57cc6f..506ed70 100644
static NTSTATUS key_encrypt( struct key *key, const UCHAR *input, ULONG input_len, UCHAR *output,
ULONG output_len )
{
@@ -1199,6 +1223,12 @@ static NTSTATUS key_set_params( struct key *key, UCHAR *iv, ULONG iv_len )
@@ -1221,6 +1258,12 @@ static NTSTATUS key_set_params( struct key *key, UCHAR *iv, ULONG iv_len )
return STATUS_NOT_IMPLEMENTED;
}
@@ -80,7 +89,7 @@ index d57cc6f..506ed70 100644
static NTSTATUS key_encrypt( struct key *key, const UCHAR *input, ULONG input_len, UCHAR *output,
ULONG output_len )
{
@@ -1324,6 +1354,8 @@ NTSTATUS WINAPI BCryptEncrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG inp
@@ -1416,6 +1459,8 @@ NTSTATUS WINAPI BCryptEncrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG inp
if (!output) return STATUS_SUCCESS;
if (output_len < *ret_len) return STATUS_BUFFER_TOO_SMALL;
@@ -89,7 +98,7 @@ index d57cc6f..506ed70 100644
if ((status = key_encrypt( key, input, input_len, output, output_len )))
return status;
@@ -1401,6 +1433,8 @@ NTSTATUS WINAPI BCryptDecrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG inp
@@ -1492,6 +1537,8 @@ NTSTATUS WINAPI BCryptDecrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG inp
if (!output) return STATUS_SUCCESS;
if (output_len < *ret_len) return STATUS_BUFFER_TOO_SMALL;
@@ -99,5 +108,5 @@ index d57cc6f..506ed70 100644
return status;
--
1.9.1
2.16.1

View File

@@ -1,17 +1,17 @@
From 3c7e2cb0745400c3e48229b7fa3baf224e2e849b Mon Sep 17 00:00:00 2001
From 66401fad72037ba43d5dcd9c457cdc9b4aef0498 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Mon, 26 Dec 2016 15:01:38 +0100
Subject: [PATCH] bcrypt/tests: Add tests for auth data in AES GCM mode.
Subject: [PATCH 24/36] bcrypt/tests: Add tests for auth data in AES GCM mode.
---
dlls/bcrypt/tests/bcrypt.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 42 insertions(+), 2 deletions(-)
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
index c826697..fafc4a1 100644
index baf5b638f9..bd22b80d9a 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -607,7 +607,9 @@ static void test_BCryptGenerateSymmetricKey(void)
@@ -610,7 +610,9 @@ static void test_BCryptGenerateSymmetricKey(void)
static void test_BCryptEncrypt(void)
{
static UCHAR nonce[] =
@@ -22,7 +22,7 @@ index c826697..fafc4a1 100644
static UCHAR secret[] =
{0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f};
static UCHAR iv[] =
@@ -633,6 +635,8 @@ static void test_BCryptEncrypt(void)
@@ -636,6 +638,8 @@ static void test_BCryptEncrypt(void)
{0x89,0xb3,0x92,0x00,0x39,0x20,0x09,0xb4,0x6a,0xd6,0xaf,0xca,0x4b,0x5b,0xfd,0xd0};
static UCHAR expected_tag2[] =
{0x9a,0x92,0x32,0x2c,0x61,0x2a,0xae,0xef,0x66,0x2a,0xfb,0x55,0xe9,0x48,0xdf,0xbd};
@@ -31,7 +31,7 @@ index c826697..fafc4a1 100644
BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO auth_info;
UCHAR *buf, ciphertext[48], ivbuf[16], tag[16];
BCRYPT_AUTH_TAG_LENGTHS_STRUCT tag_length;
@@ -806,6 +810,24 @@ static void test_BCryptEncrypt(void)
@@ -809,6 +813,24 @@ static void test_BCryptEncrypt(void)
for (i = 0; i < 16; i++)
ok(tag[i] == expected_tag2[i], "%u: %02x != %02x\n", i, tag[i], expected_tag2[i]);
@@ -56,7 +56,7 @@ index c826697..fafc4a1 100644
/* test with padding */
memcpy(ivbuf, iv, sizeof(iv));
memset(ciphertext, 0, sizeof(ciphertext));
@@ -828,7 +850,9 @@ static void test_BCryptEncrypt(void)
@@ -831,7 +853,9 @@ static void test_BCryptEncrypt(void)
static void test_BCryptDecrypt(void)
{
static UCHAR nonce[] =
@@ -67,7 +67,7 @@ index c826697..fafc4a1 100644
static UCHAR secret[] =
{0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f};
static UCHAR iv[] =
@@ -855,6 +879,8 @@ static void test_BCryptDecrypt(void)
@@ -858,6 +882,8 @@ static void test_BCryptDecrypt(void)
0x86,0x64,0xc3,0xfe,0xa3,0x07,0x61,0xf8,0x16,0xc9,0x78,0x7f,0xe7,0xb1,0xc4,0x94};
static UCHAR tag[] =
{0x89,0xb3,0x92,0x00,0x39,0x20,0x09,0xb4,0x6a,0xd6,0xaf,0xca,0x4b,0x5b,0xfd,0xd0};
@@ -76,7 +76,7 @@ index c826697..fafc4a1 100644
BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO auth_info;
BCRYPT_KEY_LENGTHS_STRUCT key_lengths;
BCRYPT_ALG_HANDLE aes;
@@ -1004,6 +1030,20 @@ static void test_BCryptDecrypt(void)
@@ -1007,6 +1033,20 @@ static void test_BCryptDecrypt(void)
ok(size == 32, "got %u\n", size);
ok(!memcmp(plaintext, expected3, sizeof(expected3)), "wrong data\n");
@@ -98,5 +98,5 @@ index c826697..fafc4a1 100644
memcpy(ivbuf, iv, sizeof(iv));
auth_info.pbTag = iv; /* wrong tag */
--
1.9.1
2.16.1

View File

@@ -1,18 +1,18 @@
From a86334fac65af406c7e634fbf4f68c4796fb1f41 Mon Sep 17 00:00:00 2001
From aad04c30ad73ffec87b46b59f65fc6d451138d0c Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Mon, 26 Dec 2016 16:20:57 +0100
Subject: [PATCH] bcrypt: Avoid crash in tests when compiling without gnutls
support.
Subject: [PATCH 25/36] bcrypt: Avoid crash in tests when compiling without
gnutls support.
---
dlls/bcrypt/bcrypt_main.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index 506ed70..b52d289 100644
index a9dfb00ab4..79e62e33c9 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -1269,12 +1269,19 @@ NTSTATUS WINAPI BCryptGenerateSymmetricKey( BCRYPT_ALG_HANDLE algorithm, BCRYPT_
@@ -1310,12 +1310,19 @@ NTSTATUS WINAPI BCryptGenerateSymmetricKey( BCRYPT_ALG_HANDLE algorithm, BCRYPT_
if (!alg || alg->hdr.magic != MAGIC_ALG) return STATUS_INVALID_HANDLE;
if (object) FIXME( "ignoring object buffer\n" );
@@ -32,7 +32,7 @@ index 506ed70..b52d289 100644
return status;
}
@@ -1294,11 +1301,15 @@ NTSTATUS WINAPI BCryptDuplicateKey( BCRYPT_KEY_HANDLE handle, BCRYPT_KEY_HANDLE
@@ -1398,11 +1405,15 @@ NTSTATUS WINAPI BCryptDuplicateKey( BCRYPT_KEY_HANDLE handle, BCRYPT_KEY_HANDLE
if (!key_orig || key_orig->hdr.magic != MAGIC_KEY) return STATUS_INVALID_HANDLE;
if (!handle_copy) return STATUS_INVALID_PARAMETER;
if (!(key_copy = HeapAlloc( GetProcessHeap(), 0, sizeof(*key_copy) )))
@@ -49,5 +49,5 @@ index 506ed70..b52d289 100644
}
--
1.9.1
2.16.1

View File

@@ -1,7 +1,7 @@
From ce3479faa24fcaab430d2c62c1d0c386089206b6 Mon Sep 17 00:00:00 2001
From 344221b351b7dc15b9cd1e75b741e2dec978e744 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sun, 5 Mar 2017 23:18:03 +0100
Subject: [PATCH] bcrypt: Implement support for ECB chain mode.
Subject: [PATCH 26/36] bcrypt: Implement support for ECB chain mode.
---
dlls/bcrypt/bcrypt_main.c | 43 ++++++++--
@@ -9,10 +9,10 @@ Subject: [PATCH] bcrypt: Implement support for ECB chain mode.
2 files changed, 244 insertions(+), 9 deletions(-)
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index b52d289..6859788 100644
index 79e62e33c9..22a653f7f2 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -225,6 +225,7 @@ enum alg_id
@@ -238,6 +238,7 @@ enum alg_id
enum mode_id
{
@@ -20,7 +20,7 @@ index b52d289..6859788 100644
MODE_ID_CBC,
MODE_ID_GCM
};
@@ -577,8 +578,9 @@ static NTSTATUS get_alg_property( const struct algorithm *alg, const WCHAR *prop
@@ -590,8 +591,9 @@ static NTSTATUS get_alg_property( const struct algorithm *alg, const WCHAR *prop
const WCHAR *mode;
switch (alg->mode)
{
@@ -31,7 +31,7 @@ index b52d289..6859788 100644
default: return STATUS_NOT_IMPLEMENTED;
}
@@ -631,7 +633,12 @@ static NTSTATUS set_alg_property( struct algorithm *alg, const WCHAR *prop, UCHA
@@ -644,7 +646,12 @@ static NTSTATUS set_alg_property( struct algorithm *alg, const WCHAR *prop, UCHA
case ALG_ID_AES:
if (!strcmpW( prop, BCRYPT_CHAINING_MODE ))
{
@@ -45,7 +45,7 @@ index b52d289..6859788 100644
{
alg->mode = MODE_ID_CBC;
return STATUS_SUCCESS;
@@ -949,7 +956,12 @@ static NTSTATUS set_key_property( struct key *key, const WCHAR *prop, UCHAR *val
@@ -1003,7 +1010,12 @@ static NTSTATUS set_key_property( struct key *key, const WCHAR *prop, UCHAR *val
{
if (!strcmpW( prop, BCRYPT_CHAINING_MODE ))
{
@@ -59,7 +59,7 @@ index b52d289..6859788 100644
{
key->mode = MODE_ID_CBC;
return STATUS_SUCCESS;
@@ -979,6 +991,7 @@ static gnutls_cipher_algorithm_t get_gnutls_cipher( const struct key *key )
@@ -1033,6 +1045,7 @@ static gnutls_cipher_algorithm_t get_gnutls_cipher( const struct key *key )
switch (key->mode)
{
case MODE_ID_GCM: return GNUTLS_CIPHER_AES_128_GCM;
@@ -67,7 +67,7 @@ index b52d289..6859788 100644
case MODE_ID_CBC:
default: return GNUTLS_CIPHER_AES_128_CBC;
}
@@ -990,6 +1003,7 @@ static gnutls_cipher_algorithm_t get_gnutls_cipher( const struct key *key )
@@ -1044,6 +1057,7 @@ static gnutls_cipher_algorithm_t get_gnutls_cipher( const struct key *key )
static NTSTATUS key_set_params( struct key *key, UCHAR *iv, ULONG iv_len )
{
@@ -75,7 +75,7 @@ index b52d289..6859788 100644
gnutls_cipher_algorithm_t cipher;
gnutls_datum_t secret, vector;
int ret;
@@ -1003,15 +1017,18 @@ static NTSTATUS key_set_params( struct key *key, UCHAR *iv, ULONG iv_len )
@@ -1057,15 +1071,18 @@ static NTSTATUS key_set_params( struct key *key, UCHAR *iv, ULONG iv_len )
if ((cipher = get_gnutls_cipher( key )) == GNUTLS_CIPHER_UNKNOWN)
return STATUS_NOT_SUPPORTED;
@@ -100,7 +100,7 @@ index b52d289..6859788 100644
{
pgnutls_perror( ret );
return STATUS_INTERNAL_ERROR;
@@ -1385,11 +1402,15 @@ NTSTATUS WINAPI BCryptEncrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG inp
@@ -1490,11 +1507,15 @@ NTSTATUS WINAPI BCryptEncrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG inp
if (!output) return STATUS_SUCCESS;
if (output_len < *ret_len) return STATUS_BUFFER_TOO_SMALL;
@@ -116,7 +116,7 @@ index b52d289..6859788 100644
bytes_left -= key->block_size;
src += key->block_size;
dst += key->block_size;
@@ -1472,11 +1493,15 @@ NTSTATUS WINAPI BCryptDecrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG inp
@@ -1576,11 +1597,15 @@ NTSTATUS WINAPI BCryptDecrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG inp
else if (output_len < *ret_len)
return STATUS_BUFFER_TOO_SMALL;
@@ -133,10 +133,10 @@ index b52d289..6859788 100644
src += key->block_size;
dst += key->block_size;
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
index fafc4a1..f9bf77b 100644
index bd22b80d9a..ade8058724 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -631,6 +631,15 @@ static void test_BCryptEncrypt(void)
@@ -634,6 +634,15 @@ static void test_BCryptEncrypt(void)
static UCHAR expected4[] =
{0xe1,0x82,0xc3,0xc0,0x24,0xfb,0x86,0x85,0xf3,0xf1,0x2b,0x7d,0x09,0xb4,0x73,0x67,
0x86,0x64,0xc3,0xfe,0xa3,0x07,0x61,0xf8,0x16,0xc9,0x78,0x7f,0xe7,0xb1,0xc4,0x94};
@@ -152,7 +152,7 @@ index fafc4a1..f9bf77b 100644
static UCHAR expected_tag[] =
{0x89,0xb3,0x92,0x00,0x39,0x20,0x09,0xb4,0x6a,0xd6,0xaf,0xca,0x4b,0x5b,0xfd,0xd0};
static UCHAR expected_tag2[] =
@@ -843,6 +852,97 @@ static void test_BCryptEncrypt(void)
@@ -846,6 +855,97 @@ static void test_BCryptEncrypt(void)
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
HeapFree(GetProcessHeap(), 0, buf);
@@ -250,7 +250,7 @@ index fafc4a1..f9bf77b 100644
ret = pBCryptCloseAlgorithmProvider(aes, 0);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
}
@@ -877,6 +977,13 @@ static void test_BCryptDecrypt(void)
@@ -880,6 +980,13 @@ static void test_BCryptDecrypt(void)
static UCHAR ciphertext4[] =
{0xe1,0x82,0xc3,0xc0,0x24,0xfb,0x86,0x85,0xf3,0xf1,0x2b,0x7d,0x09,0xb4,0x73,0x67,
0x86,0x64,0xc3,0xfe,0xa3,0x07,0x61,0xf8,0x16,0xc9,0x78,0x7f,0xe7,0xb1,0xc4,0x94};
@@ -264,7 +264,7 @@ index fafc4a1..f9bf77b 100644
static UCHAR tag[] =
{0x89,0xb3,0x92,0x00,0x39,0x20,0x09,0xb4,0x6a,0xd6,0xaf,0xca,0x4b,0x5b,0xfd,0xd0};
static UCHAR tag2[] =
@@ -1055,6 +1162,109 @@ static void test_BCryptDecrypt(void)
@@ -1058,6 +1165,109 @@ static void test_BCryptDecrypt(void)
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
HeapFree(GetProcessHeap(), 0, buf);
@@ -375,5 +375,5 @@ index fafc4a1..f9bf77b 100644
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
}
--
1.9.1
2.16.1

View File

@@ -1,8 +1,8 @@
From d0f750269e6c667bf459ed53bb748a0f558eaa47 Mon Sep 17 00:00:00 2001
From c8316aa8c5543faf138c83b50c93be6d58c82d1c Mon Sep 17 00:00:00 2001
From: Andrew Wesie <awesie@gmail.com>
Date: Mon, 1 May 2017 22:57:43 -0500
Subject: [PATCH] bcrypt: Fix BCryptEncrypt with AES_GCM and no input and no
output.
Subject: [PATCH 27/36] bcrypt: Fix BCryptEncrypt with AES_GCM and no input and
no output.
Signed-off-by: Andrew Wesie <awesie@gmail.com>
---
@@ -11,10 +11,10 @@ Signed-off-by: Andrew Wesie <awesie@gmail.com>
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index 6859788..bb92c04 100644
index 22a653f7f2..95d21f7d0b 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -1379,7 +1379,7 @@ NTSTATUS WINAPI BCryptEncrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG inp
@@ -1484,7 +1484,7 @@ NTSTATUS WINAPI BCryptEncrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG inp
*ret_len = input_len;
if (flags & BCRYPT_BLOCK_PADDING) return STATUS_INVALID_PARAMETER;
@@ -24,10 +24,10 @@ index 6859788..bb92c04 100644
if (auth_info->pbAuthData && (status = key_set_auth_data( key, auth_info->pbAuthData, auth_info->cbAuthData )))
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
index f9bf77b..ed73db5 100644
index ade8058724..159be44714 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -646,6 +646,9 @@ static void test_BCryptEncrypt(void)
@@ -649,6 +649,9 @@ static void test_BCryptEncrypt(void)
{0x9a,0x92,0x32,0x2c,0x61,0x2a,0xae,0xef,0x66,0x2a,0xfb,0x55,0xe9,0x48,0xdf,0xbd};
static UCHAR expected_tag3[] =
{0x17,0x9d,0xc0,0x7a,0xf0,0xcf,0xaa,0xd5,0x1c,0x11,0xc4,0x4b,0xd6,0xa3,0x3e,0x77};
@@ -37,7 +37,7 @@ index f9bf77b..ed73db5 100644
BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO auth_info;
UCHAR *buf, ciphertext[48], ivbuf[16], tag[16];
BCRYPT_AUTH_TAG_LENGTHS_STRUCT tag_length;
@@ -837,6 +840,21 @@ static void test_BCryptEncrypt(void)
@@ -840,6 +843,21 @@ static void test_BCryptEncrypt(void)
for (i = 0; i < 16; i++)
ok(tag[i] == expected_tag3[i], "%u: %02x != %02x\n", i, tag[i], expected_tag3[i]);
@@ -60,5 +60,5 @@ index f9bf77b..ed73db5 100644
memcpy(ivbuf, iv, sizeof(iv));
memset(ciphertext, 0, sizeof(ciphertext));
--
1.9.1
2.16.1

View File

@@ -1,304 +0,0 @@
From 3617913e722505d39009bc2dc2f32ba05289ff42 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sun, 13 Aug 2017 04:28:43 +0200
Subject: [PATCH] bcrypt: Partial implementation of BCryptImportKey and
BCryptExportKey.
---
dlls/bcrypt/bcrypt.spec | 4 +-
dlls/bcrypt/bcrypt_main.c | 101 +++++++++++++++++++++++++++++++++++++++++++++
dlls/bcrypt/tests/bcrypt.c | 46 +++++++++++++++++++++
dlls/ncrypt/ncrypt.spec | 4 +-
include/bcrypt.h | 14 +++++++
5 files changed, 165 insertions(+), 4 deletions(-)
diff --git a/dlls/bcrypt/bcrypt.spec b/dlls/bcrypt/bcrypt.spec
index fcd0f6d..28c2394 100644
--- a/dlls/bcrypt/bcrypt.spec
+++ b/dlls/bcrypt/bcrypt.spec
@@ -20,7 +20,7 @@
@ stub BCryptEnumContexts
@ stub BCryptEnumProviders
@ stub BCryptEnumRegisteredProviders
-@ stub BCryptExportKey
+@ stdcall BCryptExportKey(ptr ptr wstr ptr long ptr long)
@ stub BCryptFinalizeKeyPair
@ stdcall BCryptFinishHash(ptr ptr long long)
@ stub BCryptFreeBuffer
@@ -31,7 +31,7 @@
@ stdcall BCryptGetProperty(ptr wstr ptr long ptr long)
@ stdcall BCryptHash(ptr ptr long ptr long ptr long)
@ stdcall BCryptHashData(ptr ptr long long)
-@ stub BCryptImportKey
+@ stdcall BCryptImportKey(ptr ptr wstr ptr ptr long ptr long long)
@ stub BCryptImportKeyPair
@ stdcall BCryptOpenAlgorithmProvider(ptr wstr wstr long)
@ stub BCryptQueryContextConfiguration
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index bb92c04..f00a154 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -1091,6 +1091,13 @@ static NTSTATUS key_get_tag( struct key *key, UCHAR *tag, ULONG len )
return STATUS_SUCCESS;
}
+static NTSTATUS key_get_secret( struct key *key, UCHAR **secret, ULONG *len )
+{
+ *secret = key->secret;
+ *len = key->secret_len;
+ return STATUS_SUCCESS;
+}
+
static NTSTATUS key_destroy( struct key *key )
{
if (key->handle) pgnutls_cipher_deinit( key->handle );
@@ -1266,6 +1273,12 @@ static NTSTATUS key_get_tag( struct key *key, UCHAR *tag, ULONG len )
return STATUS_NOT_IMPLEMENTED;
}
+static NTSTATUS key_get_secret( struct key *key, UCHAR **secret, ULONG *len )
+{
+ ERR( "support for keys not available at build time\n" );
+ return STATUS_NOT_IMPLEMENTED;
+}
+
static NTSTATUS key_destroy( struct key *key )
{
ERR( "support for keys not available at build time\n" );
@@ -1334,6 +1347,94 @@ NTSTATUS WINAPI BCryptDuplicateKey( BCRYPT_KEY_HANDLE handle, BCRYPT_KEY_HANDLE
return STATUS_SUCCESS;
}
+NTSTATUS WINAPI BCryptImportKey( BCRYPT_ALG_HANDLE algorithm, BCRYPT_KEY_HANDLE decrypt_key, LPCWSTR type,
+ BCRYPT_KEY_HANDLE *key, UCHAR *object, ULONG object_len, UCHAR *input,
+ ULONG input_len, ULONG flags )
+{
+ struct algorithm *alg = algorithm;
+
+ TRACE( "%p, %p, %s, %p, %p, %u, %p, %u, %u\n", algorithm, decrypt_key, debugstr_w(type), key, object,
+ object_len, input, input_len, flags );
+
+ if (!alg || alg->hdr.magic != MAGIC_ALG) return STATUS_INVALID_HANDLE;
+ if (!key || !type || !input) return STATUS_INVALID_PARAMETER;
+
+ if (decrypt_key)
+ {
+ FIXME( "decrypting of key not yet supported\n" );
+ return STATUS_NOT_IMPLEMENTED;
+ }
+
+ if (!strcmpW( type, BCRYPT_KEY_DATA_BLOB ))
+ {
+ BCRYPT_KEY_DATA_BLOB_HEADER *key_header = (BCRYPT_KEY_DATA_BLOB_HEADER *)input;
+
+ if (input_len < sizeof(BCRYPT_KEY_DATA_BLOB_HEADER))
+ return STATUS_BUFFER_TOO_SMALL;
+
+ if (key_header->dwMagic != BCRYPT_KEY_DATA_BLOB_MAGIC)
+ return STATUS_INVALID_PARAMETER;
+
+ if (key_header->dwVersion != BCRYPT_KEY_DATA_BLOB_VERSION1)
+ {
+ FIXME( "unknown key data blob version %u\n", key_header->dwVersion );
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ if (key_header->cbKeyData + sizeof(BCRYPT_KEY_DATA_BLOB_HEADER) > input_len)
+ return STATUS_INVALID_PARAMETER;
+
+ return BCryptGenerateSymmetricKey( algorithm, key, object, object_len,
+ (UCHAR *)&key_header[1], key_header->cbKeyData, 0 );
+ }
+
+ FIXME( "unsupported key type %s\n", debugstr_w(type) );
+ return STATUS_INVALID_PARAMETER;
+}
+
+NTSTATUS WINAPI BCryptExportKey( BCRYPT_KEY_HANDLE export_key, BCRYPT_KEY_HANDLE encrypt_key, LPCWSTR type,
+ UCHAR *output, ULONG output_len, ULONG *size, ULONG flags )
+{
+ struct key *key = export_key;
+ ULONG secret_len;
+ NTSTATUS status;
+ UCHAR *secret;
+
+ TRACE( "%p, %p, %s, %p, %u, %p, %u\n", key, encrypt_key, debugstr_w(type), output, output_len, size, flags );
+
+ if (!key || key->hdr.magic != MAGIC_KEY) return STATUS_INVALID_HANDLE;
+ if (!output || !output_len || !size) return STATUS_INVALID_PARAMETER;
+
+ if (encrypt_key)
+ {
+ FIXME( "encryption of key not yet supported\n" );
+ return STATUS_NOT_IMPLEMENTED;
+ }
+
+ if ((status = key_get_secret( key, &secret, &secret_len )))
+ return status;
+
+ if (!strcmpW( type, BCRYPT_KEY_DATA_BLOB ))
+ {
+ BCRYPT_KEY_DATA_BLOB_HEADER *key_header = (BCRYPT_KEY_DATA_BLOB_HEADER *)output;
+ ULONG req_size = sizeof(BCRYPT_KEY_DATA_BLOB_HEADER) + secret_len;
+
+ *size = req_size;
+
+ if (output_len < req_size)
+ return STATUS_BUFFER_TOO_SMALL;
+
+ key_header->dwMagic = BCRYPT_KEY_DATA_BLOB_MAGIC;
+ key_header->dwVersion = BCRYPT_KEY_DATA_BLOB_VERSION1;
+ key_header->cbKeyData = secret_len;
+ memcpy( &key_header[1], secret, secret_len );
+ return STATUS_SUCCESS;
+ }
+
+ FIXME( "unsupported key type %s\n", debugstr_w(type) );
+ return STATUS_INVALID_PARAMETER;
+}
+
NTSTATUS WINAPI BCryptDestroyKey( BCRYPT_KEY_HANDLE handle )
{
struct key *key = handle;
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
index ed73db5..d52c79d 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -47,6 +47,9 @@ static NTSTATUS (WINAPI *pBCryptDecrypt)(BCRYPT_KEY_HANDLE, PUCHAR, ULONG, VOID
ULONG *, ULONG);
static NTSTATUS (WINAPI *pBCryptDuplicateKey)(BCRYPT_KEY_HANDLE, BCRYPT_KEY_HANDLE *, UCHAR *, ULONG, ULONG);
static NTSTATUS (WINAPI *pBCryptDestroyKey)(BCRYPT_KEY_HANDLE);
+static NTSTATUS (WINAPI *pBCryptImportKey)(BCRYPT_ALG_HANDLE, BCRYPT_KEY_HANDLE, LPCWSTR, BCRYPT_KEY_HANDLE *,
+ PUCHAR, ULONG, PUCHAR, ULONG, ULONG);
+static NTSTATUS (WINAPI *pBCryptExportKey)(BCRYPT_KEY_HANDLE, BCRYPT_KEY_HANDLE, LPCWSTR, PUCHAR, ULONG, ULONG *, ULONG);
static void test_BCryptGenRandom(void)
{
@@ -1287,6 +1290,46 @@ static void test_BCryptDecrypt(void)
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
}
+static void test_key_import_export(void)
+{
+ UCHAR buffer1[sizeof(BCRYPT_KEY_DATA_BLOB_HEADER) + 16];
+ UCHAR buffer2[sizeof(BCRYPT_KEY_DATA_BLOB_HEADER) + 16];
+ BCRYPT_KEY_DATA_BLOB_HEADER *key_data1 = (void*)buffer1;
+ BCRYPT_ALG_HANDLE aes;
+ BCRYPT_KEY_HANDLE key;
+ NTSTATUS ret;
+ ULONG size;
+
+ ret = pBCryptOpenAlgorithmProvider(&aes, BCRYPT_AES_ALGORITHM, NULL, 0);
+ ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+
+ key_data1->dwMagic = BCRYPT_KEY_DATA_BLOB_MAGIC;
+ key_data1->dwVersion = BCRYPT_KEY_DATA_BLOB_VERSION1;
+ key_data1->cbKeyData = 16;
+ memset(&key_data1[1], 0x11, 16);
+
+ ret = pBCryptImportKey(aes, NULL, BCRYPT_KEY_DATA_BLOB, &key, NULL, 0, buffer1, sizeof(buffer1), 0);
+ ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+
+ size = 0;
+ ret = pBCryptExportKey(key, NULL, BCRYPT_KEY_DATA_BLOB, buffer2, 1, &size, 0);
+ ok(ret == STATUS_BUFFER_TOO_SMALL, "got %08x\n", ret);
+ ok(size == sizeof(buffer2), "Expected sizeof(buffer2), got %u\n", size);
+
+ size = 0;
+ memset(buffer2, 0xff, sizeof(buffer2));
+ ret = pBCryptExportKey(key, NULL, BCRYPT_KEY_DATA_BLOB, buffer2, sizeof(buffer2), &size, 0);
+ ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+ ok(size == sizeof(buffer2), "Expected sizeof(buffer2), got %u\n", size);
+ ok(!memcmp(buffer1, buffer2, sizeof(buffer1)), "Expected exported key to match imported key\n");
+
+ ret = pBCryptDestroyKey(key);
+ ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+
+ ret = pBCryptCloseAlgorithmProvider(aes, 0);
+ ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+}
+
START_TEST(bcrypt)
{
HMODULE module;
@@ -1315,6 +1358,8 @@ START_TEST(bcrypt)
pBCryptDecrypt = (void *)GetProcAddress(module, "BCryptDecrypt");
pBCryptDuplicateKey = (void *)GetProcAddress(module, "BCryptDuplicateKey");
pBCryptDestroyKey = (void *)GetProcAddress(module, "BCryptDestroyKey");
+ pBCryptImportKey = (void *)GetProcAddress(module, "BCryptImportKey");
+ pBCryptExportKey = (void *)GetProcAddress(module, "BCryptExportKey");
test_BCryptGenRandom();
test_BCryptGetFipsAlgorithmMode();
@@ -1324,6 +1369,7 @@ START_TEST(bcrypt)
test_BCryptGenerateSymmetricKey();
test_BCryptEncrypt();
test_BCryptDecrypt();
+ test_key_import_export();
if (pBCryptHash) /* >= Win 10 */
test_BcryptHash();
diff --git a/dlls/ncrypt/ncrypt.spec b/dlls/ncrypt/ncrypt.spec
index 68735eb..d0f0f56 100644
--- a/dlls/ncrypt/ncrypt.spec
+++ b/dlls/ncrypt/ncrypt.spec
@@ -22,7 +22,7 @@
@ stub BCryptEnumContexts
@ stub BCryptEnumProviders
@ stub BCryptEnumRegisteredProviders
-@ stub BCryptExportKey
+@ stdcall BCryptExportKey(ptr ptr wstr ptr long ptr long) bcrypt.BCryptExportKey
@ stub BCryptFinalizeKeyPair
@ stdcall BCryptFinishHash(ptr ptr long long) bcrypt.BCryptFinishHash
@ stub BCryptFreeBuffer
@@ -33,7 +33,7 @@
@ stdcall BCryptGetProperty(ptr wstr ptr long ptr long) bcrypt.BCryptGetProperty
@ stdcall BCryptHash(ptr ptr long ptr long ptr long) bcrypt.BCryptHash
@ stdcall BCryptHashData(ptr ptr long long) bcrypt.BCryptHashData
-@ stub BCryptImportKey
+@ stdcall BCryptImportKey(ptr ptr wstr ptr ptr long ptr long long) bcrypt.BCryptImportKey
@ stub BCryptImportKeyPair
@ stub BCryptKeyDerivation
@ stdcall BCryptOpenAlgorithmProvider(ptr wstr wstr long) bcrypt.BCryptOpenAlgorithmProvider
diff --git a/include/bcrypt.h b/include/bcrypt.h
index 1e468a3..81822af 100644
--- a/include/bcrypt.h
+++ b/include/bcrypt.h
@@ -58,6 +58,10 @@ typedef LONG NTSTATUS;
#define BCRYPT_PROVIDER_HANDLE (const WCHAR []){'P','r','o','v','i','d','e','r','H','a','n','d','l','e',0}
#define BCRYPT_SIGNATURE_LENGTH (const WCHAR []){'S','i','g','n','a','t','u','r','e','L','e','n','g','t','h',0}
+#define BCRYPT_OPAQUE_KEY_BLOB (const WCHAR []){'O','p','a','q','u','e','K','e','y','B','l','o','b',0}
+#define BCRYPT_KEY_DATA_BLOB (const WCHAR []){'K','e','y','D','a','t','a','B','l','o','b',0}
+#define BCRYPT_AES_WRAP_KEY_BLOB (const WCHAR []){'R','f','c','3','5','6','5','K','e','y','W','r','a','p','B','l','o','b',0}
+
#define MS_PRIMITIVE_PROVIDER (const WCHAR [])\
{'M','i','c','r','o','s','o','f','t',' ','P','r','i','m','i','t','i','v','e',' ','P','r','o','v','i','d','e','r',0}
#define MS_PLATFORM_CRYPTO_PROVIDER (const WCHAR [])\
@@ -94,6 +98,13 @@ typedef struct __BCRYPT_KEY_LENGTHS_STRUCT
ULONG dwIncrement;
} BCRYPT_KEY_LENGTHS_STRUCT, BCRYPT_AUTH_TAG_LENGTHS_STRUCT;
+typedef struct _BCRYPT_KEY_DATA_BLOB_HEADER
+{
+ ULONG dwMagic;
+ ULONG dwVersion;
+ ULONG cbKeyData;
+} BCRYPT_KEY_DATA_BLOB_HEADER, *PBCRYPT_KEY_DATA_BLOB_HEADER;
+
typedef struct _BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO
{
ULONG cbSize;
@@ -139,6 +150,9 @@ typedef struct _CRYPT_PROVIDER_REG
PCRYPT_IMAGE_REG pKM;
} CRYPT_PROVIDER_REG, *PCRYPT_PROVIDER_REG;
+#define BCRYPT_KEY_DATA_BLOB_MAGIC 0x4d42444b
+#define BCRYPT_KEY_DATA_BLOB_VERSION1 1
+
typedef PVOID BCRYPT_ALG_HANDLE;
typedef PVOID BCRYPT_KEY_HANDLE;
typedef PVOID BCRYPT_HANDLE;
--
1.9.1

View File

@@ -1,7 +1,7 @@
From 7345fd134e82db7d3c53cf67bb4374496c1ed650 Mon Sep 17 00:00:00 2001
From e5bac5f440059f09e04faf552c973280b048dac2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sun, 13 Aug 2017 05:04:21 +0200
Subject: [PATCH] bcrypt: Add support for 192 and 256 bit aes keys.
Subject: [PATCH 28/36] bcrypt: Add support for 192 and 256 bit aes keys.
---
dlls/bcrypt/bcrypt_main.c | 14 ++++++++++++--
@@ -9,10 +9,10 @@ Subject: [PATCH] bcrypt: Add support for 192 and 256 bit aes keys.
2 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index f00a154..44c334f 100644
index 95d21f7d0b..4faab160e7 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -990,11 +990,21 @@ static gnutls_cipher_algorithm_t get_gnutls_cipher( const struct key *key )
@@ -1044,11 +1044,21 @@ static gnutls_cipher_algorithm_t get_gnutls_cipher( const struct key *key )
WARN( "handle block size\n" );
switch (key->mode)
{
@@ -37,7 +37,7 @@ index f00a154..44c334f 100644
FIXME( "algorithm %u not supported\n", key->alg_id );
return GNUTLS_CIPHER_UNKNOWN;
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
index d52c79d..e4c9ea0 100644
index 159be44714..a0906e9904 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -615,6 +615,9 @@ static void test_BCryptEncrypt(void)
@@ -94,5 +94,5 @@ index d52c79d..e4c9ea0 100644
* AES - ECB mode *
******************/
--
1.9.1
2.16.1

Some files were not shown because too many files have changed in this diff Show More