47MUTEX_T php_crypt_extended_init_lock;
53 php_crypt_extended_init_lock = tsrm_mutex_alloc();
60 tsrm_mutex_free(php_crypt_extended_init_lock);
69 tsrm_mutex_lock(php_crypt_extended_init_lock);
78 tsrm_mutex_unlock(php_crypt_extended_init_lock);
83#define MD5_MAGIC "$1$"
84#define MD5_MAGIC_LEN 3
86static const unsigned char itoa64[] =
87 "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
90static void to64(
char *
s, int32_t
v,
int n)
93 *
s++ = itoa64[
v & 0x3f];
105 unsigned char final[16];
106 unsigned int i, sl, pwl;
121 for (ep = sp; *ep !=
'\0' && *ep !=
'$' && ep < (sp + 8); ep++);
144 for (pl = pwl; pl > 0; pl -= 16)
145 PHP_MD5Update(&ctx,
final, (
unsigned int)(pl > 16 ? 16 : pl));
151 for (i = pwl; i != 0; i >>= 1)
169 for (i = 0; i < 1000; i++) {
193 l = (
final[ 0]<<16) | (
final[ 6]<<8) |
final[12]; to64(
p,l,4);
p += 4;
194 l = (
final[ 1]<<16) | (
final[ 7]<<8) |
final[13]; to64(
p,l,4);
p += 4;
195 l = (
final[ 2]<<16) | (
final[ 8]<<8) |
final[14]; to64(
p,l,4);
p += 4;
196 l = (
final[ 3]<<16) | (
final[ 9]<<8) |
final[15]; to64(
p,l,4);
p += 4;
197 l = (
final[ 4]<<16) | (
final[10]<<8) |
final[ 5]; to64(
p,l,4);
p += 4;
198 l =
final[11] ; to64(
p,l,2);
p += 2;
void _crypt_extended_init(void)
PHPAPI void PHP_MD5Final(unsigned char *result, PHP_MD5_CTX *ctx)
PHPAPI void PHP_MD5Update(PHP_MD5_CTX *ctx, const void *data, size_t size)
void php_shutdown_crypt_r(void)
void php_init_crypt_r(void)
void _crypt_extended_init_r(void)
char * php_md5_crypt_r(const char *pw, const char *salt, char *out)
strncmp(string $string1, string $string2, int $length)
#define ZEND_SECURE_ZERO(var, size)