7 #include "packager/media/base/request_signer.h"
9 #include "packager/base/logging.h"
10 #include "packager/base/sha1.h"
11 #include "packager/media/base/aes_encryptor.h"
12 #include "packager/media/base/rsa_key.h"
17 RequestSigner::RequestSigner(
const std::string& signer_name)
18 : signer_name_(signer_name) {}
19 RequestSigner::~RequestSigner() {}
21 AesRequestSigner::AesRequestSigner(
const std::string& signer_name,
22 std::unique_ptr<AesCbcEncryptor> encryptor)
23 : RequestSigner(signer_name), aes_cbc_encryptor_(std::move(encryptor)) {
24 DCHECK(aes_cbc_encryptor_);
26 AesRequestSigner::~AesRequestSigner() {}
29 const std::string& signer_name,
30 const std::vector<uint8_t>& aes_key,
31 const std::vector<uint8_t>& iv) {
32 std::unique_ptr<AesCbcEncryptor> encryptor(
34 if (!encryptor->InitializeWithIv(aes_key, iv))
40 std::string* signature) {
41 aes_cbc_encryptor_->Crypt(base::SHA1HashString(message), signature);
45 RsaRequestSigner::RsaRequestSigner(
46 const std::string& signer_name,
47 std::unique_ptr<RsaPrivateKey> rsa_private_key)
48 :
RequestSigner(signer_name), rsa_private_key_(std::move(rsa_private_key)) {
49 DCHECK(rsa_private_key_);
51 RsaRequestSigner::~RsaRequestSigner() {}
54 const std::string& signer_name,
55 const std::string& pkcs1_rsa_key) {
56 std::unique_ptr<RsaPrivateKey> rsa_private_key(
64 std::string* signature) {
65 return rsa_private_key_->GenerateSignature(message, signature);