mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibCrypto: Remove unused EllipticCurve
abstract class
This was required only to support our custom TLS implementation, but does not serve any purpose other than forcing improper APIs.
This commit is contained in:
parent
8ae01f81c9
commit
7180c5f13b
Notes:
github-actions[bot]
2025-02-17 23:03:41 +00:00
Author: https://github.com/devgianlu Commit: https://github.com/LadybirdBrowser/ladybird/commit/7180c5f13b0 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3606
4 changed files with 18 additions and 45 deletions
|
@ -1,24 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Michiel Visser <opensource@webmichiel.nl>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/ByteBuffer.h>
|
||||
|
||||
namespace Crypto::Curves {
|
||||
|
||||
class EllipticCurve {
|
||||
public:
|
||||
virtual size_t key_size() = 0;
|
||||
virtual ErrorOr<ByteBuffer> generate_private_key() = 0;
|
||||
virtual ErrorOr<ByteBuffer> generate_public_key(ReadonlyBytes a) = 0;
|
||||
virtual ErrorOr<ByteBuffer> compute_coordinate(ReadonlyBytes scalar_bytes, ReadonlyBytes point_bytes) = 0;
|
||||
virtual ErrorOr<ByteBuffer> derive_premaster_key(ReadonlyBytes shared_point) = 0;
|
||||
|
||||
virtual ~EllipticCurve() = default;
|
||||
};
|
||||
|
||||
}
|
|
@ -11,7 +11,6 @@
|
|||
#include <AK/StringView.h>
|
||||
#include <LibCrypto/ASN1/Constants.h>
|
||||
#include <LibCrypto/ASN1/DER.h>
|
||||
#include <LibCrypto/Curves/EllipticCurve.h>
|
||||
#include <LibCrypto/OpenSSL.h>
|
||||
|
||||
namespace {
|
||||
|
@ -134,9 +133,9 @@ struct SECPxxxr1Signature {
|
|||
}
|
||||
};
|
||||
|
||||
class SECPxxxr1 : public EllipticCurve {
|
||||
class SECPxxxr1 {
|
||||
public:
|
||||
size_t key_size() override { return 1 + (2 * m_scalar_size); }
|
||||
size_t key_size() { return 1 + (2 * m_scalar_size); }
|
||||
|
||||
ErrorOr<UnsignedBigInteger> generate_private_key_scalar();
|
||||
ErrorOr<SECPxxxr1Point> generate_public_key_point(UnsignedBigInteger scalar);
|
||||
|
@ -149,7 +148,7 @@ public:
|
|||
return shared_point;
|
||||
}
|
||||
|
||||
ErrorOr<ByteBuffer> generate_private_key() override
|
||||
ErrorOr<ByteBuffer> generate_private_key()
|
||||
{
|
||||
auto key = TRY(generate_private_key_scalar());
|
||||
|
||||
|
@ -159,14 +158,14 @@ public:
|
|||
return buffer.slice(0, size);
|
||||
}
|
||||
|
||||
ErrorOr<ByteBuffer> generate_public_key(ReadonlyBytes a) override
|
||||
ErrorOr<ByteBuffer> generate_public_key(ReadonlyBytes a)
|
||||
{
|
||||
auto a_int = UnsignedBigInteger::import_data(a);
|
||||
auto point = TRY(generate_public_key_point(a_int));
|
||||
return point.to_uncompressed();
|
||||
}
|
||||
|
||||
ErrorOr<ByteBuffer> compute_coordinate(ReadonlyBytes scalar_bytes, ReadonlyBytes point_bytes) override
|
||||
ErrorOr<ByteBuffer> compute_coordinate(ReadonlyBytes scalar_bytes, ReadonlyBytes point_bytes)
|
||||
{
|
||||
auto scalar = UnsignedBigInteger::import_data(scalar_bytes);
|
||||
auto point = TRY(SECPxxxr1Point::from_uncompressed(point_bytes));
|
||||
|
@ -174,7 +173,7 @@ public:
|
|||
return result.to_uncompressed();
|
||||
}
|
||||
|
||||
ErrorOr<ByteBuffer> derive_premaster_key(ReadonlyBytes shared_point_bytes) override
|
||||
ErrorOr<ByteBuffer> derive_premaster_key(ReadonlyBytes shared_point_bytes)
|
||||
{
|
||||
auto shared_point = TRY(SECPxxxr1Point::from_uncompressed(shared_point_bytes));
|
||||
auto premaster_key_point = TRY(derive_premaster_key_point(shared_point));
|
||||
|
|
|
@ -7,17 +7,16 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <LibCrypto/Curves/EllipticCurve.h>
|
||||
|
||||
namespace Crypto::Curves {
|
||||
|
||||
class X25519 : public EllipticCurve {
|
||||
class X25519 {
|
||||
public:
|
||||
size_t key_size() override { return 32; }
|
||||
ErrorOr<ByteBuffer> generate_private_key() override;
|
||||
ErrorOr<ByteBuffer> generate_public_key(ReadonlyBytes a) override;
|
||||
ErrorOr<ByteBuffer> compute_coordinate(ReadonlyBytes a, ReadonlyBytes b) override;
|
||||
ErrorOr<ByteBuffer> derive_premaster_key(ReadonlyBytes shared_point) override;
|
||||
size_t key_size() { return 32; }
|
||||
ErrorOr<ByteBuffer> generate_private_key();
|
||||
ErrorOr<ByteBuffer> generate_public_key(ReadonlyBytes a);
|
||||
ErrorOr<ByteBuffer> compute_coordinate(ReadonlyBytes a, ReadonlyBytes b);
|
||||
ErrorOr<ByteBuffer> derive_premaster_key(ReadonlyBytes shared_point);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -7,17 +7,16 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <LibCrypto/Curves/EllipticCurve.h>
|
||||
|
||||
namespace Crypto::Curves {
|
||||
|
||||
class X448 : public EllipticCurve {
|
||||
class X448 {
|
||||
public:
|
||||
size_t key_size() override { return 56; }
|
||||
ErrorOr<ByteBuffer> generate_private_key() override;
|
||||
ErrorOr<ByteBuffer> generate_public_key(ReadonlyBytes a) override;
|
||||
ErrorOr<ByteBuffer> compute_coordinate(ReadonlyBytes a, ReadonlyBytes b) override;
|
||||
ErrorOr<ByteBuffer> derive_premaster_key(ReadonlyBytes shared_point) override;
|
||||
size_t key_size() { return 56; }
|
||||
ErrorOr<ByteBuffer> generate_private_key();
|
||||
ErrorOr<ByteBuffer> generate_public_key(ReadonlyBytes a);
|
||||
ErrorOr<ByteBuffer> compute_coordinate(ReadonlyBytes a, ReadonlyBytes b);
|
||||
ErrorOr<ByteBuffer> derive_premaster_key(ReadonlyBytes shared_point);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue