Any projects which want to use Hush code from now on will need to be licensed as GPLv3 or we will send the lawyers: https://www.softwarefreedom.org/ Notably, Komodo (KMD) is licensed as GPLv2 and is no longer compatible to receive code changes, without causing legal issues. MIT projects, such as Zcash, also cannot pull in changes from the Hush Full Node without permission from The Hush Developers, which may in some circumstances grant an MIT license on a case-by-case basis.
35 lines
899 B
C++
35 lines
899 B
C++
// Copyright (c) 2014 The Bitcoin Core developers
|
|
// Distributed under the GPLv3 software license, see the accompanying
|
|
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
|
|
|
#include "crypto/hmac_sha512.h"
|
|
|
|
#include <string.h>
|
|
|
|
CHMAC_SHA512::CHMAC_SHA512(const unsigned char* key, size_t keylen)
|
|
{
|
|
unsigned char rkey[128];
|
|
if (keylen <= 128) {
|
|
memcpy(rkey, key, keylen);
|
|
memset(rkey + keylen, 0, 128 - keylen);
|
|
} else {
|
|
CSHA512().Write(key, keylen).Finalize(rkey);
|
|
memset(rkey + 64, 0, 64);
|
|
}
|
|
|
|
for (int n = 0; n < 128; n++)
|
|
rkey[n] ^= 0x5c;
|
|
outer.Write(rkey, 128);
|
|
|
|
for (int n = 0; n < 128; n++)
|
|
rkey[n] ^= 0x5c ^ 0x36;
|
|
inner.Write(rkey, 128);
|
|
}
|
|
|
|
void CHMAC_SHA512::Finalize(unsigned char hash[OUTPUT_SIZE])
|
|
{
|
|
unsigned char temp[64];
|
|
inner.Finalize(temp);
|
|
outer.Write(temp, 64).Finalize(hash);
|
|
}
|