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
2c1d5f5a
Commit
2c1d5f5a
authored
Aug 31, 2014
by
Pieter Hintjens
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1174 from jbreams/master
Clean up after using randombytes from libsodium
parents
83c6bc20
d1881acb
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
0 deletions
+25
-0
ctx.cpp
src/ctx.cpp
+14
-0
devurandom.c
tweetnacl/contrib/randombytes/devurandom.c
+10
-0
devurandom.h
tweetnacl/contrib/randombytes/devurandom.h
+1
-0
No files found.
src/ctx.cpp
View file @
2c1d5f5a
...
...
@@ -36,6 +36,14 @@
#include "err.hpp"
#include "msg.hpp"
#ifdef HAVE_LIBSODIUM
#ifdef HAVE_TWEETNACL
#include "randombytes.h"
#else
#include "sodium.h"
#endif
#endif
#define ZMQ_CTX_TAG_VALUE_GOOD 0xabadcafe
#define ZMQ_CTX_TAG_VALUE_BAD 0xdeadbeef
...
...
@@ -93,6 +101,12 @@ zmq::ctx_t::~ctx_t ()
// corresponding io_thread/socket objects.
free
(
slots
);
// If we've done any Curve encryption, we may have a file handle
// to /dev/urandom open that needs to be cleaned up.
#ifdef HAVE_LIBSODIUM
randombytes_close
();
#endif
// Remove the tag, so that the object is considered dead.
tag
=
ZMQ_CTX_TAG_VALUE_BAD
;
}
...
...
tweetnacl/contrib/randombytes/devurandom.c
View file @
2c1d5f5a
...
...
@@ -32,3 +32,13 @@ void randombytes(unsigned char *x,unsigned long long xlen)
xlen
-=
i
;
}
}
int
randombytes_close
(
void
)
{
int
rc
=
-
1
;
if
(
fd
!=
-
1
&&
close
(
fd
)
==
0
)
{
fd
=
-
1
;
rc
=
0
;
}
return
rc
;
}
tweetnacl/contrib/randombytes/devurandom.h
View file @
2c1d5f5a
...
...
@@ -12,6 +12,7 @@ extern "C" {
#endif
extern
void
randombytes
(
unsigned
char
*
,
unsigned
long
long
);
extern
int
randombytes_close
(
void
);
#ifdef __cplusplus
}
...
...
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