Fix media_cas_proxy_sdk build issue.
Add example binary for testing building the SDK after 'git clone' from our repo. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=227583629
This commit is contained in:
@@ -11,55 +11,50 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "util/status.h"
|
||||
#include "common/aes_cbc_util.h"
|
||||
#include "common/rsa_key.h"
|
||||
#include "common/sha_util.h"
|
||||
#include "common/status.h"
|
||||
|
||||
namespace widevine {
|
||||
namespace signature_util {
|
||||
|
||||
util::Status GenerateAesSignature(const std::string& message, const std::string& aes_key,
|
||||
const std::string& aes_iv, std::string* signature) {
|
||||
Status GenerateAesSignature(const std::string& message, const std::string& aes_key,
|
||||
const std::string& aes_iv, std::string* signature) {
|
||||
if (signature == nullptr) {
|
||||
return util::Status(util::error::INVALID_ARGUMENT, "signature is nullptr");
|
||||
return Status(error::INVALID_ARGUMENT, "signature is nullptr");
|
||||
}
|
||||
std::string hash = Sha1_Hash(message);
|
||||
if (hash.empty()) {
|
||||
return util::Status(util::error::INTERNAL, "Computed hash is empty");
|
||||
return Status(error::INTERNAL, "Computed hash is empty");
|
||||
}
|
||||
std::string sig = crypto_util::EncryptAesCbc(aes_key, aes_iv, hash);
|
||||
if (sig.empty()) {
|
||||
return util::Status(util::error::INTERNAL,
|
||||
"Computed AES signature is empty");
|
||||
return Status(error::INTERNAL, "Computed AES signature is empty");
|
||||
}
|
||||
*signature = sig;
|
||||
return util::OkStatus();
|
||||
return OkStatus();
|
||||
}
|
||||
|
||||
util::Status GenerateRsaSignature(const std::string& message,
|
||||
const std::string& private_key,
|
||||
std::string* signature) {
|
||||
Status GenerateRsaSignature(const std::string& message, const std::string& private_key,
|
||||
std::string* signature) {
|
||||
if (signature == nullptr) {
|
||||
return util::Status(util::error::INVALID_ARGUMENT, "signature is nullptr");
|
||||
return Status(error::INVALID_ARGUMENT, "signature is nullptr");
|
||||
}
|
||||
std::unique_ptr<RsaPrivateKey> rsa_private_key(
|
||||
RsaPrivateKey::Create(private_key));
|
||||
if (rsa_private_key == nullptr) {
|
||||
return util::Status(util::error::INTERNAL,
|
||||
"Failed to construct a RsaPrivateKey");
|
||||
return Status(error::INTERNAL, "Failed to construct a RsaPrivateKey");
|
||||
}
|
||||
std::string sig;
|
||||
if (!rsa_private_key->GenerateSignature(message, &sig)) {
|
||||
return util::Status(util::error::INTERNAL,
|
||||
"Failed to generate a RSA signature");
|
||||
return Status(error::INTERNAL, "Failed to generate a RSA signature");
|
||||
}
|
||||
if (sig.empty()) {
|
||||
return util::Status(util::error::INTERNAL,
|
||||
"Computed RSA signature is empty");
|
||||
return Status(error::INTERNAL, "Computed RSA signature is empty");
|
||||
}
|
||||
*signature = sig;
|
||||
return util::OkStatus();
|
||||
return OkStatus();
|
||||
}
|
||||
|
||||
} // namespace signature_util
|
||||
|
||||
Reference in New Issue
Block a user