Index: media/crypto/decryptor.h |
diff --git a/media/crypto/decryptor.h b/media/crypto/decryptor.h |
new file mode 100755 |
index 0000000000000000000000000000000000000000..de92421bb60f9e86617df795e57fddfd70da278c |
--- /dev/null |
+++ b/media/crypto/decryptor.h |
@@ -0,0 +1,64 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef MEDIA_BASE_DECRYPTOR_H_ |
+#define MEDIA_BASE_DECRYPTOR_H_ |
+ |
+#include <string> |
+ |
+#include "base/basictypes.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/synchronization/lock.h" |
+#include "media/base/media_export.h" |
+ |
+namespace crypto { |
+class SymmetricKey; |
+} |
+ |
+namespace media { |
+ |
+class DecoderBuffer; |
+ |
+// Interface for decrypting frames. |
+class MEDIA_EXPORT Decryptor { |
+ public: |
+ Decryptor(); |
+ virtual ~Decryptor(); |
+ |
+ // Add a |key_id| and |key| pair to the key system. The key is not limited to |
+ // a decryption key. It can be any data that the key system accepts, such as |
+ // a license. If multiple calls of this function set different keys for the |
+ // same |key_id|, the older key will be replaced by the newer key. |
+ virtual void AddKey(const uint8* key_id, int key_id_size, |
+ const uint8* key, int key_size) = 0; |
+ |
+ // Decrypt |input| buffer. The |input| should not be NULL. |
+ // Return a DecoderBuffer with the decrypted data if decryption succeeded. |
+ // Return NULL if decryption failed. |
+ virtual scoped_refptr<DecoderBuffer> Decrypt( |
+ const scoped_refptr<DecoderBuffer>& input) = 0; |
+ |
+ // Decrypt |input| using |key|. |offset| is the number of bytes into |input| |
+ // the encrypted data is. |
+ // Return a DecoderBuffer with the decrypted data if decryption succeeded. |
+ // Return NULL if decryption failed. |
+ static scoped_refptr<DecoderBuffer> DecryptData(const DecoderBuffer& input, |
+ crypto::SymmetricKey* key, |
+ int offset); |
+ |
+ // Generates a 16 byte CTR counter block. The format is |
+ // | iv | block counter |. |iv| is an 8 byte CTR IV. Returns counter block on |
+ // success. Returns empth string on failure. |
+ static std::string GenerateCounterBlock(uint64 iv); |
+ |
+ protected: |
+ base::Lock lock_; |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(Decryptor); |
+}; |
+ |
+} // namespace media |
+ |
+#endif // MEDIA_BASE_DECRYPTOR_H_ |