Files
thehub/libs/crypto/hmac_sha256.h

47 lines
1.3 KiB
C++

/*
* This file is part of the Flowee project
* Copyright (C) 2014 The Bitcoin Core developers
*
* 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/>.
*/
#ifndef FLOWEE_CRYPTO_HMAC_SHA256_H
#define FLOWEE_CRYPTO_HMAC_SHA256_H
#include "sha256.h"
#include <cstdint>
#include <cstdlib>
/** A hasher class for HMAC-SHA-512. */
class CHMAC_SHA256
{
private:
CSHA256 outer;
CSHA256 inner;
public:
static const size_t OUTPUT_SIZE = 32;
CHMAC_SHA256(const unsigned char* key, size_t keylen);
CHMAC_SHA256& write(const unsigned char* data, size_t len)
{
inner.write(data, len);
return *this;
}
void finalize(unsigned char hash[OUTPUT_SIZE]);
};
#endif