md5.h File Reference

#include "rtps_export.h"

Include dependency graph for md5.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  MD5_CTX

Defines

#define _MD5_H

Typedefs

typedef unsigned int MD5_u32plus

Functions

OpenDDS_Rtps_Export void MD5_Init (MD5_CTX *ctx)
OpenDDS_Rtps_Export void MD5_Update (MD5_CTX *ctx, const void *data, unsigned long size)
OpenDDS_Rtps_Export void MD5_Final (unsigned char *result, MD5_CTX *ctx)


Define Documentation

#define _MD5_H

Definition at line 29 of file md5.h.


Typedef Documentation

typedef unsigned int MD5_u32plus

Definition at line 34 of file md5.h.


Function Documentation

OpenDDS_Rtps_Export void MD5_Final ( unsigned char *  result,
MD5_CTX ctx 
)

Definition at line 246 of file md5.cpp.

References MD5_CTX::a, MD5_CTX::b, body(), MD5_CTX::buffer, MD5_CTX::c, MD5_CTX::d, MD5_CTX::hi, and MD5_CTX::lo.

Referenced by OpenDDS::RTPS::marshal_key_hash().

00247 {
00248         unsigned long used, free;
00249 
00250         used = ctx->lo & 0x3f;
00251 
00252         ctx->buffer[used++] = 0x80;
00253 
00254         free = 64 - used;
00255 
00256         if (free < 8) {
00257                 memset(&ctx->buffer[used], 0, free);
00258                 body(ctx, ctx->buffer, 64);
00259                 used = 0;
00260                 free = 64;
00261         }
00262 
00263         memset(&ctx->buffer[used], 0, free - 8);
00264 
00265         ctx->lo <<= 3;
00266         ctx->buffer[56] = ctx->lo;
00267         ctx->buffer[57] = ctx->lo >> 8;
00268         ctx->buffer[58] = ctx->lo >> 16;
00269         ctx->buffer[59] = ctx->lo >> 24;
00270         ctx->buffer[60] = ctx->hi;
00271         ctx->buffer[61] = ctx->hi >> 8;
00272         ctx->buffer[62] = ctx->hi >> 16;
00273         ctx->buffer[63] = ctx->hi >> 24;
00274 
00275         body(ctx, ctx->buffer, 64);
00276 
00277         result[0] = ctx->a;
00278         result[1] = ctx->a >> 8;
00279         result[2] = ctx->a >> 16;
00280         result[3] = ctx->a >> 24;
00281         result[4] = ctx->b;
00282         result[5] = ctx->b >> 8;
00283         result[6] = ctx->b >> 16;
00284         result[7] = ctx->b >> 24;
00285         result[8] = ctx->c;
00286         result[9] = ctx->c >> 8;
00287         result[10] = ctx->c >> 16;
00288         result[11] = ctx->c >> 24;
00289         result[12] = ctx->d;
00290         result[13] = ctx->d >> 8;
00291         result[14] = ctx->d >> 16;
00292         result[15] = ctx->d >> 24;
00293 
00294         memset(ctx, 0, sizeof(*ctx));
00295 }

OpenDDS_Rtps_Export void MD5_Init ( MD5_CTX ctx  ) 

Definition at line 201 of file md5.cpp.

References MD5_CTX::a, MD5_CTX::b, MD5_CTX::c, MD5_CTX::d, MD5_CTX::hi, and MD5_CTX::lo.

Referenced by OpenDDS::RTPS::marshal_key_hash().

00202 {
00203         ctx->a = 0x67452301;
00204         ctx->b = 0xefcdab89;
00205         ctx->c = 0x98badcfe;
00206         ctx->d = 0x10325476;
00207 
00208         ctx->lo = 0;
00209         ctx->hi = 0;
00210 }

OpenDDS_Rtps_Export void MD5_Update ( MD5_CTX ctx,
const void *  data,
unsigned long  size 
)

Definition at line 212 of file md5.cpp.

References body(), MD5_CTX::buffer, MD5_CTX::hi, and MD5_CTX::lo.

Referenced by OpenDDS::RTPS::marshal_key_hash().

00213 {
00214         MD5_u32plus saved_lo;
00215         unsigned long used;
00216 
00217         saved_lo = ctx->lo;
00218         if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo)
00219                 ctx->hi++;
00220         ctx->hi += size >> 29;
00221 
00222         used = saved_lo & 0x3f;
00223 
00224         if (used) {
00225                 unsigned long free = 64 - used;
00226 
00227                 if (size < free) {
00228                         memcpy(&ctx->buffer[used], data, size);
00229                         return;
00230                 }
00231 
00232                 memcpy(&ctx->buffer[used], data, free);
00233                 data = (unsigned char *)data + free;
00234                 size -= free;
00235                 body(ctx, ctx->buffer, 64);
00236         }
00237 
00238         if (size >= 64) {
00239                 data = body(ctx, data, size & ~(unsigned long)0x3f);
00240                 size &= 0x3f;
00241         }
00242 
00243         memcpy(ctx->buffer, data, size);
00244 }


Generated on Fri Feb 12 20:05:37 2016 for OpenDDS by  doxygen 1.4.7