Botan  1.10.9
nr.h
Go to the documentation of this file.
1 /*
2 * Nyberg-Rueppel
3 * (C) 1999-2010 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7 
8 #ifndef BOTAN_NYBERG_RUEPPEL_H__
9 #define BOTAN_NYBERG_RUEPPEL_H__
10 
11 #include <botan/dl_algo.h>
12 #include <botan/pk_ops.h>
13 #include <botan/numthry.h>
14 #include <botan/reducer.h>
15 
16 namespace Botan {
17 
18 /**
19 * Nyberg-Rueppel Public Key
20 */
21 class BOTAN_DLL NR_PublicKey : public virtual DL_Scheme_PublicKey
22  {
23  public:
24  std::string algo_name() const { return "NR"; }
25 
27 
28  size_t message_parts() const { return 2; }
29  size_t message_part_size() const { return group_q().bytes(); }
30  size_t max_input_bits() const { return (group_q().bits() - 1); }
31 
32  NR_PublicKey(const AlgorithmIdentifier& alg_id,
33  const MemoryRegion<byte>& key_bits);
34 
35  NR_PublicKey(const DL_Group& group, const BigInt& pub_key);
36  protected:
38  };
39 
40 /**
41 * Nyberg-Rueppel Private Key
42 */
43 class BOTAN_DLL NR_PrivateKey : public NR_PublicKey,
44  public virtual DL_Scheme_PrivateKey
45  {
46  public:
47  bool check_key(RandomNumberGenerator& rng, bool strong) const;
48 
49  NR_PrivateKey(const AlgorithmIdentifier& alg_id,
50  const MemoryRegion<byte>& key_bits,
52 
54  const DL_Group& group,
55  const BigInt& x = 0);
56  };
57 
58 /**
59 * Nyberg-Rueppel signature operation
60 */
61 class BOTAN_DLL NR_Signature_Operation : public PK_Ops::Signature
62  {
63  public:
65 
66  size_t message_parts() const { return 2; }
67  size_t message_part_size() const { return q.bytes(); }
68  size_t max_input_bits() const { return (q.bits() - 1); }
69 
70  SecureVector<byte> sign(const byte msg[], size_t msg_len,
72  private:
73  const BigInt& q;
74  const BigInt& x;
75  Fixed_Base_Power_Mod powermod_g_p;
76  Modular_Reducer mod_q;
77  };
78 
79 /**
80 * Nyberg-Rueppel verification operation
81 */
83  {
84  public:
86 
87  size_t message_parts() const { return 2; }
88  size_t message_part_size() const { return q.bytes(); }
89  size_t max_input_bits() const { return (q.bits() - 1); }
90 
91  bool with_recovery() const { return true; }
92 
93  SecureVector<byte> verify_mr(const byte msg[], size_t msg_len);
94  private:
95  const BigInt& q;
96  const BigInt& y;
97 
98  Fixed_Base_Power_Mod powermod_g_p, powermod_y_p;
99  Modular_Reducer mod_p, mod_q;
100  };
101 
102 }
103 
104 #endif
size_t max_input_bits() const
Definition: nr.h:30
size_t max_input_bits() const
Definition: nr.h:89
size_t message_parts() const
Definition: nr.h:87
size_t max_input_bits() const
Definition: nr.h:68
size_t message_parts() const
Definition: nr.h:66
DL_Group::Format group_format() const
Definition: nr.h:26
unsigned char byte
Definition: types.h:22
RandomNumberGenerator * rng
Definition: global_rng.cpp:165
size_t message_part_size() const
Definition: nr.h:88
size_t message_part_size() const
Definition: nr.h:29
bool with_recovery() const
Definition: nr.h:91
size_t message_part_size() const
Definition: nr.h:67
std::string algo_name() const
Definition: nr.h:24
size_t message_parts() const
Definition: nr.h:28