Specify widevine/media_cas_packager_sdk/presubmit in media_cas_packager_sdk METADATA file.
------------- Moves ecm_generator to media_cas_packager_sdk/internal. ------------- Add a simple TCP server listening on a port. My intention is to use this server to support the Simulcrypt APIs (TODO). Also add a simple TCP client binary for testing the server and also demo how to call the Simulcrypt APIs (TODO). ------------- If only a single key is in the ECM, it is the EVEN key. To make the code matches this understanding, change a parameter from 'false' to 'true'. But this change has NO impact on the produced ECM, regardless this parameter is 'false' or 'true' (i.e., whether using push_front or push_back), only a single key is in the ECM. ------------- Add classes that process Simulcrypt ECMG messages 1) Stream_set-up 2) CW_provision ------------- Renames server and client binaries. ------------- Make ecmg call ecm_generator to generate ecm. The return of the ecm to Simulcrypt caller will be implemented in the next CL. For now, using the 'key' (control word) in CW_provision message also as the 'key_id'. ------------- Move common folder ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=217358698
This commit is contained in:
@@ -42,8 +42,9 @@ static bool SerializeRsaKey(const RSA* key, std::string* serialized_key,
|
||||
return false;
|
||||
}
|
||||
if (serialized_key == nullptr) {
|
||||
LOG(ERROR) << "Pointer to hold serialized RSA" << (serialize_private_key ?
|
||||
"Private" : "Public") << "Key is nullptr.";
|
||||
LOG(ERROR) << "Pointer to hold serialized RSA"
|
||||
<< (serialize_private_key ? "Private" : "Public")
|
||||
<< "Key is nullptr.";
|
||||
return false;
|
||||
}
|
||||
BIO* bio = BIO_new(BIO_s_mem());
|
||||
@@ -52,9 +53,9 @@ static bool SerializeRsaKey(const RSA* key, std::string* serialized_key,
|
||||
return false;
|
||||
}
|
||||
bool success = false;
|
||||
if ((serialize_private_key ?
|
||||
i2d_RSAPrivateKey_bio(bio, const_cast<RSA*>(key)) :
|
||||
i2d_RSAPublicKey_bio(bio, const_cast<RSA*>(key))) != 0) {
|
||||
if ((serialize_private_key
|
||||
? i2d_RSAPrivateKey_bio(bio, const_cast<RSA*>(key))
|
||||
: i2d_RSAPublicKey_bio(bio, const_cast<RSA*>(key))) != 0) {
|
||||
int serialized_size = BIO_pending(bio);
|
||||
serialized_key->assign(serialized_size, 0);
|
||||
if (BIO_read(bio, &(*serialized_key)[0], serialized_size) ==
|
||||
@@ -64,8 +65,8 @@ static bool SerializeRsaKey(const RSA* key, std::string* serialized_key,
|
||||
LOG(ERROR) << "BIO_read failure";
|
||||
}
|
||||
} else {
|
||||
LOG(ERROR) << (serialize_private_key ? "Private" : "Public") <<
|
||||
" key serialization failure";
|
||||
LOG(ERROR) << (serialize_private_key ? "Private" : "Public")
|
||||
<< " key serialization failure";
|
||||
}
|
||||
BIO_free(bio);
|
||||
return success;
|
||||
@@ -74,13 +75,15 @@ static bool SerializeRsaKey(const RSA* key, std::string* serialized_key,
|
||||
static bool DeserializeRsaKey(const std::string& serialized_key, RSA** key,
|
||||
bool deserialize_private_key) {
|
||||
if (serialized_key.empty()) {
|
||||
LOG(ERROR) << "Serialized RSA" << (deserialize_private_key ?
|
||||
"Private" : "Public") << "Key is empty.";
|
||||
LOG(ERROR) << "Serialized RSA"
|
||||
<< (deserialize_private_key ? "Private" : "Public")
|
||||
<< "Key is empty.";
|
||||
return false;
|
||||
}
|
||||
if (key == nullptr) {
|
||||
LOG(ERROR) << "Pointer to hold new RSA " << (deserialize_private_key ?
|
||||
"private" : "public") << " key is nullptr.";
|
||||
LOG(ERROR) << "Pointer to hold new RSA "
|
||||
<< (deserialize_private_key ? "private" : "public")
|
||||
<< " key is nullptr.";
|
||||
return false;
|
||||
}
|
||||
BIO* bio = BIO_new_mem_buf(const_cast<char*>(serialized_key.data()),
|
||||
@@ -89,12 +92,12 @@ static bool DeserializeRsaKey(const std::string& serialized_key, RSA** key,
|
||||
LOG(ERROR) << "BIO_new_mem_buf returned nullptr";
|
||||
return false;
|
||||
}
|
||||
*key = deserialize_private_key ? d2i_RSAPrivateKey_bio(bio, nullptr) :
|
||||
d2i_RSAPublicKey_bio(bio, nullptr);
|
||||
*key = deserialize_private_key ? d2i_RSAPrivateKey_bio(bio, nullptr)
|
||||
: d2i_RSAPublicKey_bio(bio, nullptr);
|
||||
BIO_free(bio);
|
||||
if (*key == nullptr) {
|
||||
LOG(ERROR) << (deserialize_private_key ? "Private" : "Public") <<
|
||||
" RSA key deserialization failure";
|
||||
LOG(ERROR) << (deserialize_private_key ? "Private" : "Public")
|
||||
<< " RSA key deserialization failure";
|
||||
}
|
||||
return *key != nullptr;
|
||||
}
|
||||
@@ -139,7 +142,7 @@ bool SerializePrivateKeyInfo(const RSA* private_key,
|
||||
return false;
|
||||
}
|
||||
bool success = false;
|
||||
PKCS8_PRIV_KEY_INFO *pkcs8_pki = nullptr;
|
||||
PKCS8_PRIV_KEY_INFO* pkcs8_pki = nullptr;
|
||||
BIO* bio = nullptr;
|
||||
if (EVP_PKEY_set1_RSA(evp, const_cast<RSA*>(private_key)) == 0) {
|
||||
LOG(ERROR) << "EVP_PKEY_set1_RSA failed.";
|
||||
@@ -203,7 +206,7 @@ bool DeserializePrivateKeyInfo(const std::string& serialized_private_key,
|
||||
}
|
||||
bool success = false;
|
||||
EVP_PKEY* evp = nullptr;
|
||||
PKCS8_PRIV_KEY_INFO *pkcs8_pki = d2i_PKCS8_PRIV_KEY_INFO_bio(bio, nullptr);
|
||||
PKCS8_PRIV_KEY_INFO* pkcs8_pki = d2i_PKCS8_PRIV_KEY_INFO_bio(bio, nullptr);
|
||||
if (pkcs8_pki == nullptr) {
|
||||
LOG(ERROR) << "d2i_PKCS8_PRIV_KEY_INFO_bio returned nullptr.";
|
||||
goto cleanup;
|
||||
@@ -312,7 +315,7 @@ cleanup:
|
||||
|
||||
namespace {
|
||||
// Password retrieval function used by DeserializeEncryptedPrivateKeyInfo below.
|
||||
int get_password(char *buf, int size, int rwflag, void *u) {
|
||||
int get_password(char* buf, int size, int rwflag, void* u) {
|
||||
CHECK(buf);
|
||||
CHECK(u);
|
||||
const std::string* pass(static_cast<const std::string*>(u));
|
||||
@@ -372,9 +375,8 @@ bool RsaPrivateKeyToEncryptedPrivateKeyInfo(const std::string& rsa_private_key,
|
||||
std::string* private_key_info) {
|
||||
RSA* key = nullptr;
|
||||
if (DeserializeRsaPrivateKey(rsa_private_key, &key)) {
|
||||
bool success = SerializeEncryptedPrivateKeyInfo(key,
|
||||
passphrase,
|
||||
private_key_info);
|
||||
bool success =
|
||||
SerializeEncryptedPrivateKeyInfo(key, passphrase, private_key_info);
|
||||
RSA_free(key);
|
||||
return success;
|
||||
}
|
||||
@@ -449,8 +451,8 @@ bool ConvertToEulerTotient(const std::string& private_key,
|
||||
return false;
|
||||
}
|
||||
bssl::UniquePtr<RSA> rsa(rsa_ptr);
|
||||
if (!rsa_util::ConvertToEulerTotient(rsa.get())
|
||||
|| !rsa_util::SerializeRsaPrivateKey(rsa.get(), euler_private_key)) {
|
||||
if (!rsa_util::ConvertToEulerTotient(rsa.get()) ||
|
||||
!rsa_util::SerializeRsaPrivateKey(rsa.get(), euler_private_key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -502,8 +504,8 @@ bool ConvertToCarmichaelTotient(const std::string& private_key,
|
||||
return false;
|
||||
}
|
||||
bssl::UniquePtr<RSA> rsa(rsa_ptr);
|
||||
if (!rsa_util::ConvertToCarmichaelTotient(rsa.get())
|
||||
|| !rsa_util::SerializeRsaPrivateKey(rsa.get(), carmichael_private_key)) {
|
||||
if (!rsa_util::ConvertToCarmichaelTotient(rsa.get()) ||
|
||||
!rsa_util::SerializeRsaPrivateKey(rsa.get(), carmichael_private_key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user