summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCrypto
AgeCommit message (Collapse)Author
2022-02-06LibCrypto: Do not allow signed big integers to be negative zeroTimothy Flynn
If a big integer were to become negative zero, set the sign to instead be positive. This prevents odd scenarios where users of signed big ints would falsely think the result of some big int arithmetic is negative.
2022-01-31LibCrypto: Change UnsignedBigInteger parser to use a StringViewTimothy Flynn
SignedBigInteger already accepts a StringView; let's avoid the heap allocation in UnsignedBigInteger.
2022-01-28Userland: Remove a bunch of unnecessary Vector importskleines Filmröllchen
How silly :^)
2022-01-24AK+Userland: Make AK::decode_base64 return ErrorOrSam Atkins
2022-01-24Everywhere: Convert ByteBuffer factory methods from Optional -> ErrorOrSam Atkins
Apologies for the enormous commit, but I don't see a way to split this up nicely. In the vast majority of cases it's a simple change. A few extra places can use TRY instead of manual error checking though. :^)
2022-01-18LibCrypo: Simplify mixed-sign bitwise_orNico Weber
No behavior change.
2022-01-18LibCrypto: Remove some now-unused (and incorrect) methodsNico Weber
Removes the UnsignedBigInteger overloads of SignedBigInteger::binary_{and,or,xor}(). They're now unused, and they also didn't work when *this was negative.
2022-01-18LibCrypto+LibJS: Better bitwise binary_xor binopNico Weber
We went through some trouble to make & and | work right. Reimplement ^ in terms of & and | to make ^ work right as well. This is less fast than a direct implementation, but let's get things working first.
2022-01-18LibCrypto+LibJS: Better bigint bitwise_or binopNico Weber
Similar to the bitwise_and change, but we have to be careful to sign-extend two's complement numbers only up to the highest set bit in the positive number.
2022-01-18LibCrypto+LibJS: Better bigint bitwise_and binopNico Weber
Bitwise and is defined in terms of two's complement, so some converting needs to happen for SignedBigInteger's sign/magnitude representation to work out. UnsignedBigInteger::bitwise_not() is repurposed to convert all high-order zero bits to ones up to a limit, for the two's complement conversion to work. Fixes test262/test/language/expressions/bitwise-and/bigint.js.
2022-01-18LibJS+LibCrypto: Fix SignedBitInteger::bitwise_not and use it in LibJSNico Weber
Bitwise operators are defined on two's complement, but SignedBitInteger uses sign-magnitude. Correctly convert between the two. Let LibJS delegate to SignedBitInteger for bitwise_not, like it does for all other bitwise_ operations on bigints. No behavior change (LibJS is now the only client of SignedBitInteger::bitwise_not()).
2022-01-18LibCrypto: Add Formatter<SignedBigInteger>Nico Weber
Useful for seeing SignedBigInteger values in test failure messages.
2022-01-09LibCrypto: Link against LibCoreDaniel Bertalan
The ASN1 parser calls `LibCore::DateTime::create` and `LibCore::DateTime::now`.
2022-01-07Everywhere: Fix spelling mistakesmjz19910
2022-01-07Everywhere: Fix many spelling errorsmjz19910
2022-01-05LibCrypto: Make `Digest`s able to return `bytes`Michel Hermier
2022-01-05LibCrypto: Mutualize `Digest`sMichel Hermier
2022-01-05LibCrypto: Make `MultiHashDigestVariant` getters `const` and `nodiscard`Michel Hermier
2022-01-05LibCrypto: Remove spurious `;`Michel Hermier
2021-12-24LibCrypto: Remove redundant __builtin_memset() callDaniel Bertalan
This call caused GCC 12's static analyzer to think that we perform an out-of-bounds write to the v_key Vector. This is obviously incorrect, and comes from the fact that GCC doesn't properly track whether we use the inline storage, or the Vector is allocated on the heap. While searching for a workaround, Sam pointed out that this call is redundant as `Vector::resize()` already zeroes out the elements, so we can completely remove it. Co-authored-by: Sam Atkins <atkinssj@serenityos.org>
2021-12-22LibCrypto: Add the BigInteger conceptLinus Groh
This makes it much easier to write (template) functions that accept either a signed or unsigned bigint parameter.
2021-12-21AK+Everywhere: Replace __builtin bit functionsNick Johnson
In order to reduce our reliance on __builtin_{ffs, clz, ctz, popcount}, this commit removes all calls to these functions and replaces them with the equivalent functions in AK/BuiltinWrappers.h.
2021-12-17LibCrypto: Declobber AES header from s-box tablesAlexander Ulmer
2021-12-11Everywhere: Fix -Winconsistent-missing-override warnings from ClangDaniel Bertalan
This option is already enabled when building Lagom, so let's enable it for the main build too. We will no longer be surprised by Lagom Clang CI builds failing while everything compiles locally. Furthermore, the stronger `-Wsuggest-override` warning is enabled in this commit, which enforces the use of the `override` keyword in all classes, not just those which already have some methods marked as `override`. This works with both GCC and Clang.
2021-11-17AK: Convert AK::Format formatting helpers to returning ErrorOr<void>Andreas Kling
This isn't a complete conversion to ErrorOr<void>, but a good chunk. The end goal here is to propagate buffer allocation failures to the caller, and allow the use of TRY() with formatting functions.
2021-11-16LibCrypto: Fix subtracting two negative `SignedBigInteger`sLinus Groh
Currently, we get the following results -1 - -2 = -1 -2 - -1 = 1 Correct would be: -1 - -2 = 1 -2 - -1 = -1 This was already attempted to be fixed in 7ed8970, but that change was incorrect. This directly translates to LibJS BigInts having the same incorrect behavior - it even was tested.
2021-11-11Userland: Include Vector.h in a few places to make HeaderCheck happyAli Mohammad Pur
This header was being transitively pulled in, but that no longer happens after 5f7d008791f9e358638283dc2f0d709a601344ff.
2021-11-11LibCrypto: Pass AK::Bytes by valueAndreas Kling
2021-11-11Everywhere: Pass AK::ReadonlyBytes by valueAndreas Kling
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-11-10AK: Make ByteBuffer::try_* functions return ErrorOr<void>Andreas Kling
Same as Vector, ByteBuffer now also signals allocation failure by returning an ENOMEM Error instead of a bool, allowing us to use the TRY() and MUST() patterns.
2021-11-10Everywhere: Remove unused AK/Bitmap includesBen Wiederhake
2021-10-23AK+Everywhere: Make Base64 decoding fallibleBen Wiederhake
2021-10-06LibCrypto: Add missing header to EMSA_PSS.hBen Wiederhake
2021-09-21Libraries: Use AK::Variant default initialization where appropriateBen Wiederhake
2021-09-16LibCrypto: Use default instead of an empty constructor/destructorBrian Gianforcaro
Default implementations allow for more optimizations. See: https://pvs-studio.com/en/docs/warnings/v832/
2021-09-13LibCrypto: Fix MacOS build by replacing explicit_bzero with secure_zeroBrian Gianforcaro
2021-09-12LibCrypto: Use explicit_bzero instead of memset to zero 'secure data'Brian Gianforcaro
PVS-Studio flagged this, as memset can be optimized away by the compiler in some cases. We obviously don't want that to ever happen so make sure to always use `explicit_bzero(..)` which can't be optimized away.
2021-09-07Everywhere: Behaviour => BehaviorAndreas Kling
2021-09-06LibCrypto: Add naive implementation of {Un,}SignedBigInteger::to_doubleIdan Horowitz
2021-09-06Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safeAli Mohammad Pur
2021-09-06Everywhere: Use OOM-safe ByteBuffer APIs where possibleAli Mohammad Pur
If we can easily communicate failure, let's avoid asserting and report failure instead.
2021-09-01Everywhere: Use my cool new @serenityos.org email addressPeter Elliott
2021-08-19AK: Move FormatParser definition from header to implementation fileTimothy Flynn
This is primarily to be able to remove the GenericLexer include out of Format.h as well. A subsequent commit will add AK::Result to GenericLexer, which will cause naming conflicts with other structures named Result. This can be avoided (for now) by preventing nearly every file in the system from implicitly including GenericLexer. Other changes in this commit are to add the GenericLexer include to files where it is missing.
2021-07-19LibCrypto: Add operator<= and operator>= to SignedBigIntegerIdan Horowitz
2021-07-12LibCrypto: Add the >= operator to UnsignedBigIntegerIdan Horowitz
2021-07-09LibCrypto: Add missing implementation of SBI::divided_by(USBI)Linus Groh
2021-07-08LibCrypto: Add missing implementation of SBI::multiplied_by(USBI)Linus Groh
This only had a declaration and was creating linker errors when used. Easily fixed!
2021-07-07LibCrypto: Add operator>() to UnsignedBigInteger and SignedBigIntegerLinus Groh
Piggybacking on operator!=() and operator<().
2021-07-01LibCrypto: Replace incorrect operator in SignedBigInteger::bitwise_andGal Horowitz