|
|
| version 1.6.2.1.2.2, 2003/04/24 07:16:34 | version 1.9, 2003/04/25 10:54:54 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: copied from apache 1.3.20 sources. | Parser: copied from apache 1.3.20 sources. |
| Replaced ap_ to pa_ prefixes. linked into all targets but Apache-module target, | Replaced ap_ to PA_ prefixes. linked into all targets but Apache-module target, |
| where linked targets/apache/pa_md5c.c stub instead. | where linked targets/apache/PA_md5c.c stub instead. |
| Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001, 2003 ArtLebedev Group (http://www.artlebedev.com) |
| */ | */ |
| /* | /* |
| Line 113 static const char* IDENT_MD5_C="$Date$"; | Line 113 static const char* IDENT_MD5_C="$Date$"; |
| #include "pa_md5.h" | #include "pa_md5.h" |
| #define pa_pa_cpystrn(strDest, strSource, count) strncpy(strDest, strSource, count) | #define PA_cpystrn(strDest, strSource, count) strncpy(strDest, strSource, count) |
| /* Constants for MD5Transform routine. | /* Constants for MD5Transform routine. |
| */ | */ |
| Line 420 static void Decode(UINT4 *output, const | Line 420 static void Decode(UINT4 *output, const |
| * the FreeBSD 3.0 /usr/src/lib/libcrypt/crypt.c file, which is | * the FreeBSD 3.0 /usr/src/lib/libcrypt/crypt.c file, which is |
| * licenced as stated at the top of this file. | * licenced as stated at the top of this file. |
| */ | */ |
| PA_API_EXPORT(void) pa_to64(char *s, unsigned long v, int n) | PA_API_EXPORT(void) PA_to64(char *s, unsigned long v, int n) |
| { | { |
| static unsigned char itoa64[] = /* 0 ... 63 => ASCII - 64 */ | static unsigned char itoa64[] = /* 0 ... 63 => ASCII - 64 */ |
| "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; | "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; |
| Line 432 PA_API_EXPORT(void) pa_to64(char *s, uns | Line 432 PA_API_EXPORT(void) pa_to64(char *s, uns |
| } | } |
| PA_API_EXPORT(void) PA_MD5Encode(const unsigned char *pw, | PA_API_EXPORT(void) PA_MD5Encode(const unsigned char *pw, |
| const unsigned char *salt, | const unsigned char *salt, int mix_in_magic_string, |
| char *result, size_t nbytes) | char* result_base64, size_t result_base64_size) |
| { | { |
| /* | /* |
| * Minimum size is 8 bytes for salt, plus 1 for the trailing NUL, | * Minimum size is 8 bytes for salt, plus 1 for the trailing NUL, |
| Line 488 PA_API_EXPORT(void) PA_MD5Encode(const u | Line 488 PA_API_EXPORT(void) PA_MD5Encode(const u |
| */ | */ |
| PA_MD5Update(&ctx, pw, pwlen); | PA_MD5Update(&ctx, pw, pwlen); |
| /* | if(mix_in_magic_string) { |
| * Then our magic string | /* |
| */ | * Then our magic string |
| PA_MD5Update(&ctx, (const unsigned char *) PA_MD5PW_ID, PA_MD5PW_IDLEN); | */ |
| PA_MD5Update(&ctx, (const unsigned char *) PA_MD5PW_ID, PA_MD5PW_IDLEN); | |
| } | |
| /* | /* |
| * Then the raw salt | * Then the raw salt |
| Line 531 PA_API_EXPORT(void) PA_MD5Encode(const u | Line 533 PA_API_EXPORT(void) PA_MD5Encode(const u |
| * Now make the output string. We know our limitations, so we | * Now make the output string. We know our limitations, so we |
| * can use the string routines without bounds checking. | * can use the string routines without bounds checking. |
| */ | */ |
| pa_pa_cpystrn(passwd, PA_MD5PW_ID, PA_MD5PW_IDLEN + 1); | PA_cpystrn(passwd, PA_MD5PW_ID, PA_MD5PW_IDLEN + 1); |
| pa_pa_cpystrn(passwd + PA_MD5PW_IDLEN, (char *)sp, sl + 1); | PA_cpystrn(passwd + PA_MD5PW_IDLEN, (char *)sp, sl + 1); |
| passwd[PA_MD5PW_IDLEN + sl] = '$'; | passwd[PA_MD5PW_IDLEN + sl] = '$'; |
| passwd[PA_MD5PW_IDLEN + sl + 1] = '\0'; | passwd[PA_MD5PW_IDLEN + sl + 1] = '\0'; |
| Line 570 PA_API_EXPORT(void) PA_MD5Encode(const u | Line 572 PA_API_EXPORT(void) PA_MD5Encode(const u |
| p = passwd + strlen(passwd); | p = passwd + strlen(passwd); |
| l = (final[ 0]<<16) | (final[ 6]<<8) | final[12]; pa_to64(p, l, 4); p += 4; | l = (final[ 0]<<16) | (final[ 6]<<8) | final[12]; PA_to64(p, l, 4); p += 4; |
| l = (final[ 1]<<16) | (final[ 7]<<8) | final[13]; pa_to64(p, l, 4); p += 4; | l = (final[ 1]<<16) | (final[ 7]<<8) | final[13]; PA_to64(p, l, 4); p += 4; |
| l = (final[ 2]<<16) | (final[ 8]<<8) | final[14]; pa_to64(p, l, 4); p += 4; | l = (final[ 2]<<16) | (final[ 8]<<8) | final[14]; PA_to64(p, l, 4); p += 4; |
| l = (final[ 3]<<16) | (final[ 9]<<8) | final[15]; pa_to64(p, l, 4); p += 4; | l = (final[ 3]<<16) | (final[ 9]<<8) | final[15]; PA_to64(p, l, 4); p += 4; |
| l = (final[ 4]<<16) | (final[10]<<8) | final[ 5]; pa_to64(p, l, 4); p += 4; | l = (final[ 4]<<16) | (final[10]<<8) | final[ 5]; PA_to64(p, l, 4); p += 4; |
| l = final[11] ; pa_to64(p, l, 2); p += 2; | l = final[11] ; PA_to64(p, l, 2); p += 2; |
| *p = '\0'; | *p = '\0'; |
| /* | /* |
| * Don't leave anything around in vm they could use. | * Don't leave anything around in vm they could use. |
| */ | */ |
| memset(final, 0, sizeof(final)); | memset(final, 0, sizeof(final)); |
| pa_pa_cpystrn(result, passwd, nbytes - 1); | PA_cpystrn(result_base64, passwd, result_base64_size - 1); |
| } | } |