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 <string>
11 
12 #include "packager/base/memory/scoped_ptr.h"
13 
14 namespace edash_packager {
15 namespace media {
16 
17 class AesCbcEncryptor;
18 class RsaPrivateKey;
19 
22  public:
23  virtual ~RequestSigner();
24 
28  virtual bool GenerateSignature(const std::string& message,
29  std::string* signature) = 0;
30 
31  const std::string& signer_name() const { return signer_name_; }
32 
33  protected:
34  explicit RequestSigner(const std::string& signer_name);
35 
36  private:
37  std::string signer_name_;
38 
39  DISALLOW_COPY_AND_ASSIGN(RequestSigner);
40 };
41 
44  public:
45  ~AesRequestSigner() override;
46 
49  static AesRequestSigner* CreateSigner(const std::string& signer_name,
50  const std::string& aes_key_hex,
51  const std::string& iv_hex);
52 
54  bool GenerateSignature(const std::string& message,
55  std::string* signature) override;
56 
57  private:
58  AesRequestSigner(const std::string& signer_name,
59  scoped_ptr<AesCbcEncryptor> encryptor);
60 
61  scoped_ptr<AesCbcEncryptor> aes_cbc_encryptor_;
62 
63  DISALLOW_COPY_AND_ASSIGN(AesRequestSigner);
64 };
65 
68  public:
69  ~RsaRequestSigner() override;
70 
73  static RsaRequestSigner* CreateSigner(const std::string& signer_name,
74  const std::string& pkcs1_rsa_key);
75 
77  bool GenerateSignature(const std::string& message,
78  std::string* signature) override;
79 
80  private:
81  RsaRequestSigner(const std::string& signer_name,
82  scoped_ptr<RsaPrivateKey> rsa_private_key);
83 
84  scoped_ptr<RsaPrivateKey> rsa_private_key_;
85 
86  DISALLOW_COPY_AND_ASSIGN(RsaRequestSigner);
87 };
88 
89 } // namespace media
90 } // namespace edash_packager
91 
92 #endif // MEDIA_BASE_REQUEST_SIGNER_H_
bool GenerateSignature(const std::string &message, std::string *signature) override
RequestSigner implementation override.
static AesRequestSigner * CreateSigner(const std::string &signer_name, const std::string &aes_key_hex, const std::string &iv_hex)
virtual bool GenerateSignature(const std::string &message, std::string *signature)=0
AesRequestSigner uses AES-CBC signing.
bool GenerateSignature(const std::string &message, std::string *signature) override
RequestSigner implementation override.
static RsaRequestSigner * CreateSigner(const std::string &signer_name, const std::string &pkcs1_rsa_key)
RsaRequestSigner uses RSA-PSS signing.
Abstract class used for signature generation.