Fixed indentation.
This commit is contained in:
parent
7a253bae42
commit
fe8f5dee82
@ -563,28 +563,28 @@ BYTE* freerdp_assistance_encrypt_pass_stub(const char* password, const char* pas
|
||||
cbPasswordW = (status - 1) * 2;
|
||||
|
||||
if (!winpr_MD5_Init(&md5Ctx))
|
||||
{
|
||||
free (PasswordW);
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
free (PasswordW);
|
||||
return NULL;
|
||||
}
|
||||
if (!winpr_MD5_Update(&md5Ctx, (BYTE*)PasswordW, cbPasswordW))
|
||||
{
|
||||
free (PasswordW);
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
free (PasswordW);
|
||||
return NULL;
|
||||
}
|
||||
if (!winpr_MD5_Final(&md5Ctx, (BYTE*) PasswordHash, sizeof(PasswordHash)))
|
||||
{
|
||||
free (PasswordW);
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
free (PasswordW);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
status = ConvertToUnicode(CP_UTF8, 0, passStub, -1, &PassStubW, 0);
|
||||
|
||||
if (status <= 0)
|
||||
{
|
||||
free (PasswordW);
|
||||
{
|
||||
free (PasswordW);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
cbPassStubW = (status - 1) * 2;
|
||||
|
||||
|
@ -47,41 +47,41 @@ BOOL winpr_MD5_Init(WINPR_MD5_CTX* ctx)
|
||||
{
|
||||
#if defined(WITH_OPENSSL)
|
||||
if (MD5_Init((MD5_CTX*) ctx) != 1)
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
#elif defined(WITH_MBEDTLS) && defined(MBEDTLS_MD5_C)
|
||||
mbedtls_md5_init((mbedtls_md5_context*) ctx);
|
||||
mbedtls_md5_starts((mbedtls_md5_context*) ctx);
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL winpr_MD5_Update(WINPR_MD5_CTX* ctx, const BYTE* input, size_t ilen)
|
||||
{
|
||||
#if defined(WITH_OPENSSL)
|
||||
if (MD5_Update((MD5_CTX*) ctx, input, ilen) != 1)
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
#elif defined(WITH_MBEDTLS) && defined(MBEDTLS_MD5_C)
|
||||
mbedtls_md5_update((mbedtls_md5_context*) ctx, input, ilen);
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL winpr_MD5_Final(WINPR_MD5_CTX* ctx, BYTE* output, size_t ilen)
|
||||
{
|
||||
if (ilen < WINPR_MD5_DIGEST_LENGTH)
|
||||
return FALSE;
|
||||
if (ilen < WINPR_MD5_DIGEST_LENGTH)
|
||||
return FALSE;
|
||||
|
||||
#if defined(WITH_OPENSSL)
|
||||
if (MD5_Final(output, (MD5_CTX*) ctx) != 1)
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
#elif defined(WITH_MBEDTLS) && defined(MBEDTLS_MD5_C)
|
||||
mbedtls_md5_finish((mbedtls_md5_context*) ctx, output);
|
||||
mbedtls_md5_free((mbedtls_md5_context*) ctx);
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL winpr_MD5(const BYTE* input, size_t ilen, BYTE* output, size_t olen)
|
||||
@ -89,9 +89,9 @@ BOOL winpr_MD5(const BYTE* input, size_t ilen, BYTE* output, size_t olen)
|
||||
WINPR_MD5_CTX ctx;
|
||||
|
||||
if (!winpr_MD5_Init(&ctx))
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
if (!winpr_MD5_Update(&ctx, input, ilen))
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
return winpr_MD5_Final(&ctx, output, olen);
|
||||
}
|
||||
|
||||
@ -103,40 +103,40 @@ BOOL winpr_MD4_Init(WINPR_MD4_CTX* ctx)
|
||||
{
|
||||
#if defined(WITH_OPENSSL)
|
||||
if (MD4_Init((MD4_CTX*) ctx) != 1)
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
#elif defined(WITH_MBEDTLS) && defined(MBEDTLS_MD4_C)
|
||||
mbedtls_md4_init((mbedtls_md4_context*) ctx);
|
||||
mbedtls_md4_starts((mbedtls_md4_context*) ctx);
|
||||
#endif
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL winpr_MD4_Update(WINPR_MD4_CTX* ctx, const BYTE* input, size_t ilen)
|
||||
{
|
||||
#if defined(WITH_OPENSSL)
|
||||
if (MD4_Update((MD4_CTX*) ctx, input, ilen) != 1)
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
#elif defined(WITH_MBEDTLS) && defined(MBEDTLS_MD4_C)
|
||||
mbedtls_md4_update((mbedtls_md4_context*) ctx, input, ilen);
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL winpr_MD4_Final(WINPR_MD4_CTX* ctx, BYTE* output, size_t olen)
|
||||
{
|
||||
if (olen < WINPR_MD4_DIGEST_LENGTH)
|
||||
return FALSE;
|
||||
if (olen < WINPR_MD4_DIGEST_LENGTH)
|
||||
return FALSE;
|
||||
|
||||
#if defined(WITH_OPENSSL)
|
||||
if (MD4_Final(output, (MD4_CTX*) ctx) != 1)
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
#elif defined(WITH_MBEDTLS) && defined(MBEDTLS_MD4_C)
|
||||
mbedtls_md4_finish((mbedtls_md4_context*) ctx, output);
|
||||
mbedtls_md4_free((mbedtls_md4_context*) ctx);
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL winpr_MD4(const BYTE* input, size_t ilen, BYTE* output, size_t olen)
|
||||
@ -144,9 +144,9 @@ BOOL winpr_MD4(const BYTE* input, size_t ilen, BYTE* output, size_t olen)
|
||||
WINPR_MD4_CTX ctx;
|
||||
|
||||
if (!winpr_MD4_Init(&ctx))
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
if (!winpr_MD4_Update(&ctx, input, ilen))
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
return winpr_MD4_Final(&ctx, output, olen);
|
||||
}
|
||||
|
||||
@ -158,41 +158,41 @@ BOOL winpr_SHA1_Init(WINPR_SHA1_CTX* ctx)
|
||||
{
|
||||
#if defined(WITH_OPENSSL)
|
||||
if (SHA1_Init((SHA_CTX*) ctx) != 1)
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
#elif defined(WITH_MBEDTLS) && defined(MBEDTLS_SHA1_C)
|
||||
mbedtls_sha1_init((mbedtls_sha1_context*) ctx);
|
||||
mbedtls_sha1_starts((mbedtls_sha1_context*) ctx);
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL winpr_SHA1_Update(WINPR_SHA1_CTX* ctx, const BYTE* input, size_t ilen)
|
||||
{
|
||||
#if defined(WITH_OPENSSL)
|
||||
if (SHA1_Update((SHA_CTX*) ctx, input, ilen) != 1)
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
#elif defined(WITH_MBEDTLS) && defined(MBEDTLS_SHA1_C)
|
||||
mbedtls_sha1_update((mbedtls_sha1_context*) ctx, input, ilen);
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL winpr_SHA1_Final(WINPR_SHA1_CTX* ctx, BYTE* output, size_t olen)
|
||||
{
|
||||
if (olen < WINPR_SHA1_DIGEST_LENGTH)
|
||||
return FALSE;
|
||||
if (olen < WINPR_SHA1_DIGEST_LENGTH)
|
||||
return FALSE;
|
||||
|
||||
#if defined(WITH_OPENSSL)
|
||||
if (SHA1_Final(output, (SHA_CTX*) ctx) != 1)
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
#elif defined(WITH_MBEDTLS) && defined(MBEDTLS_SHA1_C)
|
||||
mbedtls_sha1_finish((mbedtls_sha1_context*) ctx, output);
|
||||
mbedtls_sha1_free((mbedtls_sha1_context*) ctx);
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL winpr_SHA1(const BYTE* input, size_t ilen, BYTE* output, size_t olen)
|
||||
@ -200,9 +200,9 @@ BOOL winpr_SHA1(const BYTE* input, size_t ilen, BYTE* output, size_t olen)
|
||||
WINPR_SHA1_CTX ctx;
|
||||
|
||||
if (!winpr_SHA1_Init(&ctx))
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
if (!winpr_SHA1_Update(&ctx, input, ilen))
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
return winpr_SHA1_Final(&ctx, output, olen);
|
||||
}
|
||||
|
||||
@ -362,10 +362,10 @@ BOOL winpr_HMAC_Update(WINPR_HMAC_CTX* ctx, const BYTE* input, size_t ilen)
|
||||
|
||||
BOOL winpr_HMAC_Final(WINPR_HMAC_CTX* ctx, BYTE* output, size_t olen)
|
||||
{
|
||||
/* TODO
|
||||
if (olen < ctx->digestLength)
|
||||
return FALSE;
|
||||
*/
|
||||
/* TODO
|
||||
if (olen < ctx->digestLength)
|
||||
return FALSE;
|
||||
*/
|
||||
|
||||
#if defined(WITH_OPENSSL)
|
||||
#if (OPENSSL_VERSION_NUMBER < 0x10000000L)
|
||||
@ -385,7 +385,7 @@ BOOL winpr_HMAC_Final(WINPR_HMAC_CTX* ctx, BYTE* output, size_t olen)
|
||||
}
|
||||
|
||||
BOOL winpr_HMAC(WINPR_MD_TYPE md, const BYTE* key, size_t keylen,
|
||||
const BYTE* input, size_t ilen, BYTE* output, size_t olen)
|
||||
const BYTE* input, size_t ilen, BYTE* output, size_t olen)
|
||||
{
|
||||
WINPR_HMAC_CTX ctx;
|
||||
|
||||
@ -450,7 +450,7 @@ BOOL winpr_Digest_Update(WINPR_DIGEST_CTX* ctx, const BYTE* input, size_t ilen)
|
||||
|
||||
BOOL winpr_Digest_Final(WINPR_DIGEST_CTX* ctx, BYTE* output, size_t olen)
|
||||
{
|
||||
// TODO: output length check
|
||||
// TODO: output length check
|
||||
#if defined(WITH_OPENSSL)
|
||||
if (EVP_DigestFinal_ex((EVP_MD_CTX*) ctx, output, NULL) != 1)
|
||||
return FALSE;
|
||||
|
@ -12,11 +12,11 @@ BOOL test_crypto_hash_md5()
|
||||
WINPR_MD5_CTX ctx;
|
||||
|
||||
if (!winpr_MD5_Init(&ctx))
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
if (!winpr_MD5_Update(&ctx, (BYTE*) TEST_MD5_DATA, strlen(TEST_MD5_DATA)))
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
if (!winpr_MD5_Final(&ctx, hash, sizeof(hash)))
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
|
||||
if (memcmp(hash, TEST_MD5_HASH, WINPR_MD5_DIGEST_LENGTH) != 0)
|
||||
{
|
||||
@ -46,11 +46,11 @@ BOOL test_crypto_hash_md4()
|
||||
WINPR_MD4_CTX ctx;
|
||||
|
||||
if (!winpr_MD4_Init(&ctx))
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
if (!winpr_MD4_Update(&ctx, (BYTE*) TEST_MD4_DATA, strlen(TEST_MD4_DATA)))
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
if (!winpr_MD4_Final(&ctx, hash, sizeof(hash)))
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
|
||||
if (memcmp(hash, TEST_MD4_HASH, WINPR_MD4_DIGEST_LENGTH) != 0)
|
||||
{
|
||||
@ -80,11 +80,11 @@ BOOL test_crypto_hash_sha1()
|
||||
WINPR_SHA1_CTX ctx;
|
||||
|
||||
if (!winpr_SHA1_Init(&ctx))
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
if (!winpr_SHA1_Update(&ctx, (BYTE*) TEST_SHA1_DATA, strlen(TEST_SHA1_DATA)))
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
if (!winpr_SHA1_Final(&ctx, hash, sizeof(hash)))
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
|
||||
if (memcmp(hash, TEST_SHA1_HASH, WINPR_MD5_DIGEST_LENGTH) != 0)
|
||||
{
|
||||
@ -115,11 +115,11 @@ BOOL test_crypto_hash_hmac_md5()
|
||||
WINPR_HMAC_CTX ctx;
|
||||
|
||||
if (!winpr_HMAC_Init(&ctx, WINPR_MD_MD5, TEST_HMAC_MD5_KEY, WINPR_SHA1_DIGEST_LENGTH))
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
if (!winpr_HMAC_Update(&ctx, (BYTE*) TEST_HMAC_MD5_DATA, strlen(TEST_HMAC_MD5_DATA)))
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
if (!winpr_HMAC_Final(&ctx, hash, sizeof(hash)))
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
|
||||
if (memcmp(hash, TEST_HMAC_MD5_HASH, WINPR_SHA1_DIGEST_LENGTH) != 0)
|
||||
{
|
||||
@ -150,11 +150,11 @@ BOOL test_crypto_hash_hmac_sha1()
|
||||
WINPR_HMAC_CTX ctx;
|
||||
|
||||
if (!winpr_HMAC_Init(&ctx, WINPR_MD_SHA1, TEST_HMAC_SHA1_KEY, WINPR_SHA1_DIGEST_LENGTH))
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
if (!winpr_HMAC_Update(&ctx, (BYTE*) TEST_HMAC_SHA1_DATA, strlen(TEST_HMAC_SHA1_DATA)))
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
if (!winpr_HMAC_Final(&ctx, hash, sizeof(hash)))
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
|
||||
if (memcmp(hash, TEST_HMAC_SHA1_HASH, WINPR_SHA1_DIGEST_LENGTH) != 0)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user