/* excpt.h on Digital Unix 4.0 defines function_table */
#undef function_table
+#ifdef ZEND_WIN32
+#define ZEND_SECURE_ZERO(var, size) RtlSecureZeroMemory((var), (size))
+#else
+#define ZEND_SECURE_ZERO(var, size) memset((var), 0, (size))
+#endif
+
#endif /* ZEND_PORTABILITY_H */
/*
state[0] = tmp;
tmp = 0;
- memset(x, 0, sizeof(x));
+ ZEND_SECURE_ZERO(x, sizeof(x));
}
/* }}} */
state[7] += dd;
tmp = 0;
- memset(x, 0, sizeof(x));
+ ZEND_SECURE_ZERO(x, sizeof(x));
}
/* }}} */
state[0] = tmp;
tmp = 0;
- memset(x, 0, sizeof(x));
+ ZEND_SECURE_ZERO(x, sizeof(x));
}
/* }}} */
state[9] += ee;
tmp = 0;
- memset(x, 0, sizeof(x));
+ ZEND_SECURE_ZERO(x, sizeof(x));
}
/* }}} */
context->state[5] ^= state[5] ^ block[5];
context->state[6] ^= state[6] ^ block[6];
context->state[7] ^= state[7] ^ block[7];
-
- memset(state, 0, sizeof(state));
+
+ ZEND_SECURE_ZERO(state, sizeof(state));
}
PHP_HASH_API void PHP_WHIRLPOOLInit(PHP_WHIRLPOOL_CTX *context)
crypt_res = php_crypt_blowfish_rn(password, salt, output, sizeof(output));
if (!crypt_res) {
- memset(output, 0, PHP_MAX_SALT_LEN + 1);
+ ZEND_SECURE_ZERO(output, PHP_MAX_SALT_LEN + 1);
return NULL;
} else {
result = zend_string_init(output, strlen(output), 0);
-#ifdef PHP_WIN32
- RtlSecureZeroMemory(output, PHP_MAX_SALT_LEN + 1);
-#else
- memset(output, 0, PHP_MAX_SALT_LEN + 1);
-#endif
+ ZEND_SECURE_ZERO(output, PHP_MAX_SALT_LEN + 1);
return result;
}
} else {
inside the SHA256 implementation as well. */
sha256_init_ctx(&ctx);
sha256_finish_ctx(&ctx, alt_result);
-#ifdef PHP_WIN32
- RtlSecureZeroMemory(temp_result, sizeof(temp_result));
- RtlSecureZeroMemory(p_bytes, key_len);
- RtlSecureZeroMemory(s_bytes, salt_len);
- RtlSecureZeroMemory(&ctx, sizeof(ctx));
- RtlSecureZeroMemory(&alt_ctx, sizeof(alt_ctx));
-
- if (copied_key != NULL) {
- RtlSecureZeroMemory(copied_key, key_len);
- }
- if (copied_salt != NULL) {
- RtlSecureZeroMemory(copied_salt, salt_len);
- }
-#else
- memset(temp_result, '\0', sizeof(temp_result));
- memset(p_bytes, '\0', key_len);
- memset(s_bytes, '\0', salt_len);
- memset(&ctx, '\0', sizeof(ctx));
- memset(&alt_ctx, '\0', sizeof(alt_ctx));
+ ZEND_SECURE_ZERO(temp_result, sizeof(temp_result));
+ ZEND_SECURE_ZERO(p_bytes, key_len);
+ ZEND_SECURE_ZERO(s_bytes, salt_len);
+ ZEND_SECURE_ZERO(&ctx, sizeof(ctx));
+ ZEND_SECURE_ZERO(&alt_ctx, sizeof(alt_ctx));
if (copied_key != NULL) {
- memset(copied_key, '\0', key_len);
+ ZEND_SECURE_ZERO(copied_key, key_len);
}
if (copied_salt != NULL) {
- memset(copied_salt, '\0', salt_len);
+ ZEND_SECURE_ZERO(copied_salt, salt_len);
}
-#endif
return buffer;
}
inside the SHA512 implementation as well. */
sha512_init_ctx(&ctx);
sha512_finish_ctx(&ctx, alt_result);
-#ifdef PHP_WIN32
- RtlSecureZeroMemory(temp_result, sizeof(temp_result));
- RtlSecureZeroMemory(p_bytes, key_len);
- RtlSecureZeroMemory(s_bytes, salt_len);
- RtlSecureZeroMemory(&ctx, sizeof(ctx));
- RtlSecureZeroMemory(&alt_ctx, sizeof(alt_ctx));
+ ZEND_SECURE_ZERO(temp_result, sizeof(temp_result));
+ ZEND_SECURE_ZERO(p_bytes, key_len);
+ ZEND_SECURE_ZERO(s_bytes, salt_len);
+ ZEND_SECURE_ZERO(&ctx, sizeof(ctx));
+ ZEND_SECURE_ZERO(&alt_ctx, sizeof(alt_ctx));
if (copied_key != NULL) {
- RtlSecureZeroMemory(copied_key, key_len);
+ ZEND_SECURE_ZERO(copied_key, key_len);
}
if (copied_salt != NULL) {
- RtlSecureZeroMemory(copied_salt, salt_len);
- }
-#else
- memset(temp_result, '\0', sizeof(temp_result));
- memset(p_bytes, '\0', key_len);
- memset(s_bytes, '\0', salt_len);
- memset(&ctx, '\0', sizeof(ctx));
- memset(&alt_ctx, '\0', sizeof(alt_ctx));
- if (copied_key != NULL) {
- memset(copied_key, '\0', key_len);
+ ZEND_SECURE_ZERO(copied_salt, salt_len);
}
- if (copied_salt != NULL) {
- memset(copied_salt, '\0', salt_len);
- }
-#endif
return buffer;
}
}
/* Don't leave anything around in vm they could use. */
- RtlSecureZeroMemory(final, sizeof(final));
+ ZEND_SECURE_ZERO(final, sizeof(final));
/* Then something really weird... */
for (i = pwl; i != 0; i >>= 1) {
*p = '\0';
- RtlSecureZeroMemory(final, sizeof(final));
+ ZEND_SECURE_ZERO(final, sizeof(final));
_destroyCtx1: