Botan  1.11.15
Public Types | Public Member Functions | Static Public Member Functions
Botan::OAEP Class Reference

#include <oaep.h>

Inheritance diagram for Botan::OAEP:
Botan::EME

List of all members.

Public Types

typedef SCAN_Name Spec

Public Member Functions

secure_vector< bytedecode (const byte in[], size_t in_length, size_t key_length) const
secure_vector< bytedecode (const secure_vector< byte > &in, size_t key_length) const
secure_vector< byteencode (const byte in[], size_t in_length, size_t key_length, RandomNumberGenerator &rng) const
secure_vector< byteencode (const secure_vector< byte > &in, size_t key_length, RandomNumberGenerator &rng) const
size_t maximum_input_size (size_t) const
 OAEP (HashFunction *hash, const std::string &P="")

Static Public Member Functions

static OAEPmake (const Spec &spec)

Detailed Description

OAEP (called EME1 in IEEE 1363 and in earlier versions of the library)

Definition at line 20 of file oaep.h.


Member Typedef Documentation

typedef SCAN_Name Botan::EME::Spec [inherited]

Definition at line 23 of file eme.h.


Constructor & Destructor Documentation

Botan::OAEP::OAEP ( HashFunction hash,
const std::string &  P = "" 
)
Parameters:
hashobject to use for hashing (takes ownership)
Pan optional label. Normally empty.

Definition at line 150 of file oaep.cpp.

Referenced by make().

                                                 : m_hash(hash)
   {
   m_Phash = m_hash->process(P);
   }

Member Function Documentation

secure_vector< byte > Botan::EME::decode ( const byte  in[],
size_t  in_length,
size_t  key_length 
) const [inherited]

Decode an input

Parameters:
inthe encoded plaintext
in_lengthlength of encoded plaintext in bytes
key_lengthlength of the key in bits
Returns:
plaintext

Definition at line 35 of file eme.cpp.

   {
   return unpad(msg, msg_len, key_bits);
   }
secure_vector< byte > Botan::EME::decode ( const secure_vector< byte > &  in,
size_t  key_length 
) const [inherited]

Decode an input

Parameters:
inthe encoded plaintext
key_lengthlength of the key in bits
Returns:
plaintext

Definition at line 44 of file eme.cpp.

   {
   return unpad(&msg[0], msg.size(), key_bits);
   }
secure_vector< byte > Botan::EME::encode ( const byte  in[],
size_t  in_length,
size_t  key_length,
RandomNumberGenerator rng 
) const [inherited]

Encode an input

Parameters:
inthe plaintext
in_lengthlength of plaintext in bytes
key_lengthlength of the key in bits
rnga random number generator
Returns:
encoded plaintext

Definition at line 15 of file eme.cpp.

   {
   return pad(msg, msg_len, key_bits, rng);
   }
secure_vector< byte > Botan::EME::encode ( const secure_vector< byte > &  in,
size_t  key_length,
RandomNumberGenerator rng 
) const [inherited]

Encode an input

Parameters:
inthe plaintext
key_lengthlength of the key in bits
rnga random number generator
Returns:
encoded plaintext

Definition at line 25 of file eme.cpp.

   {
   return pad(&msg[0], msg.size(), key_bits, rng);
   }
OAEP * Botan::OAEP::make ( const Spec spec) [static]

Definition at line 16 of file oaep.cpp.

References Botan::SCAN_Name::algo_name(), Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_count(), Botan::SCAN_Name::arg_count_between(), and OAEP().

   {
   if(request.algo_name() == "OAEP" && request.arg_count_between(1, 2))
      {
      auto& hashes = Algo_Registry<HashFunction>::global_registry();

      if(request.arg_count() == 1 ||
         (request.arg_count() == 2 && request.arg(1) == "MGF1"))
         {
         if(HashFunction* hash = hashes.make(request.arg(0)))
            return new OAEP(hash);
         }
      }

   return nullptr;
   }
size_t Botan::OAEP::maximum_input_size ( size_t  keybits) const [virtual]

Return the maximum input size in bytes we can support

Parameters:
keybitsthe size of the key in bits
Returns:
upper bound of input in bytes

Implements Botan::EME.

Definition at line 139 of file oaep.cpp.

   {
   if(keybits / 8 > 2*m_Phash.size() + 1)
      return ((keybits / 8) - 2*m_Phash.size() - 1);
   else
      return 0;
   }

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