gnutls_datum_t
Many GnuTLS functions return opaque binary blobs
represented by a gnutls_datum_t
handle.
A memory buffer holds the blobs' contents, which must be deallocated when
the blob is no longer needed.
These binary blobs become a
x::gnutls::datum_t
reference, a reference to a
reference-counted object which may be freely
passed around. When the last
x::gnutls::datum_t
reference to the underlying blob
goes out of scope, the underlying object gets
destroyed and the underlying memory buffer gets removed.
#include <x/gnutls/x509_privkey.H> #include <x/gnutls/datumwrapper.H> x::gnutls::x509::privkey pk(x::gnutls::x509::privkey::create()); pk->generate(GNUTLS_PK_RSA, 1024); pk->fix(); x::gnutls::datum_t pkd(pk->export_pkcs(GNUTLS_X509_FMT_PEM); pkd->save("privkey.pem");
x::gnutls::datum_t
is just a subclass of a
x::vector
.
Its typical usage includes storing PEM-formatted objects
and x::vector
provides convenient methods to save and load
the objects from files.