Fix test message format for cast receiver

Merge of https://widevine-internal-review.git.corp.google.com/c/cdm/+/206431

Message to be signed by CAST funciton is supposed to be in a certain
format: "constant prefix + SHA1(message)".

Some of our current CAST tests uses random message which break this
specification. This fixes the input message.

Test: Cast tests with run_fake_l1_tests
Bug: 359893908
Change-Id: I6b318d749971d837f13daa7b147313e8e0b1d3d0
This commit is contained in:
Cong Lin
2024-08-26 15:50:33 -07:00
committed by conglin
parent 51944dc331
commit 0ea1b8f8fd
2 changed files with 29 additions and 18 deletions

View File

@@ -5,8 +5,6 @@
#include "oemcrypto_cast_test.h"
#include "oemcrypto_usage_table_test.h"
using ::testing::Range;
namespace wvoec {
@@ -260,18 +258,8 @@ class OEMCryptoCastReceiverTest : public OEMCryptoLoadsCertificateAlternates {
ASSERT_NO_FATAL_FAILURE(s.open());
ASSERT_NO_FATAL_FAILURE(s.LoadWrappedRsaDrmKey(wrapped_drm_key_));
// The application will compute the SHA-1 Hash of the message, so this
// test must do that also.
uint8_t hash[SHA_DIGEST_LENGTH];
if (!SHA1(message.data(), message.size(), hash)) {
dump_boringssl_error();
FAIL() << "boringssl error creating SHA1 hash.";
}
// The application will prepend the digest info to the hash.
// SHA-1 digest info prefix = 0x30 0x21 0x30 ...
vector<uint8_t> digest = wvutil::a2b_hex("3021300906052b0e03021a05000414");
digest.insert(digest.end(), hash, hash + SHA_DIGEST_LENGTH);
vector<uint8_t> digest;
ASSERT_NO_FATAL_FAILURE(PrepareCastDigestedMessage(message, digest));
// OEMCrypto will apply the padding, and encrypt to generate the
// signature.