Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
websocketpp::md5 Namespace Reference

Provides MD5 hashing functionality.

Classes

struct  md5_state_s
 

Typedefs

typedef unsigned char md5_byte_t
 
typedef unsigned int md5_word_t
 
typedef struct websocketpp::md5::md5_state_s md5_state_t
 

Functions

void md5_init (md5_state_t *pms)
 
void md5_append (md5_state_t *pms, md5_byte_t const *data, size_t nbytes)
 
void md5_finish (md5_state_t *pms, md5_byte_t digest[16])
 
std::string md5_hash_string (std::string const &s)
 
std::string md5_hash_hex (std::string const &input)
 

Variables

const char hexval [16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}
 

Typedef Documentation

◆ md5_byte_t

typedef unsigned char websocketpp::md5::md5_byte_t

Definition at line 78 of file md5.hpp.

◆ md5_state_t

◆ md5_word_t

typedef unsigned int websocketpp::md5::md5_word_t

Definition at line 79 of file md5.hpp.

Function Documentation

◆ md5_append()

void websocketpp::md5::md5_append ( md5_state_t * pms,
md5_byte_t const * data,
size_t nbytes )
inline

Definition at line 357 of file md5.hpp.

357 {
358 md5_byte_t const * p = data;
359 size_t left = nbytes;
360 int offset = (pms->count[0] >> 3) & 63;
361 md5_word_t nbits = (md5_word_t)(nbytes << 3);
362
363 if (nbytes <= 0)
364 return;
365
366 /* Update the message length. */
367 pms->count[1] += nbytes >> 29;
368 pms->count[0] += nbits;
369 if (pms->count[0] < nbits)
370 pms->count[1]++;
371
372 /* Process an initial partial block. */
373 if (offset) {
374 int copy = (offset + nbytes > 64 ? 64 - offset : static_cast<int>(nbytes));
375
376 std::memcpy(pms->buf + offset, p, copy);
377 if (offset + copy < 64)
378 return;
379 p += copy;
380 left -= copy;
381 md5_process(pms, pms->buf);
382 }
383
384 /* Process full blocks. */
385 for (; left >= 64; p += 64, left -= 64)
386 md5_process(pms, p);
387
388 /* Process a final partial block. */
389 if (left)
390 std::memcpy(pms->buf, p, left);
391}
const mie::Vuint & p
Definition bn.cpp:27
unsigned char md5_byte_t
Definition md5.hpp:78
unsigned int md5_word_t
Definition md5.hpp:79
Here is the caller graph for this function:

◆ md5_finish()

void websocketpp::md5::md5_finish ( md5_state_t * pms,
md5_byte_t digest[16] )
inline

Definition at line 393 of file md5.hpp.

393 {
394 static md5_byte_t const pad[64] = {
395 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
396 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
397 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
398 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
399 };
400 md5_byte_t data[8];
401 int i;
402
403 /* Save the length before padding. */
404 for (i = 0; i < 8; ++i)
405 data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3));
406 /* Pad to 56 bytes mod 64. */
407 md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
408 /* Append the length. */
409 md5_append(pms, data, 8);
410 for (i = 0; i < 16; ++i)
411 digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
412}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ md5_hash_hex()

std::string websocketpp::md5::md5_hash_hex ( std::string const & input)
inline

Definition at line 433 of file md5.hpp.

433 {
434 std::string hash = md5_hash_string(input);
435 std::string hex;
436
437 for (size_t i = 0; i < hash.size(); i++) {
438 hex.push_back(hexval[((hash[i] >> 4) & 0xF)]);
439 hex.push_back(hexval[(hash[i]) & 0x0F]);
440 }
441
442 return hex;
443}
std::string md5_hash_string(std::string const &s)
Definition md5.hpp:415
Here is the call graph for this function:

◆ md5_hash_string()

std::string websocketpp::md5::md5_hash_string ( std::string const & s)
inline

Definition at line 415 of file md5.hpp.

415 {
416 char digest[16];
417
419
420 md5_init(&state);
421 md5_append(&state, (md5_byte_t const *)s.c_str(), s.size());
422 md5_finish(&state, (md5_byte_t *)digest);
423
424 std::string ret;
425 ret.resize(16);
426 std::copy(digest,digest+16,ret.begin());
427
428 return ret;
429}
void md5_finish(md5_state_t *pms, md5_byte_t digest[16])
Definition md5.hpp:393
void md5_init(md5_state_t *pms)
Definition md5.hpp:349
void md5_append(md5_state_t *pms, md5_byte_t const *data, size_t nbytes)
Definition md5.hpp:357
CK_RV ret
char * s
Here is the call graph for this function:
Here is the caller graph for this function:

◆ md5_init()

void websocketpp::md5::md5_init ( md5_state_t * pms)
inline

Definition at line 349 of file md5.hpp.

349 {
350 pms->count[0] = pms->count[1] = 0;
351 pms->abcd[0] = 0x67452301;
352 pms->abcd[1] = /*0xefcdab89*/ ZSW_MD5_T_MASK ^ 0x10325476;
353 pms->abcd[2] = /*0x98badcfe*/ ZSW_MD5_T_MASK ^ 0x67452301;
354 pms->abcd[3] = 0x10325476;
355}
#define ZSW_MD5_T_MASK
Definition md5.hpp:104
Here is the caller graph for this function:

Variable Documentation

◆ hexval

const char websocketpp::md5::hexval[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}

Definition at line 431 of file md5.hpp.

431{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};