IBR-DTNSuite  0.8
ibrcommon::RSASHA256Stream Class Reference

#include <RSASHA256Stream.h>

List of all members.

Public Types

typedef std::char_traits< char > traits

Public Member Functions

 RSASHA256Stream (EVP_PKEY *const pkey, bool verfiy=false)
virtual ~RSASHA256Stream ()
void reset ()
const std::pair< const int,
const std::string > 
getSign ()
int getVerification (const std::string &their_sign)

Static Public Attributes

static const size_t BUFF_SIZE = 2048

Protected Member Functions

virtual int sync ()
virtual traits::int_type overflow (traits::int_type=traits::eof())

Detailed Description

Calculates the signature of the data, which is streamed into it. The data will be hashed using SHA256 and this hash will be signed using RSA and the supplied key. You can stream as much data into it as you want. When calling getSign() the signature will be created and the stream reset.

Definition at line 17 of file RSASHA256Stream.h.


Member Typedef Documentation

typedef std::char_traits<char> ibrcommon::RSASHA256Stream::traits

Definition at line 20 of file RSASHA256Stream.h.


Constructor & Destructor Documentation

ibrcommon::RSASHA256Stream::RSASHA256Stream ( EVP_PKEY *const  pkey,
bool  verfiy = false 
)

Creates a RSASHA256Stream object. And tells if it shall verify or calculate a signature.

Parameters:
pkeythe public or private key to be used
verfiyif true, the signature will be verified, which will be given by calling getVerification()

Definition at line 7 of file RSASHA256Stream.cpp.

References BUFF_SIZE, IBRCOMMON_LOGGER, and IBRCOMMON_LOGGER_ENDL.

cleans the output buffer and the openssl context

Definition at line 32 of file RSASHA256Stream.cpp.


Member Function Documentation

const std::pair< const int, const std::string > ibrcommon::RSASHA256Stream::getSign ( )

After signing this method will return a pair containing the return code and the signature itself.

Returns:
a pair containing return code and signature. the first item is the return code, which will be 1 for success and 0 for failure. The second item will be the signature.

Definition at line 64 of file RSASHA256Stream.cpp.

References sync().

Here is the call graph for this function:

int ibrcommon::RSASHA256Stream::getVerification ( const std::string &  their_sign)

Verifies a foreign given signature.

Parameters:
their_signthe signature to be verified
Returns:
returns 1 for a correct signature, 0 for failure and -1 if some other error occurred

Definition at line 83 of file RSASHA256Stream.cpp.

References sync().

Here is the call graph for this function:

RSASHA256Stream::traits::int_type ibrcommon::RSASHA256Stream::overflow ( traits::int_type  = traits::eof()) [protected, virtual]

Writes all data from the buffer into the openssl context and clears the buffer.

Parameters:
cthe last char, for which was not room anymore in the buffer
Returns:
something that has to do with more characters following or not

Definition at line 105 of file RSASHA256Stream.cpp.

References BUFF_SIZE, IBRCOMMON_LOGGER, and IBRCOMMON_LOGGER_ENDL.

Referenced by sync().

Resets the stream and cleans up the context, which is used for calculating the signature.

Definition at line 38 of file RSASHA256Stream.cpp.

References IBRCOMMON_LOGGER, and IBRCOMMON_LOGGER_ENDL.

int ibrcommon::RSASHA256Stream::sync ( ) [protected, virtual]

Writes all unwritten data out of the buffer and into the openssl context for creation of the signature.

Returns:
maybe the last character

Definition at line 96 of file RSASHA256Stream.cpp.

References overflow().

Referenced by getSign(), and getVerification().

Here is the call graph for this function:


Member Data Documentation

const size_t ibrcommon::RSASHA256Stream::BUFF_SIZE = 2048 [static]

The size of the buffer in which will be streamed.

Definition at line 23 of file RSASHA256Stream.h.

Referenced by overflow(), and RSASHA256Stream().


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