1 /***************************************************************************** 2 * Author: Valient Gough <vgough@pobox.com> 3 * 4 ***************************************************************************** 5 * Copyright (c) 2004, Valient Gough 6 * 7 * This program is free software: you can redistribute it and/or modify it 8 * under the terms of the GNU Lesser General Public License as published by the 9 * Free Software Foundation, either version 3 of the License, or (at your 10 * option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 15 * for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public License 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 #ifndef _StreamNameIO_incl_ 22 #define _StreamNameIO_incl_ 23 24 #include <memory> 25 #include <stdint.h> 26 27 #include "CipherKey.h" 28 #include "Interface.h" 29 #include "NameIO.h" 30 31 namespace encfs { 32 33 class Cipher; 34 35 class StreamNameIO : public NameIO { 36 public: 37 static Interface CurrentInterface(); 38 39 StreamNameIO(const Interface &iface, std::shared_ptr<Cipher> cipher, 40 CipherKey key); 41 virtual ~StreamNameIO(); 42 43 virtual Interface interface() const; 44 45 virtual int maxEncodedNameLen(int plaintextNameLen) const; 46 virtual int maxDecodedNameLen(int encodedNameLen) const; 47 48 // hack to help with static builds 49 static bool Enabled(); 50 51 protected: 52 virtual int encodeName(const char *plaintextName, int length, uint64_t *iv, 53 char *encodedName, int bufferLength) const; 54 virtual int decodeName(const char *encodedName, int length, uint64_t *iv, 55 char *plaintextName, int bufferLength) const; 56 57 private: 58 int _interface; 59 std::shared_ptr<Cipher> _cipher; 60 CipherKey _key; 61 }; 62 63 } // namespace encfs 64 65 #endif 66