encfs/cipher/CipherKey.h

61 lines
1.6 KiB
C
Raw Normal View History

/*****************************************************************************
* Author: Valient Gough <vgough@pobox.com>
*
*****************************************************************************
* Copyright (c) 2007, Valient Gough
*
* 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
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* 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/>.
*/
#ifndef _CipherKey_incl_
#define _CipherKey_incl_
#include <cstring>
#include "base/shared_ptr.h"
#include "base/types.h"
namespace encfs {
class SecureMem;
class CipherKey {
public:
CipherKey(); // Creates a key for which valid() returns false.
explicit CipherKey(int length);
CipherKey(const byte *data, int length);
CipherKey(const CipherKey &src);
~CipherKey();
void operator=(const CipherKey &src);
byte *data() const;
int size() const;
// Clear memory associated with key.
void reset();
bool valid() const;
private:
bool _valid;
shared_ptr<SecureMem> _mem;
};
bool operator==(const CipherKey &a, const CipherKey &b);
} // namespace encfs
#endif