Commit 39dc9d09 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

bcrypt: Only reset init vector if the new vector is non-NULL.

parent 7d31f394
......@@ -1149,12 +1149,12 @@ static BOOL is_equal_vector( const UCHAR *vector, ULONG len, const UCHAR *vector
static NTSTATUS key_symmetric_set_vector( struct key *key, UCHAR *vector, ULONG vector_len, BOOL force_reset )
{
BOOL needs_reset = force_reset || !is_equal_vector( key->u.s.vector, key->u.s.vector_len, vector, vector_len );
free( key->u.s.vector );
key->u.s.vector = NULL;
key->u.s.vector_len = 0;
if (vector)
{
free( key->u.s.vector );
key->u.s.vector = NULL;
key->u.s.vector_len = 0;
if (!(key->u.s.vector = malloc( vector_len ))) return STATUS_NO_MEMORY;
memcpy( key->u.s.vector, vector, vector_len );
key->u.s.vector_len = vector_len;
......
......@@ -843,7 +843,7 @@ static void test_BCryptGenerateSymmetricKey(void)
ret = BCryptEncrypt(key, data, 16, NULL, NULL, 0, ciphertext, 16, &size, 0);
ok(ret == STATUS_SUCCESS, "got %#lx\n", ret);
ok(size == 16, "got %lu\n", size);
todo_wine ok(!memcmp(ciphertext, expected2, sizeof(expected2)), "wrong data\n");
ok(!memcmp(ciphertext, expected2, sizeof(expected2)), "wrong data\n");
size = 0;
memcpy(ivbuf, iv, sizeof(iv));
......@@ -1129,7 +1129,7 @@ static void test_BCryptEncrypt(void)
ret = BCryptEncrypt(key, data, 16, NULL, NULL, 0, ciphertext, 16, &size, 0);
ok(ret == STATUS_SUCCESS, "got %#lx\n", ret);
ok(size == 16, "got %lu\n", size);
todo_wine ok(!memcmp(ciphertext, expected8, sizeof(expected8)), "wrong data\n");
ok(!memcmp(ciphertext, expected8, sizeof(expected8)), "wrong data\n");
/* all zero initialization vector */
size = 0;
......@@ -1556,7 +1556,7 @@ static void test_BCryptEncrypt(void)
ret = BCryptEncrypt(key, data, 16, NULL, NULL, 0, ciphertext, 16, &size, 0);
ok(ret == STATUS_SUCCESS, "got %#lx\n", ret);
ok(size == 16, "got %lu\n", size);
todo_wine ok(!memcmp(ciphertext, expected12, sizeof(expected12)), "wrong data\n");
ok(!memcmp(ciphertext, expected12, sizeof(expected12)), "wrong data\n");
/* all zero initialization vector */
size = 0;
......@@ -1784,7 +1784,7 @@ static void test_BCryptDecrypt(void)
ret = BCryptDecrypt(key, ciphertext, 32, NULL, NULL, 0, plaintext, 32, &size, 0);
ok(ret == STATUS_SUCCESS, "got %#lx\n", ret);
ok(size == 32, "got %lu\n", size);
todo_wine ok(!memcmp(plaintext, expected4, sizeof(expected4)), "wrong data\n");
ok(!memcmp(plaintext, expected4, sizeof(expected4)), "wrong data\n");
/* test with padding smaller than block size */
size = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment