mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:37:35 +00:00
LibCrypto: Move all elliptic curve private methods into .cpp
All the elliptic curve implementations had a long list of private methods which were all stored in a single .cpp file. Now we simply use static methods instead.
This commit is contained in:
parent
596391a4ee
commit
e07ec02470
6 changed files with 171 additions and 220 deletions
|
@ -12,34 +12,12 @@
|
|||
namespace Crypto::Curves {
|
||||
|
||||
class X25519 : public EllipticCurve {
|
||||
|
||||
static constexpr u8 BITS = 255;
|
||||
static constexpr u8 BYTES = 32;
|
||||
static constexpr u8 WORDS = 8;
|
||||
static constexpr u32 A24 = 121666;
|
||||
|
||||
public:
|
||||
size_t key_size() override { return BYTES; }
|
||||
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;
|
||||
|
||||
private:
|
||||
static void import_state(u32* state, ReadonlyBytes data);
|
||||
static ErrorOr<ByteBuffer> export_state(u32* data);
|
||||
static void select(u32* state, u32* a, u32* b, u32 condition);
|
||||
static void set(u32* state, u32 value);
|
||||
static void copy(u32* state, u32* value);
|
||||
static void conditional_swap(u32* first, u32* second, u32 condition);
|
||||
static void modular_multiply_single(u32* state, u32* first, u32 second);
|
||||
static void modular_square(u32* state, u32* value);
|
||||
static void modular_multiply(u32* state, u32* first, u32* second);
|
||||
static void modular_add(u32* state, u32* first, u32* second);
|
||||
static void modular_subtract(u32* state, u32* first, u32* second);
|
||||
static void modular_reduce(u32* state, u32* data);
|
||||
static void to_power_of_2n(u32* state, u32* value, u8 n);
|
||||
static void modular_multiply_inverse(u32* state, u32* value);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue