summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCrypto/ASN1
AgeCommit message (Collapse)Author
2023-01-29AK: Deprecate the old `AK::Stream`Tim Schumacher
This also removes a few cases where the respective header wasn't actually required to be included.
2023-01-02LibCrypto: Propagate errors using TRYericLemanissier
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-14Everywhere: Stop shoving things into ::std and mentioning them as suchAli Mohammad Pur
Note that this still keeps the old behaviour of putting things in std by default on serenity so the tools can be happy, but if USING_AK_GLOBALLY is unset, AK behaves like a good citizen and doesn't try to put things in the ::std namespace. std::nothrow_t and its friends get to stay because I'm being told that compilers assume things about them and I can't yeet them into a different namespace...for now.
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-12-03Everywhere: Run clang-formatLinus Groh
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-07-12Meta+Userland: Simplify some formatterssin-ack
These are mostly minor mistakes I've encountered while working on the removal of StringView(char const*). The usage of builder.put_string over Format<FormatString>::format is preferrable as it will avoid the indirection altogether when there's no formatting to be done. Similarly, there is no need to do format(builder, "{}", number) when builder.put_u64(number) works equally well. Additionally a few Strings where only constant strings were used are replaced with StringViews.
2022-04-17LibCrypto: Implement custom BitStringView for ASN.1 decoderMichiel Visser
The ASN.1 decoder was originally using AK::BitmapView for decoded BitStrings, however the specification requires that the bits are stored in a byte from the most significant to the least significant. Storing three bits '110' would result in a byte '1100 0000', i.e. 0xC0. However, AK::BitmapView expects the bits to be stored at the bottom like '0000 0110', i.e. 0x06. For the current uses the data was always a multiple of eight bits, resulting in complete bytes, which could directly be interpreted correctly. For the implementation of the key usage extension of certificates the correct implementation of the BitString is required.
2022-04-17LibCrypto: Fix inverted boolean decoded error in ASN.1Michiel Visser
ASN.1 encodes booleans as false is zero and true is non-zero. The decoder currently returned true when the boolean was zero. Since this decoder was barely used it did not cause any problems, however for support of other certificate extensions the correct version is required.
2022-04-17LibTLS: ASN1 parse_utc_time handle pre 2000 yearsMichiel Visser
In this format the year is specified using two digits. In the case that these digits are 50 or more, we should assume that the year is in 1950-1999. If it is 49 or less, the year is 2000-2049. This is specified in RFC5280 section 4.1.2.5.1.
2022-01-24AK+Userland: Make AK::decode_base64 return ErrorOrSam Atkins
2022-01-07Everywhere: Fix many spelling errorsmjz19910
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-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-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-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-05-31LibCrypto: Fix bound checks when reading bitmapsBen Wiederhake
This only affects malformed RSA keys. Instead of accepting and continuing with potentially broken pointers (and in ASAN, crashing), we now consider bitmaps malformed, and stop parsing. Found by OSS Fuzz: #31698, long-standing-bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=31698 Fun fact: The "if" only exists because of OSS Fuzz. 8cc279ed74dc0b16a187052d2454c26c8c6ecaf2
2021-05-17Everywhere: Fix a bunch of typosLinus Groh
2021-04-22AK+Userland: Use mpfard@serenityos.org for my copyright headersAli Mohammad Pur
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 *
2021-04-18LibCrypto: Avoid creating bools from anything except boolsAnotherTest
2021-04-18LibCrypto: Implement UTCTime and GeneralizedTime parsersAnotherTest
2021-04-18LibCrypo: Add an ASN.1/DER pretty-printerAnotherTest
It's much easier to debug things when we can actually *see* them :P
2021-04-18LibCrypto: Allow the user to override the DER read kind and classAnotherTest
This is useful for parsing non-universal types.
2021-04-18LibCrypto: Add the GeneralizedTime ASN.1 typeAnotherTest
2021-03-08LibCrypto: Fail with overflow when bitfield has too many unused bitsAnotherTest
There cannot be more unused bits than the entirety of the input. Found by OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=31706#c1
2021-03-04LibCrypto: Use BitmapView instead of Bitmap::wrap()Andreas Kling
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
2021-02-14LibCrypto: Make a better ASN.1 parserAnotherTest
And use it to parse RSA keys. As a bonus, this one shouldn't be reading out of bounds or messing with the stack (as much) anymore.
2021-01-22LibCrypto: Make PEM.h able to stand aloneBen Wiederhake
These headers should probably all be converted into proper functions of LibCrypto, especially since we have shared objects.
2021-01-12Libraries: Move to Userland/Libraries/Andreas Kling