summaryrefslogtreecommitdiff
path: root/Tests/LibCrypto
AgeCommit message (Collapse)Author
2023-01-15LibCrypto: Define *BigInteger::to_base to convert big integers to StringTimothy Flynn
2023-01-15LibCrypto+Everywhere: Rename *BigInteger::to_base to to_base_deprecatedTimothy Flynn
2022-12-31LibCrypto: Don't crash in ASN1::parse_generalized_time on missing 'Z'Ben Wiederhake
2022-12-31LibCrypto: Don't crash in ASN1::parse_utc_time on missing 'Z'Ben Wiederhake
The underlying reason is an unconditional call to consume(), even if there is no reason to expect that the string continues. This crash was discovered by OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=42354 This bug exists since the code was first written in April 2021: 13abbc5ea8c6b0bb145983c7d232dbe3bdc398c3
2022-12-31LibCrypto+Tests: Test and demonstrate broken ASN1::parse_utc_timeBen Wiederhake
2022-12-06AK+Everywhere: Rename String to DeprecatedStringLinus Groh
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
2022-11-02LibCrypto: Add a way to compare UnsignedBigInteger with doubleMoustafa Raafat
This patch also make SignedBigInteger::compare_to_double make use of the new function.
2022-08-26LibCrypto: Add a constructor to (Un)SignedBigInteger taking a doubledavidot
For now this will assume that the double given is exactly representable as an integer, so no NaN, infinity or rounding.
2022-08-26LibCrypto: Make the constructors of (Un)SignedBigInteger templateddavidot
This means it can take any (un)signed word of size at most Word. This means the constructor can be disambiguated if we were to add a double constructor :^). This requires a change in just one test.
2022-08-26LibCrypto: Add a rounding mode to UnsignedBigInteger::to_doubledavidot
This allows using different options for rounding, like IEEE roundTiesToEven, which is the mode that JS requires. Also fix that the last word read from the bigint for the mantissa could be shifted incorrectly leading to incorrect results.
2022-08-24LibCrypto: Implement a (mostly) proper to_double for UnsignedBigIntegerdavidot
SignedBigInteger can immediately use this by just negating the double if the sign bit is set. For simple cases (below 2^53) we can just convert via an u64, however above that we need to extract the top 53 bits and use those as the mantissa. This function currently does not behave exactly as the JS spec specifies however it is much less naive than the previous implementation.
2022-08-24LibCrypto: Add a way to compare a SignedBigInteger with a doubledavidot
This supports any double value (except for NaNs) instead of having to cast the double to some smaller type which doesn't work for very large values.
2022-07-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
2022-05-12LibCrypto: Add Ed25519stelar7
2022-04-13LibCrypto: Add ChaCha20stelar7
2022-04-08LibCrypto: Add Poly1305stelar7
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-26LibCrypto: Correctly add length to SHA384 and SHA512 hashesMichiel Visser
The SHA384 and SHA512 hashes would produce incorrect results for data where the length % 128 was in the range 112-119. This was because the total number of bits in the hashed values was added at the end as a 64-bit number instead of a 128-bit number. In most cases this would not cause any issues, as this space was padded with zeroes, however in the case that the length % 128 was 112-119, some incorrect data ended up where this 128-bit length value was expected. This change fixes the problems in LibTLS where some websites would result in a DecryptError on handshake.
2022-03-20LibCrypto: Add DH exchange for SECP256r1 to TestCurvesMichiel Visser
2022-03-20LibCrypto+LibTLS: Add SECP256r1 support to LibTLSMichiel Visser
Add the required methods to SECP256r1 to conform to the EllipticCurve virtual base class. Using this updated version of SECP256r1, support in LibTLS is implemented.
2022-03-20LibCrypto+LibTLS: Generalize the elliptic curve interfaceMichiel Visser
These changes generalize the interface with an elliptic curve implementation. This allows LibTLS to support elliptic curves generally without needing the specifics of elliptic curve implementations. This should allow for easier addition of other elliptic curves.
2022-03-18LibCrypto: Implement the SECP256r1 elliptic curveMichiel Visser
This implementation of the secp256r1 elliptic curve uses two techniques to improve the performance of the operations. 1. All coordinates are stored in Jacobian form, (X/Z^2, Y/Z^3, Z), which removes the need for division operations during point addition or doubling. The points are converted at the start of the computation, and converted back at the end. 2. All values are transformed to Montgomery form, to allow for faster modular multiplication using the Montgomery modular multiplication method. This means that all coordinates have to be converted into this form, and back out of this form before returning them.
2022-03-09LibCrypto: Add curve X448stelar7
2022-02-18LibCrypto: Add curve x25519stelar7
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-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()).
2021-12-08LibCrypto+Tests: Avoid implicitly copying ByteBufferBen Wiederhake
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-09-06Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safeAli Mohammad Pur
2021-09-02Tests: Remove all file(GLOB) from CMakeLists in TestsAndrew Kaster
Using a file(GLOB) to find all the test files in a directory is an easy hack to get things started, but has some drawbacks. Namely, if you add a test, it won't be found again without re-running CMake. `ninja` seems to do this automatically, but it would be nice to one day stop seeing it rechecking our globbed directories.
2021-07-01LibCrypto: Add tests for SignedBigInteger bitwise operationsGal Horowitz
2021-06-29LibCrypto: Replace from_base{2,8,10,16}() & to_base10 with from_base(N)Idan Horowitz
This allows us to support parsing and serializing BigIntegers to and from any base N (such that 2 <= N <= 36).
2021-06-19LibCrypto+LibTLS: Split and move test suite into Tests directoryPeter Bocan
This change splits test-crypto.cpp from Userland into separate test suites located in Tests/ directory.