crypt_aes: Use stdbool.h bools

This commit is contained in:
Martin Piatka
2025-11-20 11:10:17 +01:00
parent da5fb4564d
commit cdb2dc1b4d
2 changed files with 9 additions and 7 deletions

View File

@@ -35,6 +35,8 @@
* John Skodon <skodonj@webquill.com>
*/
#include <stdbool.h>
#include "config.h"
#include "config_unix.h"
#include "config_win32.h"
@@ -99,7 +101,7 @@ int makeKey(keyInstance * key, BYTE direction, int keyLen, const char *keyMateri
key->Nr = rijndaelKeySetupDec(key->rk, cipherKey, keyLen);
}
rijndaelKeySetupEnc(key->ek, cipherKey, keyLen);
return TRUE;
return true;
}
int cipherInit(cipherInstance * cipher, BYTE mode, char *IV)
@@ -139,7 +141,7 @@ int cipherInit(cipherInstance * cipher, BYTE mode, char *IV)
} else {
memset(cipher->IV, 0, MAX_IV_SIZE);
}
return TRUE;
return true;
}
int blockEncrypt(cipherInstance * cipher, keyInstance * key,
@@ -187,7 +189,8 @@ int blockEncrypt(cipherInstance * cipher, keyInstance * key,
case MODE_CFB1:
iv = cipher->IV;
for (i = numBlocks; i > 0; i--) {
memcpy(outBuffer, input, 16);
for (k = 0; k < 128; k++) {
rijndaelEncrypt(key->ek, key->Nr, iv, block);
outBuffer[k >> 3] ^=
@@ -328,7 +331,8 @@ int blockDecrypt(cipherInstance * cipher, keyInstance * key,
iv = cipher->IV;
for (i = numBlocks; i > 0; i--) {
memcpy(outBuffer, input, 16);
memcpy(outBuffer, input, 16);
for (k = 0; k < 128; k++) {
rijndaelEncrypt(key->ek, key->Nr, iv, block);
for (t = 0; t < 15; t++) {
iv[t] = (iv[t] << 1) | (iv[t + 1] >> 7);
@@ -467,5 +471,5 @@ int cipherUpdateRounds(cipherInstance * cipher, keyInstance * key,
memcpy(outBuffer, block, 16);
memcpy(outBuffer, block, 16);
return true;
}

View File

@@ -47,8 +47,6 @@
#define MODE_ECB 1 /* Are we ciphering in ECB mode? */
#define MODE_CBC 2 /* Are we ciphering in CBC mode? */
#define MODE_CFB1 3 /* Are we ciphering in 1-bit CFB mode? */
#define TRUE 1
#define FALSE 0
#define BITSPERBLOCK 128 /* Default number of bits in a cipher block */
/* Error Codes */