mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-24 11:21:34 +00:00
LibCrypto: Make PKSystem
methods return a ByteBuffer
directly
It used to be that the caller would supply a buffer to write the output to. This created an anti-pattern in multiple places where the caller would allocate a `ByteBuffer` and then use `.bytes()` to provide it to the `PKSystem` method. Then the callee would resize the output buffer and reassign it, but because the resize was on `Bytes` and not on `ByteBuffer`, the caller using the latter would cause a bug. Additionally, in pretty much all cases the buffer was pre-allocated shortly before.
This commit is contained in:
parent
81eb66c6eb
commit
0fc02d4d00
Notes:
github-actions[bot]
2025-01-13 16:02:16 +00:00
Author: https://github.com/devgianlu
Commit: 0fc02d4d00
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3234
9 changed files with 69 additions and 112 deletions
|
@ -195,11 +195,11 @@ public:
|
|||
m_public_key.set(m_private_key.modulus(), m_private_key.public_exponent());
|
||||
}
|
||||
|
||||
virtual ErrorOr<void> encrypt(ReadonlyBytes in, Bytes& out) override;
|
||||
virtual ErrorOr<void> decrypt(ReadonlyBytes in, Bytes& out) override;
|
||||
virtual ErrorOr<ByteBuffer> encrypt(ReadonlyBytes in) override;
|
||||
virtual ErrorOr<ByteBuffer> decrypt(ReadonlyBytes in) override;
|
||||
|
||||
virtual ErrorOr<void> verify(ReadonlyBytes in, Bytes& out) override;
|
||||
virtual ErrorOr<void> sign(ReadonlyBytes in, Bytes& out) override;
|
||||
virtual ErrorOr<ByteBuffer> verify(ReadonlyBytes in) override;
|
||||
virtual ErrorOr<ByteBuffer> sign(ReadonlyBytes in) override;
|
||||
|
||||
virtual ByteString class_name() const override
|
||||
{
|
||||
|
@ -232,11 +232,11 @@ public:
|
|||
|
||||
~RSA_PKCS1_EME() = default;
|
||||
|
||||
virtual ErrorOr<void> encrypt(ReadonlyBytes in, Bytes& out) override;
|
||||
virtual ErrorOr<void> decrypt(ReadonlyBytes in, Bytes& out) override;
|
||||
virtual ErrorOr<ByteBuffer> encrypt(ReadonlyBytes in) override;
|
||||
virtual ErrorOr<ByteBuffer> decrypt(ReadonlyBytes in) override;
|
||||
|
||||
virtual ErrorOr<void> verify(ReadonlyBytes in, Bytes& out) override;
|
||||
virtual ErrorOr<void> sign(ReadonlyBytes in, Bytes& out) override;
|
||||
virtual ErrorOr<ByteBuffer> verify(ReadonlyBytes in) override;
|
||||
virtual ErrorOr<ByteBuffer> sign(ReadonlyBytes in) override;
|
||||
|
||||
virtual ByteString class_name() const override
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue