| 405 | } |
| 406 | |
| 407 | bool 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 | |
| 432 | bool C1::Generate(C1S1Schema schema) { |
| 433 | _schema = schema; |
nothing calls this directly
no test coverage detected