mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 13:07:46 +00:00
LibCrypto: Add curve X448
This commit is contained in:
parent
c8803afe3e
commit
0df7ad7493
4 changed files with 483 additions and 0 deletions
40
Userland/Libraries/LibCrypto/Curves/X448.h
Normal file
40
Userland/Libraries/LibCrypto/Curves/X448.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2022, stelar7 <dudedbz@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/ByteBuffer.h>
|
||||
|
||||
namespace Crypto::Curves {
|
||||
|
||||
class X448 {
|
||||
|
||||
static constexpr u16 BITS = 448;
|
||||
static constexpr u8 BYTES = 56;
|
||||
static constexpr u8 WORDS = 14;
|
||||
static constexpr u32 A24 = 39082;
|
||||
|
||||
public:
|
||||
static ErrorOr<ByteBuffer> compute_coordinate(ReadonlyBytes a, ReadonlyBytes b);
|
||||
|
||||
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, u32 data_high);
|
||||
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