Coverage Report

Created: 2024-11-29 06:10

/src/botan/build/include/public/botan/curve_gfp.h
Line
Count
Source
1
/*
2
* Elliptic curves over GF(p)
3
*
4
* (C) 2007 Martin Doering, Christoph Ludwig, Falko Strenzke
5
*     2010-2011,2012,2014,2024 Jack Lloyd
6
*
7
* Botan is released under the Simplified BSD License (see license.txt)
8
*/
9
10
#ifndef BOTAN_GFP_CURVE_H_
11
#define BOTAN_GFP_CURVE_H_
12
13
#include <botan/bigint.h>
14
15
// Currently exposed in EC_Point
16
//BOTAN_FUTURE_INTERNAL_HEADER(curve_gfp.h)
17
18
namespace Botan {
19
20
class EC_Group_Data;
21
22
/**
23
* This is an internal type which is only exposed for accidental
24
* historical reasons. Do not use it in any way.
25
*
26
* This class will be removed in Botan4.
27
*/
28
class BOTAN_UNSTABLE_API CurveGFp final {
29
   public:
30
      /**
31
      * @return curve coefficient a
32
      */
33
      const BigInt& get_a() const;
34
35
      /**
36
      * @return curve coefficient b
37
      */
38
      const BigInt& get_b() const;
39
40
      /**
41
      * Get prime modulus of the field of the curve
42
      * @return prime modulus of the field of the curve
43
      */
44
      const BigInt& get_p() const;
45
46
      size_t get_p_words() const;
47
48
      CurveGFp(const CurveGFp&) = default;
49
50
   private:
51
      friend class EC_Point;
52
      friend class EC_Group_Data;
53
54
      /**
55
      * Create an uninitialized CurveGFp
56
      */
57
791k
      CurveGFp() = default;
58
59
      CurveGFp(const EC_Group_Data* group);
60
61
      CurveGFp& operator=(const CurveGFp&) = default;
62
63
675k
      void swap(CurveGFp& other) { std::swap(m_group, other.m_group); }
64
65
1.08M
      bool operator==(const CurveGFp& other) const { return (m_group == other.m_group); }
66
67
   private:
68
3.50M
      const EC_Group_Data& group() const {
69
3.50M
         BOTAN_ASSERT_NONNULL(m_group);
70
3.50M
         return *m_group;
71
3.50M
      }
72
73
      /**
74
      * Raw pointer
75
      *
76
      * This EC_Group_Data is not owned because instead the EC_Group_Data
77
      * owns this CurveGFp, so we can always access it safely. If it was
78
      * a shared_ptr this would cause a reference cycle.
79
      */
80
      const EC_Group_Data* m_group = nullptr;
81
};
82
83
}  // namespace Botan
84
85
#endif