Botan 1.10.17

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
26 DL_Group::Format group_format() const { return DL_Group::ANSI_X9_57; }
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:
37 NR_PublicKey() {}
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,
51 RandomNumberGenerator& rng);
52
53 NR_PrivateKey(RandomNumberGenerator& rng,
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:
64 NR_Signature_Operation(const NR_PrivateKey& nr);
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,
71 RandomNumberGenerator& rng);
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 */
82 class BOTAN_DLL NR_Verification_Operation : public PK_Ops::Verification
83 {
84 public:
85 NR_Verification_Operation(const NR_PublicKey& nr);
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
Botan::NR_PublicKey::max_input_bits
size_t max_input_bits() const
Definition: nr.h:30
Botan::DL_Scheme_PrivateKey
Definition: dl_algo.h:85
Botan::NR_PublicKey::message_parts
size_t message_parts() const
Definition: nr.h:28
Botan::Fixed_Base_Power_Mod
Definition: pow_mod.h:87
Botan::BigInt
Definition: bigint.h:22
Botan::RandomNumberGenerator
Definition: rng.h:20
Botan::DL_Group::ANSI_X9_57
Definition: dl_group.h:46
Botan::NR_Verification_Operation::message_parts
size_t message_parts() const
Definition: nr.h:87
Botan::DL_Scheme_PublicKey
Definition: dl_algo.h:20
Botan::PK_Ops::Signature
Definition: pk_ops.h:49
Botan::NR_Signature_Operation
Definition: nr.h:61
Botan::NR_Verification_Operation::message_part_size
size_t message_part_size() const
Definition: nr.h:88
Botan::NR_PublicKey::message_part_size
size_t message_part_size() const
Definition: nr.h:29
Botan::NR_PublicKey::NR_PublicKey
NR_PublicKey()
Definition: nr.h:37
Botan::byte
unsigned char byte
Definition: types.h:22
Botan::NR_Verification_Operation
Definition: nr.h:82
Botan::NR_Verification_Operation::max_input_bits
size_t max_input_bits() const
Definition: nr.h:89
Botan::DL_Group
Definition: dl_group.h:20
Botan::DL_Group::Format
Format
Definition: dl_group.h:44
Botan::NR_PrivateKey
Definition: nr.h:43
Botan::NR_PublicKey::algo_name
std::string algo_name() const
Definition: nr.h:24
Botan::NR_Signature_Operation::message_part_size
size_t message_part_size() const
Definition: nr.h:67
Botan::NR_Signature_Operation::max_input_bits
size_t max_input_bits() const
Definition: nr.h:68
Botan::MemoryRegion< byte >
Botan
Definition: algo_base.h:14
Botan::NR_PublicKey
Definition: nr.h:21
Botan::NR_Signature_Operation::message_parts
size_t message_parts() const
Definition: nr.h:66
Botan::NR_Verification_Operation::with_recovery
bool with_recovery() const
Definition: nr.h:91
Botan::AlgorithmIdentifier
Definition: alg_id.h:20
Botan::NR_PublicKey::group_format
DL_Group::Format group_format() const
Definition: nr.h:26
Botan::SecureVector< byte >
Botan::Modular_Reducer
Definition: reducer.h:18
Botan::PK_Ops::Verification
Definition: pk_ops.h:85