Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling in Windows #219

Open
rafagenova opened this issue Jun 7, 2023 · 3 comments
Open

Compiling in Windows #219

rafagenova opened this issue Jun 7, 2023 · 3 comments

Comments

@rafagenova
Copy link

rafagenova commented Jun 7, 2023

Hello everybody,

Please, I have being trying to run the entropy assessment tools in a Windows computer and I think I am having problems with the libdivsufsort library.

I got the same results on Ubuntu VMWare and Windows with the exception of the IID tests.

When running the IID test with the provided truerand_8bit.bin dataset in Windows, there is one test that gives me different results than in Ubuntu.

The results that are unexpected are:

Literal Longest Repeated Substring results: Pr(X >= 1) = -0.08935833987813369874015
Length of longest repeated substring test: Failed

This probability value should not be negative. The LRS tests passed on Ubuntu with this dataset.

Please I would like to know if anyone has a solution or has an idea of what to do to fix this problem.

I am using the following command to run the entropy estiamators:

./ea_iid.exe -i -a -vv ../bin/truerand_8bit.bin 8 > truernd8.txt

I am using MSYS2 MinGW64 to compile the programs. The only library I could not find at the msys2 repository was libdivsufsort, and this is the reason I think this is the library giving me problems. All the other libraries needed were found in https://repo.msys2.org/msys/x86_64/

I installed the last version of the libdivsufsort from the https://github.com/y-256/libdivsufsort, as suggested in the wiki/Installing-Packages.

I used the following commands to build this library:

mkdir build

cd build

cmake .. -G "MinGW Makefiles"

cmake --build .

cmake --install .

Then I moved libdivsufsort.dll, divsufsort.h, libdivsufsort.dll.a and libdivsufsort.pc to their correct places in MinGW64.

The linux /dev/urandom was also not working because it is not available on windows, so I did a modification in the seed(uint64_t *xoshiro256starstarState) function in utils.h.

There was a comment in this function suggesting the use of the builtin function RdRand, so I changed the function to:

void seed(uint64_t *xoshiro256starstarState)
{
	uint64_t rand64;
	int retries = 10;
	int mem_elements = 4;
	while(mem_elements--)
	{
		while(retries--)
		{
			if( __builtin_ia32_rdrand64_step(&rand64) != 1)
			{
				perror("Can't read random seed");
				exit(-1);
			}
		}
		xoshiro256starstarState[mem_elements] = rand64;
		retries = 10;
	}

}
@rafagenova rafagenova changed the title Compilation in Windows Compiling in Windows Jun 7, 2023
@skbhaskarla
Copy link
Collaborator

Hi Rafagenova,

Windows is not officially supported but I can offer some suggestions.

I used MS Visual Studio 2019 to build the libdivsufsort library in the x86 32-bit option because I received warnings from the 64-bit option.

Next, I updated the EntropyAssessment Makefile CXXFLAGS options with an -L switch of the path to the lib folder of the libdivsufsort project. (Makefile CXX was set to "clang++".)

I also had to compile Bzip2 and Getopt libraries separately because they were not readily available as Windows libraries at the time when I was compiling the EntropyAssessment project code.

Clang was on my command line shell PATH but it must be noted that the path to must not use quotes. Example:
set PATH=%PATH%;c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\Llvm\bin;

clang version 12.0.0
Target: i686-pc-windows-msvc

Cd to SP800-90B_EntropyAssessment\cpp
Mingw32-make
Check the *.exe files

Copy the getopt.dll and divsufsort.dll to the .exe file location.
Note: The divsufsort.dll is the dll from the x86 folder.

After I compiled the EntropyAssessment project, I created a Windows Batch file to run commands like:
..\ea_non_iid -vv ....\bin\truerand_8bit.bin > result\truerand_8bit.res

Then, I used Strawberry Perl in another batch file to run the compareresults.pl script like so:
perl compareresults.pl result\truerand_8bit.res refdata\truerand_8bit.res
echo %ERRORLEVEL%

@skbhaskarla
Copy link
Collaborator

@rafagenova The Windows 10 branch is well behind master but is relevant to the comments I made above.

@joshuaehill
Copy link
Contributor

As an aside, if NIST eventually applies PR #217, then the 64-bit divsufsort will also be required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants