2018-02-28 17:28:01 -08:00
|
|
|
From 99c36c1642f054366532902bb9a41bc264d06df6 Mon Sep 17 00:00:00 2001
|
2016-12-25 13:40:45 -08:00
|
|
|
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
|
|
|
Date: Mon, 26 Dec 2016 08:41:31 +0100
|
2018-02-28 17:28:01 -08:00
|
|
|
Subject: [PATCH 22/36] bcrypt: Allow to call BCryptSetProperty on key objects.
|
2016-12-25 13:40:45 -08:00
|
|
|
|
|
|
|
---
|
|
|
|
dlls/bcrypt/bcrypt_main.c | 38 ++++++++++++++++++++++++++++++++++++--
|
|
|
|
dlls/bcrypt/tests/bcrypt.c | 4 ++++
|
|
|
|
2 files changed, 40 insertions(+), 2 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
|
2018-02-28 17:28:01 -08:00
|
|
|
index 8d4b5ade64..5913d1283e 100644
|
2016-12-25 13:40:45 -08:00
|
|
|
--- a/dlls/bcrypt/bcrypt_main.c
|
|
|
|
+++ b/dlls/bcrypt/bcrypt_main.c
|
2018-02-20 16:20:15 -08:00
|
|
|
@@ -246,6 +246,9 @@ struct algorithm
|
2017-03-09 19:53:06 -08:00
|
|
|
BOOL hmac;
|
2016-12-25 13:40:45 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
+struct key;
|
|
|
|
+static NTSTATUS set_key_property( struct key *key, const WCHAR *prop, UCHAR *value, ULONG size, ULONG flags );
|
|
|
|
+
|
|
|
|
NTSTATUS WINAPI BCryptGenRandom(BCRYPT_ALG_HANDLE handle, UCHAR *buffer, ULONG count, ULONG flags)
|
|
|
|
{
|
|
|
|
const DWORD supported_flags = BCRYPT_USE_SYSTEM_PREFERRED_RNG;
|
2018-02-20 16:20:15 -08:00
|
|
|
@@ -696,8 +699,8 @@ NTSTATUS WINAPI BCryptSetProperty( BCRYPT_HANDLE handle, const WCHAR *prop, UCHA
|
2016-12-25 13:40:45 -08:00
|
|
|
}
|
|
|
|
case MAGIC_KEY:
|
|
|
|
{
|
|
|
|
- FIXME( "keys not implemented yet\n" );
|
|
|
|
- return STATUS_NOT_IMPLEMENTED;
|
|
|
|
+ struct key *key = (struct key *)object;
|
|
|
|
+ return set_key_property( key, prop, value, size, flags );
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
WARN( "unknown magic %08x\n", object->magic );
|
2018-02-28 17:28:01 -08:00
|
|
|
@@ -972,6 +975,31 @@ static NTSTATUS key_duplicate( struct key *key_orig, struct key *key_copy )
|
2016-12-25 13:40:45 -08:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
+static NTSTATUS set_key_property( struct key *key, const WCHAR *prop, UCHAR *value, ULONG size, ULONG flags )
|
|
|
|
+{
|
|
|
|
+ if (!strcmpW( prop, BCRYPT_CHAINING_MODE ))
|
|
|
|
+ {
|
|
|
|
+ if (!strncmpW( (WCHAR *)value, BCRYPT_CHAIN_MODE_CBC, size ))
|
|
|
|
+ {
|
|
|
|
+ key->mode = MODE_ID_CBC;
|
|
|
|
+ return STATUS_SUCCESS;
|
|
|
|
+ }
|
|
|
|
+ else if (!strncmpW( (WCHAR *)value, BCRYPT_CHAIN_MODE_GCM, size ))
|
|
|
|
+ {
|
|
|
|
+ key->mode = MODE_ID_GCM;
|
|
|
|
+ return STATUS_SUCCESS;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ FIXME( "unsupported mode %s\n", debugstr_wn( (WCHAR *)value, size ) );
|
|
|
|
+ return STATUS_NOT_IMPLEMENTED;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ FIXME( "unsupported key property %s\n", debugstr_w(prop) );
|
|
|
|
+ return STATUS_NOT_IMPLEMENTED;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static gnutls_cipher_algorithm_t get_gnutls_cipher( const struct key *key )
|
|
|
|
{
|
|
|
|
switch (key->alg_id)
|
2018-02-28 17:28:01 -08:00
|
|
|
@@ -1181,6 +1209,12 @@ static NTSTATUS key_duplicate( struct key *key_orig, struct key *key_copy )
|
2016-12-25 13:40:45 -08:00
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
+static NTSTATUS set_key_property( struct key *key, const WCHAR *prop, UCHAR *value, ULONG size, ULONG flags )
|
|
|
|
+{
|
|
|
|
+ ERR( "support for keys not available at build time\n" );
|
|
|
|
+ return STATUS_NOT_IMPLEMENTED;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static NTSTATUS key_set_params( struct key *key, UCHAR *iv, ULONG iv_len )
|
|
|
|
{
|
|
|
|
ERR( "support for keys not available at build time\n" );
|
|
|
|
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
|
2018-02-28 17:28:01 -08:00
|
|
|
index 6ec429e309..baf5b638f9 100644
|
2016-12-25 13:40:45 -08:00
|
|
|
--- a/dlls/bcrypt/tests/bcrypt.c
|
|
|
|
+++ b/dlls/bcrypt/tests/bcrypt.c
|
2018-02-28 17:28:01 -08:00
|
|
|
@@ -526,6 +526,10 @@ static void test_BCryptGenerateSymmetricKey(void)
|
2016-12-25 13:40:45 -08:00
|
|
|
sizeof(BCRYPT_CHAIN_MODE_CBC), 0);
|
|
|
|
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
|
|
|
|
|
|
|
|
+ ret = pBCryptSetProperty(key, BCRYPT_CHAINING_MODE, (UCHAR *)BCRYPT_CHAIN_MODE_CBC,
|
|
|
|
+ sizeof(BCRYPT_CHAIN_MODE_CBC), 0);
|
|
|
|
+ ok(ret == STATUS_SUCCESS || broken(ret == STATUS_NOT_SUPPORTED) /* < Win 8 */, "got %08x\n", ret);
|
|
|
|
+
|
|
|
|
size = 0xdeadbeef;
|
|
|
|
ret = pBCryptEncrypt(key, NULL, 0, NULL, NULL, 0, NULL, 0, &size, 0);
|
|
|
|
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
|
|
|
|
--
|
2018-02-28 17:28:01 -08:00
|
|
|
2.16.1
|
2016-12-25 13:40:45 -08:00
|
|
|
|