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

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: Fixes 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..5d68f10481e34da43a5c9eaeaaf3e04e72a201b8 100644
--- a/media/cast/cast_defines.h
+++ b/media/cast/cast_defines.h
@@ -46,6 +46,9 @@ const size_t kMinLengthOfRtcp = 8;
// Basic RTP header + cast header.
const size_t kMinLengthOfRtp = 12 + 6;
+const size_t kAesBlockSize = 16;
+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 +133,22 @@ inline base::TimeTicks ConvertNtpToTimeTicks(uint32 ntp_seconds,
return base::TimeTicks::UnixEpoch() + elapsed_since_unix_epoch;
}
+inline std::string GetAesNonce(uint32 frame_id, const std::string& iv_mask) {
+ std::string aes_iv_mask(kAesBlockSize, 0);
wtc 2013/11/15 20:13:37 This variable should be named just "aes_iv" or "ae
pwestin 2013/11/15 22:11:10 Done.
+
+ // Serializing frame_id in big-endian order (aes_ivec[8] is the most
wtc 2013/11/15 20:13:37 aes_ivec => aes_iv or aes_nonce
pwestin 2013/11/15 22:11:10 Done.
+ // significant byte of frame_id).
+ aes_iv_mask[11] = frame_id & 0xff;
+ aes_iv_mask[10] = (frame_id >> 8) & 0xff;
+ aes_iv_mask[9] = (frame_id >> 16) & 0xff;
+ aes_iv_mask[8] = (frame_id >> 24) & 0xff;
+
+ for (size_t i = 0; i < kAesBlockSize; ++i) {
+ aes_iv_mask[i] ^= iv_mask[i];
+ }
+ return aes_iv_mask;
+}
+
} // namespace cast
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698