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

Unified Diff: media/cast/transport/utility/transport_encryption_handler.cc

Issue 388663003: Cast: Reshuffle files under media/cast (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: missing includes Created 6 years, 5 months 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/transport/utility/transport_encryption_handler.cc
diff --git a/media/cast/transport/utility/transport_encryption_handler.cc b/media/cast/transport/utility/transport_encryption_handler.cc
deleted file mode 100644
index 49a6cd3ede0a737c7419c51db6656d622b25d681..0000000000000000000000000000000000000000
--- a/media/cast/transport/utility/transport_encryption_handler.cc
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright 2014 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.
-
-#include "media/cast/transport/utility/transport_encryption_handler.h"
-
-#include "base/logging.h"
-#include "crypto/encryptor.h"
-#include "crypto/symmetric_key.h"
-#include "media/cast/transport/cast_transport_defines.h"
-
-namespace media {
-namespace cast {
-namespace transport {
-
-TransportEncryptionHandler::TransportEncryptionHandler()
- : key_(), encryptor_(), iv_mask_(), is_activated_(false) {}
-
-TransportEncryptionHandler::~TransportEncryptionHandler() {}
-
-bool TransportEncryptionHandler::Initialize(std::string aes_key,
- std::string aes_iv_mask) {
- is_activated_ = false;
- if (aes_iv_mask.size() == kAesKeySize && aes_key.size() == kAesKeySize) {
- iv_mask_ = aes_iv_mask;
- key_.reset(
- crypto::SymmetricKey::Import(crypto::SymmetricKey::AES, aes_key));
- encryptor_.reset(new crypto::Encryptor());
- encryptor_->Init(key_.get(), crypto::Encryptor::CTR, std::string());
- is_activated_ = true;
- } else if (aes_iv_mask.size() != 0 || aes_key.size() != 0) {
- DCHECK_EQ(aes_iv_mask.size(), 0u)
- << "Invalid Crypto configuration: aes_iv_mask.size";
- DCHECK_EQ(aes_key.size(), 0u)
- << "Invalid Crypto configuration: aes_key.size";
- return false;
- }
- return true;
-}
-
-bool TransportEncryptionHandler::Encrypt(uint32 frame_id,
- const base::StringPiece& data,
- std::string* encrypted_data) {
- if (!is_activated_)
- return false;
- if (!encryptor_->SetCounter(GetAesNonce(frame_id, iv_mask_))) {
- NOTREACHED() << "Failed to set counter";
- return false;
- }
- if (!encryptor_->Encrypt(data, encrypted_data)) {
- NOTREACHED() << "Encrypt error";
- return false;
- }
- return true;
-}
-
-bool TransportEncryptionHandler::Decrypt(uint32 frame_id,
- const base::StringPiece& ciphertext,
- std::string* plaintext) {
- if (!is_activated_) {
- return false;
- }
- if (!encryptor_->SetCounter(transport::GetAesNonce(frame_id, iv_mask_))) {
- NOTREACHED() << "Failed to set counter";
- return false;
- }
- if (!encryptor_->Decrypt(ciphertext, plaintext)) {
- VLOG(1) << "Decryption error";
- return false;
- }
- return true;
-}
-
-} // namespace transport
-} // namespace cast
-} // namespace media
« no previous file with comments | « media/cast/transport/utility/transport_encryption_handler.h ('k') | media/cast/video_sender/codecs/vp8/vp8_encoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698