Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
7fe03218
Commit
7fe03218
authored
Oct 23, 2015
by
Constantin Rack
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1619 from madebr/winrandombytes
TweetNaCL: add windows randombytes implementation
parents
e182438a
b2c87b9a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
104 additions
and
47 deletions
+104
-47
CMakeLists.txt
CMakeLists.txt
+16
-8
appveyor.yml
appveyor.yml
+28
-13
devurandom.h
tweetnacl/contrib/randombytes/devurandom.h
+0
-25
randombytes.h
tweetnacl/contrib/randombytes/randombytes.h
+17
-1
winrandom.c
tweetnacl/contrib/randombytes/winrandom.c
+43
-0
No files found.
CMakeLists.txt
View file @
7fe03218
...
...
@@ -3,21 +3,27 @@
cmake_minimum_required
(
VERSION 2.8
)
project
(
ZeroMQ
)
list
(
INSERT CMAKE_MODULE_PATH 0
"
${
CMAKE_SOURCE_DIR
}
"
)
option
(
WITH_OPENPGM
"Build with support for OpenPGM"
OFF
)
if
(
APPLE
)
option
(
ZMQ_BUILD_FRAMEWORK
"Build as OS X framework"
ON
)
endif
()
list
(
INSERT CMAKE_MODULE_PATH 0
"
${
CMAKE_SOURCE_DIR
}
"
)
find_package
(
Sodium
)
option
(
WITH_SODIUM
"Build with libsodium"
ON
)
option
(
WITH_TWEETNACL
"Build with tweetnacl"
ON
)
set
(
USE_TWEETNACL OFF
)
if
(
WITH_SODIUM
)
find_package
(
Sodium
)
if
(
SODIUM_FOUND
)
add_definitions
(
-DHAVE_LIBSODIUM
)
include_directories
(
${
SODIUM_INCLUDE_DIRS
}
)
endif
()
endif
()
if
(
SODIUM_FOUND
)
add_definitions
(
-DHAVE_LIBSODIUM
)
include_directories
(
${
SODIUM_INCLUDE_DIRS
}
)
else
()
if
(
WITH_TWEETNACL AND NOT SODIUM_FOUND
)
message
(
STATUS
"Building with TweetNaCL"
)
set
(
USE_TWEETNACL ON
)
add_definitions
(
-DHAVE_TWEETNACL
)
include_directories
(
...
...
@@ -29,7 +35,9 @@ else()
tweetnacl/src/tweetnacl.c
)
if
(
NOT WIN32
)
if
(
WIN32
)
list
(
APPEND TWEETNACL_SOURCES tweetnacl/contrib/randombytes/winrandom.c
)
else
()
list
(
APPEND TWEETNACL_SOURCES tweetnacl/contrib/randombytes/devurandom.c
)
endif
()
endif
()
...
...
appveyor.yml
View file @
7fe03218
...
...
@@ -10,18 +10,35 @@ environment:
CMAKE_GENERATOR
:
"
Visual
Studio
14
2015"
MSVCVERSION
:
"
v140"
MSVCYEAR
:
"
vs2015"
matrix
:
-
platform
:
Win32
configuration
:
Release
WITH_SODIUM
:
ON
WITH_TWEETNACL
:
OFF
-
platform
:
Win32
configuration
:
Release
WITH_SODIUM
:
ON
WITH_TWEETNACL
:
OFF
-
platform
:
x64
configuration
:
Debug
WITH_SODIUM
:
ON
WITH_TWEETNACL
:
OFF
-
platform
:
x64
configuration
:
Debug
WITH_SODIUM
:
ON
WITH_TWEETNACL
:
OFF
-
platform
:
Win32
configuration
:
Release
WITH_SODIUM
:
OFF
WITH_TWEETNACL
:
OFF
-
platform
:
Win32
configuration
:
Release
WITH_SODIUM
:
OFF
WITH_TWEETNACL
:
ON
matrix
:
fast_finish
:
false
platform
:
-
Win32
-
x64
configuration
:
-
Release
-
Debug
init
:
#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
-
cmake --version
...
...
@@ -45,8 +62,7 @@ before_build:
-
cmd
:
set LIBZMQ_BUILDDIR=C:\projects\build_libzmq
-
cmd
:
md "%LIBZMQ_BUILDDIR%"
-
cd "%LIBZMQ_BUILDDIR%"
-
cmd
:
cmake -D CMAKE_INCLUDE_PATH="%SODIUM_INCLUDE_DIR%" -D CMAKE_LIBRARY_PATH="%SODIUM_LIBRARY_DIR%" -D CMAKE_C_FLAGS_RELEASE="/MT" -D CMAKE_C_FLAGS_DEBUG="/MTd" -G "%CMAKE_GENERATOR%" "%APPVEYOR_BUILD_FOLDER%"
-
cmd
:
cmake -D CMAKE_INCLUDE_PATH="%SODIUM_INCLUDE_DIR%" -D CMAKE_LIBRARY_PATH="%SODIUM_LIBRARY_DIR%" -D WITH_SODIUM="%WITH_SODIUM%" -D WITH_TWEETNACL="%WITH_TWEETNACL%" -D CMAKE_C_FLAGS_RELEASE="/MT" -D CMAKE_C_FLAGS_DEBUG="/MTd" -D WITH_SODIUM="%WITH_SODIUM%" -G "%CMAKE_GENERATOR%" "%APPVEYOR_BUILD_FOLDER%"
build
:
parallel
:
true
...
...
@@ -56,11 +72,10 @@ build:
after_build
:
-
cmd
:
cd %LIBZMQ_BUILDDIR%\bin\%Configuration%"
-
cmd
:
copy "%SODIUM_LIBRARY_DIR%\libsodium.dll" .
# Pack the artifacts
-
cmd
:
7z a -y -bd -mx=9 libzmq.zip *.exe *.dll
-
ps
:
Push-AppveyorArtifact "libzmq.zip" -Filename "libzmq-${env:Platform}-${env:Configuration}.zip"
test_script
:
-
cmd
:
cd "%LIBZMQ_BUILDDIR%"
-
cmd
:
ctest -C "%Configuration%" -V
test
:
none
tweetnacl/contrib/randombytes/devurandom.h
deleted
100644 → 0
View file @
e182438a
/*
randombytes/devurandom.h version 20080713
D. J. Bernstein
Public domain.
*/
#ifndef randombytes_devurandom_H
#define randombytes_devurandom_H
#ifdef __cplusplus
extern
"C"
{
#endif
extern
void
randombytes
(
unsigned
char
*
,
unsigned
long
long
);
extern
int
randombytes_close
(
void
);
#ifdef __cplusplus
}
#endif
#ifndef randombytes_implementation
#define randombytes_implementation "devurandom"
#endif
#endif
tweetnacl/contrib/randombytes/randombytes.h
View file @
7fe03218
/*
randombytes/randombytes.h version 20080713
D. J. Bernstein
Public domain.
*/
#ifndef randombytes_H
#define randombytes_H
#include "devurandom.h"
#ifdef __cplusplus
extern
"C"
{
#endif
extern
void
randombytes
(
unsigned
char
*
,
unsigned
long
long
);
extern
int
randombytes_close
(
void
);
#ifdef __cplusplus
}
#endif
#endif
tweetnacl/contrib/randombytes/winrandom.c
0 → 100644
View file @
7fe03218
#include <windows.h>
#include <WinCrypt.h>
#define NCP ((HCRYPTPROV) 0)
HCRYPTPROV
hProvider
=
NCP
;
void
randombytes
(
unsigned
char
*
x
,
unsigned
long
long
xlen
)
{
unsigned
i
;
BOOL
ret
;
if
(
hProvider
==
NCP
)
{
for
(;;)
{
ret
=
CryptAcquireContext
(
&
hProvider
,
NULL
,
NULL
,
PROV_RSA_FULL
,
CRYPT_VERIFYCONTEXT
|
CRYPT_SILENT
);
if
(
ret
!=
FALSE
)
break
;
Sleep
(
1
);
}
}
while
(
xlen
>
0
)
{
if
(
xlen
<
1048576
)
i
=
(
unsigned
)
xlen
;
else
i
=
1048576
;
ret
=
CryptGenRandom
(
hProvider
,
i
,
x
);
if
(
ret
!=
FALSE
)
{
Sleep
(
1
);
continue
;
}
x
+=
i
;
xlen
-=
i
;
}
}
int
randombytes_close
(
void
)
{
int
rc
=
-
1
;
if
((
hProvider
!=
NCP
)
&&
(
CryptReleaseContext
(
hProvider
,
0
)
!=
FALSE
))
{
hProvider
=
NCP
;
rc
=
0
;
}
return
rc
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment