Botan  1.10.9
if_algo.h
Go to the documentation of this file.
1 /*
2 * IF Scheme
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7 
8 #ifndef BOTAN_IF_ALGO_H__
9 #define BOTAN_IF_ALGO_H__
10 
11 #include <botan/bigint.h>
12 #include <botan/x509_key.h>
13 #include <botan/pkcs8.h>
14 
15 namespace Botan {
16 
17 /**
18 * This class represents public keys
19 * of integer factorization based (IF) public key schemes.
20 */
21 class BOTAN_DLL IF_Scheme_PublicKey : public virtual Public_Key
22  {
23  public:
25  const MemoryRegion<byte>& key_bits);
26 
27  IF_Scheme_PublicKey(const BigInt& n, const BigInt& e) :
28  n(n), e(e) {}
29 
30  bool check_key(RandomNumberGenerator& rng, bool) const;
31 
32  AlgorithmIdentifier algorithm_identifier() const;
33 
34  MemoryVector<byte> x509_subject_public_key() const;
35 
36  /**
37  * @return public modulus
38  */
39  const BigInt& get_n() const { return n; }
40 
41  /**
42  * @return public exponent
43  */
44  const BigInt& get_e() const { return e; }
45 
46  size_t max_input_bits() const { return (n.bits() - 1); }
47 
48  protected:
50 
51  BigInt n, e;
52  };
53 
54 /**
55 * This class represents public keys
56 * of integer factorization based (IF) public key schemes.
57 */
58 class BOTAN_DLL IF_Scheme_PrivateKey : public virtual IF_Scheme_PublicKey,
59  public virtual Private_Key
60  {
61  public:
62 
64  const BigInt& prime1, const BigInt& prime2,
65  const BigInt& exp, const BigInt& d_exp,
66  const BigInt& mod);
67 
69  const AlgorithmIdentifier& alg_id,
70  const MemoryRegion<byte>& key_bits);
71 
72  bool check_key(RandomNumberGenerator& rng, bool) const;
73 
74  /**
75  * Get the first prime p.
76  * @return prime p
77  */
78  const BigInt& get_p() const { return p; }
79 
80  /**
81  * Get the second prime q.
82  * @return prime q
83  */
84  const BigInt& get_q() const { return q; }
85 
86  /**
87  * Get d with exp * d = 1 mod (p - 1, q - 1).
88  * @return d
89  */
90  const BigInt& get_d() const { return d; }
91 
92  const BigInt& get_c() const { return c; }
93  const BigInt& get_d1() const { return d1; }
94  const BigInt& get_d2() const { return d2; }
95 
96  MemoryVector<byte> pkcs8_private_key() const;
97 
98  protected:
100 
101  BigInt d, p, q, d1, d2, c;
102  };
103 
104 }
105 
106 #endif
BigInt n
Definition: numthry.cpp:26
const BigInt & get_d2() const
Definition: if_algo.h:94
const BigInt & get_p() const
Definition: if_algo.h:78
size_t max_input_bits() const
Definition: if_algo.h:46
const BigInt & get_e() const
Definition: if_algo.h:44
const BigInt & get_d() const
Definition: if_algo.h:90
IF_Scheme_PublicKey(const BigInt &n, const BigInt &e)
Definition: if_algo.h:27
RandomNumberGenerator * rng
Definition: global_rng.cpp:165
const BigInt & get_c() const
Definition: if_algo.h:92
const BigInt & get_d1() const
Definition: if_algo.h:93
GMP_MPZ exp
Definition: gmp_powm.cpp:29
GMP_MPZ mod
Definition: gmp_powm.cpp:29
const BigInt & get_n() const
Definition: if_algo.h:39
const BigInt & get_q() const
Definition: if_algo.h:84