2022-12-24 23:49:50 +00:00
|
|
|
// Copyright (c) 2014-2022 The Bitcoin Core developers
|
2014-10-26 01:23:23 -07:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2014-11-19 22:17:58 +01:00
|
|
|
#ifndef BITCOIN_CRYPTO_SHA512_H
|
|
|
|
#define BITCOIN_CRYPTO_SHA512_H
|
2014-10-26 01:23:23 -07:00
|
|
|
|
2022-09-23 10:48:47 +01:00
|
|
|
#include <cstdlib>
|
2014-10-26 01:23:23 -07:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
/** A hasher class for SHA-512. */
|
|
|
|
class CSHA512
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
uint64_t s[8];
|
|
|
|
unsigned char buf[128];
|
2023-01-31 11:50:10 +00:00
|
|
|
uint64_t bytes{0};
|
2014-10-26 01:23:23 -07:00
|
|
|
|
|
|
|
public:
|
2018-12-17 16:04:35 -08:00
|
|
|
static constexpr size_t OUTPUT_SIZE = 64;
|
2014-10-26 01:23:23 -07:00
|
|
|
|
|
|
|
CSHA512();
|
|
|
|
CSHA512& Write(const unsigned char* data, size_t len);
|
|
|
|
void Finalize(unsigned char hash[OUTPUT_SIZE]);
|
|
|
|
CSHA512& Reset();
|
2019-11-05 10:54:20 -08:00
|
|
|
uint64_t Size() const { return bytes; }
|
2014-10-26 01:23:23 -07:00
|
|
|
};
|
|
|
|
|
2014-11-19 22:17:58 +01:00
|
|
|
#endif // BITCOIN_CRYPTO_SHA512_H
|