mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:57:44 +00:00
LibCrypto+LibTLS: Generalize the elliptic curve interface
These changes generalize the interface with an elliptic curve implementation. This allows LibTLS to support elliptic curves generally without needing the specifics of elliptic curve implementations. This should allow for easier addition of other elliptic curves.
This commit is contained in:
parent
21bbff0349
commit
c1b041e761
10 changed files with 133 additions and 122 deletions
24
Userland/Libraries/LibCrypto/Curves/EllipticCurve.h
Normal file
24
Userland/Libraries/LibCrypto/Curves/EllipticCurve.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* 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;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue