summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCrypto
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-11-10 14:33:44 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-10 21:58:58 +0100
commita15ed8743d03c6c683f19447be20ca7dac768485 (patch)
treefe3b808b4909686757dae5c4a949ba18fe7e5eba /Userland/Libraries/LibCrypto
parent88b6428c25ea046a4bb19bb6f3f68dd4f1439539 (diff)
downloadserenity-a15ed8743d03c6c683f19447be20ca7dac768485.zip
AK: Make ByteBuffer::try_* functions return ErrorOr<void>
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.
Diffstat (limited to 'Userland/Libraries/LibCrypto')
-rw-r--r--Userland/Libraries/LibCrypto/ASN1/PEM.cpp2
-rw-r--r--Userland/Libraries/LibCrypto/PK/Code/EMSA_PSS.h4
2 files changed, 3 insertions, 3 deletions
diff --git a/Userland/Libraries/LibCrypto/ASN1/PEM.cpp b/Userland/Libraries/LibCrypto/ASN1/PEM.cpp
index c901febe41..90f957cfc9 100644
--- a/Userland/Libraries/LibCrypto/ASN1/PEM.cpp
+++ b/Userland/Libraries/LibCrypto/ASN1/PEM.cpp
@@ -39,7 +39,7 @@ ByteBuffer decode_pem(ReadonlyBytes data)
dbgln("Failed to decode PEM, likely bad Base64");
return {};
}
- if (!decoded.try_append(b64decoded.value().data(), b64decoded.value().size())) {
+ if (decoded.try_append(b64decoded.value().data(), b64decoded.value().size()).is_error()) {
dbgln("Failed to decode PEM, likely OOM condition");
return {};
}
diff --git a/Userland/Libraries/LibCrypto/PK/Code/EMSA_PSS.h b/Userland/Libraries/LibCrypto/PK/Code/EMSA_PSS.h
index b1b1a569a9..3193c772d4 100644
--- a/Userland/Libraries/LibCrypto/PK/Code/EMSA_PSS.h
+++ b/Userland/Libraries/LibCrypto/PK/Code/EMSA_PSS.h
@@ -152,8 +152,8 @@ public:
for (size_t counter = 0; counter < length / HashFunction::DigestSize - 1; ++counter) {
hash_fn.update(seed);
hash_fn.update((u8*)&counter, 4);
- if (!T.try_append(hash_fn.digest().data, HashFunction::DigestSize)) {
- dbgln("EMSA_PSS: MGF1 digest failed, not enough space");
+ if (auto result = T.try_append(hash_fn.digest().data, HashFunction::DigestSize); result.is_error()) {
+ dbgln("EMSA_PSS: MGF1 digest failed: {}", result.error());
return;
}
}