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
16namespace Botan {
17
18/**
19* Nyberg-Rueppel Public Key
20*/
21class 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
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*/
43class 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
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*/
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
DL_Scheme_PrivateKey(const AlgorithmIdentifier &alg_id, const MemoryRegion< byte > &key_bits, DL_Group::Format group_format)
Definition dl_algo.cpp:41
DL_Scheme_PublicKey(const AlgorithmIdentifier &alg_id, const MemoryRegion< byte > &key_bits, DL_Group::Format group_format)
Definition dl_algo.cpp:26
const BigInt & group_q() const
Definition dl_algo.h:50
NR_PrivateKey(const AlgorithmIdentifier &alg_id, const MemoryRegion< byte > &key_bits, RandomNumberGenerator &rng)
Definition nr.cpp:50
bool check_key(RandomNumberGenerator &rng, bool strong) const
Definition nr.cpp:63
std::string algo_name() const
Definition nr.h:24
size_t message_parts() const
Definition nr.h:28
size_t max_input_bits() const
Definition nr.h:30
size_t message_part_size() const
Definition nr.h:29
NR_PublicKey(const AlgorithmIdentifier &alg_id, const MemoryRegion< byte > &key_bits)
Definition nr.cpp:14
DL_Group::Format group_format() const
Definition nr.h:26
NR_Signature_Operation(const NR_PrivateKey &nr)
Definition nr.cpp:74
size_t message_part_size() const
Definition nr.h:67
size_t message_parts() const
Definition nr.h:66
size_t max_input_bits() const
Definition nr.h:68
size_t max_input_bits() const
Definition nr.h:89
size_t message_part_size() const
Definition nr.h:88
size_t message_parts() const
Definition nr.h:87
bool with_recovery() const
Definition nr.h:91
NR_Verification_Operation(const NR_PublicKey &nr)
Definition nr.cpp:112