clamav/libclamav/rijndael.h
Micah Snyder e48dfad49a Windows: Fix C/Rust FFI compat issue + Windows compile warnings
Primarily this commit fixes an issue with the size of the parameters
passed to cli_checklimits(). The parameters were "unsigned long", which
varies in size depending on platform.
I've switched them to uint64_t / u64.

While working on this, I observed some concerning warnigns on Windows,
and some less serious ones, primarily regarding inconsistencies with
`const` parameters.

Finally, in `scanmem.c`, there is a warning regarding use of `wchar_t *`
with `GetModuleFileNameEx()` instead of `GetModuleFileNameExW()`.
This made me realize this code assumes we're not defining `UNICODE`,
which would have such macros use the 'A' variant.
I have fixed it the best I can, although I'm still a little
uncomfortable with some of this code that uses `char` or `wchar_t`
instead of TCHAR.

I also remove the `if (GetModuleFileNameEx) {` conditional, because this
macro/function will always be defined. The original code was checking a
function pointer, and so this was a bug when integrating into ClamAV.

Regarding the changes to `rijndael.c`, I found that this module assumes
`unsigned long` == 32bits. It does not.
I have corrected it to use `uint32_t`.
2024-04-09 10:35:22 -04:00

17 lines
677 B
C

/* public domain code from http://www.efgh.com/software/rijndael.htm */
#ifndef H__RIJNDAEL
#define H__RIJNDAEL
#include "clamav-types.h"
int rijndaelSetupDecrypt(uint32_t *rk, const unsigned char *key, int keybits);
void rijndaelDecrypt(const uint32_t *rk, int nrounds, const unsigned char ciphertext[16], unsigned char plaintext[16]);
int rijndaelSetupEncrypt(uint32_t *rk, const unsigned char *key, int keybits);
void rijndaelEncrypt(const uint32_t *rk, int nrounds, const unsigned char plaintext[16], unsigned char ciphertext[16]);
#define KEYLENGTH(keybits) ((keybits)/8)
#define RKLENGTH(keybits) ((keybits)/8+28)
#define NROUNDS(keybits) ((keybits)/32+6)
#endif