summaryrefslogtreecommitdiff
path: root/AK/Random.h
AgeCommit message (Collapse)Author
2023-04-03AK+Everywhere: Change AK::fill_with_random to accept a Bytes objectTimothy Flynn
Rather than the very C-like API we currently have, accepting a void* and a length, let's take a Bytes object instead. In almost all existing cases, the compiler figures out the length.
2023-04-03AK: Prevent passing lengths greater than 256 to getentropy()Timothy Flynn
From the getentropy() man page, "The maximum permitted value for the length argument is 256". Several of our tests were passing lengths of several thousand bytes, causing getentropy() to fail with EIO, which we were completely ignoring. This caused these tests to only test long sequences of 0x00. We now loop over the provided buffer to fill it 256 bytes at a time. If getentropy() fails for any reason, we fall back to the default method of filling it with one random byte at a time.
2023-03-06AK: Remove specialized shuffle for NonnullPtrVectorAndreas Kling
2023-01-22AK: Make NonnullPtrVectors shuffleableSam Atkins
AK::shuffle() doesn't work on these, because their operator[] returns a reference to the pointed-at value, instead of to the NonnullPtr itself.
2022-12-12AK: Add a shuffle utility functionArda Cinar
This implements a shuffle function in AK/Random.h which works on any container with size() and curly brace operators. It uses fisher-yates shuffle.
2022-12-12AK: Don't use <random> on windows for ::rand()Ali Mohammad Pur
This is the same as the libc function, just use the libc function.
2022-11-26AK: Make it possible to not `using` AK classes into the global namespaceAndreas Kling
This patch adds the `USING_AK_GLOBALLY` macro which is enabled by default, but can be overridden by build flags. This is a step towards integrating Jakt and AK types.
2022-10-10Everywhere: Replace uses of __serenity__ with AK_OS_SERENITYAndrew Kaster
Now that we have OS macros for essentially every supported OS, let's try to use them everywhere.
2022-09-29Lagom: Win32 support baby stepsDiego Iastrubni
This is the initial port of Lagom to win32. This will enable developers to use Lagom as an alternative to vanilla STL/StandardC++Library - which gives a much richer environment (think QtCore - but modern). My main incentive - is to have a native Windows Ladybird working. I am starting with AK, which does not yet fully compile (on mingw). When AK is compiling (currently fails building StringBuffer.cpp) - I will continue to LibCore and then the rest of the user space libraries (excluding the GUI, which will be another different effort). Most of the code is happily stollen from Andrew Kaster's fork - he deserves the credit. Co-authored-by: Andrew Kaster <akaster@serenityos.org>
2022-07-19AK: Add support for building on Android with API version >= 30Andrew Kaster
2021-09-12AK+LibCore: Standardize on AK_OS_MACOS instead of __APPLE__Brian Gianforcaro
We use our custom platform definitions in most places, remove the few remaining places we weren't using `AK_OS_MACOS`.
2021-05-14AK: Introduce get_random_uniform()Jean-Baptiste Boric
This is arc4random_uniform(), but inside AK.
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2020-12-21Everywhere: Switch from (void) to [[maybe_unused]] (#4473)Lenny Maiorani
Problem: - `(void)` simply casts the expression to void. This is understood to indicate that it is ignored, but this is really a compiler trick to get the compiler to not generate a warning. Solution: - Use the `[[maybe_unused]]` attribute to indicate the value is unused. Note: - Functions taking a `(void)` argument list have also been changed to `()` because this is not needed and shows up in the same grep command.
2020-11-27Lagom: Various fixes to make Lagom run on OSS-Fuzz (#4176)DavidKorczynski
2020-10-20Build: Modify various parts to allow the build to succeed on FreeBSDLaurent Cimon
2020-10-17ntpquery: Don't leak local time, and check origin time in replyNico Weber
This implements the transmit time suggestion in (abandoned?) draft-ietf-ntp-data-minimization. (The other suggestions were already implemented as far as I can tell.)
2020-05-30Lagom: Adjust AK, LibCore and LibTLS to build on MacOSMarcin Gasperowicz
2020-05-27AK: Add a simple randomness APIAndreas Kling
This can be used in code that builds on non-Serenity platforms.