IBR-DTNSuite
0.12
Main Page
Namespaces
Classes
Files
File List
File Members
IBR-DTNSuite
Namespaces
Classes
Files
File List
daemon
ibrcommon
ibrcommon
data
link
net
ssl
gcm
AES128Stream.cpp
AES128Stream.h
CipherStream.cpp
CipherStream.h
HashStream.cpp
HashStream.h
HMacStream.cpp
HMacStream.h
InputCipherStream.cpp
InputCipherStream.h
iostreamBIO.cpp
iostreamBIO.h
RSASHA256Stream.cpp
RSASHA256Stream.h
TLSStream.cpp
TLSStream.h
XORStream.cpp
XORStream.h
thread
xml
appstreambuf.cpp
appstreambuf.h
config.h
Exceptions.h
ibrcommon.h
Iterator.h
Logger.cpp
Logger.h
MonotonicClock.cpp
MonotonicClock.h
refcnt_ptr.h
SyslogStream.cpp
SyslogStream.h
TimeMeasurement.cpp
TimeMeasurement.h
TLSExceptions.h
ibrdtn
tools
File Members
CipherStream.h
Go to the documentation of this file.
1
/*
2
* CipherStream.h
3
*
4
* Copyright (C) 2011 IBR, TU Braunschweig
5
*
6
* Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7
*
8
* Licensed under the Apache License, Version 2.0 (the "License");
9
* you may not use this file except in compliance with the License.
10
* You may obtain a copy of the License at
11
*
12
* http://www.apache.org/licenses/LICENSE-2.0
13
*
14
* Unless required by applicable law or agreed to in writing, software
15
* distributed under the License is distributed on an "AS IS" BASIS,
16
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
* See the License for the specific language governing permissions and
18
* limitations under the License.
19
*
20
*/
21
22
#ifndef CIPHERSTREAM_H_
23
#define CIPHERSTREAM_H_
24
25
#include "
ibrcommon/Exceptions.h
"
26
#include <streambuf>
27
#include <iostream>
28
#include <vector>
29
30
namespace
ibrcommon
31
{
32
class
CipherStream
:
public
std::basic_streambuf<char, std::char_traits<char> >,
public
std::ostream
33
{
34
public
:
35
enum
CipherMode
36
{
37
CIPHER_ENCRYPT
= 0,
38
CIPHER_DECRYPT
= 1
39
};
40
41
CipherStream
(std::ostream &stream,
const
CipherMode
mode =
CIPHER_DECRYPT
,
const
size_t
buffer = 2048);
42
virtual
~CipherStream
();
43
50
void
encrypt
(std::iostream& stream);
51
60
void
decrypt
(std::iostream& stream);
61
62
protected
:
63
virtual
void
encrypt
(
char
*buf,
const
size_t
size) = 0;
64
virtual
void
decrypt
(
char
*buf,
const
size_t
size) = 0;
65
virtual
void
encrypt_final
() {};
66
virtual
void
decrypt_final
() {};
67
68
virtual
int
sync
();
69
virtual
std::char_traits<char>::int_type
overflow
(std::char_traits<char>::int_type = std::char_traits<char>::eof());
70
71
CipherMode
_mode
;
72
73
private
:
74
std::ostream &_stream;
75
76
// Output buffer
77
std::vector<char> data_buf_;
78
79
// length of the data buffer
80
size_t
data_size_;
81
};
82
}
83
84
#endif
/* CIPHERSTREAM_H_ */
ibrcommon
ibrcommon
ssl
CipherStream.h
Generated on Thu Mar 27 2014 09:26:21 for IBR-DTNSuite by
1.8.4