mirror of
https://github.com/vgough/encfs.git
synced 2025-06-24 05:51:51 +02:00
reformat file
git-svn-id: http://encfs.googlecode.com/svn/trunk@84 db9cf616-1c43-0410-9cb8-a902689de0d6
This commit is contained in:
parent
f144de359f
commit
183dca787f
201
encfs/Cipher.h
201
encfs/Cipher.h
@ -40,126 +40,129 @@ using boost::shared_ptr;
|
|||||||
class Cipher
|
class Cipher
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// if no key length was indicated when cipher was registered, then keyLen
|
// if no key length was indicated when cipher was registered, then keyLen
|
||||||
// <= 0 will be used.
|
// <= 0 will be used.
|
||||||
typedef boost::shared_ptr<Cipher> (*CipherConstructor)( const Interface &iface,
|
typedef boost::shared_ptr<Cipher> (*CipherConstructor)(
|
||||||
int keyLenBits );
|
const Interface &iface, int keyLenBits );
|
||||||
|
|
||||||
struct CipherAlgorithm
|
struct CipherAlgorithm
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string description;
|
std::string description;
|
||||||
Interface iface;
|
Interface iface;
|
||||||
Range keyLength;
|
Range keyLength;
|
||||||
Range blockSize;
|
Range blockSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef std::list<CipherAlgorithm> AlgorithmList;
|
typedef std::list<CipherAlgorithm> AlgorithmList;
|
||||||
static AlgorithmList GetAlgorithmList( bool includeHidden = false );
|
static AlgorithmList GetAlgorithmList( bool includeHidden = false );
|
||||||
|
|
||||||
|
|
||||||
static boost::shared_ptr<Cipher> New( const Interface &iface,
|
static boost::shared_ptr<Cipher> New( const Interface &iface,
|
||||||
int keyLen = -1);
|
int keyLen = -1);
|
||||||
static boost::shared_ptr<Cipher> New( const std::string &cipherName,
|
static boost::shared_ptr<Cipher> New( const std::string &cipherName,
|
||||||
int keyLen = -1 );
|
int keyLen = -1 );
|
||||||
|
|
||||||
|
|
||||||
static bool Register(const char *cipherName,
|
static bool Register(const char *cipherName,
|
||||||
const char *description,
|
const char *description,
|
||||||
const Interface &iface,
|
const Interface &iface,
|
||||||
CipherConstructor constructor,
|
CipherConstructor constructor,
|
||||||
bool hidden = false);
|
bool hidden = false);
|
||||||
static bool Register(const char *cipherName,
|
|
||||||
const char *description,
|
|
||||||
const Interface &iface,
|
|
||||||
const Range &keyLength, const Range &blockSize,
|
|
||||||
CipherConstructor constructor,
|
|
||||||
bool hidden = false);
|
|
||||||
|
|
||||||
|
static bool Register(const char *cipherName,
|
||||||
|
const char *description,
|
||||||
|
const Interface &iface,
|
||||||
|
const Range &keyLength, const Range &blockSize,
|
||||||
|
CipherConstructor constructor,
|
||||||
|
bool hidden = false);
|
||||||
|
|
||||||
Cipher();
|
Cipher();
|
||||||
virtual ~Cipher();
|
virtual ~Cipher();
|
||||||
|
|
||||||
virtual Interface interface() const =0;
|
virtual Interface interface() const =0;
|
||||||
|
|
||||||
// create a new key based on a password
|
// create a new key based on a password
|
||||||
// if iterationCount == 0, then iteration count will be determined
|
// if iterationCount == 0, then iteration count will be determined
|
||||||
// by newKey function and filled in.
|
// by newKey function and filled in.
|
||||||
// If iterationCount == 0, then desiredFunctionDuration is how many
|
// If iterationCount == 0, then desiredFunctionDuration is how many
|
||||||
// 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 unsigned char *salt, int saltLen) =0;
|
||||||
// deprecated - for backward compatibility
|
|
||||||
virtual CipherKey newKey(const char *password, int passwdLength ) =0;
|
|
||||||
// create a new random key
|
|
||||||
virtual CipherKey newRandomKey() =0;
|
|
||||||
|
|
||||||
// data must be len encodedKeySize()
|
// deprecated - for backward compatibility
|
||||||
virtual CipherKey readKey(const unsigned char *data,
|
virtual CipherKey newKey(const char *password, int passwdLength ) =0;
|
||||||
const CipherKey &encodingKey,
|
|
||||||
bool checkKey = true) =0;
|
|
||||||
virtual void writeKey(const CipherKey &key, unsigned char *data,
|
|
||||||
const CipherKey &encodingKey) =0;
|
|
||||||
|
|
||||||
virtual std::string encodeAsString(const CipherKey &key,
|
// create a new random key
|
||||||
const CipherKey &encodingKey );
|
virtual CipherKey newRandomKey() =0;
|
||||||
|
|
||||||
// for testing purposes
|
// data must be len encodedKeySize()
|
||||||
virtual bool compareKey( const CipherKey &A, const CipherKey &B ) const =0;
|
virtual CipherKey readKey(const unsigned char *data,
|
||||||
|
const CipherKey &encodingKey,
|
||||||
|
bool checkKey = true) =0;
|
||||||
|
|
||||||
// meta-data about the cypher
|
virtual void writeKey(const CipherKey &key, unsigned char *data,
|
||||||
virtual int keySize() const=0;
|
const CipherKey &encodingKey) =0;
|
||||||
virtual int encodedKeySize() const=0; // size
|
|
||||||
virtual int cipherBlockSize() const=0; // size of a cipher block
|
|
||||||
|
|
||||||
// fill the supplied buffer with random data
|
virtual std::string encodeAsString(const CipherKey &key,
|
||||||
// The data may be pseudo random and might not be suitable for key
|
const CipherKey &encodingKey );
|
||||||
// generation. For generating keys, uses newRandomKey() instead.
|
|
||||||
// Returns true on success, false on failure.
|
|
||||||
virtual bool randomize( unsigned char *buf, int len,
|
|
||||||
bool strongRandom ) const =0;
|
|
||||||
|
|
||||||
// 64 bit MAC of the data with the given key
|
// for testing purposes
|
||||||
virtual uint64_t MAC_64( const unsigned char *src, int len,
|
virtual bool compareKey( const CipherKey &A, const CipherKey &B ) const =0;
|
||||||
const CipherKey &key, uint64_t *chainedIV = 0 ) const =0;
|
|
||||||
// based on reductions of MAC_64
|
|
||||||
unsigned int MAC_32( const unsigned char *src, int len,
|
|
||||||
const CipherKey &key, uint64_t *chainedIV = 0 ) const;
|
|
||||||
unsigned int MAC_16( const unsigned char *src, int len,
|
|
||||||
const CipherKey &key, uint64_t *chainedIV = 0 ) const;
|
|
||||||
|
|
||||||
// functional interfaces
|
// meta-data about the cypher
|
||||||
/*
|
virtual int keySize() const=0;
|
||||||
Stream encoding of data in-place. The stream data can be any length.
|
virtual int encodedKeySize() const=0; // size
|
||||||
*/
|
virtual int cipherBlockSize() const=0; // size of a cipher block
|
||||||
virtual bool streamEncode( unsigned char *data, int len,
|
|
||||||
uint64_t iv64, const CipherKey &key) const=0;
|
|
||||||
virtual bool streamDecode( unsigned char *data, int len,
|
|
||||||
uint64_t iv64, const CipherKey &key) const=0;
|
|
||||||
|
|
||||||
/*
|
// fill the supplied buffer with random data
|
||||||
These are just aliases of streamEncode / streamDecode, but there are
|
// The data may be pseudo random and might not be suitable for key
|
||||||
provided here for backward compatibility for earlier ciphers that has
|
// generation. For generating keys, uses newRandomKey() instead.
|
||||||
effectively two stream modes - one for encoding partial blocks and
|
// Returns true on success, false on failure.
|
||||||
another for encoding filenames.
|
virtual bool randomize( unsigned char *buf, int len,
|
||||||
*/
|
bool strongRandom ) const =0;
|
||||||
virtual bool nameEncode( unsigned char *data, int len,
|
|
||||||
uint64_t iv64, const CipherKey &key) const;
|
|
||||||
virtual bool nameDecode( unsigned char *data, int len,
|
|
||||||
uint64_t iv64, const CipherKey &key) const;
|
|
||||||
|
|
||||||
/*
|
// 64 bit MAC of the data with the given key
|
||||||
Block encoding of data in-place. The data size should be a multiple of
|
virtual uint64_t MAC_64( const unsigned char *src, int len,
|
||||||
the cipher block size.
|
const CipherKey &key, uint64_t *chainedIV = 0 ) const =0;
|
||||||
*/
|
|
||||||
virtual bool blockEncode(unsigned char *buf, int size,
|
// based on reductions of MAC_64
|
||||||
uint64_t iv64, const CipherKey &key) const=0;
|
unsigned int MAC_32( const unsigned char *src, int len,
|
||||||
virtual bool blockDecode(unsigned char *buf, int size,
|
const CipherKey &key, uint64_t *chainedIV = 0 ) const;
|
||||||
uint64_t iv64, const CipherKey &key) const=0;
|
unsigned int MAC_16( const unsigned char *src, int len,
|
||||||
|
const CipherKey &key, uint64_t *chainedIV = 0 ) const;
|
||||||
|
|
||||||
|
// functional interfaces
|
||||||
|
/*
|
||||||
|
Stream encoding of data in-place. The stream data can be any length.
|
||||||
|
*/
|
||||||
|
virtual bool streamEncode( unsigned char *data, int len,
|
||||||
|
uint64_t iv64, const CipherKey &key) const=0;
|
||||||
|
virtual bool streamDecode( unsigned char *data, int len,
|
||||||
|
uint64_t iv64, const CipherKey &key) const=0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
These are just aliases of streamEncode / streamDecode, but there are
|
||||||
|
provided here for backward compatibility for earlier ciphers that has
|
||||||
|
effectively two stream modes - one for encoding partial blocks and
|
||||||
|
another for encoding filenames.
|
||||||
|
*/
|
||||||
|
virtual bool nameEncode( unsigned char *data, int len,
|
||||||
|
uint64_t iv64, const CipherKey &key) const;
|
||||||
|
virtual bool nameDecode( unsigned char *data, int len,
|
||||||
|
uint64_t iv64, const CipherKey &key) const;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Block encoding of data in-place. The data size should be a multiple of
|
||||||
|
the cipher block size.
|
||||||
|
*/
|
||||||
|
virtual bool blockEncode(unsigned char *buf, int size,
|
||||||
|
uint64_t iv64, const CipherKey &key) const=0;
|
||||||
|
virtual bool blockDecode(unsigned char *buf, int size,
|
||||||
|
uint64_t iv64, const CipherKey &key) const=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user