mirror of
https://github.com/vgough/encfs.git
synced 2025-06-21 20:42:01 +02:00
add name collision test
git-svn-id: http://encfs.googlecode.com/svn/trunk@79 db9cf616-1c43-0410-9cb8-a902689de0d6
This commit is contained in:
parent
5d99db5376
commit
67821fb209
@ -47,6 +47,8 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <tr1/unordered_set>
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace rel;
|
using namespace rel;
|
||||||
@ -106,7 +108,8 @@ int checkErrorPropogation( const shared_ptr<Cipher> &cipher,
|
|||||||
const char TEST_ROOTDIR[] = "/foo";
|
const char TEST_ROOTDIR[] = "/foo";
|
||||||
|
|
||||||
static
|
static
|
||||||
bool testNameCoding( DirNode &dirNode, bool verbose )
|
bool testNameCoding( DirNode &dirNode, bool verbose,
|
||||||
|
bool collisionTest = false )
|
||||||
{
|
{
|
||||||
// encrypt a name
|
// encrypt a name
|
||||||
const char *name[] = {
|
const char *name[] = {
|
||||||
@ -161,6 +164,29 @@ bool testNameCoding( DirNode &dirNode, bool verbose )
|
|||||||
orig++;
|
orig++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (collisionTest)
|
||||||
|
{
|
||||||
|
if (verbose)
|
||||||
|
cerr << "Checking for name collections, this will take a while..\n";
|
||||||
|
// check for collision rate
|
||||||
|
char buf[64];
|
||||||
|
tr1::unordered_set<string> encryptedNames;
|
||||||
|
for (long i=0; i < 10000000; i++)
|
||||||
|
{
|
||||||
|
snprintf(buf, sizeof(buf), "%li", i);
|
||||||
|
string encName = dirNode.relativeCipherPath( buf );
|
||||||
|
// simulate a case-insisitive filesystem..
|
||||||
|
std::transform(encName.begin(), encName.end(), encName.begin(),
|
||||||
|
::toupper);
|
||||||
|
|
||||||
|
if (encryptedNames.insert(encName).second == false) {
|
||||||
|
cerr << "collision detected after " << i << " iterations";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cerr << "NO collisions detected";
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user