Re: [PATCH] bcrypt/tests: Add more BCryptGetFipsAlgorithmMode tests
On 08.09.2016 13:53, Bruno Jesus wrote:
From: Kai Blaschke <kai.blaschke(a)kb-dev.net> Signed-off-by: Bruno Jesus <00cpxxx(a)gmail.com> --- dlls/bcrypt/tests/Makefile.in | 2 +- dlls/bcrypt/tests/bcrypt.c | 49 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 2 deletions(-)
diff --git a/dlls/bcrypt/tests/Makefile.in b/dlls/bcrypt/tests/Makefile.in index 0f130b1..1bf7d2c 100644 --- a/dlls/bcrypt/tests/Makefile.in +++ b/dlls/bcrypt/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = bcrypt.dll -IMPORTS = bcrypt user32 +IMPORTS = bcrypt user32 advapi32
C_SRCS = \ bcrypt.c diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c index 9bd2cea..d16735c 100644 --- a/dlls/bcrypt/tests/bcrypt.c +++ b/dlls/bcrypt/tests/bcrypt.c @@ -61,14 +61,61 @@ static void test_BCryptGenRandom(void)
static void test_BCryptGetFipsAlgorithmMode(void) { - NTSTATUS ret; + static const WCHAR policyKeyVistaW[] = { + 'S','y','s','t','e','m','\\', + 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\', + 'C','o','n','t','r','o','l','\\', + 'L','s','a','\\', + 'F','I','P','S','A','l','g','o','r','i','t','h','m','P','o','l','i','c','y',0}; + static const WCHAR policyValueVistaW[] = {'E','n','a','b','l','e','d',0}; + static const WCHAR policyKeyXPW[] = { + 'S','y','s','t','e','m','\\', + 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\', + 'C','o','n','t','r','o','l','\\', + 'L','s','a',0}; + static const WCHAR policyValueXPW[] = { + 'F','I','P','S','A','l','g','o','r','i','t','h','m','P','o','l','i','c','y',0}; + HKEY hkey; + BOOLEAN expected; + BOOLEAN result; BOOLEAN enabled; + DWORD value, count = sizeof(value); + NTSTATUS ret;
ret = BCryptGetFipsAlgorithmMode(&enabled); ok(ret == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got 0x%x\n", ret);
ret = BCryptGetFipsAlgorithmMode(NULL); ok(ret == STATUS_INVALID_PARAMETER, "Expected STATUS_INVALID_PARAMETER, got 0x%x\n", ret); + + expected = FALSE; + + if (!RegOpenKeyW(HKEY_LOCAL_MACHINE, policyKeyVistaW, &hkey)) + { + if (!RegGetValueW(HKEY_LOCAL_MACHINE, policyKeyVistaW, policyValueVistaW, + RRF_RT_REG_DWORD, NULL, &enabled, &count)) + { + expected = !!enabled; + } + RegCloseKey(hkey); + } + else if (!RegOpenKeyW(HKEY_LOCAL_MACHINE, policyKeyXPW, &hkey)) + { + if (!RegGetValueW(HKEY_LOCAL_MACHINE, policyKeyXPW, policyValueXPW, + RRF_RT_REG_DWORD, NULL, &enabled, &count)) + { + expected = !!enabled; + } + RegCloseKey(hkey); + } + + ret = BCryptGetFipsAlgorithmMode(&result); + ok(!ret, "expected status STATUS_SUCCESS(0), got 0x%08X\n", ret); + ok(result == expected, "expected result %d, got %d\n", expected, result); + + ret = BCryptGetFipsAlgorithmMode(NULL); + ok(ret == STATUS_INVALID_PARAMETER, + "expected status STATUS_INVALID_PARAMETER(0xC000000D), got 0x%08X\n", ret);
Is it intentional that you test everything twice? It would be sufficient to add the "result == expected" check to the existing testcase above.
}
static void format_hash(const UCHAR *bytes, ULONG size, char *buf)
On Thu, Sep 8, 2016 at 11:36 AM, Sebastian Lackner <sebastian(a)fds-team.de> wrote:
Is it intentional that you test everything twice? It would be sufficient to add the "result == expected" check to the existing testcase above.
Oops, you are right. When Kai made these tests there were no previous tests, I'll fix and resend. Thanks =)
participants (2)
-
Bruno Jesus -
Sebastian Lackner