Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_BASE_ENCRYPTION_SCHEME_H_ | |
| 6 #define MEDIA_BASE_ENCRYPTION_SCHEME_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include "media/base/media_export.h" | |
| 11 | |
| 12 namespace media { | |
| 13 | |
| 14 // Specification of whether and how the stream is encrypted (in whole or part). | |
| 15 class MEDIA_EXPORT EncryptionScheme { | |
| 16 public: | |
| 17 // Algorithm and mode used for encryption. Allows an indication that no | |
|
ddorwin
2016/03/03 18:38:04
kCipherModeUnencrypted indicates that no... ?
dougsteed
2016/03/04 19:07:30
Done.
| |
| 18 // encryption has been applied. | |
| 19 enum CipherMode { | |
| 20 kCipherModeUnencrypted, | |
|
xhwang
2016/03/03 22:33:00
In new code we should use UPPER_CASE for enums:
h
dougsteed
2016/03/04 19:07:30
Prefer consistency with the other enums in media.
xhwang
2016/03/04 20:00:48
Those enums predate the requirement of using UPPER
dougsteed
2016/03/07 17:49:13
I misspoke in my comment about OEMs. I was actuall
| |
| 21 kCipherModeAesCtr, | |
| 22 kCipherModeDefault = kCipherModeAesCtr, | |
| 23 kCipherModeAesCbc, | |
| 24 kCipherModeMax = kCipherModeAesCbc | |
| 25 }; | |
| 26 | |
| 27 // V3 of the CENC standard adds pattern encryption, through two new | |
| 28 // protection schemes 'cens' (with AES-CTR) and 'cbcs' (with AES-CBC). | |
| 29 // The pattern applies only to the 'encrypted' part of the frame (as | |
|
xhwang
2016/03/03 22:33:00
Does the patter apply to all "encrypted" blocks (a
dougsteed
2016/03/04 19:07:30
Done.
| |
| 30 // defined by the relevant subsample entries), and reduces further the | |
| 31 // actual encryption applied through a repeating pattern of (encrypt:skip) | |
| 32 // 16 byte blocks. For example, in a (1:9) pattern, the first block is | |
| 33 // encrypted, and the next nine are skipped. This pattern is applied | |
| 34 // repeatedly until the end of the last 16-byte block in the subsample. | |
| 35 // Any remaining bytes are left clear. | |
| 36 // If either or both of encrypt_blocks or skip_blocks is 0, pattern | |
|
xhwang
2016/03/03 22:33:00
nit: "or both of" is redundant
dougsteed
2016/03/04 19:07:29
Done.
| |
| 37 // encryption is disabled. | |
| 38 class PatternSpec { | |
|
xhwang
2016/03/03 22:33:00
"Spec" is not in the standard and doesn't add any
dougsteed
2016/03/04 19:07:30
Done.
| |
| 39 public: | |
| 40 PatternSpec(); | |
| 41 PatternSpec(uint32_t encrypt_blocks, uint32_t skip_blocks); | |
| 42 ~PatternSpec(); | |
| 43 | |
| 44 bool Matches(const PatternSpec& other) const; | |
| 45 | |
| 46 uint32_t encrypt_blocks() const { return encrypt_blocks_; } | |
| 47 uint32_t skip_blocks() const { return skip_blocks_; } | |
| 48 | |
| 49 bool IsInEffect() const; | |
| 50 | |
| 51 private: | |
| 52 uint32_t encrypt_blocks_; | |
| 53 uint32_t skip_blocks_; | |
| 54 | |
| 55 // Allow copy and assignment. | |
| 56 }; | |
| 57 | |
| 58 EncryptionScheme(); | |
| 59 explicit EncryptionScheme(CipherMode mode); | |
| 60 EncryptionScheme(CipherMode mode, const PatternSpec& pattern); | |
| 61 ~EncryptionScheme(); | |
| 62 | |
| 63 // Returns an instance of EncryptionScheme indicating no encryption. | |
|
ddorwin
2016/03/03 18:38:04
This is good, but I meant to add this to the defau
dougsteed
2016/03/04 19:07:30
Done.
| |
| 64 static EncryptionScheme Unencrypted(); | |
|
xhwang
2016/03/03 22:33:00
+ddorwin
We use EncryptionScheme::Unencrypted() a
dougsteed
2016/03/04 19:07:30
Done.
| |
| 65 | |
| 66 bool Matches(const EncryptionScheme& other) const; | |
| 67 | |
| 68 bool is_encrypted() const; | |
|
xhwang
2016/03/03 22:33:00
nit: you can inline this as well.
dougsteed
2016/03/04 19:07:30
Done.
| |
| 69 CipherMode mode() const { return mode_; } | |
| 70 const PatternSpec& pattern() const { return pattern_; } | |
| 71 | |
| 72 private: | |
| 73 CipherMode mode_; | |
|
xhwang
2016/03/03 22:33:00
You can specify default mode here. Personally I fe
dougsteed
2016/03/04 19:07:30
Done.
| |
| 74 PatternSpec pattern_; | |
| 75 | |
| 76 // Allow copy and assignment. | |
| 77 }; | |
| 78 | |
| 79 } // namespace media | |
| 80 | |
| 81 #endif // MEDIA_BASE_ENCRYPTION_SCHEME_H_ | |
| OLD | NEW |