Botan 1.10.17
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

◆ RW_Signature_Operation()

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 }

Referenced by Botan::Core_Engine::get_signature_op().

Member Function Documentation

◆ max_input_bits()

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.

70{ return (n.bits() - 1); }

◆ message_part_size()

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::DSA_Signature_Operation, Botan::ECDSA_Signature_Operation, and Botan::NR_Signature_Operation.

Definition at line 62 of file pk_ops.h.

62{ return 0; }

◆ message_parts()

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::DSA_Signature_Operation, Botan::ECDSA_Signature_Operation, and Botan::NR_Signature_Operation.

Definition at line 56 of file pk_ops.h.

56{ return 1; }

◆ sign()

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.

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 }
static SecureVector< byte > encode_1363(const BigInt &n, size_t bytes)
Definition big_code.cpp:78
BigInt inverse_mod(const BigInt &n, const BigInt &mod)
Definition numthry.cpp:314
BigInt power_mod(const BigInt &base, const BigInt &exp, const BigInt &mod)
Definition numthry.cpp:366
BigInt mul_add(const BigInt &a, const BigInt &b, const BigInt &c)
Definition mp_numth.cpp:33
s32bit jacobi(const BigInt &a, const BigInt &n)
Definition jacobi.cpp:15
std::invalid_argument Invalid_Argument
Definition exceptn.h:20
BigInt sub_mul(const BigInt &a, const BigInt &b, const BigInt &c)
Definition mp_numth.cpp:60

References Botan::Blinder::Blinder(), Botan::BigInt::bytes(), Botan::BigInt::encode_1363(), Botan::inverse_mod(), Botan::jacobi(), Botan::mul_add(), Botan::power_mod(), and Botan::sub_mul().


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