Botan  1.10.9
Public Member Functions | List of all members
Botan::Buffered_Computation Class Referenceabstract

#include <buf_comp.h>

Inheritance diagram for Botan::Buffered_Computation:
Botan::HashFunction Botan::MessageAuthenticationCode Botan::Adler32 Botan::Comb4P Botan::CRC24 Botan::CRC32 Botan::GOST_34_11 Botan::Keccak_1600 Botan::MD2 Botan::MDx_HashFunction Botan::Parallel Botan::Skein_512 Botan::ANSI_X919_MAC Botan::CBC_MAC Botan::CMAC Botan::HMAC Botan::SSL3_MAC

Public Member Functions

void final (byte out[])
 
SecureVector< bytefinal ()
 
virtual size_t output_length () const =0
 
SecureVector< byteprocess (const byte in[], size_t length)
 
SecureVector< byteprocess (const MemoryRegion< byte > &in)
 
SecureVector< byteprocess (const std::string &in)
 
void update (const byte in[], size_t length)
 
void update (const MemoryRegion< byte > &in)
 
void update (const std::string &str)
 
void update (byte in)
 
template<typename T >
void update_be (const T in)
 
virtual ~Buffered_Computation ()
 

Detailed Description

This class represents any kind of computation which uses an internal state, such as hash functions or MACs

Definition at line 20 of file buf_comp.h.

Constructor & Destructor Documentation

virtual Botan::Buffered_Computation::~Buffered_Computation ( )
inlinevirtual

Definition at line 131 of file buf_comp.h.

131 {}

Member Function Documentation

void Botan::Buffered_Computation::final ( byte  out[])
inline
SecureVector<byte> Botan::Buffered_Computation::final ( )
inline

Complete the computation and retrieve the final result.

Returns
SecureVector holding the result

Definition at line 87 of file buf_comp.h.

88  {
89  SecureVector<byte> output(output_length());
90  final_result(&output[0]);
91  return output;
92  }
virtual size_t output_length() const =0
virtual size_t Botan::Buffered_Computation::output_length ( ) const
pure virtual
SecureVector<byte> Botan::Buffered_Computation::process ( const byte  in[],
size_t  length 
)
inline

Update and finalize computation. Does the same as calling update() and final() consecutively.

Parameters
inthe input to process as a byte array
lengththe length of the byte array
Returns
the result of the call to final()

Definition at line 101 of file buf_comp.h.

Referenced by Botan::Randpool::add_entropy(), Botan::EME1::EME1(), Botan::RTSS_Share::split(), and Botan::Cert_Extension::Subject_Key_ID::Subject_Key_ID().

102  {
103  add_data(in, length);
104  return final();
105  }
SecureVector<byte> Botan::Buffered_Computation::process ( const MemoryRegion< byte > &  in)
inline

Update and finalize computation. Does the same as calling update() and final() consecutively.

Parameters
inthe input to process
Returns
the result of the call to final()

Definition at line 113 of file buf_comp.h.

References Botan::MemoryRegion< T >::size().

114  {
115  add_data(&in[0], in.size());
116  return final();
117  }
size_t size() const
Definition: secmem.h:29
SecureVector<byte> Botan::Buffered_Computation::process ( const std::string &  in)
inline

Update and finalize computation. Does the same as calling update() and final() consecutively.

Parameters
inthe input to process as a string
Returns
the result of the call to final()

Definition at line 125 of file buf_comp.h.

126  {
127  update(in);
128  return final();
129  }
void update(const byte in[], size_t length)
Definition: buf_comp.h:33
void Botan::Buffered_Computation::update ( const byte  in[],
size_t  length 
)
inline
void Botan::Buffered_Computation::update ( const MemoryRegion< byte > &  in)
inline

Add new input to process.

Parameters
inthe input to process as a MemoryRegion

Definition at line 39 of file buf_comp.h.

References Botan::MemoryRegion< T >::size().

40  {
41  add_data(&in[0], in.size());
42  }
size_t size() const
Definition: secmem.h:29
void Botan::Buffered_Computation::update ( const std::string &  str)
inline

Add new input to process.

Parameters
strthe input to process as a std::string. Will be interpreted as a byte array based on the strings encoding.

Definition at line 63 of file buf_comp.h.

64  {
65  add_data(reinterpret_cast<const byte*>(str.data()), str.size());
66  }
void Botan::Buffered_Computation::update ( byte  in)
inline

Process a single byte.

Parameters
inthe byte to process

Definition at line 72 of file buf_comp.h.

72 { add_data(&in, 1); }
template<typename T >
void Botan::Buffered_Computation::update_be ( const T  in)
inline

Add an integer in big-endian order

Parameters
inthe value

Definition at line 48 of file buf_comp.h.

References Botan::get_byte().

Referenced by Botan::KDF2::derive(), Botan::PKCS5_PBKDF2::derive_key(), Botan::Record_Reader::get_record(), and Botan::MGF1::mask().

49  {
50  for(size_t i = 0; i != sizeof(T); ++i)
51  {
52  byte b = get_byte(i, in);
53  add_data(&b, 1);
54  }
55  }
byte get_byte(size_t byte_num, T input)
Definition: get_byte.h:21
unsigned char byte
Definition: types.h:22

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