Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntoskrnl.exe/tests/ntoskrnl.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c index 86d04eab59f..4221bc4d9fb 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -92,10 +92,11 @@ struct testsign_context HCERTSTORE root_store, publisher_store; };
+static const WCHAR container_name[] = L"wine_testsign"; + static BOOL testsign_create_cert(struct testsign_context *ctx) { BYTE encoded_name[100], encoded_key_id[200], public_key_info_buffer[1000]; - WCHAR container_name[26]; BYTE hash_buffer[16], cert_buffer[1000], provider_nameA[100], serial[16]; CERT_PUBLIC_KEY_INFO *public_key_info = (CERT_PUBLIC_KEY_INFO *)public_key_info_buffer; CRYPT_KEY_PROV_INFO provider_info = {0}; @@ -110,10 +111,13 @@ static BOOL testsign_create_cert(struct testsign_context *ctx)
memset(ctx, 0, sizeof(*ctx));
- srand(time(NULL)); - swprintf(container_name, ARRAY_SIZE(container_name), L"wine_testsign%u", rand()); - ret = CryptAcquireContextW(&ctx->provider, container_name, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); + if (!ret && GetLastError() == NTE_EXISTS) + { + ret = CryptAcquireContextW(&ctx->provider, container_name, NULL, PROV_RSA_FULL, CRYPT_DELETEKEYSET); + ok(ret, "Failed to delete container, error %#x\n", GetLastError()); + ret = CryptAcquireContextW(&ctx->provider, container_name, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); + } ok(ret, "Failed to create container, error %#x\n", GetLastError());
ret = CryptGenKey(ctx->provider, AT_SIGNATURE, CRYPT_EXPORTABLE, &key); @@ -245,6 +249,9 @@ static void testsign_cleanup(struct testsign_context *ctx)
ret = CryptReleaseContext(ctx->provider, 0); ok(ret, "failed to release context, error %u\n", GetLastError()); + + ret = CryptAcquireContextW(&ctx->provider, container_name, NULL, PROV_RSA_FULL, CRYPT_DELETEKEYSET); + ok(ret, "Failed to delete container, error %#x\n", GetLastError()); }
static void testsign_sign(struct testsign_context *ctx, const WCHAR *filename)