blob: 31ece7a42710744d2fdd0fedc6bf8094867fec84 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/*
* Copyright (c) 2012 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
#include <windows.h>
namespace Swift {
class WindowsRegistry {
public:
static bool isFIPSEnabled() {
char* pathForXP = "System\\CurrentControlSet\\Control\\Lsa";
char* pathSinceVista = "System\\CurrentControlSet\\Control\\Lsa\\FIPSAlgorithmPolicy";
char* keyForXP = "FIPSAlgorithmPolicy";
char* keySinceVista = "Enabled";
OSVERSIONINFO osvi;
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osvi);
char* keyForOS = osvi.dwMajorVersion < 6 ? keyForXP : keySinceVista;
char* pathForOS = osvi.dwMajorVersion < 6 ? pathForXP : pathSinceVista;
/* http://support.microsoft.com/kb/811833 */
/* http://msdn.microsoft.com/en-us/library/ms724911%28VS.85%29.aspx */
HKEY key;
bool result = false;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
pathForOS,
0,
KEY_READ,
&key) != ERROR_SUCCESS) {
/* If we can't find the key that says we're FIPS, we're not FIPS */
return result;
}
DWORD keyType = REG_DWORD;
DWORD data;
DWORD length = sizeof(data);
if (RegQueryValueEx(key,
keyForOS,
NULL,
&keyType,
(LPBYTE)&data,
&length) == ERROR_SUCCESS) {
result = data != 0;
}
RegCloseKey(key);
return result;
}
};
}
|