Botan: src/pubkey/if_algo/if_algo.h Source File

Botan 1.10.16

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:
24 IF_Scheme_PublicKey(const AlgorithmIdentifier& alg_id,
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:
49 IF_Scheme_PublicKey() {}
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
63 IF_Scheme_PrivateKey(RandomNumberGenerator& rng,
64 const BigInt& prime1, const BigInt& prime2,
65 const BigInt& exp, const BigInt& d_exp,
66 const BigInt& mod);
67
68 IF_Scheme_PrivateKey(RandomNumberGenerator& rng,
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:
99 IF_Scheme_PrivateKey() {}
100
101 BigInt d, p, q, d1, d2, c;
102 };
103
104 }
105
106 #endif
Botan::IF_Scheme_PublicKey::get_n
const BigInt & get_n() const
Definition: if_algo.h:39
Botan::IF_Scheme_PublicKey::n
BigInt n
Definition: if_algo.h:51
Botan::IF_Scheme_PrivateKey::IF_Scheme_PrivateKey
IF_Scheme_PrivateKey()
Definition: if_algo.h:99
Botan::BigInt
Definition: bigint.h:22
Botan::IF_Scheme_PrivateKey
Definition: if_algo.h:58
Botan::RandomNumberGenerator
Definition: rng.h:20
Botan::IF_Scheme_PublicKey
Definition: if_algo.h:21
Botan::Private_Key
Definition: pk_keys.h:86
Botan::IF_Scheme_PublicKey::max_input_bits
size_t max_input_bits() const
Definition: if_algo.h:46
Botan::IF_Scheme_PublicKey::IF_Scheme_PublicKey
IF_Scheme_PublicKey(const BigInt &n, const BigInt &e)
Definition: if_algo.h:27
Botan::IF_Scheme_PrivateKey::get_d
const BigInt & get_d() const
Definition: if_algo.h:90
Botan::IF_Scheme_PrivateKey::get_d2
const BigInt & get_d2() const
Definition: if_algo.h:94
Botan::IF_Scheme_PublicKey::IF_Scheme_PublicKey
IF_Scheme_PublicKey()
Definition: if_algo.h:49
Botan::IF_Scheme_PublicKey::get_e
const BigInt & get_e() const
Definition: if_algo.h:44
Botan::MemoryRegion< byte >
Botan
Definition: algo_base.h:14
Botan::MemoryVector< byte >
Botan::IF_Scheme_PrivateKey::q
BigInt q
Definition: if_algo.h:101
Botan::IF_Scheme_PrivateKey::get_d1
const BigInt & get_d1() const
Definition: if_algo.h:93
Botan::Public_Key
Definition: pk_keys.h:21
Botan::IF_Scheme_PrivateKey::get_q
const BigInt & get_q() const
Definition: if_algo.h:84
Botan::AlgorithmIdentifier
Definition: alg_id.h:20
Botan::IF_Scheme_PrivateKey::get_c
const BigInt & get_c() const
Definition: if_algo.h:92
Botan::IF_Scheme_PrivateKey::get_p
const BigInt & get_p() const
Definition: if_algo.h:78