#endif
WINPR_API int winpr_RAND(BYTE* output, size_t len);
+WINPR_API int winpr_RAND_pseudo(BYTE* output, size_t len);
#ifdef __cplusplus
}
extern "C" {
#endif
-int winpr_openssl_BytesToKey(int cipher, int md, const BYTE* salt, const BYTE* data, int datal, int count, BYTE* key, BYTE* iv);
+WINPR_API int winpr_openssl_BytesToKey(int cipher, int md, const BYTE* salt, const BYTE* data, int datal, int count, BYTE* key, BYTE* iv);
#ifdef __cplusplus
}
if (addmd++)
{
- if (mbedtls_md_update(&ctx, &(md_buf[0]), mds) != 0)
+ if (mbedtls_md_update(&ctx, md_buf, mds) != 0)
goto err;
}
goto err;
}
- if (mbedtls_md_finish(&ctx, &(md_buf[0])) != 0)
+ if (mbedtls_md_finish(&ctx, md_buf) != 0)
goto err;
mds = mbedtls_md_get_size(md_info);
{
if (mbedtls_md_starts(&ctx) != 0)
goto err;
- if (mbedtls_md_update(&ctx, &(md_buf[0]), mds) != 0)
+ if (mbedtls_md_update(&ctx, md_buf, mds) != 0)
goto err;
- if (mbedtls_md_finish(&ctx, &(md_buf[0])) != 0)
+ if (mbedtls_md_finish(&ctx, md_buf) != 0)
goto err;
}
rv = cipher_info->key_bitlen / 8;
err:
mbedtls_md_free(&ctx);
- SecureZeroMemory(&(md_buf[0]), EVP_MAX_MD_SIZE);
+ SecureZeroMemory(md_buf, 64);
return rv;
#endif
#include <mbedtls/hmac_drbg.h>
#endif
-#undef WITH_OPENSSL
-
int winpr_RAND(BYTE* output, size_t len)
{
#if defined(WITH_OPENSSL)
#endif
return 0;
}
+
+int winpr_RAND_pseudo(BYTE* output, size_t len)
+{
+#if defined(WITH_OPENSSL)
+ RAND_pseudo_bytes(output, len);
+#elif defined(WITH_MBEDTLS) && defined(MBEDTLS_HAVEGE_C)
+ mbedtls_havege_state hs;
+ mbedtls_havege_init(&hs);
+ mbedtls_havege_random(&hs, output, len);
+ mbedtls_havege_free(&hs);
+#endif
+ return 0;
+}
#include "config.h"
#endif
-#include <stdio.h>
-
#include <winpr/crt.h>
#include <winpr/rpc.h>
+#include <winpr/crypto.h>
#ifndef _WIN32
-#include <openssl/rand.h>
-
#include "../log.h"
#define TAG WINPR_TAG("rpc")
RPC_STATUS UuidCreate(UUID* Uuid)
{
- RAND_pseudo_bytes((void*) Uuid, 16);
+ winpr_RAND_pseudo((BYTE*) Uuid, 16);
return RPC_S_OK;
}
RPC_STATUS UuidCreateSequential(UUID* Uuid)
{
- RAND_pseudo_bytes((void*) Uuid, 16);
+ winpr_RAND_pseudo((BYTE*) Uuid, 16);
return RPC_S_OK;
}
#include "config.h"
#endif
-#include <stdlib.h>
-
#include <winpr/windows.h>
#include <winpr/crt.h>
#include <winpr/ssl.h>
#include <winpr/print.h>
-#include <openssl/ssl.h>
-#include <openssl/err.h>
-
#include "sspi.h"
#include "sspi_winpr.h"
${${MODULE_PREFIX}_DRIVER}
${${MODULE_PREFIX}_TESTS})
-include_directories(${ZLIB_INCLUDE_DIRS})
include_directories(${OPENSSL_INCLUDE_DIR})
add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
-set(${MODULE_PREFIX}_LIBS
- ${ZLIB_LIBRARIES}
- ${OPENSSL_LIBRARIES})
+set(${MODULE_PREFIX}_LIBS ${OPENSSL_LIBRARIES})
if(WIN32)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} secur32 crypt32)
#include <winpr/ntlm.h>
#include <winpr/crt.h>
-
-#ifdef WITH_OPENSSL
-#include <openssl/ssl.h>
-#include <openssl/md4.h>
-#endif
+#include <winpr/crypto.h>
/**
* Define NTOWFv1(Password, User, Domain) as
BYTE* NTOWFv1W(LPWSTR Password, UINT32 PasswordLength, BYTE* NtHash)
{
+ WINPR_MD4_CTX md4;
+
if (!Password)
return NULL;
if (!NtHash && !(NtHash = malloc(16)))
return NULL;
-#ifdef WITH_OPENSSL
- {
- MD4_CTX md4_ctx;
- MD4_Init(&md4_ctx);
- MD4_Update(&md4_ctx, Password, PasswordLength);
- MD4_Final((void*) NtHash, &md4_ctx);
- }
-#endif
+ winpr_MD4_Init(&md4);
+ winpr_MD4_Update(&md4, (BYTE*) Password, (size_t) PasswordLength);
+ winpr_MD4_Final(&md4, NtHash);
return NtHash;
}
CopyMemory(&buffer[UserLength], Domain, DomainLength);
/* Compute the HMAC-MD5 hash of the above value using the NTLMv1 hash as the key, the result is the NTLMv2 hash */
-#ifdef WITH_OPENSSL
- HMAC(EVP_md5(), (void*) NtHashV1, 16, buffer, UserLength + DomainLength, (void*) NtHash, NULL);
-#endif
+ winpr_HMAC(WINPR_MD_MD5, NtHashV1, 16, buffer, UserLength + DomainLength, NtHash);
free(buffer);
}
/* Compute the HMAC-MD5 hash of the above value using the NTLMv1 hash as the key, the result is the NTLMv2 hash */
-#ifdef WITH_OPENSSL
- HMAC(EVP_md5(), (void*) NtHashV1, 16, buffer, UserLength + DomainLength, (void*) NtHash, NULL);
-#endif
+ winpr_HMAC(WINPR_MD_MD5, NtHashV1, 16, buffer, UserLength + DomainLength, NtHash);
free(buffer);