mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 06:27:45 +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
|
@ -7,10 +7,11 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <LibCrypto/Curves/EllipticCurve.h>
|
||||
|
||||
namespace Crypto::Curves {
|
||||
|
||||
class X25519 {
|
||||
class X25519 : public EllipticCurve {
|
||||
|
||||
static constexpr u8 BITS = 255;
|
||||
static constexpr u8 BYTES = 32;
|
||||
|
@ -18,7 +19,11 @@ class X25519 {
|
|||
static constexpr u32 A24 = 121666;
|
||||
|
||||
public:
|
||||
static ErrorOr<ByteBuffer> compute_coordinate(ReadonlyBytes a, ReadonlyBytes b);
|
||||
size_t key_size() override { return BYTES; }
|
||||
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;
|
||||
|
||||
private:
|
||||
static void import_state(u32* state, ReadonlyBytes data);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue