xoreos  0.0.5
Classes | Namespaces | Macros | Functions
md5.cpp File Reference

Hashing/digesting using the MD5 algorithm. More...

#include <cstring>
#include "src/common/md5.h"
#include "src/common/ustring.h"
#include "src/common/readstream.h"
Include dependency graph for md5.cpp:

Go to the source code of this file.

Classes

struct  Common::MD5Context
 

Namespaces

 Common
 

Macros

#define F(x, y, z)   ((z) ^ ((x) & ((y) ^ (z))))
 
#define G(x, y, z)   ((y) ^ ((z) & ((x) ^ (y))))
 
#define H(x, y, z)   (((x) ^ (y)) ^ (z))
 
#define H2(x, y, z)   ((x) ^ ((y) ^ (z)))
 
#define I(x, y, z)   ((y) ^ ((x) | ~(z)))
 
#define STEP(f, a, b, c, d, x, t, s)
 
#define SET(n)
 
#define GET(n)   (ctx.block[(n)])
 

Functions

static const byteCommon::md5Body (MD5Context &ctx, const byte *data, size_t size)
 
static void Common::md5Update (MD5Context &ctx, const byte *data, size_t size)
 
static void Common::md5Final (byte *result, MD5Context &ctx)
 
void Common::hashMD5 (ReadStream &stream, std::vector< byte > &digest)
 Hash the stream into an MD5 digest of 16 bytes. More...
 
void Common::hashMD5 (const byte *data, size_t dataLength, std::vector< byte > &digest)
 Hash the data into an MD5 digest of 16 bytes. More...
 
void Common::hashMD5 (const UString &string, std::vector< byte > &digest)
 Hash the string into an MD5 digest of 16 bytes. More...
 
void Common::hashMD5 (const std::vector< byte > &data, std::vector< byte > &digest)
 Hash the array of data into an MD5 digest of 16 bytes. More...
 
bool Common::compareMD5Digest (ReadStream &stream, const std::vector< byte > &digest)
 Hash the stream and compare the digests, returning true if they match. More...
 
bool Common::compareMD5Digest (const byte *data, size_t dataLength, const std::vector< byte > &digest)
 Hash the array of data and compare the digests, returning true if they match. More...
 
bool Common::compareMD5Digest (const UString &string, const std::vector< byte > &digest)
 Hash the string and compare the digests, returning true if they match. More...
 
bool Common::compareMD5Digest (const std::vector< byte > &data, const std::vector< byte > &digest)
 Hash the array of data and compare the digests, returning true if they match. More...
 

Detailed Description

Hashing/digesting using the MD5 algorithm.

Definition in file md5.cpp.

Macro Definition Documentation

◆ F

#define F (   x,
  y,
 
)    ((z) ^ ((x) & ((y) ^ (z))))

Definition at line 94 of file md5.cpp.

◆ G

#define G (   x,
  y,
 
)    ((y) ^ ((z) & ((x) ^ (y))))

Definition at line 95 of file md5.cpp.

Referenced by Common::md5Body().

◆ GET

#define GET (   n)    (ctx.block[(n)])

Definition at line 128 of file md5.cpp.

Referenced by Common::md5Body().

◆ H

#define H (   x,
  y,
 
)    (((x) ^ (y)) ^ (z))

Definition at line 96 of file md5.cpp.

◆ H2

#define H2 (   x,
  y,
 
)    ((x) ^ ((y) ^ (z)))

Definition at line 97 of file md5.cpp.

◆ I

#define I (   x,
  y,
 
)    ((y) ^ ((x) | ~(z)))

Definition at line 98 of file md5.cpp.

◆ SET

#define SET (   n)
Value:
(ctx.block[(n)] = \
(uint32)ptr[(n) * 4] | \
((uint32)ptr[(n) * 4 + 1] << 8) | \
((uint32)ptr[(n) * 4 + 2] << 16) | \
((uint32)ptr[(n) * 4 + 3] << 24))
uint32_t uint32
Definition: types.h:204

Definition at line 122 of file md5.cpp.

Referenced by Common::md5Body().

◆ STEP

#define STEP (   f,
  a,
  b,
  c,
  d,
  x,
  t,
 
)
Value:
(a) += f((b), (c), (d)) + (x) + (t); \
(a) = (((a) << (s)) | (((a) & 0xFFFFFFFF) >> (32 - (s)))); \
(a) += (b);

Definition at line 103 of file md5.cpp.

Referenced by Common::md5Body().