IBR-DTNSuite
0.8
|
#include <RSASHA256Stream.h>
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()) |
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.
typedef std::char_traits<char> ibrcommon::RSASHA256Stream::traits |
Definition at line 20 of file RSASHA256Stream.h.
ibrcommon::RSASHA256Stream::RSASHA256Stream | ( | EVP_PKEY *const | pkey, |
bool | verfiy = false |
||
) |
Creates a RSASHA256Stream object. And tells if it shall verify or calculate a signature.
pkey | the public or private key to be used |
verfiy | if 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.
ibrcommon::RSASHA256Stream::~RSASHA256Stream | ( | ) | [virtual] |
cleans the output buffer and the openssl context
Definition at line 32 of file RSASHA256Stream.cpp.
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.
Definition at line 64 of file RSASHA256Stream.cpp.
References sync().
int ibrcommon::RSASHA256Stream::getVerification | ( | const std::string & | their_sign | ) |
Verifies a foreign given signature.
their_sign | the signature to be verified |
Definition at line 83 of file RSASHA256Stream.cpp.
References sync().
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.
c | the last char, for which was not room anymore in the buffer |
Definition at line 105 of file RSASHA256Stream.cpp.
References BUFF_SIZE, IBRCOMMON_LOGGER, and IBRCOMMON_LOGGER_ENDL.
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 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.
Definition at line 96 of file RSASHA256Stream.cpp.
References overflow().
Referenced by getSign(), and getVerification().
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().