FBB::CryptBuf - std::streambuf derived base class for DecryptBuf and EncryptBuf
Contents
Bobcat
Bobcat is an acronym of `Brokken’s Own Base Classes And Templates’.
Bobcat Project Files
o https://fbb-git.gitlab.io/bobcat/: gitlab project page;
o bobcat_5.09.01-x.dsc: detached signature;
o bobcat_5.09.01-x.tar.gz: source archive;
o bobcat_5.09.01-x_i386.changes: change log;
o libbobcat1_5.09.01-x_*.deb: debian package containing the libraries;
o libbobcat1-dev_5.09.01-x_*.deb: debian package containing the libraries, headers and manual pages;
Bugs
None Reported.
Copyright
This is free software, distributed under the terms of the GNU General Public License (GPL).
Description
The class CryptBuf inherits from EoiBuf and may therefore be used as a base class of classes specializing
std::streambuf. It is used as base class for the classes DecryptBuf and EncryptBuf, offering a protected
member for accessing cipher information.
Example
Here is an example from the implementation of EncryptBuf’s constructor:
#include "encryptbuf.ih"
EncryptBuf::EncryptBuf(ostream &outStream, char const *type,
string key, string const &iv, size_t size)
:
CryptBuf(type, size),
d_ctx(EVP_CIPHER_CTX_new()),
d_encrypted(size + EVP_MAX_BLOCK_LENGTH, 0),
d_iv(iv),
d_key(key),
d_outStream(outStream)
{
prepareIV();
if (
not EVP_EncryptInit_ex(d_ctx, md(), 0, ucharPtr(d_key),
ucharPtr(d_iv))
)
throw Exception{ 1 } << "Encrypt initialization failed";
setp();
}
Files
bobcat/cryptbuf - defines the class interface
Inherits From
EoiBuf (and thus from: std::streambuf)
Name
FBB::CryptBuf - std::streambuf derived base class for DecryptBuf and EncryptBuf
Namespace
FBB
All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the
namespace FBB.
Protected Constructor
Analogously to std::streambuf only a protected constructor is available.
o CryptBuf(charconst*type,size_tbufSize):
The type is a null-terminated byte string specifying the de/encryption method. E.g., aes-128-cbc.
For an overview see the encryptbuf(3bobcat) man-page. The bufSize parameter defines the initial
size of the internally used buffer (defined by EoiBuf).
Copy and move constructors (and assignment operators) are not available.
Protected Member Function
All members of std:streambuf and EoiBuf are available, as FBB::CryptBuf inherits from these classes.
o EVP_CIPHERconst*md()const:
A pointer to the cipher information is returned.
See Also
bobcat(7), decryptbuf(3bobcat), encryptbuf(3bobcat), eoibuf(3bobcat), eoi(3bobcat)
Synopsis
#include<bobcat/cryptbuf>
Linking option: -lbobcat-lcrypto