MCPcopy Create free account
hub / github.com/3rdparty/libprocess / generate_hmac_sha256

Function generate_hmac_sha256

src/ssl/utilities.cpp:353–377  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351
352
353Try<string> generate_hmac_sha256(
354 const string& message,
355 const string& key)
356{
357 unsigned int md_len = 0;
358 unsigned char buffer[EVP_MAX_MD_SIZE] = {0};
359
360 unsigned char* rc = HMAC(
361 EVP_sha256(),
362 key.data(),
363 key.size(),
364 reinterpret_cast<const unsigned char*>(message.data()),
365 message.size(),
366 buffer,
367 &md_len);
368
369 if (rc == nullptr) {
370 const char* reason = ERR_reason_error_string(ERR_get_error());
371
372 return Error(
373 "HMAC failed" + (reason == nullptr ? "" : ": " + string(reason)));
374 }
375
376 return string(reinterpret_cast<char*>(buffer), md_len);
377}
378
379
380template<typename Reader>

Callers 3

parseMethod · 0.85
createMethod · 0.85
TESTFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by 1

TESTFunction · 0.68