mirror of
https://github.com/vgough/encfs.git
synced 2025-06-15 17:36:39 +02:00
Merge pull request #148 from jetwhiz/fork-master
Bugfix: Labels are backwards for "Block" and "Block32" encoding Set default to Block32 on OSX and Windows.
This commit is contained in:
commit
0426051a3e
@ -71,7 +71,7 @@ static bool BlockIO32_registered = NameIO::Register(
|
|||||||
// description of block name encoding algorithm..
|
// description of block name encoding algorithm..
|
||||||
// xgroup(setup)
|
// xgroup(setup)
|
||||||
gettext_noop(
|
gettext_noop(
|
||||||
"Block encoding with base32 output for case-sensitive systems"),
|
"Block encoding with base32 output for case-insensitive systems"),
|
||||||
BlockNameIO::CurrentInterface(true), NewBlockNameIO32);
|
BlockNameIO::CurrentInterface(true), NewBlockNameIO32);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -91,9 +91,9 @@ static bool BlockIO32_registered = NameIO::Register(
|
|||||||
- Version 4.0 adds support for base32, creating names more suitable for
|
- Version 4.0 adds support for base32, creating names more suitable for
|
||||||
case-insensitive filesystems (eg Mac).
|
case-insensitive filesystems (eg Mac).
|
||||||
*/
|
*/
|
||||||
Interface BlockNameIO::CurrentInterface(bool caseSensitive) {
|
Interface BlockNameIO::CurrentInterface(bool caseInsensitive) {
|
||||||
// implement major version 4 plus support for two prior versions
|
// implement major version 4 plus support for two prior versions
|
||||||
if (caseSensitive)
|
if (caseInsensitive)
|
||||||
return Interface("nameio/block32", 4, 0, 2);
|
return Interface("nameio/block32", 4, 0, 2);
|
||||||
else
|
else
|
||||||
return Interface("nameio/block", 4, 0, 2);
|
return Interface("nameio/block", 4, 0, 2);
|
||||||
@ -101,12 +101,12 @@ Interface BlockNameIO::CurrentInterface(bool caseSensitive) {
|
|||||||
|
|
||||||
BlockNameIO::BlockNameIO(const rel::Interface &iface,
|
BlockNameIO::BlockNameIO(const rel::Interface &iface,
|
||||||
const shared_ptr<Cipher> &cipher, const CipherKey &key,
|
const shared_ptr<Cipher> &cipher, const CipherKey &key,
|
||||||
int blockSize, bool caseSensitiveEncoding)
|
int blockSize, bool caseInsensitiveEncoding)
|
||||||
: _interface(iface.current()),
|
: _interface(iface.current()),
|
||||||
_bs(blockSize),
|
_bs(blockSize),
|
||||||
_cipher(cipher),
|
_cipher(cipher),
|
||||||
_key(key),
|
_key(key),
|
||||||
_caseSensitive(caseSensitiveEncoding) {
|
_caseInsensitive(caseInsensitiveEncoding) {
|
||||||
// just to be safe..
|
// just to be safe..
|
||||||
rAssert(blockSize < 128);
|
rAssert(blockSize < 128);
|
||||||
}
|
}
|
||||||
@ -114,7 +114,7 @@ BlockNameIO::BlockNameIO(const rel::Interface &iface,
|
|||||||
BlockNameIO::~BlockNameIO() {}
|
BlockNameIO::~BlockNameIO() {}
|
||||||
|
|
||||||
Interface BlockNameIO::interface() const {
|
Interface BlockNameIO::interface() const {
|
||||||
return CurrentInterface(_caseSensitive);
|
return CurrentInterface(_caseInsensitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
int BlockNameIO::maxEncodedNameLen(int plaintextNameLen) const {
|
int BlockNameIO::maxEncodedNameLen(int plaintextNameLen) const {
|
||||||
@ -122,15 +122,15 @@ int BlockNameIO::maxEncodedNameLen(int plaintextNameLen) const {
|
|||||||
// the size of too much space rather then too little.
|
// the size of too much space rather then too little.
|
||||||
int numBlocks = (plaintextNameLen + _bs) / _bs;
|
int numBlocks = (plaintextNameLen + _bs) / _bs;
|
||||||
int encodedNameLen = numBlocks * _bs + 2; // 2 checksum bytes
|
int encodedNameLen = numBlocks * _bs + 2; // 2 checksum bytes
|
||||||
if (_caseSensitive)
|
if (_caseInsensitive)
|
||||||
return B256ToB32Bytes(encodedNameLen);
|
return B256ToB32Bytes(encodedNameLen);
|
||||||
else
|
else
|
||||||
return B256ToB64Bytes(encodedNameLen);
|
return B256ToB64Bytes(encodedNameLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
int BlockNameIO::maxDecodedNameLen(int encodedNameLen) const {
|
int BlockNameIO::maxDecodedNameLen(int encodedNameLen) const {
|
||||||
int decLen256 = _caseSensitive ? B32ToB256Bytes(encodedNameLen)
|
int decLen256 = _caseInsensitive ? B32ToB256Bytes(encodedNameLen)
|
||||||
: B64ToB256Bytes(encodedNameLen);
|
: B64ToB256Bytes(encodedNameLen);
|
||||||
return decLen256 - 2; // 2 checksum bytes removed..
|
return decLen256 - 2; // 2 checksum bytes removed..
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ int BlockNameIO::encodeName(const char *plaintextName, int length, uint64_t *iv,
|
|||||||
int encodedStreamLen = length + 2 + padding;
|
int encodedStreamLen = length + 2 + padding;
|
||||||
int encLen;
|
int encLen;
|
||||||
|
|
||||||
if (_caseSensitive) {
|
if (_caseInsensitive) {
|
||||||
encLen = B256ToB32Bytes(encodedStreamLen);
|
encLen = B256ToB32Bytes(encodedStreamLen);
|
||||||
|
|
||||||
changeBase2Inline((unsigned char *)encodedName, encodedStreamLen, 8, 5,
|
changeBase2Inline((unsigned char *)encodedName, encodedStreamLen, 8, 5,
|
||||||
@ -186,7 +186,7 @@ int BlockNameIO::encodeName(const char *plaintextName, int length, uint64_t *iv,
|
|||||||
int BlockNameIO::decodeName(const char *encodedName, int length, uint64_t *iv,
|
int BlockNameIO::decodeName(const char *encodedName, int length, uint64_t *iv,
|
||||||
char *plaintextName, int bufferLength) const {
|
char *plaintextName, int bufferLength) const {
|
||||||
int decLen256 =
|
int decLen256 =
|
||||||
_caseSensitive ? B32ToB256Bytes(length) : B64ToB256Bytes(length);
|
_caseInsensitive ? B32ToB256Bytes(length) : B64ToB256Bytes(length);
|
||||||
int decodedStreamLen = decLen256 - 2;
|
int decodedStreamLen = decLen256 - 2;
|
||||||
|
|
||||||
// don't bother trying to decode files which are too small
|
// don't bother trying to decode files which are too small
|
||||||
@ -198,7 +198,7 @@ int BlockNameIO::decodeName(const char *encodedName, int length, uint64_t *iv,
|
|||||||
BUFFER_INIT(tmpBuf, 32, (unsigned int)length);
|
BUFFER_INIT(tmpBuf, 32, (unsigned int)length);
|
||||||
|
|
||||||
// decode into tmpBuf,
|
// decode into tmpBuf,
|
||||||
if (_caseSensitive) {
|
if (_caseInsensitive) {
|
||||||
AsciiToB32((unsigned char *)tmpBuf, (unsigned char *)encodedName, length);
|
AsciiToB32((unsigned char *)tmpBuf, (unsigned char *)encodedName, length);
|
||||||
changeBase2Inline((unsigned char *)tmpBuf, length, 5, 8, false);
|
changeBase2Inline((unsigned char *)tmpBuf, length, 5, 8, false);
|
||||||
} else {
|
} else {
|
||||||
|
@ -38,11 +38,11 @@ class Cipher;
|
|||||||
*/
|
*/
|
||||||
class BlockNameIO : public NameIO {
|
class BlockNameIO : public NameIO {
|
||||||
public:
|
public:
|
||||||
static rel::Interface CurrentInterface(bool caseSensitive = false);
|
static rel::Interface CurrentInterface(bool caseInsensitive = false);
|
||||||
|
|
||||||
BlockNameIO(const rel::Interface &iface, const shared_ptr<Cipher> &cipher,
|
BlockNameIO(const rel::Interface &iface, const shared_ptr<Cipher> &cipher,
|
||||||
const CipherKey &key, int blockSize,
|
const CipherKey &key, int blockSize,
|
||||||
bool caseSensitiveEncoding = false);
|
bool caseInsensitiveEncoding = false);
|
||||||
virtual ~BlockNameIO();
|
virtual ~BlockNameIO();
|
||||||
|
|
||||||
virtual rel::Interface interface() const;
|
virtual rel::Interface interface() const;
|
||||||
@ -64,7 +64,7 @@ class BlockNameIO : public NameIO {
|
|||||||
int _bs;
|
int _bs;
|
||||||
shared_ptr<Cipher> _cipher;
|
shared_ptr<Cipher> _cipher;
|
||||||
CipherKey _key;
|
CipherKey _key;
|
||||||
bool _caseSensitive;
|
bool _caseInsensitive;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1016,7 +1016,14 @@ RootPtr createV6Config(EncFS_Context *ctx, const shared_ptr<EncFS_Opts> &opts) {
|
|||||||
keySize = 256;
|
keySize = 256;
|
||||||
blockSize = DefaultBlockSize;
|
blockSize = DefaultBlockSize;
|
||||||
alg = findCipherAlgorithm("AES", keySize);
|
alg = findCipherAlgorithm("AES", keySize);
|
||||||
|
|
||||||
|
// If case-insensitive system, opt for Block32 filename encoding
|
||||||
|
#if defined(__APPLE__) || defined(WIN32)
|
||||||
|
nameIOIface = BlockNameIO::CurrentInterface(true);
|
||||||
|
#else
|
||||||
nameIOIface = BlockNameIO::CurrentInterface();
|
nameIOIface = BlockNameIO::CurrentInterface();
|
||||||
|
#endif
|
||||||
|
|
||||||
blockMACBytes = 8;
|
blockMACBytes = 8;
|
||||||
blockMACRandBytes = 0; // using uniqueIV, so this isn't necessary
|
blockMACRandBytes = 0; // using uniqueIV, so this isn't necessary
|
||||||
externalIV = true;
|
externalIV = true;
|
||||||
@ -1029,7 +1036,13 @@ RootPtr createV6Config(EncFS_Context *ctx, const shared_ptr<EncFS_Opts> &opts) {
|
|||||||
keySize = 192;
|
keySize = 192;
|
||||||
blockSize = DefaultBlockSize;
|
blockSize = DefaultBlockSize;
|
||||||
alg = findCipherAlgorithm("AES", keySize);
|
alg = findCipherAlgorithm("AES", keySize);
|
||||||
|
|
||||||
|
// If case-insensitive system, opt for Block32 filename encoding
|
||||||
|
#if defined(__APPLE__) || defined(WIN32)
|
||||||
|
nameIOIface = BlockNameIO::CurrentInterface(true);
|
||||||
|
#else
|
||||||
nameIOIface = BlockNameIO::CurrentInterface();
|
nameIOIface = BlockNameIO::CurrentInterface();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (opts->requireMac) {
|
if (opts->requireMac) {
|
||||||
blockMACBytes = 8;
|
blockMACBytes = 8;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user