1
0
mirror of https://github.com/biergaizi/codecrypt synced 2024-06-24 07:48:13 +00:00
codecrypt/src/hash.h

64 lines
1.5 KiB
C
Raw Normal View History

2012-09-30 09:55:23 +00:00
2012-11-05 21:45:35 +00:00
/*
* This file is part of Codecrypt.
*
2016-04-17 13:47:47 +00:00
* Copyright (C) 2013-2016 Mirek Kratochvil <exa.exa@gmail.com>
*
2012-11-05 21:45:35 +00:00
* Codecrypt 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.
*
* Codecrypt 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 Codecrypt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _ccr_hash_h_
#define _ccr_hash_h_
2012-09-30 09:55:23 +00:00
2012-12-25 13:39:39 +00:00
#include <vector>
#include <string>
#include <map>
2012-12-25 13:39:39 +00:00
#include "types.h"
#include "factoryof.h"
2012-12-25 13:39:39 +00:00
/*
2012-12-25 13:39:39 +00:00
* hash-providing functor class, meant to be instantiated by user.
*/
2012-12-25 13:39:39 +00:00
class hash_func
{
public:
virtual std::vector<byte> operator() (const std::vector<byte>&) = 0;
virtual uint size() = 0; //in bytes
};
2012-12-02 11:50:29 +00:00
2014-03-10 12:57:25 +00:00
class hash_proc
{
public:
virtual uint size() = 0;
virtual void init() = 0;
2014-04-06 11:37:26 +00:00
virtual void eat (const byte*begin, const byte*end) = 0;
2014-03-10 12:57:25 +00:00
virtual std::vector<byte> finish() = 0;
virtual ~hash_proc() {}
2014-04-06 11:37:26 +00:00
void eat (const std::vector<byte>&a) {
2015-10-31 21:58:17 +00:00
return eat (& (a[0]), & (a[a.size()]));
2014-04-06 11:37:26 +00:00
}
typedef std::map<std::string, factoryof<hash_proc>*> suite_t;
static suite_t& suite();
virtual bool cryptographically_significant() {
return true;
}
2014-03-10 12:57:25 +00:00
};
2012-09-30 09:55:23 +00:00
#endif