DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
request_signer.h
1 // Copyright 2014 Google Inc. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #ifndef MEDIA_BASE_REQUEST_SIGNER_H_
8 #define MEDIA_BASE_REQUEST_SIGNER_H_
9 
10 #include <memory>
11 #include <string>
12 
13 #include "packager/base/macros.h"
14 
15 namespace shaka {
16 namespace media {
17 
18 class AesCbcEncryptor;
19 class RsaPrivateKey;
20 
23  public:
24  virtual ~RequestSigner();
25 
29  virtual bool GenerateSignature(const std::string& message,
30  std::string* signature) = 0;
31 
32  const std::string& signer_name() const { return signer_name_; }
33 
34  protected:
35  explicit RequestSigner(const std::string& signer_name);
36 
37  private:
38  std::string signer_name_;
39 
40  DISALLOW_COPY_AND_ASSIGN(RequestSigner);
41 };
42 
45  public:
46  ~AesRequestSigner() override;
47 
50  static AesRequestSigner* CreateSigner(const std::string& signer_name,
51  const std::string& aes_key_hex,
52  const std::string& iv_hex);
53 
55  bool GenerateSignature(const std::string& message,
56  std::string* signature) override;
57 
58  private:
59  AesRequestSigner(const std::string& signer_name,
60  std::unique_ptr<AesCbcEncryptor> encryptor);
61 
62  std::unique_ptr<AesCbcEncryptor> aes_cbc_encryptor_;
63 
64  DISALLOW_COPY_AND_ASSIGN(AesRequestSigner);
65 };
66 
69  public:
70  ~RsaRequestSigner() override;
71 
74  static RsaRequestSigner* CreateSigner(const std::string& signer_name,
75  const std::string& pkcs1_rsa_key);
76 
78  bool GenerateSignature(const std::string& message,
79  std::string* signature) override;
80 
81  private:
82  RsaRequestSigner(const std::string& signer_name,
83  std::unique_ptr<RsaPrivateKey> rsa_private_key);
84 
85  std::unique_ptr<RsaPrivateKey> rsa_private_key_;
86 
87  DISALLOW_COPY_AND_ASSIGN(RsaRequestSigner);
88 };
89 
90 } // namespace media
91 } // namespace shaka
92 
93 #endif // MEDIA_BASE_REQUEST_SIGNER_H_
static RsaRequestSigner * CreateSigner(const std::string &signer_name, const std::string &pkcs1_rsa_key)
Abstract class used for signature generation.
static AesRequestSigner * CreateSigner(const std::string &signer_name, const std::string &aes_key_hex, const std::string &iv_hex)
RsaRequestSigner uses RSA-PSS signing.
bool GenerateSignature(const std::string &message, std::string *signature) override
RequestSigner implementation override.
bool GenerateSignature(const std::string &message, std::string *signature) override
RequestSigner implementation override.
AesRequestSigner uses AES-CBC signing.
virtual bool GenerateSignature(const std::string &message, std::string *signature)=0