AnotherTest
3b432eed98
LibCrypto: Correct RFC5246 un-padding behaviour
...
The decrypted data is legally allowed to have any amount of padding, so
long as it is block-aligned, we should not assume that padding bytes
fall inside the same block, or that an entire block cannot be padding.
Fixes #2072
2020-05-03 11:46:40 +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
4d932ce701
LibCrypto: Tweak ::prune_padding() to be more intuitive with loop bounds
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
e366416d51
LibCrypto: Preallocate capacity and cache trimmed_length() in UnsignedBigInteger
2020-05-02 12:24:10 +02:00
AnotherTest
bb46e5f608
LibTLS: Switch to Hash::Manager for hashing and add SHA1
...
Now we can talk to google.com
2020-05-02 12:24:10 +02:00
AnotherTest
43a49f5fff
LibCrypto: Add a Hash::Manager that can act as any one of the hashes
2020-05-02 12:24:10 +02:00
AnotherTest
e997661e26
LibCrypto: Implement SHA1 Hash Function
2020-05-02 12:24:10 +02:00
AnotherTest
e015ffd5f0
LibCrypto: Ensure that EME padding does not contain zeros
...
With this fix, we can now reliably open TLS connections!
2020-05-02 12:24:10 +02:00
AnotherTest
05e2c7d9cf
LibCrypto+LibTLS: Reformat everything
...
I have no idea how I'll squash _this_ one...
2020-05-02 12:24:10 +02:00
AnotherTest
a1e1570552
LibCrypto+LibTLS: Generalise the use of IV length
...
This is in preparation for the upcoming Galois/Counter mode, which
conventionally has 12 bytes of IV as opposed to CBC's 16 bytes.
...Also fixes a lot of style issues, since the author finally found the
project's clang config file in the repository root :^)
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
2247036acf
LibTLS: Implement a preliminary version of the TLS protocol
...
TLS::TLSv12 is a Core::Socket, however, I think splitting that into a
TLS::Socket would probably be beneficial
2020-05-02 12:24:10 +02:00
AnotherTest
f1578d7e9e
LibCrypto: Fix issues in the Crypto stack
...
This commit fixes up the following:
- HMAC should not reuse a single hasher when successively updating
- AES Key should not assume its user key is valid signed char*
- Mode should have a virtual destructor
And adds a RFC5246 padding mode, which is required for TLS
2020-05-02 12:24:10 +02:00
AnotherTest
7adb93ede9
LibCrypto: Implement RSA in terms of UnsignedBigInteger
...
This commit also adds enough ASN.1/DER to parse RSA keys
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
709c691f38
LibCrypto: Fix bug in big int subtraction
...
A regression test was added to the suite.
This commit also generally simplifies the subtraction method.
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
2843dce498
LibCrypto: Fix a bug in big int addition
...
There was a bug when dealing with a carry when the addition
result for the current word was UINT32_MAX.
This commit also adds a regression test for the bug.
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
AnotherTest
8c645916b4
LibCrypto: Add SHA512
...
There is quite a bit of avoidable duplication, however, I could not get
the compiler to be happy about SHA2<Size> (see FIXMEs)
2020-05-02 12:24:10 +02:00
AnotherTest
ca097b093b
LibCrypto: Add SHA256 hash function
2020-05-02 12:24:10 +02:00
AnotherTest
f2cd004d11
LibCrypto: Implement HMAC
2020-05-02 12:24:10 +02:00
AnotherTest
4f89a377a4
LibCrypto: Move each subsection into its own namespace
2020-05-02 12:24:10 +02:00
AnotherTest
bffb2c7542
LibCrypto: Add HashFunction and implement MD5
2020-05-02 12:24:10 +02:00
AnotherTest
899ca245ae
LibCrypto: Implement Cipher and AES_CBC
...
Also adds a test program to userland
2020-05-02 12:24:10 +02:00