#ifndef CRYPTO_H_INCLUDED
#define CRYPTO_H_INCLUDED


#include <NTL/ZZ.h>
#include <NTL/GF2X.h>

#include <crypto/ostring.h>

extern "C" {

#include <nettle/sha.h>
#include <nettle/hmac.h>
#include <nettle/aes.h>

}

#include <iostream>
#include <fstream>
#include <cstdlib>


class Int_overflow_error {};
class Parse_error {};
class General_error {};
class Key_error {};
class Decrypt_error {};
class Init_error {};


void dump(const ostring&);
void dumphex(const ostring&);

void prettyprint(std::ostream&, const ostring&);
void prettyprint(std::ostream&, const NTL::ZZ&);
void prettyprint(std::ostream&, const NTL::GF2X&);
void printostring(std::ostream&, const ostring&);

ostring Xor(const ostring&, const ostring&);
NTL::ZZ hex_to_ZZ(const ostring&);
int hex_to_int(octet);


ostring i2osp(const NTL::ZZ&, long);
NTL::ZZ os2ip(const ostring&);
ostring poly2osp(const NTL::GF2X&, long);
NTL::GF2X os2polyp(const ostring&);

inline long NumBits1(const NTL::GF2X& a)
   { return deg(a); }

inline long NumBytes1(const NTL::GF2X& a)
   { return (NumBits1(a) + 7)/8; }


#endif /* CRYPTO_H_INCLUDED */

