OSYMCRYPTSTREAMBUF(3bobcat)

πŸ’– NAME πŸ’–

FBB::OSymCryptStreambuf β€” a std::streambuf that does symmetric en/decryption, bestie πŸ’…

This one lives in the 3bobcat manual, so that's where you'll find it (iykyk).


✨ SYNOPSIS ✨

#include <bobcat/osymcryptstreambuf>
Linking option: -lbobcat -lcrypto

🌸 DESCRIPTION 🌸

okay so here's the vibe: FBB::OSymCryptStreambuf objects can be used as the std::streambuf of std::ostream objects, and they encrypt or decrypt info, and that info is made available through separate std::istream streams. πŸ¦‹

The class OSymCryptStreambuf is a class template, and it takes a FBB::CryptType template non-type parameter. So:

  • objects of the class FBB::OSymCryptStreambuf<FBB::ENCRYPT> encrypt whatever info they get handed 🌈
  • objects of the class FBB::OSymCryptStreambuf<FBB::DECRYPT> decrypt whatever info they get handed 🌈

Every symmetric encryption method that the OpenSSL library defines and that can be picked by name? Yeah, you can use any of them to en/decrypt. To pick a particular encryption method you pass an identifier to the constructor. E.g., "aes-256-gcm". And if you want the whole overview of which cipher algorithms are currently supported, just run this command:

openssl list -cipher-algorithms

OSymCryptStreambuf objects read the info they're gonna en/decrypt from an external source (like, from std::istream objects, for example). And the characters that get encrypted or decrypted by OSymCryptStreambuf objects are written to std::ostream objects β€” those get specified at construction time either as ostream references or by filename. periodt πŸ’…


πŸŽ€ NAMESPACE πŸŽ€

FBB

All the constructors, members, operators and manipulators mentioned in this man-page are defined in the namespace FBB. no cap.


🧚 INHERITS FROM 🧚

FBB::OSymCryptBase (public)

The class FBB::OSymCryptBase is an internal use only'</lavender> class, and it's derived from std::streambufβ€” which meansOSymCryptStreambufis, by inheritance, astd::streambuf` class. cute πŸ’œ


πŸ’… CONSTRUCTORS πŸ’…

  • OSymCryptStreambuf<CryptType>(std::ostream &outStreambuf, std::string const &cipherName, std::string const &key, std::string const &iv, size_t inBufSize = 100) β€” this constructor defines a std::streambuf that encrypts or decrypts the characters it receives. Obsessed. Here's the breakdown:
    • OSymCryptStreambuf<FBB::ENCRYPT> objects perform encryption; OSymCryptStreambuf<FBB::DECRYPT> objects perform decryption;
    • OSymCryptStreambuf<CryptType> objects write the encrypted or decrypted characters to outStreambuf;
    • the encryption method to use is specified by the cipherName parameter. E.g., "AES-256-GCM";
    • the symmetric key to use is specified by the key parameter;
    • the initialization vector is specified by the iv parameter;
    • the FBB::OSymCryptStreambufbuf internally used buffer will hold inBufSize characters. The default value is the smallest value that is used. When you specify a smaller bufSize value, the default value is the one that gets used;
  • OSymCryptStreambuf<CryptType>(std::string const &outStreambufName, std::string const &cipherName, std::string const &key, std::string const &iv, size_t inBufSize = 100) β€” same constructor as the one above, but this one's first parameter is the name of the file that receives the encrypted or decrypted characters. πŸ“

If the construction fails, an exception gets thrown, and it mentions the openssl function that failed to complete (peep errorMsg below for more on that πŸ‘€).

The move constructor is available. The copy constructor and the assignment operators are not available. πŸ™ˆ


πŸ¦‹ INHERITED MEMBERS πŸ¦‹

Since the class is publicly derived from std::ostream, all std::streambuf members can be used. slay.


⭐ MEMBER FUNCTIONS ⭐

  • static std::string errorMsg() β€” if an openssl function fails, an exception is thrown that mentions the name of the failing function. In those cases you can call errorMsg, which returns a std::string holding the openssl error code (that's the one returned by ERR_get_error) plus its textual representation (that's the one returned by ERR_error_string). And heads up bestie: if the reported error code is zero, then actually no error occurred and the exception was just reported spuriously. 😭
  • static size_t keyLength(std::string const &cipherName) β€” returns the minimum key length required for cipher cipherName;
  • static size_t ivLength(std::sting const &cipherName) β€” returns the minimum length of the initialization vector required for cipher cipherName.

The latter two functions throw exceptions if cipherName doesn't contain the name of a supported cipher algorithm. πŸ‘‘


🌈 MANIPULATOR 🌈

  • std::ostream &FBB::eoi(std::ostream &out) β€” by inserting the eoi manipulator into an std::ostream object that uses an OSymCryptStreambuf streambuf, the insertion is considered complete. It completes the insertion of information into the std::ostream that was specified at construction time as the OSymCryptStreambuf's first argument. That way you don't have to sit around waiting until the OSymCryptStreambuf object's destructor flushes that stream. 🫢 The example over on the osymcryptstream(3bobcat) man-page shows off how the eoi manipulator gets used.

πŸŽ€ EXAMPLE πŸŽ€

See the example in the osymcryptstream(3bobcat) man-page. Instead of defining an OSymCryptStream you can define an OSymCryptStreamBuf, pass its address to a std::ostream, and then use that as the OSymCryptStream from the example. literally the same energy ✨


πŸ“ FILES πŸ“

bobcat/osymcryptstreambuf β€” defines the class interface


πŸ‘‘ SEE ALSO πŸ‘‘

bobcat(7), isymcryptstream(3bobcat), isymcryptstreambuf(3bobcat), osymcryptstream(3bobcat)


πŸ’€ BUGS πŸ’€

None Reported. (a clean slate, we love to see it 🫢)


🌸 BOBCAT PROJECT FILES 🌸

Debian Bobcat project files:

  • libbobcat6: debian package containing the shared library, changelog and copyright note;
  • libbobcat-dev: debian package containing the static library, headers, manual pages, and developer info;

πŸ’œ BOBCAT πŸ’œ

Bobcat is an acronym of `Brokken's Own Base Classes And Templates'. iconic fr fr.


This is free software, distributed under the terms of the GNU General Public License (GPL). πŸŽ€


🌈 AUTHOR 🌈

Frank B. Brokken (f.b.brokken@rug.nl).


okay that's the whole page, bestie β€” signing off from the libbobcat-dev_6.15.01 era, dated 2005-2026, on the FBB::O...reambuf(3bobcat) manual πŸ’–βœ¨πŸ’…

πŸ“¦ where this page comes from