MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / TLS_hmac

Function TLS_hmac

extra/yassl/src/handshake.cpp:660–688  ·  view source on GitHub ↗

TLS type HAMC

Source from the content-addressed store, hash-verified

658
659// TLS type HAMC
660void TLS_hmac(SSL& ssl, byte* digest, const byte* buffer, uint sz,
661 ContentType content, bool verify)
662{
663 mySTL::auto_ptr<Digest> hmac;
664 opaque seq[SEQ_SZ] = { 0x00, 0x00, 0x00, 0x00 };
665 opaque length[LENGTH_SZ];
666 opaque inner[SIZEOF_ENUM + VERSION_SZ + LENGTH_SZ]; // type + version + len
667
668 c16toa(sz, length);
669 c32toa(ssl.get_SEQIncrement(verify), &seq[sizeof(uint32)]);
670
671 MACAlgorithm algo = ssl.getSecurity().get_parms().mac_algorithm_;
672
673 if (algo == sha)
674 hmac.reset(NEW_YS HMAC_SHA(ssl.get_macSecret(verify), SHA_LEN));
675 else if (algo == rmd)
676 hmac.reset(NEW_YS HMAC_RMD(ssl.get_macSecret(verify), RMD_LEN));
677 else
678 hmac.reset(NEW_YS HMAC_MD5(ssl.get_macSecret(verify), MD5_LEN));
679
680 hmac->update(seq, SEQ_SZ); // seq_num
681 inner[0] = content; // type
682 inner[SIZEOF_ENUM] = ssl.getSecurity().get_connection().version_.major_;
683 inner[SIZEOF_ENUM + SIZEOF_ENUM] =
684 ssl.getSecurity().get_connection().version_.minor_; // version
685 memcpy(&inner[SIZEOF_ENUM + VERSION_SZ], length, LENGTH_SZ); // length
686 hmac->update(inner, sizeof(inner));
687 hmac->get_digest(digest, buffer, sz); // content
688}
689
690
691// compute TLSv1 PRF (pseudo random function using HMAC)

Callers 4

cipherFinishedFunction · 0.85
buildMessageFunction · 0.85
ProcessMethod · 0.85
timing_verifyFunction · 0.85

Calls 11

c16toaFunction · 0.85
c32toaFunction · 0.85
HMAC_SHAClass · 0.85
HMAC_RMDClass · 0.85
HMAC_MD5Class · 0.85
get_SEQIncrementMethod · 0.80
get_parmsMethod · 0.80
get_macSecretMethod · 0.80
get_digestMethod · 0.80
resetMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected