ucommon  7.0.0
About: GNU uCommon C++ is a portable and optimized class framework for writing C++ applications that need to use threads and support concurrent synchronization, and that use sockets, XML parsing, object serialization, thread-optimized string and data structure classes, etc..
  Fossies Dox: ucommon-7.0.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Loading...
Searching...
No Matches
ucommon::Digest Class Reference

A cryptographic digest class. More...

#include <secure.h>

Public Member Functions

 Digest (const char *type)
 
 Digest ()
 
 ~Digest ()
 
bool puts (const char *str)
 
Digestoperator<< (const char *str)
 
Digestoperator<< (int16_t value)
 
Digestoperator<< (int32_t value)
 
Digestoperator<< (const PrintProtocol &p)
 
bool put (const void *memory, size_t size)
 
unsigned size () const
 
secure::keybytes key (void)
 
secure::string str (void)
 
 operator secure::string ()
 
void set (const char *id)
 
Digestoperator= (const char *id)
 
bool operator*= (const char *text)
 
bool operator+= (const char *text)
 
secure::string operator* ()
 
bool operator! () const
 
 operator bool () const
 
void recycle (bool binary=false)
 Finalize and recycle current digest to start a new digest. More...
 
void reset (void)
 Reset and restart digest object. More...
 

Static Public Member Functions

static bool has (const char *name)
 Test to see if a specific digest type is supported. More...
 
static secure::string uuid (const char *name, const uint8_t *ns=NULL)
 
static secure::string md5 (const char *text)
 Shortcut for short md5 digests if supported... More...
 
static secure::string sha1 (const char *text)
 
static secure::string sha256 (const char *text)
 
static secure::string sha384 (const char *text)
 
static secure::keybytes md5 (const uint8_t *mem, size_t size)
 
static secure::keybytes sha1 (const uint8_t *mem, size_t size)
 
static secure::keybytes sha256 (const uint8_t *mem, size_t size)
 
static secure::keybytes sha384 (const uint8_t *mem, size_t size)
 

Protected Member Functions

void release (void)
 
const uint8_t * get (void)
 

Private Member Functions

 __DELETE_COPY (Digest)
 

Private Attributes

void * context
 
union {
   const void *   hashtype
 
   int   hashid
 
}; 
 
unsigned bufsize
 
uint8_t buffer [512/8]
 
char textbuf [512/8+1]
 

Detailed Description

A cryptographic digest class.

This class can support md5 digests, sha1, sha256, etc, depending on what the underlying library supports. The hash class accumulates the hash in the object.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 509 of file secure.h.

Constructor & Destructor Documentation

◆ Digest() [1/2]

ucommon::Digest::Digest ( const char *  type)

Definition at line 47 of file common.cpp.

References bufsize, context, hashid, hashtype, set(), and textbuf.

Here is the call graph for this function:

◆ Digest() [2/2]

ucommon::Digest::Digest ( )

Definition at line 38 of file common.cpp.

References bufsize, context, hashid, hashtype, and textbuf.

◆ ~Digest()

ucommon::Digest::~Digest ( )

Definition at line 58 of file common.cpp.

References buffer, and release().

Here is the call graph for this function:

Member Function Documentation

◆ __DELETE_COPY()

ucommon::Digest::__DELETE_COPY ( Digest  )
private

◆ get()

const uint8_t * ucommon::Digest::get ( void  )
protected

Definition at line 139 of file digest.cpp.

References buffer, bufsize, context, hashid, size(), and textbuf.

Referenced by key(), and str().

Here is the call graph for this function:

◆ has()

bool ucommon::Digest::has ( const char *  name)
static

Test to see if a specific digest type is supported.

Parameters
nameof digest we want to check.
Returns
true if supported, false if not.

Definition at line 69 of file digest.cpp.

References ucommon::__context::map_digest().

Referenced by main(), md5(), sha1(), sha256(), sha384(), and uuid().

Here is the call graph for this function:

◆ key()

secure::keybytes ucommon::Digest::key ( void  )

Definition at line 75 of file common.cpp.

References buffer, bufsize, and get().

Here is the call graph for this function:

◆ md5() [1/2]

secure::string ucommon::Digest::md5 ( const char *  text)
static

Shortcut for short md5 digests if supported...

Parameters
textto create a digest for.
Returns
digest string.

Definition at line 155 of file common.cpp.

References digest(), and has().

Here is the call graph for this function:

◆ md5() [2/2]

secure::keybytes ucommon::Digest::md5 ( const uint8_t *  mem,
size_t  size 
)
static

Definition at line 111 of file common.cpp.

References digest(), has(), and size().

Here is the call graph for this function:

◆ operator bool()

ucommon::Digest::operator bool ( ) const
inline

Definition at line 602 of file secure.h.

◆ operator secure::string()

ucommon::Digest::operator secure::string ( )
inline

Definition at line 575 of file secure.h.

References ucommon::str().

Here is the call graph for this function:

◆ operator!()

bool ucommon::Digest::operator! ( ) const
inline

Definition at line 598 of file secure.h.

◆ operator*()

secure::string ucommon::Digest::operator* ( )
inline

Definition at line 594 of file secure.h.

References ucommon::str().

Here is the call graph for this function:

◆ operator*=()

bool ucommon::Digest::operator*= ( const char *  text)
inline

Definition at line 586 of file secure.h.

◆ operator+=()

bool ucommon::Digest::operator+= ( const char *  text)
inline

Definition at line 590 of file secure.h.

◆ operator<<() [1/4]

Digest & ucommon::Digest::operator<< ( const char *  str)
inline

Definition at line 541 of file secure.h.

References ucommon::str().

Here is the call graph for this function:

◆ operator<<() [2/4]

Digest & ucommon::Digest::operator<< ( const PrintProtocol p)
inline

Definition at line 558 of file secure.h.

References ucommon::PrintProtocol::_print().

Here is the call graph for this function:

◆ operator<<() [3/4]

Digest & ucommon::Digest::operator<< ( int16_t  value)
inline

Definition at line 546 of file secure.h.

◆ operator<<() [4/4]

Digest & ucommon::Digest::operator<< ( int32_t  value)
inline

Definition at line 552 of file secure.h.

◆ operator=()

Digest & ucommon::Digest::operator= ( const char *  id)
inline

Definition at line 581 of file secure.h.

◆ put()

bool ucommon::Digest::put ( const void *  memory,
size_t  size 
)

Definition at line 79 of file digest.cpp.

References context, hashid, and size().

Referenced by digest().

Here is the call graph for this function:

◆ puts()

bool ucommon::Digest::puts ( const char *  str)
inline

Definition at line 537 of file secure.h.

References ucommon::str().

Here is the call graph for this function:

◆ recycle()

void ucommon::Digest::recycle ( bool  binary = false)

Finalize and recycle current digest to start a new digest.

Parameters
binarydigest used rather than text if true.

Definition at line 103 of file digest.cpp.

References buffer, bufsize, context, hashid, reset(), size(), and textbuf.

Here is the call graph for this function:

◆ release()

void ucommon::Digest::release ( void  )
protected

Definition at line 23 of file digest.cpp.

References buffer, bufsize, context, hashid, and textbuf.

Referenced by set(), and ~Digest().

◆ reset()

void ucommon::Digest::reset ( void  )

Reset and restart digest object.

Definition at line 88 of file digest.cpp.

References bufsize, context, hashid, MAX_DIGEST_HASHSIZE, and temp.

Referenced by digest(), and recycle().

◆ set()

void ucommon::Digest::set ( const char *  id)

Definition at line 53 of file digest.cpp.

References context, hashid, ucommon::secure::init(), ucommon::__context::map_digest(), and release().

Referenced by Digest().

Here is the call graph for this function:

◆ sha1() [1/2]

secure::string ucommon::Digest::sha1 ( const char *  text)
static

Definition at line 165 of file common.cpp.

References digest(), and has().

Here is the call graph for this function:

◆ sha1() [2/2]

secure::keybytes ucommon::Digest::sha1 ( const uint8_t *  mem,
size_t  size 
)
static

Definition at line 122 of file common.cpp.

References digest(), has(), and size().

Here is the call graph for this function:

◆ sha256() [1/2]

secure::string ucommon::Digest::sha256 ( const char *  text)
static

Definition at line 175 of file common.cpp.

References digest(), and has().

Here is the call graph for this function:

◆ sha256() [2/2]

secure::keybytes ucommon::Digest::sha256 ( const uint8_t *  mem,
size_t  size 
)
static

Definition at line 133 of file common.cpp.

References digest(), has(), and size().

Here is the call graph for this function:

◆ sha384() [1/2]

secure::string ucommon::Digest::sha384 ( const char *  text)
static

Definition at line 185 of file common.cpp.

References digest(), and has().

Here is the call graph for this function:

◆ sha384() [2/2]

secure::keybytes ucommon::Digest::sha384 ( const uint8_t *  mem,
size_t  size 
)
static

Definition at line 144 of file common.cpp.

References digest(), has(), and size().

Here is the call graph for this function:

◆ size()

unsigned ucommon::Digest::size ( ) const
inline

Definition at line 567 of file secure.h.

Referenced by get(), md5(), put(), recycle(), sha1(), sha256(), and sha384().

◆ str()

secure::string ucommon::Digest::str ( void  )

Definition at line 64 of file common.cpp.

References bufsize, get(), and textbuf.

Referenced by uuid().

Here is the call graph for this function:

◆ uuid()

secure::string ucommon::Digest::uuid ( const char *  name,
const uint8_t *  ns = NULL 
)
static

Definition at line 86 of file common.cpp.

References has(), ucommon::String::hexdump(), md, and str().

Here is the call graph for this function:

Member Data Documentation

◆ 

union { ... } ucommon::Digest::@18

◆ buffer

uint8_t ucommon::Digest::buffer[512/8]
private

Definition at line 520 of file secure.h.

Referenced by get(), key(), recycle(), release(), and ~Digest().

◆ bufsize

unsigned ucommon::Digest::bufsize
private

Definition at line 519 of file secure.h.

Referenced by Digest(), get(), key(), recycle(), release(), reset(), and str().

◆ context

void* ucommon::Digest::context
private

Definition at line 512 of file secure.h.

Referenced by Digest(), get(), put(), recycle(), release(), reset(), and set().

◆ hashid

int ucommon::Digest::hashid

Definition at line 516 of file secure.h.

Referenced by Digest(), get(), put(), recycle(), release(), reset(), and set().

◆ hashtype

const void* ucommon::Digest::hashtype

Definition at line 515 of file secure.h.

Referenced by Digest().

◆ textbuf

char ucommon::Digest::textbuf[512/8+1]
private

Definition at line 521 of file secure.h.

Referenced by Digest(), get(), recycle(), release(), and str().


The documentation for this class was generated from the following files: