IBR-DTNSuite
0.10
|
#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 39 of file RSASHA256Stream.h.
typedef std::char_traits<char> ibrcommon::RSASHA256Stream::traits |
Definition at line 42 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 28 of file RSASHA256Stream.cpp.
References BUFF_SIZE, ibrcommon::LogLevel::critical, IBRCOMMON_LOGGER_ENDL, and IBRCOMMON_LOGGER_TAG.
|
virtual |
cleans the output buffer and the openssl context
Definition at line 53 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 84 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 103 of file RSASHA256Stream.cpp.
References sync().
|
protectedvirtual |
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 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.
|
protectedvirtual |
Writes all unwritten data out of the buffer and into the openssl context for creation of the signature.
Definition at line 116 of file RSASHA256Stream.cpp.
References overflow().
Referenced by getSign(), and getVerification().
|
static |
The size of the buffer in which will be streamed.
Definition at line 45 of file RSASHA256Stream.h.
Referenced by overflow(), and RSASHA256Stream().