Commit Graph

110 Commits

Author SHA1 Message Date
James E. King III
cc9648b68c Add BOOST_UUID_COMPAT_PRE_1_71_MD5 compatibility mode 2019-06-25 13:21:13 -04:00
James E. King III
eabf964e98 Fix endian issue copying md5 result to byte buffer.
Fix the sha1 and md5 unit tests for endian correctness.
Originally identified by BinCaoWR in GitHub issue #86 and PR #87

This fixes #86
This closes #87
2019-06-25 13:21:13 -04:00
tinko92
24e3e0db36 Fix for typo (LICENCE) and for https links to license (#103)
* Fix Typo in link to License.
* Changed links to https.
2019-04-22 08:56:05 -04:00
Andrey Semashev
abfb3a918a Implement std::hash in terms of hash_value.
Not only it makes the two implementations equivalent, it also fixes the bug
of to_string throwing an exception in the noexcept function. It is also
more efficient as there is no need for the temporary string construction.
2019-04-19 06:45:24 -04:00
Andrey Semashev
bc789d8a76 Disable getentropy backend on Linux and Android.
Since getentropy is implemented via getrandom in Linux kernel, getentropy
cannot work if the kernel doesn't support getrandom. Given this, there is
no reason to ever use getentropy on Linux.

We used to allow this backend based on glibc version check, but there are
configurations where a newer glibc is running with an older kernel, and
getentropy always fails in runtime. Disabling getentropy in such cases
allows to fall back to the generic POSIX backend.
2019-04-19 06:44:25 -04:00
tomy2105
32469a666d Avoid undefining BOOST_AUTO_LINK_NOMANGLE
Avoid undefining BOOST_AUTO_LINK_NOMANGLE if it was previously defined.
2019-04-19 06:44:04 -04:00
Marcel Raad
2400f69519 Fix -Wmissing-noreturn clang warning
Mark function only consisting of a BOOST_THROW_EXCEPTION statement as
BOOST_NORETURN.
According to [0], "Callers of throw_exception are allowed to assume
that the function never returns", and the two predefined versions are
marked with BOOST_NORETURN.

[0] https://www.boost.org/doc/libs/1_69_0/libs/exception/doc/throw_exception.html
2019-02-25 15:31:04 -05:00
Marcel Raad
695c6782c6 Fix -Wextra-semi clang warning
Remove a superfluous semicolon after a function definition.
2019-02-25 15:31:04 -05:00
James E. King III
92cf9dd7d4 Make entropy_error default visible
See https://github.com/boostorg/function/pull/24 as to why.
2018-10-25 12:21:49 -04:00
James E. King III
496c0c8ee5
Update sha1.hpp header, it had the wrong path in it. 2018-10-17 19:33:43 -04:00
Andrey Semashev
2c142e311a Disabled getrandom provider on Android prior to API version 28.
Android supports getrandom and getentropy functions only since API version 28.

As part of the fix converted Linux/Android platform detection from Boost.Predef
to direct checks of platform-specific macros. This is to work around
Boost.Predef problem described in [1] - depending on header inclusion order
Boost.Predef may indicate Linux or Android. When that problem is fixed we
may change back to Boost.Predef.

Fixes https://github.com/boostorg/uuid/issues/76.

[1]: https://github.com/boostorg/predef/issues/81#issuecomment-413329061
2018-08-19 10:36:00 -04:00
Andrey Semashev
405f961431 Add support for Linux-specific getrandom call to obtain random data.
getrandom is the base implementation for getentropy on Linux. It is also
available in the form of a syscall, which can be called directly on systems with
glibc versions older than 2.25 which don't yet provide wrappers for getrandom or
getentropy but have a recent enough Linux kernel (for example, Debian Stretch).

On systems other than Linux (e.g. Solaris) getentropy is documented as a
source for initialization of a user-space PRNG instead of a direct source
for random data. Since we use the random data directly to initialize UUIDs,
using getrandom on other platforms, where available, would be more preferable
than getentropy. Unfortunately, the only other platform that is known to support
both getentropy and getrandom (Solaris) documents getrandom to return 0
on error, which is a valid return value on Linux. It's not clear if this is
a documentation error or a true incompatibility, and I have no way to test,
so do not use getrandom on Solaris for now. For this reason (and in case
if it is also used on some other platforms) getentropy backend is still
preserved.

For running tests in the CI on the getentropy backend added the
BOOST_UUID_RANDOM_PROVIDER_DISABLE_GETRANDOM macro, which will disable getrandom
if one is detected. Currently, the macro is only used for tests on Linux.
2018-06-18 10:27:40 -04:00
Andrey Semashev
4a9f620b6d Add support for movability to random generators. Fix POSIX random provider.
The commit adds support for move constructors and assignment to random UUID
generators and random providers. Also, in POSIX random provider, the commit
improves handling of return value from ::read(), which returns -1
in case of error and may return 0 in case of success. Retry the call when
it was interrupted before reading any bytes from /dev/urandom.

Added new tests for movability and compile-fail tests for no copyability.

This addresses GitHub issue:

https://github.com/boostorg/uuid/issues/71
2018-06-18 10:24:46 -04:00
James E. King III
a29e092870 fix compile error on MSVC2010 with new std::hash adapter 2018-05-15 21:17:01 -04:00
James E. King III
33da3e2a5b issue-65: remove deprecated sha1 header compatibility redirect which was moved to detail in the last release 2018-05-08 13:50:25 -04:00
James E. King III
903e8928f6 issue-59: add std::hash support header 2018-05-07 07:54:31 -04:00
James E. King, III
d37088ab07 synchronize changes with winapi for bcrypt availability
This fixes #63
2018-03-26 16:04:12 -04:00
James E. King III
52ee2828e9 fix warnings identified in new random provider code through the test matrix, on Windows 64-bit targets 2017-12-20 14:50:26 -05:00
James E. King III
a8a1ec3d82 Changed the default random_generator implementation to use
operating-system provided entropy as it is more secure and
faster for the typical use case of generating one uuid at
a time.

This is a breaking change for anyone passing a mt19937
into one of the explicit constructors of random_generator,
which would be quite rare.

Changed the default random provider on Windows to use BCrypt
where available, falling back to Wincrypt when necessary or
when explicitly requested through a macro.

Provide a new random_generator_mt19937 type definition for
use cases where a large number of uuids need to be created
with high performance.  This is equivalent to the previous
definition of random_generator.

Provide a random generation benchmark test showing the
cutoff where the mt19937-based generator will outperform the
standard generator based on wall time.

Removed template specialization for boost::random::random_device
so that any UniformRandomNumberGenerator can be used properly
with random_generator.

Replaced the seed_rng detail implementation (which had a number
of flaws) with a replacement header-only random_provider
implementation.

Note: entropy generation errors will cause an entropy_error
to be thrown from random_generator.  The previous implementation
ignored errors and silently failed.

Added internal support for entropy generation on cloudabi
platform leveraging the new random_provider implementation.

Added internal support for Universal Windows Platform (UWP)
development leveraging the new random_provider implementation.

Added internal support for getentropy() on Linux and OpenBSD
if certain requirements are met.

This fixes #24
This closes #53
2017-12-18 09:56:02 -05:00
James E. King, III
8a81273ebf revert change to string_generator so it continues to
throw std::runtime_error like it always had before
therefore removing a breaking change before release

remove one unnecessary code branch in string_generator
2017-11-10 20:04:37 -05:00
James E. King, III
5a48cab9af provide a name_generator_latest that always uses the latest hashing
algorithm for applications that do not need stable hashing over time

This fixes #50
2017-11-04 19:50:09 -04:00
James E. King, III
288fd3ef13 remove non-standards compliant code which is inconsequential in seed_rng 2017-11-03 07:55:54 -07:00
James E. King, III
46234e79bc fix warning on older msvc in md5 code 2017-11-01 19:39:51 -04:00
Andrey Semashev
438bbd0bdf Updated Boost.WinAPI usage to the new location and namespace. 2017-10-25 01:16:03 +03:00
James E. King, III
40c3f1a435 resolve some build warnings identified in the test matrix 2017-10-14 22:06:05 -04:00
James E. King, III
a7962053b8 9343: fix incorrect uuid format in string generator comment 2017-10-14 07:55:40 -04:00
James E. King, III
3d2f7758e9 refactor name_generator to have a configurable hash algorithm
and provide backwards compatibility for sha1, and also added
md5 to complete the RFC 4122 spec implementation

as such, boost::uuids::name_generator is deprecated, however
still defined to use the same implementation in previous boost
releases, and name_generator_sha1 as well as name_generator_md5
now exist, in preparation for whatever will replace sha1.

to properly test the new header structure, I took the bjam
rule from winapi to isolate each header as an include and make sure
it has no dependencies on other headers to be included first,
and was able to remove a few test files that became unnecessary.

This fixes #26
2017-10-10 09:01:43 -04:00
James E. King, III
31f74b28f3 add RFC-4122 namespaces from appendix C to name generator 2017-09-22 21:03:10 -07:00
James E. King, III
5369a9af95 trac-10665: fix name_generator implementation const correctness, now matches documentation 2017-08-12 17:43:46 -07:00
Edward Diener
1061e09eb8 Merge pull request #17 from jeking3/trac-11482
Fix boost trac 8630, 9343, 11482, 11483, 12253 improving invalid string generator handling in uuid
2017-08-09 18:35:45 -04:00
James E. King, III
07f68d3b9c 11482: uuid string generator now throws if there is any unexpected input following successful conversion of a uuid in the input string
11483: uuid string generator now throws std::invalid_argument instead of std::runtime_error on an invalid uuid string
12253: make the uuid parser reject invalid data and added negative test cases to prove it
2017-08-09 15:38:37 -04:00
James E. King, III
cdfda85fec 12971: fix compiler warning converting from NULL on Windows 2017-08-03 15:57:59 -04:00
Tobias Klauser
59a01cd4ed Use null_deleter from Boost.Core instead of own definition 2017-01-11 10:08:02 +01:00
Edward Diener
51bad2970d Autolink the correct DLL under Windows CE. 2016-09-15 16:20:45 -04:00
Edward Diener
0d243a660d Merge pull request #13 from Lastique/patch-1
Use more fine-grained WinAPI headers
2016-09-15 00:19:06 -04:00
Edward Diener
56a6f6a93d Merge pull request #9 from MarcelRaad/patch-1
Fix compilation with BOOST_NO_ANSI_APIS
2016-09-15 00:02:07 -04:00
Edward Diener
a0ab10f4fa Merge pull request #8 from Lastique/comparison_optimization
Optimize equality comparison operator for SSE4.1.
2016-09-14 23:50:11 -04:00
Takeshi Abe
4faa13bf05 Suppress warning: "BOOST_MSVC" is not defined [-Wundef] 2016-04-12 13:14:25 +09:00
Andrey Semashev
4c63349396 Use more fine-grained WinAPI headers 2016-01-31 21:52:55 +03:00
Erich Keane
9639d21af6 Fixed padded output of UUID when std::left is set
The defect https://svn.boost.org/trac/boost/ticket/11385 reports a
situation where a uuid's single-hex-digit values are improperly padded
when std::left is set on the stream.

It is fixed by ensuring that the ostream overload always uses std::right
to be consistent with the default behavior.
2015-12-29 13:06:15 -08:00
Marcel Raad
f48322f640 Fix compilation with BOOST_NO_ANSI_APIS
With BOOST_NO_ANSI_APIS, there is no CryptAcquireContextA.
2015-09-21 09:02:34 +02:00
Andrey Semashev
9f4f09ccbe Replaced tabs with spaces. 2015-09-14 03:25:24 +03:00
Andrey Semashev
3fbcd76115 Slightly optimized equality comparison operator. 2015-09-13 19:43:48 +03:00
Andrey Semashev
edb204e6fd Silenced MSVC warning about int to bool conversion. 2015-09-13 18:13:09 +03:00
Andrey Semashev
9133fdc62d Added a check for AVX support that was added in VS2013. Enabling AVX implies enabling all SSE versions. 2015-09-13 18:12:20 +03:00
Edward Diener
cb8da94c4c Bug was fixed in VS2015 ( BOOST_MSVC 1900 on up ) 2015-09-10 13:03:13 -04:00
Edward Diener
70ff8e38ea Fixes for PR "Added a workaround for MSVC 12 (VS2013) optimizer bug. #4". 2015-09-09 17:39:08 -04:00
Takeshi Abe
a19682a4cf do not nest the _MSC_VER stuff inside the BOOST_WINDOWS one 2015-08-22 11:28:55 +09:00
Takeshi Abe
5774b8a205 use MSVC-specific pragmas conditionally 2015-08-22 11:01:08 +09:00
Takeshi Abe
ba35c3c14c fix for the non-MSVC case on Windows 2015-08-21 11:13:35 +09:00