.TH "FBB::ISymCryptStreambuf" "3bobcat" "2005\-2023" "libbobcat\-dev_6\&.04\&.00" "Symmetric en\- and decryption" .PP .SH "NAME" FBB::ISymCryptStreambuf \- Streambuf performing symmetric en/decryption .SH "SYNOPSIS" \fB#include \fP .br Linking option: \fI\-lbobcat \-lcrypto\fP .PP .SH "DESCRIPTION" \fBFBB::ISymCryptStreambuf\fP objects can be used as \fIstd::streambuf\fP objects of \fIstd::istream\fP objected, and encrypt or decrypt information that is made available via separate \fIstd::istream\fP streams\&. .PP The class \fIISymCryptStreambuf\fP is a class template, using a \fIFBB::CryptType\fP template non\-type parameter\&. Objects of the class \fIFBB::ISymCryptStreambuf\fP encrypt the information they receive, objects of the class \fIFBB::ISymCryptStreambuf\fP decrypt the information they receive\&. .PP All symmetric encryption methods defined by the OpenSSL library that can be selected by name may be used to en/decrypt information\&. To select a particular encryption method an identifier is passed to the constructor\&. E\&.g\&., \fI\(dq\&aes\-256\-gcm\(dq\&\fP\&. For an overview of the currently supported cipher algorithms issue the command .nf openssl list \-cipher\-algorithms .fi .PP \fIISymCryptStreambuf\fP objects read the information to en/decrypt from \fIstd::istream\fP objects, which are at construction\-time specified as \fIistream\fP references or by filename\&. The characters that are thereupon extracted or read from \fIISymCryptStream\fP objects are en/decrypted, and could, e\&.g\&., be written to some output stream\&. .PP .SH "NAMESPACE" \fBFBB\fP .br All constructors, members, operators and manipulators, mentioned in this man\-page, are defined in the namespace \fBFBB\fP\&. .PP .SH "INHERITS FROM" \fBFBB::ISymCryptBase\fP (public) .PP The class \fIFBB::ISymCryptBase\fP is an `internal use only\(cq\& class, derived from \fIstd::streambuf\fP, and therefore \fIISymCryptStreambuf\fP is a \fIstd::streambuf\fP class\&. .PP .SH "CONSTRUCTORS" .IP o \fBISymCryptStreambuf(std::istream &inStream, std::string const &cipherName, std::string const &key, std::string const &iv, size_t inBufSize = 100)\fP: .br This constructor defines a \fIstd::streambuf\fP object encrypting or decrypting the characters which are read from \fIinStream\fP\&. .IP \- \fIISymCryptStreambuf\fP objects perform encryption; .br \fIISymCryptStreambuf\fP objects perform decryption; .IP \- \fIISymCryptStreambuf\fP objects receive the characters to encrypt or decrypt from \fIstd::istream &in\fP; .br \- The encryption method to use is specified by the \fIcipherName\fP parameter\&. E\&.g\&., \fI\(dq\&AES\-256\-GCM\(dq\&\fP; .br \- The symmetric key to use is specified by the \fIkey\fP parameter; .br \- The initialization vector is specified by the \fIiv\fP parameter; .br \- The \fIFBB::ISymCryptStreambufbuf\fP internally used buffer will hold \fIinBufSize\fP characters\&. The default value is the smallest value that is used\&. When specifying a smaller \fIbufSize\fP value than the default value then the default value is used; .br .IP .IP o \fBISymCryptStreambuf(std::string const &inStreamName, std::string const &cipherName, std::string const &key, std::string const &iv, size_t inBufSize = 100)\fP: .br Same constructor as the previous one, but this constructor\(cq\&s first parameter specifies the name of the file containing the characters to encrypt or decrypt\&. .PP If the construction fails an exception is thrown, mentioning the openssl function that failed to complete (see also \fIerrorMsg\fP below)\&. .PP The move constructor is available, the copy constructor and assignment operators are not available, .PP .SH "INHERITED MEMBERS" .PP Since the class is publicly derived from \fBstd::istreambuf\fP, all \fIstd::streambuf\fP members can can be used\&. .PP .SH "MEMBER FUNCTIONS" .IP o \fBstatic std::string errorMsg()\fP: .br If an openssl function fails an exception is thrown mentioning the name of the failing function\&. In those cases the function \fIerrorMsg\fP can be called returning a \fIstd::string\fP containing the openssl error code (returned by \fIERR_get_error\fP) and its textual representation (returned by \fIERR_error_string\fP)\&. If the reported error code is zero, then in fact no error has occurred and the exception was spuriously reported; .IP .IP o \fBstatic size_t keyLength(std::string const &cipherName)\fP: .br returns the minimum key length required for cipher \fIcipherName\fP; .IP .IP o \fBstatic size_t ivLength(std::sting const &cipherName)\fP: .br returns the minimum length of the initialization vector that is required for cipher \fIcipherName\fP\&. .PP The latter two functions throw exceptions if \fIcipherName\fP does not contain the name of a supported cipher algorithm\&. .PP .SH "EXAMPLE" See the example in the \fBisymcryptstream\fP(3bobcat) man\-page\&. Instead of defining an \fIISymCryptStream\fP an \fIISymCryptStreamBuf\fP can be defined, passing its address to a \fIstd::istream\fP which can then be used as the \fIISymCryptStream\fP used in the example\&. .PP .SH "FILES" \fIbobcat/isymcryptstream\fP \- defines the class interface .PP .SH "SEE ALSO" \fBbobcat\fP(7), \fBisymcryptstream\fP(3bobcat), \fBosymcryptstream\fP(3bobcat), \fBosymcryptstreambuf\fP(3bobcat) .PP .SH "BUGS" None Reported\&. .PP .SH "BOBCAT PROJECT FILES" .PP .IP o \fIhttps://fbb\-git\&.gitlab\&.io/bobcat/\fP: gitlab project page; .IP o \fIbobcat_6\&.04\&.00\-x\&.dsc\fP: detached signature; .IP o \fIbobcat_6\&.04\&.00\-x\&.tar\&.gz\fP: source archive; .IP o \fIbobcat_6\&.04\&.00\-x_i386\&.changes\fP: change log; .IP o \fIlibbobcat1_6\&.04\&.00\-x_*\&.deb\fP: debian package containing the libraries; .IP o \fIlibbobcat1\-dev_6\&.04\&.00\-x_*\&.deb\fP: debian package containing the libraries, headers and manual pages; .PP .SH "BOBCAT" Bobcat is an acronym of `Brokken\(cq\&s Own Base Classes And Templates\(cq\&\&. .PP .SH "COPYRIGHT" This is free software, distributed under the terms of the GNU General Public License (GPL)\&. .PP .SH "AUTHOR" Frank B\&. Brokken (\fBf\&.b\&.brokken@rug\&.nl\fP)\&. .PP