liveMedia/our_md5hl.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include "our_md5.h"
#include "NetCommon.h"

Include dependency graph for our_md5hl.c:

Go to the source code of this file.

Defines

#define LENGTH   16
#define BUFSIZ   255

Functions

char * our_MD5End (MD5_CTX *ctx, char *buf)
char * our_MD5File (const char *filename, char *buf)
char * our_MD5Data (const unsigned char *data, unsigned int len, char *buf)


Define Documentation

#define BUFSIZ   255

Definition at line 17 of file our_md5hl.c.

Referenced by our_MD5File().

#define LENGTH   16

Definition at line 1 of file our_md5hl.c.

Referenced by our_MD5End().


Function Documentation

char* our_MD5Data ( const unsigned char *  data,
unsigned int  len,
char *  buf 
)

Definition at line 61 of file our_md5hl.c.

References our_MD5End(), our_MD5Init(), and ourMD5Update().

Referenced by Authenticator::computeDigestResponse(), RTSPClient::sendRequest(), and Authenticator::setRealmAndRandomNonce().

00062 {
00063     MD5_CTX ctx;
00064 
00065     our_MD5Init(&ctx);
00066     ourMD5Update(&ctx,data,len);
00067     return our_MD5End(&ctx, buf);
00068 }

char* our_MD5End ( MD5_CTX ctx,
char *  buf 
)

Definition at line 22 of file our_md5hl.c.

References LENGTH, and our_MD5Final().

Referenced by our_MD5Data(), and our_MD5File().

00023 {
00024     int i;
00025     unsigned char digest[LENGTH];
00026     static const char hex[]="0123456789abcdef";
00027 
00028     if (!buf)
00029         buf = (char*)malloc(2*LENGTH + 1);
00030     if (!buf)
00031         return 0;
00032     our_MD5Final(digest, ctx);
00033     for (i = 0; i < LENGTH; i++) {
00034         buf[i+i] = hex[digest[i] >> 4];
00035         buf[i+i+1] = hex[digest[i] & 0x0f];
00036     }
00037     buf[i+i] = '\0';
00038     return buf;
00039 }

char* our_MD5File ( const char *  filename,
char *  buf 
)

Definition at line 42 of file our_md5hl.c.

References BUFSIZ, NULL, our_MD5End(), our_MD5Init(), and ourMD5Update().

00043 {
00044     unsigned char buffer[BUFSIZ];
00045     MD5_CTX ctx;
00046     int i;
00047         FILE* f;
00048 
00049     our_MD5Init(&ctx);
00050     f = fopen(filename, "r");
00051     if (f == NULL) return 0;
00052     while ((i = fread(buffer,1,sizeof buffer,f)) > 0) {
00053         ourMD5Update(&ctx,buffer,i);
00054     }
00055     fclose(f);
00056     if (i < 0) return 0;
00057     return our_MD5End(&ctx, buf);
00058 }


Generated on Thu May 17 07:14:17 2012 for live by  doxygen 1.5.2