MCPcopy Create free account
hub / github.com/apache/brpc / ComputeDigestBase

Method ComputeDigestBase

src/brpc/policy/rtmp_protocol.cpp:407–430  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

405}
406
407bool C1S1Base::ComputeDigestBase(const void* key, int key_size,
408 void* digest) const {
409 char buf[SIZE - DigestBlock::DIGEST_SIZE];
410 char* p = buf;
411 WriteBigEndian4Bytes(&p, time);
412 WriteBigEndian4Bytes(&p, version);
413 if (_schema == SCHEMA0) {
414 key_blk.Save(p);
415 digest_blk.SaveWithoutDigest(p + KeyBlock::SIZE);
416 } else if (_schema == SCHEMA1) {
417 digest_blk.SaveWithoutDigest(p);
418 key_blk.Save(p + DigestBlock::SIZE - DigestBlock::DIGEST_SIZE);
419 } else {
420 LOG(ERROR) << "Invalid schema=" << (int)_schema;
421 return false;
422 }
423 char tmp_digest[EVP_MAX_MD_SIZE];
424 if (openssl_HMACsha256(key, key_size, buf, sizeof(buf), tmp_digest) != 0) {
425 LOG(WARNING) << "Fail to compute digest of C1/S1";
426 return false;
427 }
428 memcpy(digest, tmp_digest, DigestBlock::DIGEST_SIZE);
429 return true;
430}
431
432bool C1::Generate(C1S1Schema schema) {
433 _schema = schema;

Callers

nothing calls this directly

Calls 4

WriteBigEndian4BytesFunction · 0.85
openssl_HMACsha256Function · 0.85
SaveMethod · 0.80
SaveWithoutDigestMethod · 0.80

Tested by

no test coverage detected