Slightly improved storage of the padding size.
This commit is contained in:
parent
86af5fa51f
commit
334d828c5b
@ -335,7 +335,7 @@ static int encrypt(const char* const passphrase, const CHR* const input_path, co
|
||||
goto clean_up;
|
||||
}
|
||||
|
||||
SET_NIBBLE(buffer[padding - 1U], padding);
|
||||
SET_LOWBITS(buffer[padding - 1U], padding - 1U);
|
||||
if ((status = slunkcrypt_encrypt_inplace(ctx, buffer, padding)) != SLUNKCRYPT_SUCCESS)
|
||||
{
|
||||
FPUTS((status == SLUNKCRYPT_ABORTED) ? T("\n\nProcess interrupted!\n\n") : T("\n\nSlunkCrypt error: Failed to encrypt data!\n\n"), stderr);
|
||||
@ -502,14 +502,7 @@ static int decrypt(const char* const passphrase, const CHR* const input_path, co
|
||||
goto clean_up;
|
||||
}
|
||||
|
||||
const size_t padding = GET_NIBBLE(buffer[sizeof(uint64_t) - 1U]);
|
||||
if ((!padding) || (padding > sizeof(uint64_t)))
|
||||
{
|
||||
FPRINTF(stderr, T("\n\nPadding error: Erroneous padding length encountered! [0x%02X]\n\n"), (unsigned int)padding);
|
||||
FPUTS(T("Wrong passphrase or corrupted file?\n\n"), stderr);
|
||||
goto clean_up;
|
||||
}
|
||||
|
||||
const size_t padding = GET_LOWBITS(buffer[sizeof(uint64_t) - 1U]) + 1U;
|
||||
if (padding != sizeof(uint64_t))
|
||||
{
|
||||
const size_t count = sizeof(uint64_t) - padding;
|
||||
|
@ -21,7 +21,7 @@ uint64_t round_down(const uint64_t value, const uint64_t base);
|
||||
|
||||
#define ARRAY_SIZE(X) (sizeof((X)) / sizeof(*(X)))
|
||||
#define BOUND(MIN,VAL,MAX) (((VAL) < (MIN)) ? (MIN) : (((VAL) > (MAX)) ? (MAX) : (VAL)))
|
||||
#define GET_NIBBLE(X) ((X) & 0x0F)
|
||||
#define SET_NIBBLE(X, Y) do { X = ((X) & 0xF0) | ((Y) & 0x0F); } while(0)
|
||||
#define GET_LOWBITS(X) ((X) & 0x07)
|
||||
#define SET_LOWBITS(X, Y) do { X = ((X) & 0xF8) | ((Y) & 0x07); } while(0)
|
||||
|
||||
#endif
|
||||
|
@ -35,8 +35,8 @@ printf "\n"
|
||||
PASSWRD="$(./frontend/bin/slunkcrypt${SUFFIX} --make-pw)"
|
||||
|
||||
./frontend/bin/slunkcrypt${SUFFIX} --self-test
|
||||
./frontend/bin/slunkcrypt${SUFFIX} --encrypt "${PASSWRD}" /tmp/${TMP_NAME}.dat /tmp/${TMP_NAME}.enc
|
||||
./frontend/bin/slunkcrypt${SUFFIX} --decrypt "${PASSWRD}" /tmp/${TMP_NAME}.enc /tmp/${TMP_NAME}.out
|
||||
./frontend/bin/slunkcrypt${SUFFIX} --encrypt ":${PASSWRD}" /tmp/${TMP_NAME}.dat /tmp/${TMP_NAME}.enc
|
||||
./frontend/bin/slunkcrypt${SUFFIX} --decrypt ":${PASSWRD}" /tmp/${TMP_NAME}.enc /tmp/${TMP_NAME}.out
|
||||
|
||||
printf "\033[1;36m\n------------------------------------------------------------------------------\033[0m\n"
|
||||
printf "\033[1;36mRe-compile\n"
|
||||
|
Loading…
Reference in New Issue
Block a user