devgianlu
a019efb24b
LibCrypto+LibJS: Remove {Signed,Unsigned}BigInteger to_base_deprecated
...
Use `to_base` instead.
2025-04-28 12:05:26 +02:00
devgianlu
ac16008d09
LibCrypto: Remove unused create_invalid method on UnsignedBigInteger
2025-04-28 12:05:26 +02:00
Jess
12cbefbee7
LibJS+LibCrypto: Use a bitwise approach for BigInt's as*IntN methods
...
This speeds up expressions such as `BigInt.asIntN(0x4000000000000, 1n)`
(#3615 ). And those involving very large bigints.
2025-03-20 09:44:12 +01:00
Jess
8fda05d8b7
LibCrypto: Introduce a falible API for SignedBigInteger::shift_left
2025-02-19 09:00:59 -05:00
Pavel Shliak
8d13115d9a
LibCrypto: Clean up #include directives
...
This change aims to improve the speed of incremental builds.
2024-11-21 14:08:33 +01:00
Timothy Flynn
b94307583b
LibCrypto: Add user-defined literals to convert numbers to a BigInt
...
It is much more convenient to define constants with:
1000_bigint
Than with:
Crypto::UnsignedBigInteger { 1000 }
2024-11-20 19:04:30 -05:00
Timothy Flynn
e236f1d2ae
LibCrypto: Define UnsignedBigInteger::operator<=
...
We have all comparison operators except less-than-or-equal already.
2024-11-20 19:04:30 -05:00
Timothy Flynn
93712b24bf
Everywhere: Hoist the Libraries folder to the top-level
2024-11-10 12:50:45 +01:00
Andreas Kling
13d7c09125
Libraries: Move to Userland/Libraries/
2021-01-12 12:17:46 +01:00
asynts
843ebbd2c3
Everywhere: Replace a bundle of dbg with dbgln.
...
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-11 21:49:29 +01:00
Ben Wiederhake
67b24cb3a6
LibCrypto: Document word order (endianness) of bigint
2020-08-16 16:35:23 +02:00
AnotherTest
b00ffc860b
LibCrypto: Do not trim leading zeros in export_data by default
...
This fixes the issue with the exported data having a leading zero,
causing RSA::encrypt to trim the block down, and ruining the encryption.
Fixes #2691 :^)
2020-07-31 18:25:20 +02:00
asynts
4709b700bd
LibCrypto: Change [XXX]BigInteger::export_data() to use Span.
2020-07-27 19:58:09 +02:00
asynts
68cf22d580
LibCrypto: This method wrote to a const pointer.
2020-07-27 19:58:09 +02:00
Tom
3fdacef07f
LibCrypto: Optimize UnsignedBigInteger import_data/export_data
...
No need to do complicated math to import or export numbers,
just convert the byte stream to words and vice versa.
2020-07-25 12:53:02 +02:00
AnotherTest
02c53fd1f9
LibCrypto: Add bitwise operations (and/or/xor)
2020-06-07 19:29:40 +02:00
Emanuele Torre
937d0be762
Meta: Add a script check the presence of "#pragma once" in header files
...
.. and make travis run it.
I renamed check-license-headers.sh to check-style.sh and expanded it so
that it now also checks for the presence of "#pragma once" in .h files.
It also checks the presence of a (single) blank line above and below the
"#pragma once" line.
I also added "#pragma once" to all the files that need it: even the ones
we are not check.
I also added/removed blank lines in order to make the script not fail.
I also ran clang-format on the files I modified.
2020-05-29 07:59:45 +02:00
Andreas Kling
444b6c8407
LibCrypto: Cache the "trimmed length" of UnsignedBigIntegers
...
This avoids repeated traversals of the underlying words and gives a
30% speed-up on "test-crypto -t pk" :^)
2020-05-07 12:23:09 +02:00
DexesTTP
8aeccf4f02
LibCrypto: Added BigInteger 'division by u16' operator
2020-05-03 14:31:26 +02:00
DexesTTP
28ea347e55
LibCrypto: Added static non-allocating UnsignedBigInteger operators
...
This changes the plus, minus, etc... operators from UnsignedBigInteger to use a
static helper method. The static methods do not allocate any variables, instead
all the required BigInteger output and temporary variables are required on call
as parameters.
This change already optimizes the number of allocations in complex operations
such as multiply or divide, by having a single allocation per call (instead of
one per loop).
This new API also provides a way to limit the number of allocations for complex
computations in other parts of the code. This is done by using these helpers in
any place that currently makes use of the standard operators.
2020-05-03 14:31:26 +02:00
DexesTTP
d008a38f93
LibCrypto: Small fixes in BigInteger & test-crypto
2020-05-03 14:31:26 +02:00
AnotherTest
c9321b4f00
LibCrypto: Make UnsignedBigInteger as fast as architecturally possible
...
This commit attempts to make UnsignedBigInteger as fast as possible
without changing the underlaying architecture.
This effort involves
- Preallocating space for vector operations
- Avoiding calls to computationally expensive functions
- Inlining or flattening functions (sensibly)
2020-05-02 12:24:10 +02:00
AnotherTest
adab43987d
LibCrypto: Rename UnsignedBigInteger APIs to match their actions
2020-05-02 12:24:10 +02:00
AnotherTest
8d20a526e5
LibCrypto: Preallocate 128 words of space for UnsignedBigInteger
...
This shaves off 1 second of runtime
2020-05-02 12:24:10 +02:00
AnotherTest
6b742c69bd
LibCrypto: Add ::import_data() and ::export_data() to UnsignedBigInteger
...
These functions allow conversion to-and-from big-endian buffers
This commit also adds a ""_bigint operator for easy bigint use
2020-05-02 12:24:10 +02:00
Itamar
c52d3e65b9
LibCrypto: Cleanup UnsignedBigInteger a bit
...
- Add missing 'explicit' to the constructor
- Remove unneeded 'AK::' in AK::Vector
- Avoid copying 'words' in constructor
2020-05-02 12:24:10 +02:00
Itamar
2125a4debb
LibCrypto: Add base-10 string de/serialization methods for bigint
2020-05-02 12:24:10 +02:00
Itamar
0d2777752e
LibCrypto: Add UnsignedBigInteger division
...
The division operation returns both the quotient and the remainder.
2020-05-02 12:24:10 +02:00
Itamar
2959c4a5e9
LibCrypto: Add UnsignedBigInteger multiplication
...
Also added documentation for the runtime complexity of some operations.
2020-05-02 12:24:10 +02:00
Itamar
e0cf40518c
LibCrypto: Add UnsignedBigInteger subtraction and comparison
2020-05-02 12:24:10 +02:00
Itamar
6201f741d4
LibCrypto: Add UnsignedBigInteger and implement addition
...
UnsignedBigInteger stores an unsigned ainteger of arbitrary length.
A big integer is represented as a vector of word. Each
word is an unsigned int.
2020-05-02 12:24:10 +02:00