aboutsummaryrefslogtreecommitdiff
path: root/src/hash.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2014-04-20 17:36:25 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2014-06-21 19:47:39 +0200
commit977cdadea8a77eed04f1f0fd341ba9dedc3fa783 (patch)
tree842e2239a98d6f5c329e639f4ca953e5ea865f82 /src/hash.cpp
parent540ce6aa10996661a62853797538d2a703664ea2 (diff)
downloadbitcoin-977cdadea8a77eed04f1f0fd341ba9dedc3fa783.tar.xz
Add a built-in SHA256/SHA512 implementation.
This also moves the HMAC-SHA512 implementation to sha2.cpp.
Diffstat (limited to 'src/hash.cpp')
-rw-r--r--src/hash.cpp41
1 files changed, 0 insertions, 41 deletions
diff --git a/src/hash.cpp b/src/hash.cpp
index 7b054bd154..bddd8abf38 100644
--- a/src/hash.cpp
+++ b/src/hash.cpp
@@ -56,44 +56,3 @@ unsigned int MurmurHash3(unsigned int nHashSeed, const std::vector<unsigned char
return h1;
}
-
-int HMAC_SHA512_Init(HMAC_SHA512_CTX *pctx, const void *pkey, size_t len)
-{
- unsigned char key[128];
- if (len <= 128)
- {
- memcpy(key, pkey, len);
- memset(key + len, 0, 128-len);
- }
- else
- {
- SHA512_CTX ctxKey;
- SHA512_Init(&ctxKey);
- SHA512_Update(&ctxKey, pkey, len);
- SHA512_Final(key, &ctxKey);
- memset(key + 64, 0, 64);
- }
-
- for (int n=0; n<128; n++)
- key[n] ^= 0x5c;
- SHA512_Init(&pctx->ctxOuter);
- SHA512_Update(&pctx->ctxOuter, key, 128);
-
- for (int n=0; n<128; n++)
- key[n] ^= 0x5c ^ 0x36;
- SHA512_Init(&pctx->ctxInner);
- return SHA512_Update(&pctx->ctxInner, key, 128);
-}
-
-int HMAC_SHA512_Update(HMAC_SHA512_CTX *pctx, const void *pdata, size_t len)
-{
- return SHA512_Update(&pctx->ctxInner, pdata, len);
-}
-
-int HMAC_SHA512_Final(unsigned char *pmd, HMAC_SHA512_CTX *pctx)
-{
- unsigned char buf[64];
- SHA512_Final(buf, &pctx->ctxInner);
- SHA512_Update(&pctx->ctxOuter, buf, 64);
- return SHA512_Final(pmd, &pctx->ctxOuter);
-}