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

Unified 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: Addressed comments 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 side-by-side diff with in-line comments
Download patch
Index: media/cast/cast_defines.h
diff --git a/media/cast/cast_defines.h b/media/cast/cast_defines.h
index f44e5fb82614a3ab20bea4e195952594ac571aeb..32810229e4e05514dd4ddacaae96aa3b8a64e5d3 100644
--- a/media/cast/cast_defines.h
+++ b/media/cast/cast_defines.h
@@ -46,6 +46,8 @@ const size_t kMinLengthOfRtcp = 8;
// Basic RTP header + cast header.
const size_t kMinLengthOfRtp = 12 + 6;
+const size_t kAesKeySize = 16;
+
// Each uint16 represents one packet id within a cast frame.
typedef std::set<uint16> PacketIdSet;
// Each uint8 represents one cast frame.
@@ -130,6 +132,20 @@ inline base::TimeTicks ConvertNtpToTimeTicks(uint32 ntp_seconds,
return base::TimeTicks::UnixEpoch() + elapsed_since_unix_epoch;
}
+inline std::string GetAesNounce(uint32 frame_id, const std::string& iv_mask) {
+ std::string aes_ivec(kAesKeySize, 0);
+
+ aes_ivec[11] = frame_id & 0xff;
+ aes_ivec[10] = (frame_id >> 8) & 0xff;
+ aes_ivec[9] = (frame_id >> 16) & 0xff;
+ aes_ivec[8] = (frame_id >> 24) & 0xff;
+
+ for (size_t i = 0; i < kAesKeySize; ++i) {
+ aes_ivec[i] ^= iv_mask[i];
+ }
+ return aes_ivec;
+}
+
} // namespace cast
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698