Botan  1.10.9
Public Member Functions | List of all members
Botan::NR_Signature_Operation Class Reference

#include <nr.h>

Inheritance diagram for Botan::NR_Signature_Operation:
Botan::PK_Ops::Signature

Public Member Functions

size_t max_input_bits () const
 
size_t message_part_size () const
 
size_t message_parts () const
 
 NR_Signature_Operation (const NR_PrivateKey &nr)
 
SecureVector< bytesign (const byte msg[], size_t msg_len, RandomNumberGenerator &rng)
 

Detailed Description

Nyberg-Rueppel signature operation

Definition at line 61 of file nr.h.

Constructor & Destructor Documentation

Botan::NR_Signature_Operation::NR_Signature_Operation ( const NR_PrivateKey nr)

Definition at line 74 of file nr.cpp.

74  :
75  q(nr.group_q()),
76  x(nr.get_x()),
77  powermod_g_p(nr.group_g(), nr.group_p()),
78  mod_q(nr.group_q())
79  {
80  }

Member Function Documentation

size_t Botan::NR_Signature_Operation::max_input_bits ( ) const
inlinevirtual

Get the maximum message size in bits supported by this public key.

Returns
maximum message in bits

Implements Botan::PK_Ops::Signature.

Definition at line 68 of file nr.h.

68 { return (q.bits() - 1); }
size_t bits() const
Definition: bigint.cpp:253
size_t Botan::NR_Signature_Operation::message_part_size ( ) const
inlinevirtual

Find out the message part size supported by this scheme/key.

Returns
size of the message parts

Reimplemented from Botan::PK_Ops::Signature.

Definition at line 67 of file nr.h.

67 { return q.bytes(); }
size_t bytes() const
Definition: bigint.cpp:245
size_t Botan::NR_Signature_Operation::message_parts ( ) const
inlinevirtual

Find out the number of message parts supported by this scheme.

Returns
number of message parts

Reimplemented from Botan::PK_Ops::Signature.

Definition at line 66 of file nr.h.

66 { return 2; }
SecureVector< byte > Botan::NR_Signature_Operation::sign ( const byte  msg[],
size_t  msg_len,
RandomNumberGenerator rng 
)
virtual

Implements Botan::PK_Ops::Signature.

Definition at line 83 of file nr.cpp.

References Botan::RandomNumberGenerator::add_entropy(), Botan::BigInt::binary_encode(), Botan::BigInt::bits(), Botan::BigInt::bytes(), Botan::BigInt::randomize(), and Botan::Modular_Reducer::reduce().

85  {
86  rng.add_entropy(msg, msg_len);
87 
88  BigInt f(msg, msg_len);
89 
90  if(f >= q)
91  throw Invalid_Argument("NR_Signature_Operation: Input is out of range");
92 
93  BigInt c, d;
94 
95  while(c == 0)
96  {
97  BigInt k;
98  do
99  k.randomize(rng, q.bits());
100  while(k >= q);
101 
102  c = mod_q.reduce(powermod_g_p(k) + f);
103  d = mod_q.reduce(k - x * c);
104  }
105 
106  SecureVector<byte> output(2*q.bytes());
107  c.binary_encode(&output[output.size() / 2 - c.bytes()]);
108  d.binary_encode(&output[output.size() - d.bytes()]);
109  return output;
110  }
void binary_encode(byte buf[]) const
Definition: bigint.cpp:340
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
size_t bits() const
Definition: bigint.cpp:253
RandomNumberGenerator * rng
Definition: global_rng.cpp:165
BigInt reduce(const BigInt &x) const
Definition: reducer.cpp:32
size_t bytes() const
Definition: bigint.cpp:245

The documentation for this class was generated from the following files: