/*
*  Naamari - an AES/SHA-based manual file crypto-synchronizer for cloud transfers
*  Copyright (c) 2015-2017 Sunkware
*  Key FP = 6B6D C8E9 3438 6E9C 3D97  56E5 2CE9 A476 99EF 28F6
*
*  This program is free software: you can redistribute it and/or modify
*  it under the terms of the GNU 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 General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*  ----------------------------------------------------------------
*  WWW:       sunkware.org
*  E-mail:    sunkware@gmail.com
*  ----------------------------------------------------------------
*/

#ifndef CONTEXTGLOB_H
#define CONTEXTGLOB_H


#include "defines.h"

#include "hasher.h"


namespace cryptrav
{


class ContextGlob
{
 private:

  quint8       keyR[KEY_SIZE]; // key to generate Randomen in file-nomen
  quint8       keyC[KEY_SIZE]; // key to generate Cryptomen filename
  quint8       keyS[KEY_SIZE]; // key to generate Salt each time new file/new version is encrypted
  quint8       keyH[KEY_SIZE]; // key to hash which verifies integrity
  quint8       keyB[KEY_SIZE]; // key to hash which calculates per-Block-keys
  bool         areKeysReady;


  QString      pathHallway; // where files before encryption/after decryption are placed
  bool         isHallwayReady;

  QString      pathNominis; // where dir-structure and filenames with harbour-names inside are gathered ("nominis" is a Latin for "names")
  bool         isNominisReady;

  QString      pathHarbour; // where encrypted files are kept; net pusher/puller looks here
  bool         isHarbourReady;


  quint8       passTermChr; // character to append to entered password before hashing; 0 by default (see constructor)


  void         clearKeys(void);

  void         Reset(void);


 public:
  ContextGlob();

  quint8*      getKeyR(void);
  quint8*      getKeyC(void);
  quint8*      getKeyS(void);
  quint8*      getKeyH(void);
  quint8*      getKeyB(void);
  qint32       loadKeys(QString pathFile, quint8* passHash);


  QString      getHallwayPath(void);
  bool         setHallwayPath(QString path);

  QString      getNominisPath(void);
  bool         setNominisPath(QString path);

  QString      getHarbourPath(void);
  bool         setHarbourPath(QString path);


  quint8       getPassTermChr(void);
  void         setPassTermChr(quint8 chr);


  bool         areKeysSet(void);
  bool         isReady(void);

  ~ContextGlob();
};


} // namespace "cryptrav"

#endif // CONTEXTGLOB_H
