IBR-DTNSuite  0.10
ibrcommon::RSASHA256Stream Class Reference

#include <RSASHA256Stream.h>

Inheritance diagram for ibrcommon::RSASHA256Stream:
Inheritance graph
Collaboration diagram for ibrcommon::RSASHA256Stream:
Collaboration graph

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 39 of file RSASHA256Stream.h.

Member Typedef Documentation

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

Definition at line 42 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 28 of file RSASHA256Stream.cpp.

References BUFF_SIZE, ibrcommon::LogLevel::critical, IBRCOMMON_LOGGER_ENDL, and IBRCOMMON_LOGGER_TAG.

ibrcommon::RSASHA256Stream::~RSASHA256Stream ( )
virtual

cleans the output buffer and the openssl context

Definition at line 53 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 84 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 103 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())
protectedvirtual

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 125 of file RSASHA256Stream.cpp.

References BUFF_SIZE, ibrcommon::LogLevel::critical, IBRCOMMON_LOGGER_ENDL, and IBRCOMMON_LOGGER_TAG.

Referenced by sync().

void ibrcommon::RSASHA256Stream::reset ( )

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

Definition at line 58 of file RSASHA256Stream.cpp.

References ibrcommon::LogLevel::critical, IBRCOMMON_LOGGER_ENDL, and IBRCOMMON_LOGGER_TAG.

int ibrcommon::RSASHA256Stream::sync ( )
protectedvirtual

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 116 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 45 of file RSASHA256Stream.h.

Referenced by overflow(), and RSASHA256Stream().


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