Botan: Botan::RSA_Private_Operation Class Reference

Botan 1.10.12

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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

`#include <rsa.h>`

Inheritance diagram for Botan::RSA_Private_Operation:

## Public Member Functions
SecureVector< byte > | decrypt (const byte msg[], size_t msg_len)
size_t | max_input_bits () const
virtual size_t | message_part_size () const
virtual size_t | message_parts () const
| RSA_Private_Operation (const RSA_PrivateKey &rsa)
SecureVector< byte > | sign (const byte msg[], size_t msg_len, RandomNumberGenerator &rng)

## Detailed Description

RSA private (decrypt/sign) operation

Definition at line 89 of file rsa.h.

## Constructor & Destructor Documentation

Botan::RSA_Private_Operation::RSA_Private_Operation | ( | const RSA_PrivateKey & | rsa | ) |

Definition at line 63 of file rsa.cpp.

References Botan::BigInt::bits(), Botan::Global_State_Management::global_state(), Botan::inverse_mod(), m, Botan::mul_add(), Botan::Modular_Reducer::reduce(), and Botan::sub_mul().

63 :
64 n(rsa.get_n()),
65 q(rsa.get_q()),
66 c(rsa.get_c()),
67 powermod_e_n(rsa.get_e(), rsa.get_n()),
68 powermod_d1_p(rsa.get_d1(), rsa.get_p()),
69 powermod_d2_q(rsa.get_d2(), rsa.get_q()),
70 mod_p(rsa.get_p())
71 {
72 BigInt k(global_state().global_rng(), n.bits() - 1);
73 blinder = Blinder(powermod_e_n(k), inverse_mod(k, n), n);
74 }
Botan::BigInt::bits
size_t bits() const
Definition: bigint.cpp:253
Botan::Global_State_Management::global_state
Library_State & global_state()
Definition: global_state.cpp:32
Botan::inverse_mod
BigInt inverse_mod(const BigInt &n, const BigInt &mod)
Definition: numthry.cpp:202

## Member Function Documentation

SecureVector< byte > Botan::RSA_Private_Operation::decrypt | ( | const byte | msg[],
|  | size_t | msg_len
| ) |  |
| virtual

Implements Botan::PK_Ops::Decryption.

Definition at line 107 of file rsa.cpp.

References Botan::Blinder::blind(), BOTAN_ASSERT, Botan::BigInt::encode(), m, and Botan::Blinder::unblind().

108 {
109 BigInt m(msg, msg_len);
110 BigInt x = blinder.unblind(private_op(blinder.blind(m)));
111
112 BOTAN_ASSERT(m == powermod_e_n(x),
113 "RSA private op failed consistency check");
114
115 return BigInt::encode(x);
116 }
Botan::BigInt::encode
static SecureVector< byte > encode(const BigInt &n, Base base=Binary)
Definition: big_code.cpp:64
m
endian little unaligned ok family x86< aliases > ia32 x86 ix86 i86pc x86pc bepc</aliases >< submodels > i386 i486 i586 i686 pentium2 pentium3 pentium4 pentium m prescott k6 athlon atom32</submodels >< submodel_aliases > pentium i586 pentiumpro i686 pentium_pro i686 pentium2 pentium2 pentiumii pentium2 pentium3 pentium3 pentiumiii pentium3 x86family5 i586 x86family6 i686 pentiumm pentium m intelpentiumm pentium m intelpentium4 pentium4 duron athlon athlon xp athlon k7 athlon p2 i686 p3 i686 p4 pentium4 intelcput2250 prescott intelcput2300 prescott intelcput2400 prescott intelcput2500 prescott intelcput2600 prescott intelcput2700 prescott</submodel_aliases >< isa_extn > pentium m
Definition: x86_32.txt:65
Botan::Blinder::unblind
BigInt unblind(const BigInt &x) const
Definition: blinding.cpp:42
Botan::Blinder::blind
BigInt blind(const BigInt &x) const
Definition: blinding.cpp:29
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, msg)
Definition: assert.h:19

size_t Botan::RSA_Private_Operation::max_input_bits | ( |  | ) | const
| inlinevirtual

Implements Botan::PK_Ops::Decryption.

Definition at line 95 of file rsa.h.

References m.

95 { return (n.bits() - 1); }
Botan::BigInt::bits
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::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::DSA_Signature_Operation, and Botan::NR_Signature_Operation.

Definition at line 56 of file pk_ops.h.

56 { return 1; }

SecureVector< byte > Botan::RSA_Private_Operation::sign | ( | const byte | msg[],
|  | size_t | msg_len,
|  | RandomNumberGenerator & | rng
| ) |  |
| virtual

Implements Botan::PK_Ops::Signature.

Definition at line 90 of file rsa.cpp.

References Botan::Blinder::blind(), Botan::BigInt::bytes(), Botan::BigInt::encode_1363(), m, and Botan::Blinder::unblind().

92 {
93 /* We don't check signatures against powermod_e_n here because
94 PK_Signer checks verification consistency for all signature
95 algorithms.
96 */
97
98 BigInt m(msg, msg_len);
99 BigInt x = blinder.unblind(private_op(blinder.blind(m)));
100 return BigInt::encode_1363(x, n.bytes());
101 }
m
endian little unaligned ok family x86< aliases > ia32 x86 ix86 i86pc x86pc bepc</aliases >< submodels > i386 i486 i586 i686 pentium2 pentium3 pentium4 pentium m prescott k6 athlon atom32</submodels >< submodel_aliases > pentium i586 pentiumpro i686 pentium_pro i686 pentium2 pentium2 pentiumii pentium2 pentium3 pentium3 pentiumiii pentium3 x86family5 i586 x86family6 i686 pentiumm pentium m intelpentiumm pentium m intelpentium4 pentium4 duron athlon athlon xp athlon k7 athlon p2 i686 p3 i686 p4 pentium4 intelcput2250 prescott intelcput2300 prescott intelcput2400 prescott intelcput2500 prescott intelcput2600 prescott intelcput2700 prescott</submodel_aliases >< isa_extn > pentium m
Definition: x86_32.txt:65
Botan::Blinder::unblind
BigInt unblind(const BigInt &x) const
Definition: blinding.cpp:42
Botan::Blinder::blind
BigInt blind(const BigInt &x) const
Definition: blinding.cpp:29
Botan::BigInt::encode_1363
static SecureVector< byte > encode_1363(const BigInt &n, size_t bytes)
Definition: big_code.cpp:78
Botan::BigInt::bytes
size_t bytes() const
Definition: bigint.cpp:245

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

- src/pubkey/rsa/rsa.h
- src/pubkey/rsa/rsa.cpp