
BUG=163 R=phoglund@webrtc.org Review URL: https://webrtc-codereview.appspot.com/1907004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4428 4adac7df-926f-26a2-2b94-8c16560cd09d
66 lines
2.4 KiB
C++
66 lines
2.4 KiB
C++
/*
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#ifndef SRC_VIDEO_ENGINE_TEST_AUTO_TEST_HELPERS_RANDOM_ENCRYPTION_H_
|
|
#define SRC_VIDEO_ENGINE_TEST_AUTO_TEST_HELPERS_RANDOM_ENCRYPTION_H_
|
|
|
|
#include "webrtc/common_types.h"
|
|
|
|
// These algorithms attempt to create an uncrackable encryption
|
|
// scheme by completely disregarding the input data.
|
|
class RandomEncryption : public webrtc::Encryption {
|
|
public:
|
|
explicit RandomEncryption(unsigned int rand_seed);
|
|
|
|
virtual void encrypt(int channel_no,
|
|
unsigned char* in_data,
|
|
unsigned char* out_data,
|
|
int bytes_in,
|
|
int* bytes_out) OVERRIDE {
|
|
GenerateRandomData(out_data, bytes_in, bytes_out);
|
|
}
|
|
|
|
virtual void decrypt(int channel_no,
|
|
unsigned char* in_data,
|
|
unsigned char* out_data,
|
|
int bytes_in,
|
|
int* bytes_out) OVERRIDE {
|
|
GenerateRandomData(out_data, bytes_in, bytes_out);
|
|
}
|
|
|
|
virtual void encrypt_rtcp(int channel_no,
|
|
unsigned char* in_data,
|
|
unsigned char* out_data,
|
|
int bytes_in,
|
|
int* bytes_out) OVERRIDE {
|
|
GenerateRandomData(out_data, bytes_in, bytes_out);
|
|
}
|
|
|
|
virtual void decrypt_rtcp(int channel_no,
|
|
unsigned char* in_data,
|
|
unsigned char* out_data,
|
|
int bytes_in,
|
|
int* bytes_out) OVERRIDE {
|
|
GenerateRandomData(out_data, bytes_in, bytes_out);
|
|
}
|
|
|
|
private:
|
|
// Generates some completely random data with roughly the right length.
|
|
void GenerateRandomData(unsigned char* out_data,
|
|
int bytes_in,
|
|
int* bytes_out);
|
|
|
|
// Makes up a length within +- 50 of the original length, without
|
|
// overstepping the contract for encrypt / decrypt.
|
|
int MakeUpSimilarLength(int original_length);
|
|
};
|
|
|
|
#endif // SRC_VIDEO_ENGINE_TEST_AUTO_TEST_HELPERS_RANDOM_ENCRYPTION_H_
|