Botan: Botan::NR_Signature_Operation Class Reference

Botan 1.10.17

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

`#include <nr.h>`

Inheritance diagram for Botan::NR_Signature_Operation:

## 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< byte > | sign (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

## ◆ NR_Signature_Operation()

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

## ◆ max_input_bits()

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); }
Botan::BigInt::bits
size_t bits() const
Definition: bigint.cpp:254

## ◆ message_part_size()

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(); }
Botan::BigInt::bytes
size_t bytes() const
Definition: bigint.cpp:246

## ◆ message_parts()

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; }

## ◆ sign()

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.

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 }
Botan::BigInt::bits
size_t bits() const
Definition: bigint.cpp:254
Botan::Invalid_Argument
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
Botan::BigInt::binary_encode
void binary_encode(byte buf[]) const
Definition: bigint.cpp:341
Botan::BigInt::bytes
size_t bytes() const
Definition: bigint.cpp:246
Botan::Modular_Reducer::reduce
BigInt reduce(const BigInt &x) const
Definition: reducer.cpp:32

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

- src/pubkey/nr/nr.h
- src/pubkey/nr/nr.cpp