#include <string.h>
#include <stdio.h>
#include <openssl/md5.h>
#include "rtv.h"
int generate_hash(unsigned char * src, unsigned char * dst)
{
MD5_CTX md5_context;
unsigned char digits[] = "0123456789";
unsigned char md5[16];
int i;
u32 hash;
MD5_Init(&md5_context);
MD5_Update(&md5_context, src, strlen(src));
MD5_Final(md5, &md5_context);
hash = 0;
for (i = 0; i < 16; i += 4 ) {
hash ^= (md5[i]) |
(md5[i + 1] << 8) |
(md5[i + 2] << 16) |
(md5[i + 3] << 24);
}
for (i = 0; i < 3; i++, hash /= 10)
dst[i] = digits[hash % 10];
dst[i] = 0;
return 0;
}
void generate_reset_key(char * SN, char * ResetPin, char * dst)
{
unsigned char digits[] = "9876543210123456789";
unsigned char hash1[4];
unsigned char hash2[4];
u32 i;
generate_hash(SN, hash1);
generate_hash(hash1, hash2);
dst[0] = digits[(hash1[2] + hash2[1] + ResetPin[0]) % 19];
dst[1] = digits[(hash1[1] + hash2[1] + ResetPin[1]) % 19];
dst[2] = digits[(hash1[2] + hash2[2] + ResetPin[2]) % 19];
dst[3] = digits[(hash1[3] + hash2[3] + ResetPin[3]) % 19]; /* always '9' */
dst[4] = 0;
}
-- ToddLarason - 31 May 2002
| Topic ParentalControls . { Edit | Attach | Ref-By | Printable | Diffs | r1.2 | > | r1.1 | More } |
| Revision r1.2 - 01 Apr 2003 - 04:45 GMT - TWikiGuest |
Copyright © 2001 by the contributing authors.
All material on this collaboration tool is the property of the contributing authors. Ideas, requests, problems regarding TWiki? Send feedback. |