Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: media/cast/cast_defines.h

Issue 62843002: Cast: Added support for AES-CTR crypto. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync TOT Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/cast/cast_config.h ('k') | media/cast/cast_receiver.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_CAST_CAST_DEFINES_H_ 5 #ifndef MEDIA_CAST_CAST_DEFINES_H_
6 #define MEDIA_CAST_CAST_DEFINES_H_ 6 #define MEDIA_CAST_CAST_DEFINES_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
(...skipping 30 matching lines...) Expand all
41 kDefaultRtpMaxDelayMs = 100, 41 kDefaultRtpMaxDelayMs = 100,
42 }; 42 };
43 43
44 const uint16 kRtcpCastAllPacketsLost = 0xffff; 44 const uint16 kRtcpCastAllPacketsLost = 0xffff;
45 45
46 const size_t kMinLengthOfRtcp = 8; 46 const size_t kMinLengthOfRtcp = 8;
47 47
48 // Basic RTP header + cast header. 48 // Basic RTP header + cast header.
49 const size_t kMinLengthOfRtp = 12 + 6; 49 const size_t kMinLengthOfRtp = 12 + 6;
50 50
51 const size_t kAesBlockSize = 16;
52 const size_t kAesKeySize = 16;
53
51 // Each uint16 represents one packet id within a cast frame. 54 // Each uint16 represents one packet id within a cast frame.
52 typedef std::set<uint16> PacketIdSet; 55 typedef std::set<uint16> PacketIdSet;
53 // Each uint8 represents one cast frame. 56 // Each uint8 represents one cast frame.
54 typedef std::map<uint8, PacketIdSet> MissingFramesAndPacketsMap; 57 typedef std::map<uint8, PacketIdSet> MissingFramesAndPacketsMap;
55 58
56 // TODO(pwestin): Re-factor the functions bellow into a class with static 59 // TODO(pwestin): Re-factor the functions bellow into a class with static
57 // methods. 60 // methods.
58 61
59 // January 1970, in NTP seconds. 62 // January 1970, in NTP seconds.
60 // Network Time Protocol (NTP), which is in seconds relative to 0h UTC on 63 // Network Time Protocol (NTP), which is in seconds relative to 0h UTC on
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 163 }
161 return (frame_id_wrap_count_ << 8) + over_the_wire_frame_id; 164 return (frame_id_wrap_count_ << 8) + over_the_wire_frame_id;
162 } 165 }
163 166
164 private: 167 private:
165 bool first_; 168 bool first_;
166 bool can_we_wrap_; 169 bool can_we_wrap_;
167 uint32 frame_id_wrap_count_; 170 uint32 frame_id_wrap_count_;
168 }; 171 };
169 172
173 inline std::string GetAesNonce(uint32 frame_id, const std::string& iv_mask) {
174 std::string aes_nonce(kAesBlockSize, 0);
175
176 // Serializing frame_id in big-endian order (aes_nonce[8] is the most
177 // significant byte of frame_id).
178 aes_nonce[11] = frame_id & 0xff;
179 aes_nonce[10] = (frame_id >> 8) & 0xff;
180 aes_nonce[9] = (frame_id >> 16) & 0xff;
181 aes_nonce[8] = (frame_id >> 24) & 0xff;
182
183 for (size_t i = 0; i < kAesBlockSize; ++i) {
184 aes_nonce[i] ^= iv_mask[i];
185 }
186 return aes_nonce;
187 }
188
170 } // namespace cast 189 } // namespace cast
171 } // namespace media 190 } // namespace media
172 191
173 #endif // MEDIA_CAST_CAST_DEFINES_H_ 192 #endif // MEDIA_CAST_CAST_DEFINES_H_
OLDNEW
« no previous file with comments | « media/cast/cast_config.h ('k') | media/cast/cast_receiver.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698