1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-18 21:35:06 +00:00
serenity/Userland/Libraries/LibCrypto/Curves/SECP256r1.h
Michiel Visser e07ec02470 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.
2022-03-20 00:51:50 +03:30

30 lines
772 B
C++

/*
* Copyright (c) 2022, Michiel Visser <opensource@webmichiel.nl>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/UFixedBigInt.h>
#include <LibCrypto/Curves/EllipticCurve.h>
namespace Crypto::Curves {
struct JacobianPoint {
u256 x { 0u };
u256 y { 0u };
u256 z { 0u };
};
class SECP256r1 : public EllipticCurve {
public:
size_t key_size() override { return 1 + 2 * 32; }
ErrorOr<ByteBuffer> generate_private_key() override;
ErrorOr<ByteBuffer> generate_public_key(ReadonlyBytes a) override;
ErrorOr<ByteBuffer> compute_coordinate(ReadonlyBytes scalar_bytes, ReadonlyBytes point_bytes) override;
ErrorOr<ByteBuffer> derive_premaster_key(ReadonlyBytes shared_point) override;
};
}