Debian Codegraph @

src/lib/pubkey/curve448/x448/x448_internal.h

raw
1 /*
2 * X448 Internal
3 * (C) 2024 Jack Lloyd
4 * 2024 Fabian Albert - Rohde & Schwarz Cybersecurity
5 *
6 * Botan is released under the Simplified BSD License (see license.txt)
7 */
8 #ifndef BOTAN_X448_INTERNAL_H_
9 #define BOTAN_X448_INTERNAL_H_
10
11 #include <botan/secmem.h>
12 #include <botan/strong_type.h>
13
14 namespace Botan {
15
16 constexpr size_t X448_LEN = 56;
17
18 using Point448 = Strong<std::array<uint8_t, X448_LEN>, struct Point448_>;
19
20 // Note that we do not use the scalar of x448_scalar.h since the x448 algorithm
21 // requires a scalar that is even. When reducing (modulo the group order) the scalar using
22 // this class, the computation becomes invalid. Since we do not need to reduce, we
23 // simply work on bytes for x448 */
24 using ScalarX448 = Strong<std::array<uint8_t, X448_LEN>, struct ScalarX448_>;
25
26 /**
27 * @brief Multiply a scalar with the standard group element (5)
28 *
29 * @param k scalar
30 * @return encoded point
31 */
32 Point448 x448_basepoint(const ScalarX448& k);
33
34 /**
35 * @brief Multiply a scalar @p k with a point @p u
36 *
37 * @param k scalar
38 * @param u point on curve
39 * @return k * u
40 */
41 Point448 x448(const ScalarX448& k, const Point448& u);
42
43 /// Encode a point to a 56 byte vector. RFC 7748 Section 5 (encodeUCoordinate)
44 secure_vector<uint8_t> encode_point(const Point448& p);
45
46 /// Decode a point from a byte array. RFC 7748 Section 5 (decodeUCoordinate)
47 Point448 decode_point(std::span<const uint8_t> p_bytes);
48
49 /// Decode a scalar from a byte array. RFC 7748 Section 5 (decodeScalar448)
50 ScalarX448 decode_scalar(std::span<const uint8_t> scalar_bytes);
51
52 } // namespace Botan
53
54 #endif // BOTAN_X448_INTERNAL_H_