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

#include <rw.h>

Inheritance diagram for Botan::RW_Signature_Operation:
Botan::PK_Ops::Signature

Public Member Functions

size_t max_input_bits () const
 
virtual size_t message_part_size () const
 
virtual size_t message_parts () const
 
 RW_Signature_Operation (const RW_PrivateKey &rw)
 
SecureVector< bytesign (const byte msg[], size_t msg_len, RandomNumberGenerator &rng)
 

Detailed Description

Rabin-Williams Signature Operation

Definition at line 65 of file rw.h.

Constructor & Destructor Documentation

Botan::RW_Signature_Operation::RW_Signature_Operation ( const RW_PrivateKey rw)

Definition at line 62 of file rw.cpp.

62  :
63  n(rw.get_n()),
64  e(rw.get_e()),
65  q(rw.get_q()),
66  c(rw.get_c()),
67  powermod_d1_p(rw.get_d1(), rw.get_p()),
68  powermod_d2_q(rw.get_d2(), rw.get_q()),
69  mod_p(rw.get_p())
70  {
71  }

Member Function Documentation

size_t Botan::RW_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 70 of file rw.h.

References n.

70 { return (n.bits() - 1); }
size_t bits() const
Definition: bigint.cpp:253
virtual size_t Botan::PK_Ops::Signature::message_part_size ( ) const
inlinevirtualinherited

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

Returns
size of the message parts

Reimplemented in Botan::ECDSA_Signature_Operation, Botan::GOST_3410_Signature_Operation, Botan::DSA_Signature_Operation, and Botan::NR_Signature_Operation.

Definition at line 62 of file pk_ops.h.

62 { return 0; }
virtual size_t Botan::PK_Ops::Signature::message_parts ( ) const
inlinevirtualinherited

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

Returns
number of message parts

Reimplemented in Botan::ECDSA_Signature_Operation, Botan::GOST_3410_Signature_Operation, Botan::DSA_Signature_Operation, and Botan::NR_Signature_Operation.

Definition at line 56 of file pk_ops.h.

Referenced by Botan::PK_Signer::signature().

56 { return 1; }
SecureVector< byte > Botan::RW_Signature_Operation::sign ( const byte  msg[],
size_t  msg_len,
RandomNumberGenerator rng 
)
virtual

Implements Botan::PK_Ops::Signature.

Definition at line 74 of file rw.cpp.

References Botan::BigInt::bits(), Botan::Blinder::blind(), Botan::BigInt::bytes(), Botan::BigInt::encode_1363(), Botan::Blinder::initialized(), Botan::inverse_mod(), Botan::jacobi(), Botan::mul_add(), Botan::power_mod(), r, Botan::Modular_Reducer::reduce(), Botan::sub_mul(), and Botan::Blinder::unblind().

76  {
77  if(!blinder.initialized())
78  {
79  BigInt k(rng, n.bits() / 2);
80  blinder = Blinder(power_mod(k, e, n), inverse_mod(k, n), n);
81  }
82 
83  BigInt i(msg, msg_len);
84 
85  if(i >= n || i % 16 != 12)
86  throw Invalid_Argument("Rabin-Williams: invalid input");
87 
88  if(jacobi(i, n) != 1)
89  i >>= 1;
90 
91  i = blinder.blind(i);
92 
93  BigInt j1 = powermod_d1_p(i);
94  BigInt j2 = powermod_d2_q(i);
95  j1 = mod_p.reduce(sub_mul(j1, j2, c));
96 
97  BigInt r = blinder.unblind(mul_add(j1, q, j2));
98 
99  r = std::min(r, n - r);
100 
101  return BigInt::encode_1363(r, n.bytes());
102  }
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
bool initialized() const
Definition: blinding.h:25
size_t bits() const
Definition: bigint.cpp:253
RandomNumberGenerator * rng
Definition: global_rng.cpp:165
s32bit jacobi(const BigInt &a, const BigInt &n)
Definition: jacobi.cpp:15
BigInt reduce(const BigInt &x) const
Definition: reducer.cpp:32
BigInt inverse_mod(const BigInt &n, const BigInt &mod)
Definition: numthry.cpp:202
BigInt sub_mul(const BigInt &a, const BigInt &b, const BigInt &c)
Definition: mp_numth.cpp:60
BigInt power_mod(const BigInt &base, const BigInt &exp, const BigInt &mod)
Definition: numthry.cpp:251
BigInt r
Definition: numthry.cpp:26
static SecureVector< byte > encode_1363(const BigInt &n, size_t bytes)
Definition: big_code.cpp:78
BigInt mul_add(const BigInt &a, const BigInt &b, const BigInt &c)
Definition: mp_numth.cpp:33
size_t bytes() const
Definition: bigint.cpp:245

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