Bitcoin ABC  0.24.7
P2P Digital Currency
hkdf_sha256_32.cpp
Go to the documentation of this file.
1 // Copyright (c) 2018 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
6 
7 #include <cassert>
8 #include <cstring>
9 
10 CHKDF_HMAC_SHA256_L32::CHKDF_HMAC_SHA256_L32(const uint8_t *ikm, size_t ikmlen,
11  const std::string &salt) {
12  CHMAC_SHA256((const uint8_t *)salt.data(), salt.size())
13  .Write(ikm, ikmlen)
14  .Finalize(m_prk);
15 }
16 
17 void CHKDF_HMAC_SHA256_L32::Expand32(const std::string &info,
18  uint8_t hash[OUTPUT_SIZE]) {
19  // expand a 32byte key (single round)
20  assert(info.size() <= 128);
21  static const uint8_t one[1] = {1};
22  CHMAC_SHA256(m_prk, 32)
23  .Write((const uint8_t *)info.data(), info.size())
24  .Write(one, 1)
25  .Finalize(hash);
26 }
CHKDF_HMAC_SHA256_L32::m_prk
uint8_t m_prk[32]
Definition: hkdf_sha256_32.h:19
CHMAC_SHA256
A hasher class for HMAC-SHA-256.
Definition: hmac_sha256.h:14
CHMAC_SHA256::Finalize
void Finalize(uint8_t hash[OUTPUT_SIZE])
Definition: hmac_sha256.cpp:30
CHKDF_HMAC_SHA256_L32::Expand32
void Expand32(const std::string &info, uint8_t hash[OUTPUT_SIZE])
Definition: hkdf_sha256_32.cpp:17
CHKDF_HMAC_SHA256_L32::CHKDF_HMAC_SHA256_L32
CHKDF_HMAC_SHA256_L32(const uint8_t *ikm, size_t ikmlen, const std::string &salt)
Definition: hkdf_sha256_32.cpp:10
CHMAC_SHA256::Write
CHMAC_SHA256 & Write(const uint8_t *data, size_t len)
Definition: hmac_sha256.h:23
hkdf_sha256_32.h