WvStreams
Main Page
Modules
Classes
Files
File List
File Members
include
wvtripledes.h
1
/* -*- Mode: C++ -*-
2
* Worldvisions Tunnel Vision Software:
3
* Copyright (C) 1997-2003 Net Integration Technologies, Inc.
4
*
5
* TripleDES cryptography abstractions.
6
*/
7
#ifndef __WVTRIPLEDES_H
8
#define __WVTRIPLEDES_H
9
10
#include "wvencoder.h"
11
#include "wvencoderstream.h"
12
#include "wvcrypto.h"
13
14
#include <openssl/des.h>
15
22
class
WvTripleDESEncoder
:
public
WvCryptoEncoder
23
{
24
public
:
25
enum
Mode
{
26
ECBEncrypt
,
27
ECBDecrypt
,
28
CFBEncrypt
,
29
CFBDecrypt
,
30
CBCEncrypt
,
31
CBCDecrypt
32
};
33
34
/*
35
* Creates a new TripleDES cipher encoder.
36
*
37
* "mode" is the encryption mode
38
* "key[1-3]" are the initial keys
39
*/
40
WvTripleDESEncoder
(
Mode
mode,
const
void
*key1,
const
void
*key2,
41
const
void
*key3);
42
/* virtual ~WvTripleDESEncoder(); */
43
44
/*
45
* Sets the current TripleDES keys and resets the initialization
46
* vector to all nulls.
47
*
48
* "key[1-3]" are the new keys
49
*/
50
virtual
void
setkey(
const
void
*key)
51
{
52
setkey(key, (
unsigned
char
*)key+DES_KEY_SZ,
53
(
unsigned
char
*)key+(DES_KEY_SZ*2));
54
return
;
55
}
56
virtual
void
setkey(
const
void
*_key1,
const
void
*_key2,
57
const
void
*_key3);
58
59
/*
60
* Sets the current TripleDES initialization vector.
61
*
62
* "iv" is the new IV must be 8 bytes
63
*/
64
virtual
void
setiv(
const
void
*iv);
65
66
protected
:
67
virtual
bool
_encode
(
WvBuf
&in,
WvBuf
&out,
bool
flush
);
68
virtual
bool
_reset
();
// supported: restores most recently set
69
// key and initialization vector
70
71
private
:
72
Mode
mode;
73
des_cblock key;
74
des_key_schedule deskey1;
75
des_key_schedule deskey2;
76
des_key_schedule deskey3;
77
des_cblock ivec;
// initialization vector
78
int
ivecoff;
// current offset into initvec
79
};
80
81
91
class
WvTripleDESStream
:
public
WvEncoderStream
92
{
93
public
:
94
WvTripleDESStream
(
WvStream
*_cloned,
const
void
*_key1,
95
const
void
*_key2,
const
void
*_key3,
96
WvTripleDESEncoder::Mode
readmode =
WvTripleDESEncoder::CFBDecrypt
,
97
WvTripleDESEncoder::Mode
writemode =
WvTripleDESEncoder::CFBEncrypt
);
98
virtual
~
WvTripleDESStream
() { }
99
};
100
101
#endif // __WVTRIPLEDES_H
Generated on Thu Oct 31 2013 23:17:05 for WvStreams by
1.8.4