{
crc_actual = crc64_update(crc_actual, buffer, count);
bytes_read += count;
- if (mcrypt_enc_process_inplace(ctx, buffer, count) != 0)
+ if (mcrypt_encrypt_inplace(ctx, buffer, count) != 0)
{
FPUTS(T("\n\nMCrypt error: Failed to encrypt data!\n\n"), stderr);
goto clean_up;
if (count > 0U)
{
bytes_read += count;
- if (mcrypt_dec_process_inplace(ctx, buffer, count) != 0)
+ if (mcrypt_decrypt_inplace(ctx, buffer, count) != 0)
{
FPUTS(T("\n\nMCrypt error: Failed to decrypt data!\n\n"), stderr);
goto clean_up;
const size_t length = strlen(text_plain) + 1U;
int result = 1;
- mcrypt_t ctx_enc = MCRYPT_NULL, ctx_dec = MCRYPT_NULL;
+ mcrypt_t ctx = MCRYPT_NULL;
FPUTS(T("Self-test is running, please be patient... "), stderr);
goto clean_up;
}
- ctx_enc = mcrypt_alloc(seed, passphrase);
- if (!ctx_enc)
+ ctx = mcrypt_alloc(seed, passphrase);
+ if (!ctx)
{
FPUTS(T("error!\n\nnWhoops: Failed to initialize encoder!\n\n"), stderr);
goto clean_up;
}
- if (mcrypt_enc_process_inplace(ctx_enc, text_temp, length) != 0)
+ if (mcrypt_encrypt_inplace(ctx, (uint8_t*)text_temp, length) != 0)
{
FPUTS(T("error!\n\nWhoops: Failed to encrypt the message!\n\n"), stderr);
goto clean_up;
goto clean_up;
}
- ctx_dec = mcrypt_alloc(seed, passphrase);
- if (!ctx_dec)
+ if (mcrypt_reset(ctx, seed, passphrase) != 0)
{
FPUTS(T("error!\n\nWhoops: Failed to initialize decoder!\n\n"), stderr);
goto clean_up;
}
- if (mcrypt_dec_process_inplace(ctx_dec, text_temp, length) != 0)
+ if (mcrypt_decrypt_inplace(ctx, (uint8_t*)text_temp, length) != 0)
{
FPUTS(T("error!\n\nWhoops: Failed to decrypt the message!\n\n"), stderr);
goto clean_up;
clean_up:
- if (ctx_enc)
- {
- mcrypt_free(ctx_enc);
- }
-
- if (ctx_dec)
+ if (ctx)
{
- mcrypt_free(ctx_dec);
+ mcrypt_free(ctx);
}
if (text_temp)
#define FPUTS(X,Y) fputws((X),(Y))
#define FPRINTF(X,Y,...) fwprintf((X),(Y),__VA_ARGS__)
#define FOPEN(X,Y) _wfsopen((X),(Y),_SH_SECURE)
-#define FILENO(X) _fileno((X))
-#define FSTAT64(X,Y) _fstati64((X),(Y))
-#define STAT64_T struct _stati64
#ifdef __MINGW32__
#define PRISTR "ls"
#define PRIstr "hs"
#define FPUTS(X,Y) fputs((X),(Y))
#define FPRINTF(X,Y,...) fprintf((X),(Y),__VA_ARGS__)
#define FOPEN(X,Y) fopen((X),(Y))
-#define FILENO(X) fileno((X))
-#define FSTAT64(X,Y) fstat64((X),(Y))
-#define STAT64_T struct stat64
#define PRISTR "s"
#define PRIstr "s"
#define PRIwcs "ls"
#define WIN32_LEAN_AND_MEAN 1
#define _CRT_SECURE_NO_WARNINGS 1
#else
-#define _LARGEFILE64_SOURCE 1
+#define _GNU_SOURCE 1
#endif
#include "utils.h"
#include <Windows.h>
#include <io.h>
#include <fcntl.h>
+#define STAT_T struct _stati64
+#define FSTAT(X,Y) _fstati64((X),(Y))
+#define FILENO(X) _fileno((X))
#define S_IFMT _S_IFMT
#define S_IFDIR _S_IFDIR
#define S_IFIFO _S_IFIFO
+#else
+#if defined(__USE_LARGEFILE64) && (__USE_LARGEFILE64)
+#define STAT_T struct stat64
+#define FSTAT(X,Y) fstat64((X),(Y))
+#else
+#define STAT_T struct stat
+#define FSTAT(X,Y) fstat((X),(Y))
+#endif
+#define FILENO(X) fileno((X))
#endif
void init_terminal(void)
uint64_t get_file_size(FILE* const file)
{
- STAT64_T stat;
- if (FSTAT64(FILENO(file), &stat) != 0)
+ STAT_T stat;
+ if (FSTAT(FILENO(file), &stat) != 0)
{
return UINT64_MAX;
}
const CHR* get_file_name(const CHR* path)
{
const CHR* ptr;
- while (ptr = STRRCHR(path, T('/')))
+ while ((ptr = STRRCHR(path, T('/'))))
{
path = ptr + 1U;
}
- while (ptr = STRRCHR(path, T('\\')))
+ while ((ptr = STRRCHR(path, T('\\'))))
{
path = ptr + 1U;
}
/*
* Encryption routines
*/
-int mcrypt_enc_process(const mcrypt_t context, const uint8_t* const input, uint8_t* const output, size_t length);
-int mcrypt_enc_process_inplace(const mcrypt_t context, uint8_t* const buffer, size_t length);
+int mcrypt_encrypt(const mcrypt_t context, const uint8_t* const input, uint8_t* const output, size_t length);
+int mcrypt_encrypt_inplace(const mcrypt_t context, uint8_t* const buffer, size_t length);
/*
* Decryption routines
*/
-int mcrypt_dec_process(const mcrypt_t context, const uint8_t* const input, uint8_t* const output, size_t length);
-int mcrypt_dec_process_inplace(const mcrypt_t context, uint8_t* const buffer, size_t length);
+int mcrypt_decrypt(const mcrypt_t context, const uint8_t* const input, uint8_t* const output, size_t length);
+int mcrypt_decrypt_inplace(const mcrypt_t context, uint8_t* const buffer, size_t length);
/*
* Auxiliary functions
return 0;
}
-int mcrypt_enc_process(const mcrypt_t context, const uint8_t* const input, uint8_t* const output, size_t length)
+int mcrypt_encrypt(const mcrypt_t context, const uint8_t* const input, uint8_t* const output, size_t length)
{
crypt_state_t* const state = (crypt_state_t*)context;
if (!state)
return 0;
}
-int mcrypt_enc_process_inplace(const mcrypt_t context, uint8_t* const buffer, size_t length)
+int mcrypt_encrypt_inplace(const mcrypt_t context, uint8_t* const buffer, size_t length)
{
crypt_state_t* const state = (crypt_state_t*)context;
if (!state)
}
-int mcrypt_dec_process(const mcrypt_t context, const uint8_t* const input, uint8_t* const output, size_t length)
+int mcrypt_decrypt(const mcrypt_t context, const uint8_t* const input, uint8_t* const output, size_t length)
{
crypt_state_t* const state = (crypt_state_t*)context;
if (!state)
return 0;
}
-int mcrypt_dec_process_inplace(const mcrypt_t context, uint8_t* const buffer, size_t length)
+int mcrypt_decrypt_inplace(const mcrypt_t context, uint8_t* const buffer, size_t length)
{
crypt_state_t* const state = (crypt_state_t*)context;
if (!state)