2008-01-07 09:09:04 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* Author: Valient Gough <vgough@pobox.com>
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
|
|
|
* Copyright (c) 2004, Valient Gough
|
|
|
|
*
|
2012-10-03 07:12:17 +02:00
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU Lesser General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
2013-10-20 00:35:26 +02:00
|
|
|
* option) any later version.
|
2008-01-07 09:09:04 +01:00
|
|
|
*
|
2012-10-03 07:12:17 +02:00
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
2008-01-07 09:09:04 +01:00
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
2012-10-03 07:12:17 +02:00
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-01-07 09:09:04 +01:00
|
|
|
*/
|
|
|
|
|
2013-01-29 04:07:54 +01:00
|
|
|
#include "base/base64.h"
|
2013-03-05 07:36:32 +01:00
|
|
|
#include "cipher/CipherV1.h"
|
2013-01-29 04:07:54 +01:00
|
|
|
#include "fs/NullNameIO.h"
|
2008-01-07 09:09:04 +01:00
|
|
|
|
2008-05-15 19:03:30 +02:00
|
|
|
#include <cstring>
|
|
|
|
|
2013-03-05 07:29:58 +01:00
|
|
|
namespace encfs {
|
|
|
|
|
2013-10-20 00:35:26 +02:00
|
|
|
static shared_ptr<NameIO> NewNNIO(const Interface &,
|
|
|
|
const shared_ptr<CipherV1> &) {
|
|
|
|
return shared_ptr<NameIO>(new NullNameIO());
|
2008-01-07 09:09:04 +01:00
|
|
|
}
|
|
|
|
|
2012-04-26 04:34:15 +02:00
|
|
|
static Interface NNIOIface = makeInterface("nameio/null", 1, 0, 0);
|
2013-10-20 00:35:26 +02:00
|
|
|
static bool NullNameIO_registered = NameIO::Register(
|
|
|
|
"Null", "No encryption of filenames", NNIOIface, NewNNIO, false);
|
2008-01-07 09:09:04 +01:00
|
|
|
|
2013-10-20 00:35:26 +02:00
|
|
|
NullNameIO::NullNameIO() {}
|
2008-01-07 09:09:04 +01:00
|
|
|
|
2013-10-20 00:35:26 +02:00
|
|
|
NullNameIO::~NullNameIO() {}
|
2008-01-07 09:09:04 +01:00
|
|
|
|
2013-10-20 00:35:26 +02:00
|
|
|
Interface NullNameIO::interface() const { return NNIOIface; }
|
2008-01-07 09:09:04 +01:00
|
|
|
|
2013-10-20 00:35:26 +02:00
|
|
|
Interface NullNameIO::CurrentInterface() { return NNIOIface; }
|
2008-01-07 09:09:04 +01:00
|
|
|
|
2013-10-20 00:35:26 +02:00
|
|
|
int NullNameIO::maxEncodedNameLen(int plaintextNameLen) const {
|
2013-01-29 04:07:54 +01:00
|
|
|
return plaintextNameLen;
|
2008-01-07 09:09:04 +01:00
|
|
|
}
|
|
|
|
|
2013-10-20 00:35:26 +02:00
|
|
|
int NullNameIO::maxDecodedNameLen(int encodedNameLen) const {
|
2013-01-29 04:07:54 +01:00
|
|
|
return encodedNameLen;
|
2008-01-07 09:09:04 +01:00
|
|
|
}
|
|
|
|
|
2013-10-20 00:35:26 +02:00
|
|
|
int NullNameIO::encodeName(const char *plaintextName, int length, uint64_t *iv,
|
|
|
|
char *encodedName) const {
|
|
|
|
memcpy(encodedName, plaintextName, length);
|
2013-01-29 04:07:54 +01:00
|
|
|
return length;
|
2008-01-07 09:09:04 +01:00
|
|
|
}
|
|
|
|
|
2013-10-20 00:35:26 +02:00
|
|
|
int NullNameIO::decodeName(const char *encodedName, int length, uint64_t *iv,
|
|
|
|
char *plaintextName) const {
|
|
|
|
memcpy(plaintextName, encodedName, length);
|
2013-01-29 04:07:54 +01:00
|
|
|
return length;
|
2008-01-07 09:09:04 +01:00
|
|
|
}
|
|
|
|
|
2013-10-20 00:35:26 +02:00
|
|
|
bool NullNameIO::Enabled() { return true; }
|
2008-01-07 09:09:04 +01:00
|
|
|
|
2013-03-05 07:29:58 +01:00
|
|
|
} // namespace encfs
|