mirror of
https://github.com/vgough/encfs.git
synced 2025-06-20 03:37:50 +02:00
Consolidate rAssert statements in BlockNameIO
Whitespace cleanup StreamNameIO rAssert statements should be the same
This commit is contained in:
parent
a0e02cb3ea
commit
6db69c2b0a
@ -137,17 +137,16 @@ int BlockNameIO::maxDecodedNameLen(int encodedNameLen) const {
|
|||||||
int BlockNameIO::encodeName(const char *plaintextName, int length, uint64_t *iv,
|
int BlockNameIO::encodeName(const char *plaintextName, int length, uint64_t *iv,
|
||||||
char *encodedName, int bufferLength) const {
|
char *encodedName, int bufferLength) const {
|
||||||
|
|
||||||
// copy the data into the encoding buffer..
|
|
||||||
rAssert(length <= (bufferLength - 2));
|
|
||||||
memcpy(encodedName + 2, plaintextName, length);
|
|
||||||
|
|
||||||
// Pad encryption buffer to block boundary..
|
// Pad encryption buffer to block boundary..
|
||||||
int padding = _bs - length % _bs;
|
int padding = _bs - length % _bs;
|
||||||
if (padding == 0) padding = _bs; // padding a full extra block!
|
if (padding == 0) padding = _bs; // padding a full extra block!
|
||||||
|
|
||||||
rAssert(padding <= (bufferLength - length - 2));
|
rAssert(bufferLength >= length + 2 + padding);
|
||||||
memset(encodedName + length + 2, (unsigned char)padding, padding);
|
memset(encodedName + length + 2, (unsigned char)padding, padding);
|
||||||
|
|
||||||
|
// copy the data into the encoding buffer..
|
||||||
|
memcpy(encodedName + 2, plaintextName, length);
|
||||||
|
|
||||||
// store the IV before it is modified by the MAC call.
|
// store the IV before it is modified by the MAC call.
|
||||||
uint64_t tmpIV = 0;
|
uint64_t tmpIV = 0;
|
||||||
if (iv && _interface >= 3) tmpIV = *iv;
|
if (iv && _interface >= 3) tmpIV = *iv;
|
||||||
|
@ -99,18 +99,17 @@ int StreamNameIO::encodeName(const char *plaintextName, int length,
|
|||||||
|
|
||||||
// add on checksum bytes
|
// add on checksum bytes
|
||||||
unsigned char *encodeBegin;
|
unsigned char *encodeBegin;
|
||||||
|
rAssert(bufferLength >= length + 2);
|
||||||
if (_interface >= 1) {
|
if (_interface >= 1) {
|
||||||
// current versions store the checksum at the beginning
|
// current versions store the checksum at the beginning
|
||||||
encodedName[0] = (mac >> 8) & 0xff;
|
encodedName[0] = (mac >> 8) & 0xff;
|
||||||
encodedName[1] = (mac)&0xff;
|
encodedName[1] = (mac)&0xff;
|
||||||
encodeBegin = (unsigned char *)encodedName + 2;
|
encodeBegin = (unsigned char *)encodedName + 2;
|
||||||
rAssert(length <= (bufferLength - 2));
|
|
||||||
} else {
|
} else {
|
||||||
// encfs 0.x stored checksums at the end.
|
// encfs 0.x stored checksums at the end.
|
||||||
encodedName[length] = (mac >> 8) & 0xff;
|
encodedName[length] = (mac >> 8) & 0xff;
|
||||||
encodedName[length + 1] = (mac)&0xff;
|
encodedName[length + 1] = (mac)&0xff;
|
||||||
encodeBegin = (unsigned char *)encodedName;
|
encodeBegin = (unsigned char *)encodedName;
|
||||||
rAssert(length <= bufferLength);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// stream encode the plaintext bytes
|
// stream encode the plaintext bytes
|
||||||
|
Loading…
x
Reference in New Issue
Block a user