mirror of
https://github.com/vgough/encfs.git
synced 2024-11-25 17:33:19 +01:00
move code into encfs namespace, split protobufs
git-svn-id: http://encfs.googlecode.com/svn/trunk@93 db9cf616-1c43-0410-9cb8-a902689de0d6
This commit is contained in:
parent
fb9a8ff879
commit
7799c88df6
@ -50,6 +50,9 @@ if (APPLE)
|
|||||||
add_definitions (-D__FreeBSD__=10)
|
add_definitions (-D__FreeBSD__=10)
|
||||||
endif (APPLE)
|
endif (APPLE)
|
||||||
|
|
||||||
|
find_package (Protobuf REQUIRED)
|
||||||
|
include_directories (${PROTOBUF_INCLUDE_DIR})
|
||||||
|
|
||||||
find_package (GLog REQUIRED)
|
find_package (GLog REQUIRED)
|
||||||
include_directories (${GLOG_INCLUDE_DIRS})
|
include_directories (${GLOG_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
find_package (Protobuf REQUIRED)
|
|
||||||
include_directories (${PROTOBUF_INCLUDE_DIR})
|
|
||||||
|
|
||||||
find_package (TinyXML REQUIRED)
|
find_package (TinyXML REQUIRED)
|
||||||
include_directories (${TINYXML_INCLUDE_DIR})
|
include_directories (${TINYXML_INCLUDE_DIR})
|
||||||
set (LIBS ${LIBS} ${TINYXML_LIBRARIES})
|
set (LIBS ${LIBS} ${TINYXML_LIBRARIES})
|
||||||
|
|
||||||
protobuf_generate_cpp (PROTO_SRCS PROTO_HDRS config.proto)
|
find_package (Protobuf REQUIRED)
|
||||||
|
|
||||||
|
|
||||||
|
protobuf_generate_cpp (PROTO_SRCS PROTO_HDRS ${Encfs_SOURCE_DIR}/protos/interface.proto)
|
||||||
|
|
||||||
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake
|
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||||
|
@ -28,9 +28,11 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
#include "base/types.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
ConfigReader::ConfigReader()
|
ConfigReader::ConfigReader()
|
||||||
{
|
{
|
||||||
@ -69,7 +71,7 @@ bool ConfigReader::load(const char *fileName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ConfigVar in;
|
ConfigVar in;
|
||||||
in.write( (unsigned char *)buf, size );
|
in.write( (byte *)buf, size );
|
||||||
delete[] buf;
|
delete[] buf;
|
||||||
|
|
||||||
return loadFromVar( in );
|
return loadFromVar( in );
|
||||||
@ -132,9 +134,9 @@ ConfigVar ConfigReader::toVar() const
|
|||||||
for(it = vars.begin(); it != vars.end(); ++it)
|
for(it = vars.begin(); it != vars.end(); ++it)
|
||||||
{
|
{
|
||||||
out.writeInt( it->first.size() );
|
out.writeInt( it->first.size() );
|
||||||
out.write( (unsigned char*)it->first.data(), it->first.size() );
|
out.write( (byte*)it->first.data(), it->first.size() );
|
||||||
out.writeInt( it->second.size() );
|
out.writeInt( it->second.size() );
|
||||||
out.write( (unsigned char*)it->second.buffer(), it->second.size() );
|
out.write( (byte*)it->second.buffer(), it->second.size() );
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
@ -155,3 +157,4 @@ ConfigVar &ConfigReader::operator[] ( const std::string &varName )
|
|||||||
return vars[ varName ];
|
return vars[ varName ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
#include "base/ConfigVar.h"
|
#include "base/ConfigVar.h"
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
handles Configuration load / store for Encfs filesystems.
|
handles Configuration load / store for Encfs filesystems.
|
||||||
|
|
||||||
@ -63,4 +65,6 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include <glog/logging.h>
|
#include <glog/logging.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
#ifndef MIN
|
#ifndef MIN
|
||||||
inline int MIN(int a, int b)
|
inline int MIN(int a, int b)
|
||||||
{
|
{
|
||||||
@ -70,7 +72,7 @@ void ConfigVar::resetOffset()
|
|||||||
pd->offset = 0;
|
pd->offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ConfigVar::read(unsigned char *buffer_, int bytes) const
|
int ConfigVar::read(byte *buffer_, int bytes) const
|
||||||
{
|
{
|
||||||
int toCopy = MIN( bytes, pd->buffer.size() - pd->offset );
|
int toCopy = MIN( bytes, pd->buffer.size() - pd->offset );
|
||||||
|
|
||||||
@ -82,7 +84,7 @@ int ConfigVar::read(unsigned char *buffer_, int bytes) const
|
|||||||
return toCopy;
|
return toCopy;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ConfigVar::write(const unsigned char *data, int bytes)
|
int ConfigVar::write(const byte *data, int bytes)
|
||||||
{
|
{
|
||||||
if(pd->buffer.size() == (unsigned int)pd->offset)
|
if(pd->buffer.size() == (unsigned int)pd->offset)
|
||||||
{
|
{
|
||||||
@ -115,7 +117,7 @@ int ConfigVar::at() const
|
|||||||
void ConfigVar::writeString(const char *data, int bytes)
|
void ConfigVar::writeString(const char *data, int bytes)
|
||||||
{
|
{
|
||||||
writeInt( bytes );
|
writeInt( bytes );
|
||||||
write( (const unsigned char *)data, bytes );
|
write( (const byte *)data, bytes );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -129,13 +131,13 @@ void ConfigVar::writeInt(int val)
|
|||||||
// third byte: 0x001fb000 0000,0000 0001,1111 1100,0000 0000,0000
|
// third byte: 0x001fb000 0000,0000 0001,1111 1100,0000 0000,0000
|
||||||
// fourth byte: 0x0fe00000 0000,1111 1110,0000
|
// fourth byte: 0x0fe00000 0000,1111 1110,0000
|
||||||
// fifth byte: 0xf0000000 1111,0000
|
// fifth byte: 0xf0000000 1111,0000
|
||||||
unsigned char digit[5];
|
byte digit[5];
|
||||||
|
|
||||||
digit[4] = (unsigned char)((val & 0x0000007f));
|
digit[4] = (byte)((val & 0x0000007f));
|
||||||
digit[3] = 0x80 | (unsigned char)((val & 0x00003f80) >> 7);
|
digit[3] = 0x80 | (byte)((val & 0x00003f80) >> 7);
|
||||||
digit[2] = 0x80 | (unsigned char)((val & 0x001fc000) >> 14);
|
digit[2] = 0x80 | (byte)((val & 0x001fc000) >> 14);
|
||||||
digit[1] = 0x80 | (unsigned char)((val & 0x0fe00000) >> 21);
|
digit[1] = 0x80 | (byte)((val & 0x0fe00000) >> 21);
|
||||||
digit[0] = 0x80 | (unsigned char)((val & 0xf0000000) >> 28);
|
digit[0] = 0x80 | (byte)((val & 0xf0000000) >> 28);
|
||||||
|
|
||||||
// find the starting point - we only need to output starting at the most
|
// find the starting point - we only need to output starting at the most
|
||||||
// significant non-zero digit..
|
// significant non-zero digit..
|
||||||
@ -148,7 +150,7 @@ void ConfigVar::writeInt(int val)
|
|||||||
|
|
||||||
int ConfigVar::readInt() const
|
int ConfigVar::readInt() const
|
||||||
{
|
{
|
||||||
const unsigned char * buf = (const unsigned char *)buffer();
|
const byte * buf = (const byte *)buffer();
|
||||||
int bytes = this->size();
|
int bytes = this->size();
|
||||||
int offset = at();
|
int offset = at();
|
||||||
int value = 0;
|
int value = 0;
|
||||||
@ -158,7 +160,7 @@ int ConfigVar::readInt() const
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
unsigned char tmp = buf[offset++];
|
byte tmp = buf[offset++];
|
||||||
highBitSet = tmp & 0x80;
|
highBitSet = tmp & 0x80;
|
||||||
|
|
||||||
value = (value << 7) | (int)(tmp & 0x7f);
|
value = (value << 7) | (int)(tmp & 0x7f);
|
||||||
@ -227,10 +229,10 @@ const ConfigVar & operator >> (const ConfigVar &src, std::string &result)
|
|||||||
|
|
||||||
int readLen;
|
int readLen;
|
||||||
|
|
||||||
unsigned char tmpBuf[32];
|
byte tmpBuf[32];
|
||||||
if(length > (int)sizeof(tmpBuf))
|
if(length > (int)sizeof(tmpBuf))
|
||||||
{
|
{
|
||||||
unsigned char *ptr = new unsigned char[length];
|
byte *ptr = new byte[length];
|
||||||
readLen = src.read( ptr, length );
|
readLen = src.read( ptr, length );
|
||||||
result.assign( (char*)ptr, length );
|
result.assign( (char*)ptr, length );
|
||||||
delete[] ptr;
|
delete[] ptr;
|
||||||
@ -251,3 +253,4 @@ const ConfigVar & operator >> (const ConfigVar &src, std::string &result)
|
|||||||
return src;
|
return src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "base/shared_ptr.h"
|
#include "base/shared_ptr.h"
|
||||||
|
#include "base/types.h"
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
class ConfigVar
|
class ConfigVar
|
||||||
{
|
{
|
||||||
@ -46,10 +49,10 @@ public:
|
|||||||
void resetOffset();
|
void resetOffset();
|
||||||
|
|
||||||
// read bytes
|
// read bytes
|
||||||
int read(unsigned char *buffer, int size) const;
|
int read(byte *buffer, int size) const;
|
||||||
|
|
||||||
// write bytes..
|
// write bytes..
|
||||||
int write(const unsigned char *data, int size);
|
int write(const byte *data, int size);
|
||||||
|
|
||||||
int readInt() const;
|
int readInt() const;
|
||||||
int readInt( int defaultValue ) const;
|
int readInt( int defaultValue ) const;
|
||||||
@ -77,5 +80,7 @@ const ConfigVar & operator >> (const ConfigVar &, bool &);
|
|||||||
const ConfigVar & operator >> (const ConfigVar &, int &);
|
const ConfigVar & operator >> (const ConfigVar &, int &);
|
||||||
const ConfigVar & operator >> (const ConfigVar &, std::string &str);
|
const ConfigVar & operator >> (const ConfigVar &, std::string &str);
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
#include "base/Error.h"
|
#include "base/Error.h"
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
Error::Error(const char *msg)
|
Error::Error(const char *msg)
|
||||||
: runtime_error(msg)
|
: runtime_error(msg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include <glog/logging.h>
|
#include <glog/logging.h>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
class Error : public std::runtime_error
|
class Error : public std::runtime_error
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -21,5 +23,7 @@ public:
|
|||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
#include <glog/logging.h>
|
#include <glog/logging.h>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
std::ostream& operator << (std::ostream& out, const Interface &iface)
|
std::ostream& operator << (std::ostream& out, const Interface &iface)
|
||||||
{
|
{
|
||||||
out << iface.name() << "(" << iface.major()
|
out << iface.name() << "(" << iface.major()
|
||||||
@ -82,3 +84,4 @@ bool operator != (const Interface &a, const Interface &b)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
@ -22,7 +22,9 @@
|
|||||||
#define _Interface_incl_
|
#define _Interface_incl_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "base/config.pb.h"
|
#include "base/interface.pb.h"
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
// check if A implements the interface described by B.
|
// check if A implements the interface described by B.
|
||||||
// Note that implements(A, B) is not the same as implements(B, A)
|
// Note that implements(A, B) is not the same as implements(B, A)
|
||||||
@ -38,5 +40,7 @@ const ConfigVar & operator >> (const ConfigVar &, Interface &);
|
|||||||
|
|
||||||
bool operator != (const Interface &a, const Interface &b);
|
bool operator != (const Interface &a, const Interface &b);
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
namespace rel
|
namespace encfs
|
||||||
{
|
{
|
||||||
|
|
||||||
class Lock
|
class Lock
|
||||||
@ -60,7 +60,7 @@ inline void Lock::leave()
|
|||||||
_mutex = 0;
|
_mutex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace rel
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#ifndef _Range_incl_
|
#ifndef _Range_incl_
|
||||||
#define _Range_incl_
|
#define _Range_incl_
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
class Range
|
class Range
|
||||||
{
|
{
|
||||||
@ -112,4 +113,5 @@ inline int Range::inc() const
|
|||||||
return increment;
|
return increment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
#endif
|
#endif
|
||||||
|
@ -41,6 +41,8 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
XmlValue::~XmlValue()
|
XmlValue::~XmlValue()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -106,7 +108,7 @@ bool XmlValue::read(const char *path, bool *out) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XmlValue::readB64(const char *path, unsigned char *data, int length) const
|
bool XmlValue::readB64(const char *path, byte *data, int length) const
|
||||||
{
|
{
|
||||||
XmlValuePtr value = find(path);
|
XmlValuePtr value = find(path);
|
||||||
if (!value)
|
if (!value)
|
||||||
@ -246,3 +248,4 @@ XmlValuePtr XmlReader::operator[] ( const char *name ) const
|
|||||||
return XmlValuePtr(new XmlNode(element));
|
return XmlValuePtr(new XmlNode(element));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "base/shared_ptr.h"
|
#include "base/shared_ptr.h"
|
||||||
|
#include "base/types.h"
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
class XmlValue;
|
class XmlValue;
|
||||||
typedef shared_ptr<XmlValue> XmlValuePtr;
|
typedef shared_ptr<XmlValue> XmlValuePtr;
|
||||||
@ -51,7 +54,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool read(const char *path, std::string *out) const;
|
bool read(const char *path, std::string *out) const;
|
||||||
bool readB64(const char *path, unsigned char *out, int length) const;
|
bool readB64(const char *path, byte *out, int length) const;
|
||||||
|
|
||||||
bool read(const char *path, int *out) const;
|
bool read(const char *path, int *out) const;
|
||||||
bool read(const char *path, long *out) const;
|
bool read(const char *path, long *out) const;
|
||||||
@ -79,4 +82,6 @@ private:
|
|||||||
shared_ptr<XmlReaderData> pd;
|
shared_ptr<XmlReaderData> pd;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -22,17 +22,19 @@
|
|||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
// change between two powers of two, stored as the low bits of the bytes in the
|
// change between two powers of two, stored as the low bits of the bytes in the
|
||||||
// arrays.
|
// arrays.
|
||||||
// It is the caller's responsibility to make sure the output array is large
|
// It is the caller's responsibility to make sure the output array is large
|
||||||
// enough.
|
// enough.
|
||||||
void changeBase2(unsigned char *src, int srcLen, int src2Pow,
|
void changeBase2(byte *src, int srcLen, int src2Pow,
|
||||||
unsigned char *dst, int dstLen, int dst2Pow)
|
byte *dst, int dstLen, int dst2Pow)
|
||||||
{
|
{
|
||||||
unsigned long work = 0;
|
unsigned long work = 0;
|
||||||
int workBits = 0; // number of bits left in the work buffer
|
int workBits = 0; // number of bits left in the work buffer
|
||||||
unsigned char *end = src + srcLen;
|
byte *end = src + srcLen;
|
||||||
unsigned char *origDst = dst;
|
byte *origDst = dst;
|
||||||
const int mask = (1 << dst2Pow) -1;
|
const int mask = (1 << dst2Pow) -1;
|
||||||
|
|
||||||
// copy the new bits onto the high bits of the stream.
|
// copy the new bits onto the high bits of the stream.
|
||||||
@ -63,12 +65,12 @@ void changeBase2(unsigned char *src, int srcLen, int src2Pow,
|
|||||||
to be written, then write the value at the tail end of the recursion.
|
to be written, then write the value at the tail end of the recursion.
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
void changeBase2Inline(unsigned char *src, int srcLen,
|
void changeBase2Inline(byte *src, int srcLen,
|
||||||
int src2Pow, int dst2Pow,
|
int src2Pow, int dst2Pow,
|
||||||
bool outputPartialLastByte,
|
bool outputPartialLastByte,
|
||||||
unsigned long work,
|
unsigned long work,
|
||||||
int workBits,
|
int workBits,
|
||||||
unsigned char *outLoc)
|
byte *outLoc)
|
||||||
{
|
{
|
||||||
const int mask = (1 << dst2Pow) -1;
|
const int mask = (1 << dst2Pow) -1;
|
||||||
if(!outLoc)
|
if(!outLoc)
|
||||||
@ -84,7 +86,7 @@ void changeBase2Inline(unsigned char *src, int srcLen,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// we have at least one value that can be output
|
// we have at least one value that can be output
|
||||||
unsigned char outVal = work & mask;
|
byte outVal = work & mask;
|
||||||
work >>= dst2Pow;
|
work >>= dst2Pow;
|
||||||
workBits -= dst2Pow;
|
workBits -= dst2Pow;
|
||||||
|
|
||||||
@ -112,7 +114,7 @@ void changeBase2Inline(unsigned char *src, int srcLen,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void changeBase2Inline(unsigned char *src, int srcLen,
|
void changeBase2Inline(byte *src, int srcLen,
|
||||||
int src2Pow, int dst2Pow,
|
int src2Pow, int dst2Pow,
|
||||||
bool outputPartialLastByte)
|
bool outputPartialLastByte)
|
||||||
{
|
{
|
||||||
@ -128,7 +130,7 @@ void changeBase2Inline(unsigned char *src, int srcLen,
|
|||||||
// '.' included in the encrypted names, so that it can be reserved for files
|
// '.' included in the encrypted names, so that it can be reserved for files
|
||||||
// with special meaning.
|
// with special meaning.
|
||||||
static const char B642AsciiTable[] = ",-0123456789";
|
static const char B642AsciiTable[] = ",-0123456789";
|
||||||
void B64ToAscii(unsigned char *in, int length)
|
void B64ToAscii(byte *in, int length)
|
||||||
{
|
{
|
||||||
for(int offset=0; offset<length; ++offset)
|
for(int offset=0; offset<length; ++offset)
|
||||||
{
|
{
|
||||||
@ -146,20 +148,20 @@ void B64ToAscii(unsigned char *in, int length)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const unsigned char Ascii2B64Table[] =
|
static const byte Ascii2B64Table[] =
|
||||||
" 01 23456789:; ";
|
" 01 23456789:; ";
|
||||||
// 0123456789 123456789 123456789 123456789 123456789 123456789 1234
|
// 0123456789 123456789 123456789 123456789 123456789 123456789 1234
|
||||||
// 0 1 2 3 4 5 6
|
// 0 1 2 3 4 5 6
|
||||||
void AsciiToB64(unsigned char *in, int length)
|
void AsciiToB64(byte *in, int length)
|
||||||
{
|
{
|
||||||
return AsciiToB64(in, in, length);
|
return AsciiToB64(in, in, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsciiToB64(unsigned char *out, const unsigned char *in, int length)
|
void AsciiToB64(byte *out, const byte *in, int length)
|
||||||
{
|
{
|
||||||
while(length--)
|
while(length--)
|
||||||
{
|
{
|
||||||
unsigned char ch = *in++;
|
byte ch = *in++;
|
||||||
if(ch >= 'A')
|
if(ch >= 'A')
|
||||||
{
|
{
|
||||||
if(ch >= 'a')
|
if(ch >= 'a')
|
||||||
@ -174,7 +176,7 @@ void AsciiToB64(unsigned char *out, const unsigned char *in, int length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void B32ToAscii(unsigned char *buf, int len)
|
void B32ToAscii(byte *buf, int len)
|
||||||
{
|
{
|
||||||
for(int offset=0; offset<len; ++offset)
|
for(int offset=0; offset<len; ++offset)
|
||||||
{
|
{
|
||||||
@ -188,23 +190,24 @@ void B32ToAscii(unsigned char *buf, int len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsciiToB32(unsigned char *in, int length)
|
void AsciiToB32(byte *in, int length)
|
||||||
{
|
{
|
||||||
return AsciiToB32(in, in, length);
|
return AsciiToB32(in, in, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsciiToB32(unsigned char *out, const unsigned char *in, int length)
|
void AsciiToB32(byte *out, const byte *in, int length)
|
||||||
{
|
{
|
||||||
while(length--)
|
while(length--)
|
||||||
{
|
{
|
||||||
unsigned char ch = *in++;
|
byte ch = *in++;
|
||||||
int lch = toupper(ch);
|
int lch = toupper(ch);
|
||||||
if (lch >= 'A')
|
if (lch >= 'A')
|
||||||
lch -= 'A';
|
lch -= 'A';
|
||||||
else
|
else
|
||||||
lch += 26 - '2';
|
lch += 26 - '2';
|
||||||
|
|
||||||
*out++ = (unsigned char)lch;
|
*out++ = (byte)lch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
@ -21,6 +21,9 @@
|
|||||||
#ifndef _base64_incl_
|
#ifndef _base64_incl_
|
||||||
#define _base64_incl_
|
#define _base64_incl_
|
||||||
|
|
||||||
|
#include "base/types.h"
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
inline int B64ToB256Bytes( int numB64Bytes )
|
inline int B64ToB256Bytes( int numB64Bytes )
|
||||||
{
|
{
|
||||||
@ -46,29 +49,31 @@ inline int B256ToB32Bytes( int numB256Bytes )
|
|||||||
/*
|
/*
|
||||||
convert data between different bases - each being a power of 2.
|
convert data between different bases - each being a power of 2.
|
||||||
*/
|
*/
|
||||||
void changeBase2(unsigned char *src, int srcLength, int srcPow2,
|
void changeBase2(byte *src, int srcLength, int srcPow2,
|
||||||
unsigned char *dst, int dstLength, int dstPow2);
|
byte *dst, int dstLength, int dstPow2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
same as changeBase2, but writes output over the top of input data.
|
same as changeBase2, but writes output over the top of input data.
|
||||||
*/
|
*/
|
||||||
void changeBase2Inline(unsigned char *buf, int srcLength,
|
void changeBase2Inline(byte *buf, int srcLength,
|
||||||
int srcPow2, int dst2Pow,
|
int srcPow2, int dst2Pow,
|
||||||
bool outputPartialLastByte);
|
bool outputPartialLastByte);
|
||||||
|
|
||||||
|
|
||||||
// inplace translation from values [0,2^6] => base64 ASCII
|
// inplace translation from values [0,2^6] => base64 ASCII
|
||||||
void B64ToAscii(unsigned char *buf, int length);
|
void B64ToAscii(byte *buf, int length);
|
||||||
// inplace translation from values [0,2^5] => base32 ASCII
|
// inplace translation from values [0,2^5] => base32 ASCII
|
||||||
void B32ToAscii(unsigned char *buf, int length);
|
void B32ToAscii(byte *buf, int length);
|
||||||
|
|
||||||
// inplace translation from values base64 ASCII => [0,2^6]
|
// inplace translation from values base64 ASCII => [0,2^6]
|
||||||
void AsciiToB64(unsigned char *buf, int length);
|
void AsciiToB64(byte *buf, int length);
|
||||||
void AsciiToB64(unsigned char *out, const unsigned char *in, int length);
|
void AsciiToB64(byte *out, const byte *in, int length);
|
||||||
|
|
||||||
// inplace translation from values base32 ASCII => [0,2^5]
|
// inplace translation from values base32 ASCII => [0,2^5]
|
||||||
void AsciiToB32(unsigned char *buf, int length);
|
void AsciiToB32(byte *buf, int length);
|
||||||
void AsciiToB32(unsigned char *out, const unsigned char *in, int length);
|
void AsciiToB32(byte *out, const byte *in, int length);
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
10
base/types.h
Normal file
10
base/types.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#ifndef TYPES_H
|
||||||
|
#define TYPES_H
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
|
typedef unsigned char byte;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // TYPES_H
|
@ -7,6 +7,7 @@ find_package (GTest REQUIRED)
|
|||||||
|
|
||||||
add_library (encfs-cipher
|
add_library (encfs-cipher
|
||||||
readpassphrase.cpp
|
readpassphrase.cpp
|
||||||
|
BlockCipher.cpp
|
||||||
Cipher.cpp
|
Cipher.cpp
|
||||||
CipherKey.cpp
|
CipherKey.cpp
|
||||||
MemoryPool.cpp
|
MemoryPool.cpp
|
||||||
|
@ -21,22 +21,24 @@
|
|||||||
#include "base/config.h"
|
#include "base/config.h"
|
||||||
#include "cipher/Cipher.h"
|
#include "cipher/Cipher.h"
|
||||||
|
|
||||||
#include "base/Interface.h"
|
|
||||||
#include "base/Range.h"
|
|
||||||
#include "base/base64.h"
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "base/Interface.h"
|
||||||
|
#include "base/Range.h"
|
||||||
|
#include "base/base64.h"
|
||||||
|
|
||||||
// for static build. Need to reference the modules which are registered at
|
// for static build. Need to reference the modules which are registered at
|
||||||
// run-time, to ensure that the linker doesn't optimize them away.
|
// run-time, to ensure that the linker doesn't optimize them away.
|
||||||
#include "NullCipher.h"
|
#include "cipher/NullCipher.h"
|
||||||
#include "SSL_Cipher.h"
|
#include "cipher/SSL_Cipher.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
#define REF_MODULE(TYPE) \
|
#define REF_MODULE(TYPE) \
|
||||||
if( !TYPE::Enabled() ) \
|
if( !TYPE::Enabled() ) \
|
||||||
cerr << "referenceModule: should never happen\n";
|
cerr << "referenceModule: should never happen\n";
|
||||||
@ -180,7 +182,7 @@ Cipher::~Cipher()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Cipher::MAC_32( const unsigned char *src, int len,
|
unsigned int Cipher::MAC_32( const byte *src, int len,
|
||||||
const CipherKey &key, uint64_t *chainedIV ) const
|
const CipherKey &key, uint64_t *chainedIV ) const
|
||||||
{
|
{
|
||||||
uint64_t mac64 = MAC_64( src, len, key, chainedIV );
|
uint64_t mac64 = MAC_64( src, len, key, chainedIV );
|
||||||
@ -190,7 +192,7 @@ unsigned int Cipher::MAC_32( const unsigned char *src, int len,
|
|||||||
return mac32;
|
return mac32;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Cipher::MAC_16( const unsigned char *src, int len,
|
unsigned int Cipher::MAC_16( const byte *src, int len,
|
||||||
const CipherKey &key, uint64_t *chainedIV ) const
|
const CipherKey &key, uint64_t *chainedIV ) const
|
||||||
{
|
{
|
||||||
uint64_t mac64 = MAC_64( src, len, key, chainedIV );
|
uint64_t mac64 = MAC_64( src, len, key, chainedIV );
|
||||||
@ -205,12 +207,12 @@ string Cipher::encodeAsString(const CipherKey &key,
|
|||||||
const CipherKey &encodingKey )
|
const CipherKey &encodingKey )
|
||||||
{
|
{
|
||||||
int encodedKeySize = this->encodedKeySize();
|
int encodedKeySize = this->encodedKeySize();
|
||||||
unsigned char *keyBuf = new unsigned char[ encodedKeySize ];
|
byte *keyBuf = new byte[ encodedKeySize ];
|
||||||
|
|
||||||
this->writeKey( key, keyBuf, encodingKey );
|
this->writeKey( key, keyBuf, encodingKey );
|
||||||
|
|
||||||
int b64Len = B256ToB64Bytes( encodedKeySize );
|
int b64Len = B256ToB64Bytes( encodedKeySize );
|
||||||
unsigned char *b64Key = new unsigned char[ b64Len + 1 ];
|
byte *b64Key = new byte[ b64Len + 1 ];
|
||||||
|
|
||||||
changeBase2( keyBuf, encodedKeySize, 8, b64Key,
|
changeBase2( keyBuf, encodedKeySize, 8, b64Key,
|
||||||
b64Len, 6 );
|
b64Len, 6 );
|
||||||
@ -225,3 +227,4 @@ bool Cipher::hasStreamMode() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
@ -24,11 +24,14 @@
|
|||||||
#include "cipher/CipherKey.h"
|
#include "cipher/CipherKey.h"
|
||||||
#include "base/Interface.h"
|
#include "base/Interface.h"
|
||||||
#include "base/Range.h"
|
#include "base/Range.h"
|
||||||
|
#include "base/types.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Mostly pure virtual interface defining operations on a cipher.
|
Mostly pure virtual interface defining operations on a cipher.
|
||||||
|
|
||||||
@ -91,7 +94,7 @@ public:
|
|||||||
// milliseconds the password derivation function should take to run.
|
// milliseconds the password derivation function should take to run.
|
||||||
virtual CipherKey newKey(const char *password, int passwdLength,
|
virtual CipherKey newKey(const char *password, int passwdLength,
|
||||||
int &iterationCount, long desiredFunctionDuration,
|
int &iterationCount, long desiredFunctionDuration,
|
||||||
const unsigned char *salt, int saltLen) =0;
|
const byte *salt, int saltLen) =0;
|
||||||
|
|
||||||
// deprecated - for backward compatibility
|
// deprecated - for backward compatibility
|
||||||
virtual CipherKey newKey(const char *password, int passwdLength ) =0;
|
virtual CipherKey newKey(const char *password, int passwdLength ) =0;
|
||||||
@ -100,11 +103,11 @@ public:
|
|||||||
virtual CipherKey newRandomKey() =0;
|
virtual CipherKey newRandomKey() =0;
|
||||||
|
|
||||||
// data must be len encodedKeySize()
|
// data must be len encodedKeySize()
|
||||||
virtual CipherKey readKey(const unsigned char *data,
|
virtual CipherKey readKey(const byte *data,
|
||||||
const CipherKey &encodingKey,
|
const CipherKey &encodingKey,
|
||||||
bool checkKey = true) =0;
|
bool checkKey = true) =0;
|
||||||
|
|
||||||
virtual void writeKey(const CipherKey &key, unsigned char *data,
|
virtual void writeKey(const CipherKey &key, byte *data,
|
||||||
const CipherKey &encodingKey) =0;
|
const CipherKey &encodingKey) =0;
|
||||||
|
|
||||||
virtual std::string encodeAsString(const CipherKey &key,
|
virtual std::string encodeAsString(const CipherKey &key,
|
||||||
@ -124,37 +127,39 @@ public:
|
|||||||
// The data may be pseudo random and might not be suitable for key
|
// The data may be pseudo random and might not be suitable for key
|
||||||
// generation. For generating keys, uses newRandomKey() instead.
|
// generation. For generating keys, uses newRandomKey() instead.
|
||||||
// Returns true on success, false on failure.
|
// Returns true on success, false on failure.
|
||||||
virtual bool randomize( unsigned char *buf, int len,
|
virtual bool randomize( byte *buf, int len,
|
||||||
bool strongRandom ) const =0;
|
bool strongRandom ) const =0;
|
||||||
|
|
||||||
// 64 bit MAC of the data with the given key
|
// 64 bit MAC of the data with the given key
|
||||||
virtual uint64_t MAC_64( const unsigned char *src, int len,
|
virtual uint64_t MAC_64( const byte *src, int len,
|
||||||
const CipherKey &key, uint64_t *chainedIV = 0 ) const =0;
|
const CipherKey &key, uint64_t *chainedIV = 0 ) const =0;
|
||||||
|
|
||||||
// based on reductions of MAC_64
|
// based on reductions of MAC_64
|
||||||
unsigned int MAC_32( const unsigned char *src, int len,
|
unsigned int MAC_32( const byte *src, int len,
|
||||||
const CipherKey &key, uint64_t *chainedIV = 0 ) const;
|
const CipherKey &key, uint64_t *chainedIV = 0 ) const;
|
||||||
unsigned int MAC_16( const unsigned char *src, int len,
|
unsigned int MAC_16( const byte *src, int len,
|
||||||
const CipherKey &key, uint64_t *chainedIV = 0 ) const;
|
const CipherKey &key, uint64_t *chainedIV = 0 ) const;
|
||||||
|
|
||||||
// functional interfaces
|
// functional interfaces
|
||||||
/*
|
/*
|
||||||
Stream encoding of data in-place. The stream data can be any length.
|
Stream encoding of data in-place. The stream data can be any length.
|
||||||
*/
|
*/
|
||||||
virtual bool streamEncode( unsigned char *data, int len,
|
virtual bool streamEncode( byte *data, int len,
|
||||||
uint64_t iv64, const CipherKey &key) const=0;
|
uint64_t iv64, const CipherKey &key) const=0;
|
||||||
virtual bool streamDecode( unsigned char *data, int len,
|
virtual bool streamDecode( byte *data, int len,
|
||||||
uint64_t iv64, const CipherKey &key) const=0;
|
uint64_t iv64, const CipherKey &key) const=0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Block encoding of data in-place. The data size should be a multiple of
|
Block encoding of data in-place. The data size should be a multiple of
|
||||||
the cipher block size.
|
the cipher block size.
|
||||||
*/
|
*/
|
||||||
virtual bool blockEncode(unsigned char *buf, int size,
|
virtual bool blockEncode(byte *buf, int size,
|
||||||
uint64_t iv64, const CipherKey &key) const=0;
|
uint64_t iv64, const CipherKey &key) const=0;
|
||||||
virtual bool blockDecode(unsigned char *buf, int size,
|
virtual bool blockDecode(byte *buf, int size,
|
||||||
uint64_t iv64, const CipherKey &key) const=0;
|
uint64_t iv64, const CipherKey &key) const=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#include "cipher/CipherKey.h"
|
#include "cipher/CipherKey.h"
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
AbstractCipherKey::AbstractCipherKey()
|
AbstractCipherKey::AbstractCipherKey()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -28,3 +30,5 @@ AbstractCipherKey::~AbstractCipherKey()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
#include "base/shared_ptr.h"
|
#include "base/shared_ptr.h"
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
class AbstractCipherKey
|
class AbstractCipherKey
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -32,5 +34,7 @@ public:
|
|||||||
|
|
||||||
typedef shared_ptr<AbstractCipherKey> CipherKey;
|
typedef shared_ptr<AbstractCipherKey> CipherKey;
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -47,6 +47,8 @@ using namespace std;
|
|||||||
# include <openssl/crypto.h>
|
# include <openssl/crypto.h>
|
||||||
# include <openssl/buffer.h>
|
# include <openssl/buffer.h>
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
static BUF_MEM *allocBlock( int size )
|
static BUF_MEM *allocBlock( int size )
|
||||||
{
|
{
|
||||||
BUF_MEM *block = BUF_MEM_new( );
|
BUF_MEM *block = BUF_MEM_new( );
|
||||||
@ -87,7 +89,7 @@ void MemBlock::allocate(int size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
internalData = mem;
|
internalData = mem;
|
||||||
data = reinterpret_cast<unsigned char *>(mem->data);
|
data = reinterpret_cast<byte *>(mem->data);
|
||||||
VALGRIND_MAKE_MEM_UNDEFINED( data, size );
|
VALGRIND_MAKE_MEM_UNDEFINED( data, size );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,4 +163,5 @@ SecureMem::~SecureMem()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
|
@ -21,19 +21,23 @@
|
|||||||
#ifndef _MemoryPool_incl_
|
#ifndef _MemoryPool_incl_
|
||||||
#define _MemoryPool_incl_
|
#define _MemoryPool_incl_
|
||||||
|
|
||||||
|
#include "base/types.h"
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Memory Pool for fixed sized objects.
|
Memory Pool for fixed sized objects.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
MemBlock mb( size );
|
MemBlock mb( size );
|
||||||
// do things with storage in mb.data
|
// do things with storage in mb.data
|
||||||
unsigned char *buffer = mb.data;
|
byte *buffer = mb.data;
|
||||||
|
|
||||||
// memblock freed when destructed
|
// memblock freed when destructed
|
||||||
*/
|
*/
|
||||||
struct MemBlock
|
struct MemBlock
|
||||||
{
|
{
|
||||||
unsigned char *data;
|
byte *data;
|
||||||
void *internalData;
|
void *internalData;
|
||||||
|
|
||||||
MemBlock();
|
MemBlock();
|
||||||
@ -61,5 +65,7 @@ struct SecureMem
|
|||||||
~SecureMem();
|
~SecureMem();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
static Interface NullInterface = makeInterface( "nullCipher", 1, 0, 0 );
|
static Interface NullInterface = makeInterface( "nullCipher", 1, 0, 0 );
|
||||||
static Range NullKeyRange(0);
|
static Range NullKeyRange(0);
|
||||||
@ -81,7 +82,7 @@ Interface NullCipher::interface() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
CipherKey NullCipher::newKey(const char *, int,
|
CipherKey NullCipher::newKey(const char *, int,
|
||||||
int &, long, const unsigned char *, int )
|
int &, long, const byte *, int )
|
||||||
{
|
{
|
||||||
return gNullKey;
|
return gNullKey;
|
||||||
}
|
}
|
||||||
@ -96,25 +97,25 @@ CipherKey NullCipher::newRandomKey()
|
|||||||
return gNullKey;
|
return gNullKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NullCipher::randomize( unsigned char *buf, int len, bool ) const
|
bool NullCipher::randomize( byte *buf, int len, bool ) const
|
||||||
{
|
{
|
||||||
memset( buf, 0, len );
|
memset( buf, 0, len );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t NullCipher::MAC_64(const unsigned char *, int ,
|
uint64_t NullCipher::MAC_64(const byte *, int ,
|
||||||
const CipherKey &, uint64_t *) const
|
const CipherKey &, uint64_t *) const
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CipherKey NullCipher::readKey( const unsigned char *,
|
CipherKey NullCipher::readKey( const byte *,
|
||||||
const CipherKey &, bool)
|
const CipherKey &, bool)
|
||||||
{
|
{
|
||||||
return gNullKey;
|
return gNullKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NullCipher::writeKey(const CipherKey &, unsigned char *,
|
void NullCipher::writeKey(const CipherKey &, byte *,
|
||||||
const CipherKey &)
|
const CipherKey &)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -142,7 +143,7 @@ int NullCipher::cipherBlockSize() const
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NullCipher::streamEncode( unsigned char *src, int len,
|
bool NullCipher::streamEncode( byte *src, int len,
|
||||||
uint64_t iv64, const CipherKey &key) const
|
uint64_t iv64, const CipherKey &key) const
|
||||||
{
|
{
|
||||||
(void)src;
|
(void)src;
|
||||||
@ -152,7 +153,7 @@ bool NullCipher::streamEncode( unsigned char *src, int len,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NullCipher::streamDecode( unsigned char *src, int len,
|
bool NullCipher::streamDecode( byte *src, int len,
|
||||||
uint64_t iv64, const CipherKey &key) const
|
uint64_t iv64, const CipherKey &key) const
|
||||||
{
|
{
|
||||||
(void)src;
|
(void)src;
|
||||||
@ -162,13 +163,13 @@ bool NullCipher::streamDecode( unsigned char *src, int len,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NullCipher::blockEncode( unsigned char *, int , uint64_t,
|
bool NullCipher::blockEncode( byte *, int , uint64_t,
|
||||||
const CipherKey & ) const
|
const CipherKey & ) const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NullCipher::blockDecode( unsigned char *, int, uint64_t,
|
bool NullCipher::blockDecode( byte *, int, uint64_t,
|
||||||
const CipherKey & ) const
|
const CipherKey & ) const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@ -179,3 +180,4 @@ bool NullCipher::Enabled()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include "cipher/Cipher.h"
|
#include "cipher/Cipher.h"
|
||||||
#include "base/Interface.h"
|
#include "base/Interface.h"
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Implements Cipher interface for a pass-through mode. May be useful for
|
Implements Cipher interface for a pass-through mode. May be useful for
|
||||||
testing, but that's it.
|
testing, but that's it.
|
||||||
@ -41,16 +43,16 @@ public:
|
|||||||
// create a new key based on a password
|
// create a new key based on a password
|
||||||
virtual CipherKey newKey(const char *password, int passwdLength,
|
virtual CipherKey newKey(const char *password, int passwdLength,
|
||||||
int &iterationCount, long desiredDuration,
|
int &iterationCount, long desiredDuration,
|
||||||
const unsigned char *salt, int saltLen);
|
const byte *salt, int saltLen);
|
||||||
virtual CipherKey newKey(const char *password, int passwdLength);
|
virtual CipherKey newKey(const char *password, int passwdLength);
|
||||||
// create a new random key
|
// create a new random key
|
||||||
virtual CipherKey newRandomKey();
|
virtual CipherKey newRandomKey();
|
||||||
|
|
||||||
// data must be len keySize()
|
// data must be len keySize()
|
||||||
virtual CipherKey readKey(const unsigned char *data,
|
virtual CipherKey readKey(const byte *data,
|
||||||
const CipherKey &encodingKey,
|
const CipherKey &encodingKey,
|
||||||
bool checkKey);
|
bool checkKey);
|
||||||
virtual void writeKey(const CipherKey &key, unsigned char *data,
|
virtual void writeKey(const CipherKey &key, byte *data,
|
||||||
const CipherKey &encodingKey);
|
const CipherKey &encodingKey);
|
||||||
virtual bool compareKey( const CipherKey &A,
|
virtual bool compareKey( const CipherKey &A,
|
||||||
const CipherKey &B ) const;
|
const CipherKey &B ) const;
|
||||||
@ -60,27 +62,28 @@ public:
|
|||||||
virtual int encodedKeySize() const;
|
virtual int encodedKeySize() const;
|
||||||
virtual int cipherBlockSize() const;
|
virtual int cipherBlockSize() const;
|
||||||
|
|
||||||
virtual bool randomize( unsigned char *buf, int len,
|
virtual bool randomize( byte *buf, int len,
|
||||||
bool strongRandom ) const;
|
bool strongRandom ) const;
|
||||||
|
|
||||||
virtual uint64_t MAC_64(const unsigned char *data, int len,
|
virtual uint64_t MAC_64(const byte *data, int len,
|
||||||
const CipherKey &key, uint64_t *chainedIV) const;
|
const CipherKey &key, uint64_t *chainedIV) const;
|
||||||
|
|
||||||
// functional interfaces
|
// functional interfaces
|
||||||
virtual bool streamEncode(unsigned char *in, int len,
|
virtual bool streamEncode(byte *in, int len,
|
||||||
uint64_t iv64, const CipherKey &key) const;
|
uint64_t iv64, const CipherKey &key) const;
|
||||||
virtual bool streamDecode(unsigned char *in, int len,
|
virtual bool streamDecode(byte *in, int len,
|
||||||
uint64_t iv64, const CipherKey &key) const;
|
uint64_t iv64, const CipherKey &key) const;
|
||||||
|
|
||||||
virtual bool blockEncode(unsigned char *buf, int size,
|
virtual bool blockEncode(byte *buf, int size,
|
||||||
uint64_t iv64, const CipherKey &key) const;
|
uint64_t iv64, const CipherKey &key) const;
|
||||||
virtual bool blockDecode(unsigned char *buf, int size,
|
virtual bool blockDecode(byte *buf, int size,
|
||||||
uint64_t iv64, const CipherKey &key) const;
|
uint64_t iv64, const CipherKey &key) const;
|
||||||
|
|
||||||
// hack to help with static builds
|
// hack to help with static builds
|
||||||
static bool Enabled();
|
static bool Enabled();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -43,7 +43,8 @@
|
|||||||
#include "base/i18n.h"
|
#include "base/i18n.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace rel;
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
const int MAX_KEYLENGTH = 64; // in bytes (256 bit)
|
const int MAX_KEYLENGTH = 64; // in bytes (256 bit)
|
||||||
const int MAX_IVLENGTH = 16;
|
const int MAX_IVLENGTH = 16;
|
||||||
@ -65,13 +66,13 @@ inline int MIN(int a, int b)
|
|||||||
DEPRECATED: this is here for backward compatibilty only. Use PBKDF
|
DEPRECATED: this is here for backward compatibilty only. Use PBKDF
|
||||||
*/
|
*/
|
||||||
int BytesToKey( int keyLen, int ivLen, const EVP_MD *md,
|
int BytesToKey( int keyLen, int ivLen, const EVP_MD *md,
|
||||||
const unsigned char *data, int dataLen,
|
const byte *data, int dataLen,
|
||||||
unsigned int rounds, unsigned char *key, unsigned char *iv)
|
unsigned int rounds, byte *key, byte *iv)
|
||||||
{
|
{
|
||||||
if( data == NULL || dataLen == 0 )
|
if( data == NULL || dataLen == 0 )
|
||||||
return 0; // OpenSSL returns nkey here, but why? It is a failure..
|
return 0; // OpenSSL returns nkey here, but why? It is a failure..
|
||||||
|
|
||||||
unsigned char mdBuf[ EVP_MAX_MD_SIZE ];
|
byte mdBuf[ EVP_MAX_MD_SIZE ];
|
||||||
unsigned int mds=0;
|
unsigned int mds=0;
|
||||||
int addmd =0;
|
int addmd =0;
|
||||||
int nkey = key ? keyLen : 0;
|
int nkey = key ? keyLen : 0;
|
||||||
@ -127,8 +128,8 @@ long time_diff(const timeval &end, const timeval &start)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int SSL_Cipher::TimedPBKDF2(const char *pass, int passlen,
|
int SSL_Cipher::TimedPBKDF2(const char *pass, int passlen,
|
||||||
const unsigned char *salt, int saltlen,
|
const byte *salt, int saltlen,
|
||||||
int keylen, unsigned char *out,
|
int keylen, byte *out,
|
||||||
long desiredPDFTime)
|
long desiredPDFTime)
|
||||||
{
|
{
|
||||||
int iter = 1000;
|
int iter = 1000;
|
||||||
@ -138,7 +139,7 @@ int SSL_Cipher::TimedPBKDF2(const char *pass, int passlen,
|
|||||||
{
|
{
|
||||||
gettimeofday( &start, 0 );
|
gettimeofday( &start, 0 );
|
||||||
int res = PKCS5_PBKDF2_HMAC_SHA1(
|
int res = PKCS5_PBKDF2_HMAC_SHA1(
|
||||||
pass, passlen, const_cast<unsigned char*>(salt), saltlen,
|
pass, passlen, const_cast<byte*>(salt), saltlen,
|
||||||
iter, keylen, out);
|
iter, keylen, out);
|
||||||
if(res != 1)
|
if(res != 1)
|
||||||
return -1;
|
return -1;
|
||||||
@ -329,14 +330,14 @@ SSLKey::~SSLKey()
|
|||||||
pthread_mutex_destroy( &mutex );
|
pthread_mutex_destroy( &mutex );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned char* KeyData( const shared_ptr<SSLKey> &key )
|
inline byte* KeyData( const shared_ptr<SSLKey> &key )
|
||||||
{
|
{
|
||||||
return (unsigned char *)key->buf.data;
|
return (byte *)key->buf.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned char* IVData( const shared_ptr<SSLKey> &key )
|
inline byte* IVData( const shared_ptr<SSLKey> &key )
|
||||||
{
|
{
|
||||||
return (unsigned char *)key->buf.data + key->keySize;
|
return (byte *)key->buf.data + key->keySize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void initKey(const shared_ptr<SSLKey> &key, const EVP_CIPHER *_blockCipher,
|
void initKey(const shared_ptr<SSLKey> &key, const EVP_CIPHER *_blockCipher,
|
||||||
@ -424,7 +425,7 @@ Interface SSL_Cipher::interface() const
|
|||||||
*/
|
*/
|
||||||
CipherKey SSL_Cipher::newKey(const char *password, int passwdLength,
|
CipherKey SSL_Cipher::newKey(const char *password, int passwdLength,
|
||||||
int &iterationCount, long desiredDuration,
|
int &iterationCount, long desiredDuration,
|
||||||
const unsigned char *salt, int saltLen)
|
const byte *salt, int saltLen)
|
||||||
{
|
{
|
||||||
shared_ptr<SSLKey> key( new SSLKey( _keySize, _ivLength) );
|
shared_ptr<SSLKey> key( new SSLKey( _keySize, _ivLength) );
|
||||||
|
|
||||||
@ -446,7 +447,7 @@ CipherKey SSL_Cipher::newKey(const char *password, int passwdLength,
|
|||||||
// known iteration length
|
// known iteration length
|
||||||
if(PKCS5_PBKDF2_HMAC_SHA1(
|
if(PKCS5_PBKDF2_HMAC_SHA1(
|
||||||
password, passwdLength,
|
password, passwdLength,
|
||||||
const_cast<unsigned char*>(salt), saltLen,
|
const_cast<byte*>(salt), saltLen,
|
||||||
iterationCount, _keySize + _ivLength, KeyData(key)) != 1)
|
iterationCount, _keySize + _ivLength, KeyData(key)) != 1)
|
||||||
{
|
{
|
||||||
LOG(ERROR) << "openssl error, PBKDF2 failed";
|
LOG(ERROR) << "openssl error, PBKDF2 failed";
|
||||||
@ -469,7 +470,7 @@ CipherKey SSL_Cipher::newKey(const char *password, int passwdLength)
|
|||||||
// now we use BytesToKey, which can deal with Blowfish keys larger then
|
// now we use BytesToKey, which can deal with Blowfish keys larger then
|
||||||
// 128 bits.
|
// 128 bits.
|
||||||
bytes = BytesToKey( _keySize, _ivLength, EVP_sha1(),
|
bytes = BytesToKey( _keySize, _ivLength, EVP_sha1(),
|
||||||
(unsigned char *)password, passwdLength, 16,
|
(byte *)password, passwdLength, 16,
|
||||||
KeyData(key), IVData(key) );
|
KeyData(key), IVData(key) );
|
||||||
|
|
||||||
// the reason for moving from EVP_BytesToKey to BytesToKey function..
|
// the reason for moving from EVP_BytesToKey to BytesToKey function..
|
||||||
@ -482,7 +483,7 @@ CipherKey SSL_Cipher::newKey(const char *password, int passwdLength)
|
|||||||
{
|
{
|
||||||
// for backward compatibility with filesystems created with 1:0
|
// for backward compatibility with filesystems created with 1:0
|
||||||
bytes = EVP_BytesToKey( _blockCipher, EVP_sha1(), NULL,
|
bytes = EVP_BytesToKey( _blockCipher, EVP_sha1(), NULL,
|
||||||
(unsigned char *)password, passwdLength, 16,
|
(byte *)password, passwdLength, 16,
|
||||||
KeyData(key), IVData(key) );
|
KeyData(key), IVData(key) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -502,9 +503,9 @@ CipherKey SSL_Cipher::newKey(const char *password, int passwdLength)
|
|||||||
CipherKey SSL_Cipher::newRandomKey()
|
CipherKey SSL_Cipher::newRandomKey()
|
||||||
{
|
{
|
||||||
const int bufLen = MAX_KEYLENGTH;
|
const int bufLen = MAX_KEYLENGTH;
|
||||||
unsigned char tmpBuf[ bufLen ];
|
byte tmpBuf[ bufLen ];
|
||||||
int saltLen = 20;
|
int saltLen = 20;
|
||||||
unsigned char saltBuf[ saltLen ];
|
byte saltBuf[ saltLen ];
|
||||||
|
|
||||||
if(!randomize(tmpBuf, bufLen, true) ||
|
if(!randomize(tmpBuf, bufLen, true) ||
|
||||||
!randomize(saltBuf, saltLen, true))
|
!randomize(saltBuf, saltLen, true))
|
||||||
@ -532,14 +533,14 @@ CipherKey SSL_Cipher::newRandomKey()
|
|||||||
Compute a 64-bit check value for the data using HMAC.
|
Compute a 64-bit check value for the data using HMAC.
|
||||||
*/
|
*/
|
||||||
static uint64_t _checksum_64(SSLKey *key,
|
static uint64_t _checksum_64(SSLKey *key,
|
||||||
const unsigned char *data,
|
const byte *data,
|
||||||
int dataLen,
|
int dataLen,
|
||||||
uint64_t *chainedIV)
|
uint64_t *chainedIV)
|
||||||
{
|
{
|
||||||
rAssert( dataLen > 0 );
|
rAssert( dataLen > 0 );
|
||||||
Lock lock( key->mutex );
|
Lock lock( key->mutex );
|
||||||
|
|
||||||
unsigned char md[EVP_MAX_MD_SIZE];
|
byte md[EVP_MAX_MD_SIZE];
|
||||||
unsigned int mdLen = EVP_MAX_MD_SIZE;
|
unsigned int mdLen = EVP_MAX_MD_SIZE;
|
||||||
|
|
||||||
HMAC_Init_ex( &key->mac_ctx, 0, 0, 0, 0 );
|
HMAC_Init_ex( &key->mac_ctx, 0, 0, 0, 0 );
|
||||||
@ -548,7 +549,7 @@ static uint64_t _checksum_64(SSLKey *key,
|
|||||||
{
|
{
|
||||||
// toss in the chained IV as well
|
// toss in the chained IV as well
|
||||||
uint64_t tmp = *chainedIV;
|
uint64_t tmp = *chainedIV;
|
||||||
unsigned char h[8];
|
byte h[8];
|
||||||
for(unsigned int i=0; i<8; ++i)
|
for(unsigned int i=0; i<8; ++i)
|
||||||
{
|
{
|
||||||
h[i] = tmp & 0xff;
|
h[i] = tmp & 0xff;
|
||||||
@ -563,9 +564,9 @@ static uint64_t _checksum_64(SSLKey *key,
|
|||||||
rAssert(mdLen >= 8);
|
rAssert(mdLen >= 8);
|
||||||
|
|
||||||
// chop this down to a 64bit value..
|
// chop this down to a 64bit value..
|
||||||
unsigned char h[8] = {0,0,0,0,0,0,0,0};
|
byte h[8] = {0,0,0,0,0,0,0,0};
|
||||||
for(unsigned int i=0; i<(mdLen-1); ++i)
|
for(unsigned int i=0; i<(mdLen-1); ++i)
|
||||||
h[i%8] ^= (unsigned char)(md[i]);
|
h[i%8] ^= (byte)(md[i]);
|
||||||
|
|
||||||
uint64_t value = (uint64_t)h[0];
|
uint64_t value = (uint64_t)h[0];
|
||||||
for(int i=1; i<8; ++i)
|
for(int i=1; i<8; ++i)
|
||||||
@ -574,7 +575,7 @@ static uint64_t _checksum_64(SSLKey *key,
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SSL_Cipher::randomize( unsigned char *buf, int len,
|
bool SSL_Cipher::randomize( byte *buf, int len,
|
||||||
bool strongRandom ) const
|
bool strongRandom ) const
|
||||||
{
|
{
|
||||||
// to avoid warnings of uninitialized data from valgrind
|
// to avoid warnings of uninitialized data from valgrind
|
||||||
@ -597,7 +598,7 @@ bool SSL_Cipher::randomize( unsigned char *buf, int len,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t SSL_Cipher::MAC_64( const unsigned char *data, int len,
|
uint64_t SSL_Cipher::MAC_64( const byte *data, int len,
|
||||||
const CipherKey &key, uint64_t *chainedIV ) const
|
const CipherKey &key, uint64_t *chainedIV ) const
|
||||||
{
|
{
|
||||||
shared_ptr<SSLKey> mk = dynamic_pointer_cast<SSLKey>(key);
|
shared_ptr<SSLKey> mk = dynamic_pointer_cast<SSLKey>(key);
|
||||||
@ -609,13 +610,13 @@ uint64_t SSL_Cipher::MAC_64( const unsigned char *data, int len,
|
|||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
CipherKey SSL_Cipher::readKey(const unsigned char *data,
|
CipherKey SSL_Cipher::readKey(const byte *data,
|
||||||
const CipherKey &masterKey, bool checkKey)
|
const CipherKey &masterKey, bool checkKey)
|
||||||
{
|
{
|
||||||
shared_ptr<SSLKey> mk = dynamic_pointer_cast<SSLKey>(masterKey);
|
shared_ptr<SSLKey> mk = dynamic_pointer_cast<SSLKey>(masterKey);
|
||||||
rAssert(mk->keySize == _keySize);
|
rAssert(mk->keySize == _keySize);
|
||||||
|
|
||||||
unsigned char tmpBuf[ 2 * MAX_KEYLENGTH ];
|
byte tmpBuf[ 2 * MAX_KEYLENGTH ];
|
||||||
|
|
||||||
// First N bytes are checksum bytes.
|
// First N bytes are checksum bytes.
|
||||||
unsigned int checksum = 0;
|
unsigned int checksum = 0;
|
||||||
@ -654,7 +655,7 @@ CipherKey SSL_Cipher::readKey(const unsigned char *data,
|
|||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSL_Cipher::writeKey(const CipherKey &ckey, unsigned char *data,
|
void SSL_Cipher::writeKey(const CipherKey &ckey, byte *data,
|
||||||
const CipherKey &masterKey)
|
const CipherKey &masterKey)
|
||||||
{
|
{
|
||||||
shared_ptr<SSLKey> key = dynamic_pointer_cast<SSLKey>(ckey);
|
shared_ptr<SSLKey> key = dynamic_pointer_cast<SSLKey>(ckey);
|
||||||
@ -665,7 +666,7 @@ void SSL_Cipher::writeKey(const CipherKey &ckey, unsigned char *data,
|
|||||||
rAssert(mk->keySize == _keySize);
|
rAssert(mk->keySize == _keySize);
|
||||||
rAssert(mk->ivLength == _ivLength);
|
rAssert(mk->ivLength == _ivLength);
|
||||||
|
|
||||||
unsigned char tmpBuf[ 2 * MAX_KEYLENGTH ];
|
byte tmpBuf[ 2 * MAX_KEYLENGTH ];
|
||||||
|
|
||||||
unsigned int bufLen = key->buf.size;
|
unsigned int bufLen = key->buf.size;
|
||||||
rAssert(_keySize + _ivLength == bufLen );
|
rAssert(_keySize + _ivLength == bufLen );
|
||||||
@ -729,19 +730,19 @@ int SSL_Cipher::cipherBlockSize() const
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSL_Cipher::setIVec(unsigned char *ivec, uint64_t seed,
|
void SSL_Cipher::setIVec(byte *ivec, uint64_t seed,
|
||||||
const shared_ptr<SSLKey> &key) const
|
const shared_ptr<SSLKey> &key) const
|
||||||
{
|
{
|
||||||
if (iface.major() >= 3)
|
if (iface.major() >= 3)
|
||||||
{
|
{
|
||||||
memcpy( ivec, IVData(key), _ivLength );
|
memcpy( ivec, IVData(key), _ivLength );
|
||||||
|
|
||||||
unsigned char md[EVP_MAX_MD_SIZE];
|
byte md[EVP_MAX_MD_SIZE];
|
||||||
unsigned int mdLen = EVP_MAX_MD_SIZE;
|
unsigned int mdLen = EVP_MAX_MD_SIZE;
|
||||||
|
|
||||||
for(int i=0; i<8; ++i)
|
for(int i=0; i<8; ++i)
|
||||||
{
|
{
|
||||||
md[i] = (unsigned char)(seed & 0xff);
|
md[i] = (byte)(seed & 0xff);
|
||||||
seed >>= 8;
|
seed >>= 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -764,7 +765,7 @@ void SSL_Cipher::setIVec(unsigned char *ivec, uint64_t seed,
|
|||||||
// could get a victim to store a carefully crafted file, they could later
|
// could get a victim to store a carefully crafted file, they could later
|
||||||
// determine if the victim had the file in encrypted storage (without decrypting
|
// determine if the victim had the file in encrypted storage (without decrypting
|
||||||
// the file).
|
// the file).
|
||||||
void SSL_Cipher::setIVec_old(unsigned char *ivec,
|
void SSL_Cipher::setIVec_old(byte *ivec,
|
||||||
unsigned int seed,
|
unsigned int seed,
|
||||||
const shared_ptr<SSLKey> &key) const
|
const shared_ptr<SSLKey> &key) const
|
||||||
{
|
{
|
||||||
@ -795,9 +796,9 @@ void SSL_Cipher::setIVec_old(unsigned char *ivec,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void flipBytes(unsigned char *buf, int size)
|
static void flipBytes(byte *buf, int size)
|
||||||
{
|
{
|
||||||
unsigned char revBuf[64];
|
byte revBuf[64];
|
||||||
|
|
||||||
int bytesLeft = size;
|
int bytesLeft = size;
|
||||||
while(bytesLeft)
|
while(bytesLeft)
|
||||||
@ -814,13 +815,13 @@ static void flipBytes(unsigned char *buf, int size)
|
|||||||
memset(revBuf, 0, sizeof(revBuf));
|
memset(revBuf, 0, sizeof(revBuf));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void shuffleBytes(unsigned char *buf, int size)
|
static void shuffleBytes(byte *buf, int size)
|
||||||
{
|
{
|
||||||
for(int i=0; i<size-1; ++i)
|
for(int i=0; i<size-1; ++i)
|
||||||
buf[i+1] ^= buf[i];
|
buf[i+1] ^= buf[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unshuffleBytes(unsigned char *buf, int size)
|
static void unshuffleBytes(byte *buf, int size)
|
||||||
{
|
{
|
||||||
for(int i=size-1; i; --i)
|
for(int i=size-1; i; --i)
|
||||||
buf[i] ^= buf[i-1];
|
buf[i] ^= buf[i-1];
|
||||||
@ -829,7 +830,7 @@ static void unshuffleBytes(unsigned char *buf, int size)
|
|||||||
/* Partial blocks are encoded with a stream cipher. We make multiple passes on
|
/* Partial blocks are encoded with a stream cipher. We make multiple passes on
|
||||||
the data to ensure that the ends of the data depend on each other.
|
the data to ensure that the ends of the data depend on each other.
|
||||||
*/
|
*/
|
||||||
bool SSL_Cipher::streamEncode(unsigned char *buf, int size,
|
bool SSL_Cipher::streamEncode(byte *buf, int size,
|
||||||
uint64_t iv64, const CipherKey &ckey) const
|
uint64_t iv64, const CipherKey &ckey) const
|
||||||
{
|
{
|
||||||
rAssert( size > 0 );
|
rAssert( size > 0 );
|
||||||
@ -840,7 +841,7 @@ bool SSL_Cipher::streamEncode(unsigned char *buf, int size,
|
|||||||
|
|
||||||
Lock lock( key->mutex );
|
Lock lock( key->mutex );
|
||||||
|
|
||||||
unsigned char ivec[ MAX_IVLENGTH ];
|
byte ivec[ MAX_IVLENGTH ];
|
||||||
int dstLen=0, tmpLen=0;
|
int dstLen=0, tmpLen=0;
|
||||||
|
|
||||||
shuffleBytes( buf, size );
|
shuffleBytes( buf, size );
|
||||||
@ -865,7 +866,7 @@ bool SSL_Cipher::streamEncode(unsigned char *buf, int size,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SSL_Cipher::streamDecode(unsigned char *buf, int size,
|
bool SSL_Cipher::streamDecode(byte *buf, int size,
|
||||||
uint64_t iv64, const CipherKey &ckey) const
|
uint64_t iv64, const CipherKey &ckey) const
|
||||||
{
|
{
|
||||||
rAssert( size > 0 );
|
rAssert( size > 0 );
|
||||||
@ -876,7 +877,7 @@ bool SSL_Cipher::streamDecode(unsigned char *buf, int size,
|
|||||||
|
|
||||||
Lock lock( key->mutex );
|
Lock lock( key->mutex );
|
||||||
|
|
||||||
unsigned char ivec[ MAX_IVLENGTH ];
|
byte ivec[ MAX_IVLENGTH ];
|
||||||
int dstLen=0, tmpLen=0;
|
int dstLen=0, tmpLen=0;
|
||||||
|
|
||||||
setIVec( ivec, iv64 + 1, key );
|
setIVec( ivec, iv64 + 1, key );
|
||||||
@ -902,7 +903,7 @@ bool SSL_Cipher::streamDecode(unsigned char *buf, int size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SSL_Cipher::blockEncode(unsigned char *buf, int size,
|
bool SSL_Cipher::blockEncode(byte *buf, int size,
|
||||||
uint64_t iv64, const CipherKey &ckey ) const
|
uint64_t iv64, const CipherKey &ckey ) const
|
||||||
{
|
{
|
||||||
rAssert( size > 0 );
|
rAssert( size > 0 );
|
||||||
@ -916,7 +917,7 @@ bool SSL_Cipher::blockEncode(unsigned char *buf, int size,
|
|||||||
|
|
||||||
Lock lock( key->mutex );
|
Lock lock( key->mutex );
|
||||||
|
|
||||||
unsigned char ivec[ MAX_IVLENGTH ];
|
byte ivec[ MAX_IVLENGTH ];
|
||||||
|
|
||||||
int dstLen = 0, tmpLen = 0;
|
int dstLen = 0, tmpLen = 0;
|
||||||
setIVec( ivec, iv64, key );
|
setIVec( ivec, iv64, key );
|
||||||
@ -932,7 +933,7 @@ bool SSL_Cipher::blockEncode(unsigned char *buf, int size,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SSL_Cipher::blockDecode(unsigned char *buf, int size,
|
bool SSL_Cipher::blockDecode(byte *buf, int size,
|
||||||
uint64_t iv64, const CipherKey &ckey ) const
|
uint64_t iv64, const CipherKey &ckey ) const
|
||||||
{
|
{
|
||||||
rAssert( size > 0 );
|
rAssert( size > 0 );
|
||||||
@ -946,7 +947,7 @@ bool SSL_Cipher::blockDecode(unsigned char *buf, int size,
|
|||||||
|
|
||||||
Lock lock( key->mutex );
|
Lock lock( key->mutex );
|
||||||
|
|
||||||
unsigned char ivec[ MAX_IVLENGTH ];
|
byte ivec[ MAX_IVLENGTH ];
|
||||||
|
|
||||||
int dstLen = 0, tmpLen = 0;
|
int dstLen = 0, tmpLen = 0;
|
||||||
setIVec( ivec, iv64, key );
|
setIVec( ivec, iv64, key );
|
||||||
@ -971,3 +972,5 @@ bool SSL_Cipher::hasStreamMode() const
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
@ -24,12 +24,14 @@
|
|||||||
#include "cipher/Cipher.h"
|
#include "cipher/Cipher.h"
|
||||||
#include "base/Interface.h"
|
#include "base/Interface.h"
|
||||||
|
|
||||||
class SSLKey;
|
|
||||||
#ifndef EVP_CIPHER
|
#ifndef EVP_CIPHER
|
||||||
struct evp_cipher_st;
|
struct evp_cipher_st;
|
||||||
typedef struct evp_cipher_st EVP_CIPHER;
|
typedef struct evp_cipher_st EVP_CIPHER;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
class SSLKey;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Implements Cipher interface for OpenSSL's ciphers.
|
Implements Cipher interface for OpenSSL's ciphers.
|
||||||
|
|
||||||
@ -89,17 +91,17 @@ class SSL_Cipher : public Cipher
|
|||||||
// create a new key based on a password
|
// create a new key based on a password
|
||||||
virtual CipherKey newKey(const char *password, int passwdLength,
|
virtual CipherKey newKey(const char *password, int passwdLength,
|
||||||
int &iterationCount, long desiredDuration,
|
int &iterationCount, long desiredDuration,
|
||||||
const unsigned char *salt, int saltLen);
|
const byte *salt, int saltLen);
|
||||||
// deprecated - for backward compatibility
|
// deprecated - for backward compatibility
|
||||||
virtual CipherKey newKey(const char *password, int passwdLength);
|
virtual CipherKey newKey(const char *password, int passwdLength);
|
||||||
// create a new random key
|
// create a new random key
|
||||||
virtual CipherKey newRandomKey();
|
virtual CipherKey newRandomKey();
|
||||||
|
|
||||||
// data must be len keySize()
|
// data must be len keySize()
|
||||||
virtual CipherKey readKey(const unsigned char *data,
|
virtual CipherKey readKey(const byte *data,
|
||||||
const CipherKey &encodingKey,
|
const CipherKey &encodingKey,
|
||||||
bool checkKey);
|
bool checkKey);
|
||||||
virtual void writeKey(const CipherKey &key, unsigned char *data,
|
virtual void writeKey(const CipherKey &key, byte *data,
|
||||||
const CipherKey &encodingKey);
|
const CipherKey &encodingKey);
|
||||||
virtual bool compareKey( const CipherKey &A,
|
virtual bool compareKey( const CipherKey &A,
|
||||||
const CipherKey &B ) const;
|
const CipherKey &B ) const;
|
||||||
@ -111,19 +113,19 @@ class SSL_Cipher : public Cipher
|
|||||||
|
|
||||||
virtual bool hasStreamMode() const;
|
virtual bool hasStreamMode() const;
|
||||||
|
|
||||||
virtual bool randomize( unsigned char *buf, int len,
|
virtual bool randomize( byte *buf, int len,
|
||||||
bool strongRandom ) const;
|
bool strongRandom ) const;
|
||||||
|
|
||||||
virtual uint64_t MAC_64( const unsigned char *src, int len,
|
virtual uint64_t MAC_64( const byte *src, int len,
|
||||||
const CipherKey &key, uint64_t *augment ) const;
|
const CipherKey &key, uint64_t *augment ) const;
|
||||||
|
|
||||||
// functional interfaces
|
// functional interfaces
|
||||||
/*
|
/*
|
||||||
Stream encoding in-place.
|
Stream encoding in-place.
|
||||||
*/
|
*/
|
||||||
virtual bool streamEncode(unsigned char *in, int len,
|
virtual bool streamEncode(byte *in, int len,
|
||||||
uint64_t iv64, const CipherKey &key) const;
|
uint64_t iv64, const CipherKey &key) const;
|
||||||
virtual bool streamDecode(unsigned char *in, int len,
|
virtual bool streamDecode(byte *in, int len,
|
||||||
uint64_t iv64, const CipherKey &key) const;
|
uint64_t iv64, const CipherKey &key) const;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -131,9 +133,9 @@ class SSL_Cipher : public Cipher
|
|||||||
blocks are always expected to begin on a block boundary. See
|
blocks are always expected to begin on a block boundary. See
|
||||||
blockSize().
|
blockSize().
|
||||||
*/
|
*/
|
||||||
virtual bool blockEncode(unsigned char *buf, int size,
|
virtual bool blockEncode(byte *buf, int size,
|
||||||
uint64_t iv64, const CipherKey &key) const;
|
uint64_t iv64, const CipherKey &key) const;
|
||||||
virtual bool blockDecode(unsigned char *buf, int size,
|
virtual bool blockDecode(byte *buf, int size,
|
||||||
uint64_t iv64, const CipherKey &key) const;
|
uint64_t iv64, const CipherKey &key) const;
|
||||||
|
|
||||||
// hack to help with static builds
|
// hack to help with static builds
|
||||||
@ -143,17 +145,19 @@ class SSL_Cipher : public Cipher
|
|||||||
// number of iterations based on a desired execution time (in microseconds).
|
// number of iterations based on a desired execution time (in microseconds).
|
||||||
// Returns the number of iterations applied.
|
// Returns the number of iterations applied.
|
||||||
static int TimedPBKDF2(const char *pass, int passLen,
|
static int TimedPBKDF2(const char *pass, int passLen,
|
||||||
const unsigned char *salt, int saltLen,
|
const byte *salt, int saltLen,
|
||||||
int keyLen, unsigned char *out,
|
int keyLen, byte *out,
|
||||||
long desiredPDFTimeMicroseconds);
|
long desiredPDFTimeMicroseconds);
|
||||||
private:
|
private:
|
||||||
void setIVec( unsigned char *ivec, uint64_t seed,
|
void setIVec( byte *ivec, uint64_t seed,
|
||||||
const shared_ptr<SSLKey> &key ) const;
|
const shared_ptr<SSLKey> &key ) const;
|
||||||
|
|
||||||
// deprecated - for backward compatibility
|
// deprecated - for backward compatibility
|
||||||
void setIVec_old( unsigned char *ivec, unsigned int seed,
|
void setIVec_old( byte *ivec, unsigned int seed,
|
||||||
const shared_ptr<SSLKey> &key ) const;
|
const shared_ptr<SSLKey> &key ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
#include <openssl/engine.h>
|
#include <openssl/engine.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
unsigned long pthreads_thread_id()
|
unsigned long pthreads_thread_id()
|
||||||
{
|
{
|
||||||
return (unsigned long)pthread_self();
|
return (unsigned long)pthread_self();
|
||||||
@ -107,3 +109,4 @@ void openssl_shutdown(bool threaded)
|
|||||||
pthreads_locking_cleanup();
|
pthreads_locking_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
@ -21,9 +21,13 @@
|
|||||||
#ifndef _openssl_incl_
|
#ifndef _openssl_incl_
|
||||||
#define _openssl_incl_
|
#define _openssl_incl_
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
void openssl_init(bool isThreaded);
|
void openssl_init(bool isThreaded);
|
||||||
void openssl_shutdown(bool isThreaded);
|
void openssl_shutdown(bool isThreaded);
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,6 +63,9 @@ inline static int MAX(int a, int b)
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace gnu;
|
using namespace gnu;
|
||||||
|
using namespace encfs;
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
// Maximum number of arguments that we're going to pass on to fuse. Doesn't
|
// Maximum number of arguments that we're going to pass on to fuse. Doesn't
|
||||||
// affect how many arguments we can handle, just how many we can pass on..
|
// affect how many arguments we can handle, just how many we can pass on..
|
||||||
@ -111,6 +114,8 @@ struct EncFS_Args
|
|||||||
|
|
||||||
static int oldStderr = STDERR_FILENO;
|
static int oldStderr = STDERR_FILENO;
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
static
|
static
|
||||||
void usage(const char *name)
|
void usage(const char *name)
|
||||||
{
|
{
|
||||||
|
@ -20,14 +20,16 @@
|
|||||||
|
|
||||||
#include "fs/BlockFileIO.h"
|
#include "fs/BlockFileIO.h"
|
||||||
|
|
||||||
#include "base/config.pb.h"
|
|
||||||
#include "base/Error.h"
|
#include "base/Error.h"
|
||||||
#include "base/i18n.h"
|
#include "base/i18n.h"
|
||||||
#include "cipher/MemoryPool.h"
|
#include "cipher/MemoryPool.h"
|
||||||
|
#include "fs/fsconfig.pb.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <glog/logging.h>
|
#include <glog/logging.h>
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
template<typename Type>
|
template<typename Type>
|
||||||
inline Type min( Type A, Type B )
|
inline Type min( Type A, Type B )
|
||||||
{
|
{
|
||||||
@ -424,3 +426,4 @@ int BlockFileIO::blockTruncate( off_t size, FileIO *base )
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
@ -21,8 +21,10 @@
|
|||||||
#ifndef _BlockFileIO_incl_
|
#ifndef _BlockFileIO_incl_
|
||||||
#define _BlockFileIO_incl_
|
#define _BlockFileIO_incl_
|
||||||
|
|
||||||
#include "FileIO.h"
|
#include "fs/FileIO.h"
|
||||||
#include "FSConfig.h"
|
#include "fs/FSConfig.h"
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Implements block scatter / gather interface. Requires derived classes to
|
Implements block scatter / gather interface. Requires derived classes to
|
||||||
@ -64,5 +66,7 @@ protected:
|
|||||||
mutable IORequest _cache;
|
mutable IORequest _cache;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <glog/logging.h>
|
#include <glog/logging.h>
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
static shared_ptr<NameIO> NewBlockNameIO( const Interface &iface,
|
static shared_ptr<NameIO> NewBlockNameIO( const Interface &iface,
|
||||||
const shared_ptr<Cipher> &cipher, const CipherKey &key )
|
const shared_ptr<Cipher> &cipher, const CipherKey &key )
|
||||||
{
|
{
|
||||||
@ -248,3 +250,5 @@ bool BlockNameIO::Enabled()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
class Cipher;
|
class Cipher;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -65,5 +67,7 @@ private:
|
|||||||
bool _caseSensitive;
|
bool _caseSensitive;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
find_package (FUSE REQUIRED)
|
find_package (FUSE REQUIRED)
|
||||||
include_directories (${FUSE_INCLUDE_DIR})
|
include_directories (${FUSE_INCLUDE_DIR})
|
||||||
|
|
||||||
|
protobuf_generate_cpp (PROTO_SRCS PROTO_HDRS ${Encfs_SOURCE_DIR}/protos/fsconfig.proto)
|
||||||
|
|
||||||
enable_testing ()
|
enable_testing ()
|
||||||
find_package (GTest)
|
find_package (GTest)
|
||||||
|
|
||||||
|
include_directories (${Encfs_BINARY_DIR}/base)
|
||||||
add_library (encfs-fs
|
add_library (encfs-fs
|
||||||
encfs.cpp
|
encfs.cpp
|
||||||
Context.cpp
|
Context.cpp
|
||||||
|
@ -20,16 +20,18 @@
|
|||||||
|
|
||||||
#include "fs/CipherFileIO.h"
|
#include "fs/CipherFileIO.h"
|
||||||
|
|
||||||
#include "base/config.pb.h"
|
|
||||||
#include "base/Error.h"
|
#include "base/Error.h"
|
||||||
#include "cipher/Cipher.h"
|
#include "cipher/Cipher.h"
|
||||||
#include "cipher/MemoryPool.h"
|
#include "cipher/MemoryPool.h"
|
||||||
|
#include "fs/fsconfig.pb.h"
|
||||||
|
|
||||||
#include <glog/logging.h>
|
#include <glog/logging.h>
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Version 3:0 adds support for block-only encryption by adding space for
|
Version 3:0 adds support for block-only encryption by adding space for
|
||||||
a full block to the file header.
|
a full block to the file header.
|
||||||
@ -511,3 +513,4 @@ bool CipherFileIO::isWritable() const
|
|||||||
return base->isWritable();
|
return base->isWritable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
class Cipher;
|
class Cipher;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -95,4 +97,6 @@ private:
|
|||||||
CipherKey key;
|
CipherKey key;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include "fs/FileUtils.h"
|
#include "fs/FileUtils.h"
|
||||||
#include "fs/DirNode.h"
|
#include "fs/DirNode.h"
|
||||||
|
|
||||||
using namespace rel;
|
namespace encfs {
|
||||||
|
|
||||||
EncFS_Context::EncFS_Context()
|
EncFS_Context::EncFS_Context()
|
||||||
{
|
{
|
||||||
@ -173,3 +173,4 @@ void EncFS_Context::eraseNode(const char *path, void *pl)
|
|||||||
delete ph;
|
delete ph;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
@ -33,6 +33,8 @@ using std::tr1::unordered_map;
|
|||||||
using std::unordered_map;
|
using std::unordered_map;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
struct EncFS_Args;
|
struct EncFS_Args;
|
||||||
struct EncFS_Opts;
|
struct EncFS_Opts;
|
||||||
class FileNode;
|
class FileNode;
|
||||||
@ -102,5 +104,7 @@ private:
|
|||||||
|
|
||||||
int remountFS( EncFS_Context *ctx );
|
int remountFS( EncFS_Context *ctx );
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "fs/Context.h"
|
#include "fs/Context.h"
|
||||||
#include "fs/DirNode.h"
|
#include "fs/DirNode.h"
|
||||||
#include "fs/FileUtils.h"
|
#include "fs/FileUtils.h"
|
||||||
|
#include "fs/fsconfig.pb.h"
|
||||||
|
|
||||||
|
|
||||||
#include <glog/logging.h>
|
#include <glog/logging.h>
|
||||||
@ -46,7 +47,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace rel;
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
class DirDeleter
|
class DirDeleter
|
||||||
{
|
{
|
||||||
@ -814,3 +816,6 @@ int DirNode::unlink( const char *plaintextName )
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
|
@ -36,6 +36,8 @@
|
|||||||
#include "fs/NameIO.h"
|
#include "fs/NameIO.h"
|
||||||
#include "fs/FSConfig.h"
|
#include "fs/FSConfig.h"
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
class Cipher;
|
class Cipher;
|
||||||
class RenameOp;
|
class RenameOp;
|
||||||
struct RenameEl;
|
struct RenameEl;
|
||||||
@ -170,4 +172,6 @@ private:
|
|||||||
shared_ptr<NameIO> naming;
|
shared_ptr<NameIO> naming;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -25,9 +25,12 @@
|
|||||||
#include "base/shared_ptr.h"
|
#include "base/shared_ptr.h"
|
||||||
#include "cipher/CipherKey.h"
|
#include "cipher/CipherKey.h"
|
||||||
#include "fs/encfs.h"
|
#include "fs/encfs.h"
|
||||||
|
#include "fs/fsconfig.pb.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
enum ConfigType
|
enum ConfigType
|
||||||
{
|
{
|
||||||
Config_None = 0,
|
Config_None = 0,
|
||||||
@ -42,7 +45,6 @@ enum ConfigType
|
|||||||
struct EncFS_Opts;
|
struct EncFS_Opts;
|
||||||
class Cipher;
|
class Cipher;
|
||||||
class NameIO;
|
class NameIO;
|
||||||
class EncfsConfig;
|
|
||||||
|
|
||||||
CipherKey getUserKey(const EncfsConfig &config, bool useStdin);
|
CipherKey getUserKey(const EncfsConfig &config, bool useStdin);
|
||||||
CipherKey getUserKey(const EncfsConfig &config,
|
CipherKey getUserKey(const EncfsConfig &config,
|
||||||
@ -77,5 +79,7 @@ struct FSConfig
|
|||||||
|
|
||||||
typedef shared_ptr<FSConfig> FSConfigPtr;
|
typedef shared_ptr<FSConfig> FSConfigPtr;
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -18,7 +18,9 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FileIO.h"
|
#include "fs/FileIO.h"
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
FileIO::FileIO()
|
FileIO::FileIO()
|
||||||
{
|
{
|
||||||
@ -39,3 +41,4 @@ bool FileIO::setIV( uint64_t iv )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
struct IORequest
|
struct IORequest
|
||||||
{
|
{
|
||||||
off_t offset;
|
off_t offset;
|
||||||
@ -82,5 +84,7 @@ private:
|
|||||||
FileIO &operator = ( const FileIO & );
|
FileIO &operator = ( const FileIO & );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -39,19 +39,20 @@
|
|||||||
#include "cipher/Cipher.h"
|
#include "cipher/Cipher.h"
|
||||||
#include "cipher/MemoryPool.h"
|
#include "cipher/MemoryPool.h"
|
||||||
|
|
||||||
|
#include "fs/CipherFileIO.h"
|
||||||
|
#include "fs/DirNode.h"
|
||||||
|
#include "fs/FileIO.h"
|
||||||
#include "fs/FileNode.h"
|
#include "fs/FileNode.h"
|
||||||
#include "fs/FileUtils.h"
|
#include "fs/FileUtils.h"
|
||||||
#include "fs/CipherFileIO.h"
|
|
||||||
#include "fs/RawFileIO.h"
|
|
||||||
#include "fs/MACFileIO.h"
|
#include "fs/MACFileIO.h"
|
||||||
#include "fs/DirNode.h"
|
#include "fs/RawFileIO.h"
|
||||||
|
#include "fs/fsconfig.pb.h"
|
||||||
#include "fs/FileIO.h"
|
|
||||||
|
|
||||||
#include <glog/logging.h>
|
#include <glog/logging.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace rel;
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO: locking at the FileNode level is inefficient, since this precludes
|
TODO: locking at the FileNode level is inefficient, since this precludes
|
||||||
@ -301,3 +302,4 @@ int FileNode::sync(bool datasync)
|
|||||||
return fh;
|
return fh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
class Cipher;
|
class Cipher;
|
||||||
class FileIO;
|
class FileIO;
|
||||||
class DirNode;
|
class DirNode;
|
||||||
@ -95,6 +97,7 @@ private:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -25,10 +25,10 @@
|
|||||||
#define _BSD_SOURCE // pick up setenv on RH7.3
|
#define _BSD_SOURCE // pick up setenv on RH7.3
|
||||||
|
|
||||||
#include "fs/encfs.h"
|
#include "fs/encfs.h"
|
||||||
|
#include "fs/fsconfig.pb.h"
|
||||||
|
|
||||||
#include "base/autosprintf.h"
|
#include "base/autosprintf.h"
|
||||||
#include "base/config.h"
|
#include "base/config.h"
|
||||||
#include "base/config.pb.h"
|
|
||||||
#include "base/ConfigReader.h"
|
#include "base/ConfigReader.h"
|
||||||
#include "base/Error.h"
|
#include "base/Error.h"
|
||||||
#include "base/i18n.h"
|
#include "base/i18n.h"
|
||||||
@ -69,6 +69,8 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace gnu;
|
using namespace gnu;
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
static const int DefaultBlockSize = 2048;
|
static const int DefaultBlockSize = 2048;
|
||||||
// The maximum length of text passwords. If longer are needed,
|
// The maximum length of text passwords. If longer are needed,
|
||||||
// use the extpass option, as extpass can return arbitrary length binary data.
|
// use the extpass option, as extpass can return arbitrary length binary data.
|
||||||
@ -1674,3 +1676,4 @@ int remountFS(EncFS_Context *ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#include "fs/encfs.h"
|
#include "fs/encfs.h"
|
||||||
#include "fs/FSConfig.h"
|
#include "fs/FSConfig.h"
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
// true if the path points to an existing node (of any type)
|
// true if the path points to an existing node (of any type)
|
||||||
bool fileExists( const char *fileName );
|
bool fileExists( const char *fileName );
|
||||||
// true if path is a directory
|
// true if path is a directory
|
||||||
@ -131,4 +133,6 @@ bool readV6Config( const char *configFile, EncfsConfig &config,
|
|||||||
bool readProtoConfig( const char *configFile, EncfsConfig &config,
|
bool readProtoConfig( const char *configFile, EncfsConfig &config,
|
||||||
struct ConfigInfo *);
|
struct ConfigInfo *);
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
#endif
|
#endif
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "fs/MACFileIO.h"
|
#include "fs/MACFileIO.h"
|
||||||
|
#include "fs/fsconfig.pb.h"
|
||||||
|
|
||||||
#include "base/config.pb.h"
|
|
||||||
#include "base/Error.h"
|
#include "base/Error.h"
|
||||||
#include "base/i18n.h"
|
#include "base/i18n.h"
|
||||||
#include "cipher/MemoryPool.h"
|
#include "cipher/MemoryPool.h"
|
||||||
@ -32,6 +32,8 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Version 1.0 worked on blocks of size (blockSize + headerSize).
|
// Version 1.0 worked on blocks of size (blockSize + headerSize).
|
||||||
// That is, it took [blockSize] worth of user data and added headers.
|
// That is, it took [blockSize] worth of user data and added headers.
|
||||||
@ -293,3 +295,5 @@ bool MACFileIO::isWritable() const
|
|||||||
{
|
{
|
||||||
return base->isWritable();
|
return base->isWritable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include "cipher/Cipher.h"
|
#include "cipher/Cipher.h"
|
||||||
#include "fs/BlockFileIO.h"
|
#include "fs/BlockFileIO.h"
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
class MACFileIO : public BlockFileIO
|
class MACFileIO : public BlockFileIO
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -63,5 +65,7 @@ private:
|
|||||||
bool warnOnly;
|
bool warnOnly;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
|
|
||||||
#include <glog/logging.h>
|
#include <glog/logging.h>
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
static Interface MemBlockFileIO_iface = makeInterface("FileIO/MemBlock",
|
static Interface MemBlockFileIO_iface = makeInterface("FileIO/MemBlock",
|
||||||
1, 0, 0);
|
1, 0, 0);
|
||||||
|
|
||||||
@ -74,3 +76,4 @@ bool MemBlockFileIO::isWritable() const {
|
|||||||
return impl->isWritable();
|
return impl->isWritable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
class MemFileIO;
|
class MemFileIO;
|
||||||
|
|
||||||
class MemBlockFileIO : public BlockFileIO {
|
class MemBlockFileIO : public BlockFileIO {
|
||||||
@ -55,5 +57,7 @@ class MemBlockFileIO : public BlockFileIO {
|
|||||||
MemFileIO *impl;
|
MemFileIO *impl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#include <glog/logging.h>
|
#include <glog/logging.h>
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
static Interface MemFileIO_iface = makeInterface("FileIO/Mem", 1, 0, 0);
|
static Interface MemFileIO_iface = makeInterface("FileIO/Mem", 1, 0, 0);
|
||||||
|
|
||||||
MemFileIO* NewMemFileIO(const Interface& iface) {
|
MemFileIO* NewMemFileIO(const Interface& iface) {
|
||||||
@ -104,3 +106,4 @@ bool MemFileIO::isWritable() const {
|
|||||||
return writable;
|
return writable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
@ -22,11 +22,13 @@
|
|||||||
#ifndef _MEMFILEIO_incl_
|
#ifndef _MEMFILEIO_incl_
|
||||||
#define _MEMFILEIO_incl_
|
#define _MEMFILEIO_incl_
|
||||||
|
|
||||||
#include "FileIO.h"
|
#include "fs/FileIO.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
class MemFileIO : public FileIO {
|
class MemFileIO : public FileIO {
|
||||||
public:
|
public:
|
||||||
MemFileIO(int size);
|
MemFileIO(int size);
|
||||||
@ -54,5 +56,7 @@ class MemFileIO : public FileIO {
|
|||||||
bool writable;
|
bool writable;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -36,6 +36,8 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
#define REF_MODULE(TYPE) \
|
#define REF_MODULE(TYPE) \
|
||||||
do { \
|
do { \
|
||||||
if(!TYPE::Enabled() ) \
|
if(!TYPE::Enabled() ) \
|
||||||
@ -336,3 +338,6 @@ std::string NameIO::decodeName( const char *path, int length ) const
|
|||||||
_encodeName( path, length ) :
|
_encodeName( path, length ) :
|
||||||
_decodeName( path, length );
|
_decodeName( path, length );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
#include "base/Interface.h"
|
#include "base/Interface.h"
|
||||||
#include "cipher/CipherKey.h"
|
#include "cipher/CipherKey.h"
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
class Cipher;
|
class Cipher;
|
||||||
|
|
||||||
class NameIO
|
class NameIO
|
||||||
@ -137,6 +139,7 @@ do { \
|
|||||||
} \
|
} \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
static shared_ptr<NameIO> NewNNIO( const Interface &,
|
static shared_ptr<NameIO> NewNNIO( const Interface &,
|
||||||
const shared_ptr<Cipher> &, const CipherKey & )
|
const shared_ptr<Cipher> &, const CipherKey & )
|
||||||
{
|
{
|
||||||
@ -82,3 +84,5 @@ bool NullNameIO::Enabled()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
|
@ -21,7 +21,9 @@
|
|||||||
#ifndef _NullNameIO_incl_
|
#ifndef _NullNameIO_incl_
|
||||||
#define _NullNameIO_incl_
|
#define _NullNameIO_incl_
|
||||||
|
|
||||||
#include "NameIO.h"
|
#include "fs/NameIO.h"
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
class NullNameIO : public NameIO
|
class NullNameIO : public NameIO
|
||||||
{
|
{
|
||||||
@ -47,6 +49,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -37,6 +37,8 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
static Interface RawFileIO_iface = makeInterface("FileIO/Raw", 1, 0, 0);
|
static Interface RawFileIO_iface = makeInterface("FileIO/Raw", 1, 0, 0);
|
||||||
|
|
||||||
FileIO *NewRawFileIO( const Interface &iface )
|
FileIO *NewRawFileIO( const Interface &iface )
|
||||||
@ -328,3 +330,6 @@ bool RawFileIO::isWritable() const
|
|||||||
{
|
{
|
||||||
return canWrite;
|
return canWrite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
|
@ -21,10 +21,12 @@
|
|||||||
#ifndef _RawFileIO_incl_
|
#ifndef _RawFileIO_incl_
|
||||||
#define _RawFileIO_incl_
|
#define _RawFileIO_incl_
|
||||||
|
|
||||||
#include "FileIO.h"
|
#include "fs/FileIO.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
class RawFileIO : public FileIO
|
class RawFileIO : public FileIO
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -60,5 +62,7 @@ protected:
|
|||||||
bool canWrite;
|
bool canWrite;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
static shared_ptr<NameIO> NewStreamNameIO( const Interface &iface,
|
static shared_ptr<NameIO> NewStreamNameIO( const Interface &iface,
|
||||||
const shared_ptr<Cipher> &cipher, const CipherKey &key)
|
const shared_ptr<Cipher> &cipher, const CipherKey &key)
|
||||||
{
|
{
|
||||||
@ -204,3 +206,5 @@ bool StreamNameIO::Enabled()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include "cipher/CipherKey.h"
|
#include "cipher/CipherKey.h"
|
||||||
#include "fs/NameIO.h"
|
#include "fs/NameIO.h"
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
class Cipher;
|
class Cipher;
|
||||||
|
|
||||||
class StreamNameIO : public NameIO
|
class StreamNameIO : public NameIO
|
||||||
@ -54,6 +56,7 @@ private:
|
|||||||
CipherKey _key;
|
CipherKey _key;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -60,14 +60,14 @@ using namespace std;
|
|||||||
|
|
||||||
#include <glog/logging.h>
|
#include <glog/logging.h>
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
#ifndef MIN
|
#ifndef MIN
|
||||||
#define MIN(a,b) (((a)<(b)) ? (a): (b))
|
#define MIN(a,b) (((a)<(b)) ? (a): (b))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ESUCCESS 0
|
#define ESUCCESS 0
|
||||||
|
|
||||||
using rel::Lock;
|
|
||||||
|
|
||||||
#define GET_FN(ctx, finfo) ctx->getNode((void*)(uintptr_t)finfo->fh)
|
#define GET_FN(ctx, finfo) ctx->getNode((void*)(uintptr_t)finfo->fh)
|
||||||
|
|
||||||
static EncFS_Context * context()
|
static EncFS_Context * context()
|
||||||
@ -789,5 +789,7 @@ int encfs_removexattr( const char *path, const char *name )
|
|||||||
return withCipherPath( "removexattr", path, _do_removexattr, name );
|
return withCipherPath( "removexattr", path, _do_removexattr, name );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif // HAVE_XATTR
|
#endif // HAVE_XATTR
|
||||||
|
|
||||||
|
@ -57,6 +57,8 @@ static __inline int setfsgid(gid_t gid)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
int encfs_getattr(const char *path, struct stat *stbuf);
|
int encfs_getattr(const char *path, struct stat *stbuf);
|
||||||
int encfs_fgetattr(const char *path, struct stat *stbuf,
|
int encfs_fgetattr(const char *path, struct stat *stbuf,
|
||||||
struct fuse_file_info *fi);
|
struct fuse_file_info *fi);
|
||||||
@ -105,5 +107,7 @@ int encfs_removexattr( const char *path, const char *name );
|
|||||||
|
|
||||||
int encfs_utimens( const char *path, const struct timespec ts[2] );
|
int encfs_utimens( const char *path, const struct timespec ts[2] );
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -56,6 +56,8 @@ using std::unordered_set;
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
const int FSBlockSize = 256;
|
const int FSBlockSize = 256;
|
||||||
|
|
||||||
static
|
static
|
||||||
@ -552,5 +554,5 @@ int main(int argc, char *argv[])
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
#include "fs/MemFileIO.h"
|
#include "fs/MemFileIO.h"
|
||||||
#include "fs/MemBlockFileIO.h"
|
#include "fs/MemBlockFileIO.h"
|
||||||
|
|
||||||
|
using namespace encfs;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
TEST(BlockFileIOTest, BasicIO) {
|
TEST(BlockFileIOTest, BasicIO) {
|
||||||
@ -63,5 +65,5 @@ TEST(BlockFileIOTest, BasicIO) {
|
|||||||
ASSERT_NO_FATAL_FAILURE(compare(&base, &block, 0, 1024));
|
ASSERT_NO_FATAL_FAILURE(compare(&base, &block, 0, 1024));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace encfs
|
||||||
|
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
#include "fs/MACFileIO.h"
|
#include "fs/MACFileIO.h"
|
||||||
#include "fs/MemFileIO.h"
|
#include "fs/MemFileIO.h"
|
||||||
|
|
||||||
|
using namespace encfs;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
TEST(MemIOTest, BasicIO) {
|
TEST(MemIOTest, BasicIO) {
|
||||||
|
@ -30,13 +30,16 @@
|
|||||||
#include "cipher/Cipher.h"
|
#include "cipher/Cipher.h"
|
||||||
#include "cipher/MemoryPool.h"
|
#include "cipher/MemoryPool.h"
|
||||||
|
|
||||||
#include "fs/MemFileIO.h"
|
|
||||||
#include "fs/FileUtils.h"
|
|
||||||
#include "fs/FSConfig.h"
|
#include "fs/FSConfig.h"
|
||||||
|
#include "fs/fsconfig.pb.h"
|
||||||
|
#include "fs/FileUtils.h"
|
||||||
#include "fs/MACFileIO.h"
|
#include "fs/MACFileIO.h"
|
||||||
|
#include "fs/MemFileIO.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
FSConfigPtr makeConfig(const shared_ptr<Cipher>& cipher, int blockSize) {
|
FSConfigPtr makeConfig(const shared_ptr<Cipher>& cipher, int blockSize) {
|
||||||
FSConfigPtr cfg = FSConfigPtr(new FSConfig);
|
FSConfigPtr cfg = FSConfigPtr(new FSConfig);
|
||||||
cfg->cipher = cipher;
|
cfg->cipher = cipher;
|
||||||
@ -169,3 +172,5 @@ int main(int argc, char **argv) {
|
|||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#include "fs/FileUtils.h"
|
#include "fs/FileUtils.h"
|
||||||
#include "fs/FSConfig.h"
|
#include "fs/FSConfig.h"
|
||||||
|
|
||||||
|
namespace encfs {
|
||||||
|
|
||||||
class FileIO;
|
class FileIO;
|
||||||
|
|
||||||
FSConfigPtr makeConfig(const shared_ptr<Cipher>& cipher, int blockSize);
|
FSConfigPtr makeConfig(const shared_ptr<Cipher>& cipher, int blockSize);
|
||||||
@ -19,5 +21,7 @@ void comparisonTest(FSConfigPtr& cfg, FileIO* a, FileIO* b);
|
|||||||
|
|
||||||
void compare(FileIO* a, FileIO* b, int offset, int len);
|
void compare(FileIO* a, FileIO* b, int offset, int len);
|
||||||
|
|
||||||
|
} // namespace encfs
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
|
|
||||||
|
package encfs;
|
||||||
|
|
||||||
|
option optimize_for = CODE_SIZE;
|
||||||
|
|
||||||
|
import "interface.proto";
|
||||||
|
|
||||||
message EncfsConfig
|
message EncfsConfig
|
||||||
{
|
{
|
||||||
optional string creator = 1;
|
optional string creator = 1;
|
||||||
@ -34,15 +40,3 @@ message EncryptedKey
|
|||||||
optional int32 kdf_duration = 11 [default=500];
|
optional int32 kdf_duration = 11 [default=500];
|
||||||
}
|
}
|
||||||
|
|
||||||
message Interface
|
|
||||||
{
|
|
||||||
required string name = 1;
|
|
||||||
required uint32 major = 2; // major version number
|
|
||||||
required uint32 minor = 3; // minor version number
|
|
||||||
|
|
||||||
// Age indicates number of major versions supported. 0 means no backward
|
|
||||||
// compatibility. See libtool "updating version information" for more
|
|
||||||
// details on how major/minor/age are used for versioning libraries.
|
|
||||||
optional uint32 age = 4;
|
|
||||||
}
|
|
||||||
|
|
17
protos/interface.proto
Normal file
17
protos/interface.proto
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
package encfs;
|
||||||
|
|
||||||
|
option optimize_for = CODE_SIZE;
|
||||||
|
|
||||||
|
message Interface
|
||||||
|
{
|
||||||
|
required string name = 1;
|
||||||
|
required uint32 major = 2; // major version number
|
||||||
|
required uint32 minor = 3; // minor version number
|
||||||
|
|
||||||
|
// Age indicates number of major versions supported. 0 means no backward
|
||||||
|
// compatibility. See libtool "updating version information" for more
|
||||||
|
// details on how major/minor/age are used for versioning libraries.
|
||||||
|
optional uint32 age = 4;
|
||||||
|
}
|
||||||
|
|
@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace gnu;
|
using namespace gnu;
|
||||||
|
using namespace encfs;
|
||||||
|
|
||||||
static int showInfo( int argc, char **argv );
|
static int showInfo( int argc, char **argv );
|
||||||
static int showVersion( int argc, char **argv );
|
static int showVersion( int argc, char **argv );
|
||||||
|
Loading…
Reference in New Issue
Block a user