Crypto++
Main Page
Namespaces
Classes
Files
File List
File Members
default.h
1
#ifndef CRYPTOPP_DEFAULT_H
2
#define CRYPTOPP_DEFAULT_H
3
4
#include "sha.h"
5
#include "hmac.h"
6
#include "
des.h
"
7
#include "
filters.h
"
8
#include "
modes.h
"
9
10
NAMESPACE_BEGIN(CryptoPP)
11
12
typedef
DES_EDE2
Default_BlockCipher
;
13
typedef
SHA
DefaultHashModule
;
14
typedef
HMAC
<DefaultHashModule>
DefaultMAC
;
15
16
//! Password-Based Encryptor using DES-EDE2
17
class
DefaultEncryptor
: public
ProxyFilter
18
{
19
public
:
20
DefaultEncryptor
(
const
char
*passphrase,
BufferedTransformation
*attachment = NULL);
21
DefaultEncryptor
(
const
byte *passphrase,
size_t
passphraseLength,
BufferedTransformation
*attachment = NULL);
22
23
protected
:
24
void
FirstPut(
const
byte *);
25
void
LastPut(
const
byte *inString,
size_t
length);
26
27
private
:
28
SecByteBlock
m_passphrase;
29
CBC_Mode<Default_BlockCipher>::Encryption
m_cipher;
30
};
31
32
//! Password-Based Decryptor using DES-EDE2
33
class
DefaultDecryptor
:
public
ProxyFilter
34
{
35
public
:
36
DefaultDecryptor
(
const
char
*passphrase,
BufferedTransformation
*attachment = NULL,
bool
throwException=
true
);
37
DefaultDecryptor
(
const
byte *passphrase,
size_t
passphraseLength,
BufferedTransformation
*attachment = NULL,
bool
throwException=
true
);
38
39
class
Err
:
public
Exception
40
{
41
public
:
42
Err
(
const
std::string &s)
43
:
Exception
(
DATA_INTEGRITY_CHECK_FAILED
, s) {}
44
};
45
class
KeyBadErr
:
public
Err
{
public
:
KeyBadErr
() :
Err
(
"DefaultDecryptor: cannot decrypt message with this passphrase"
) {}};
46
47
enum
State {WAITING_FOR_KEYCHECK, KEY_GOOD, KEY_BAD};
48
State CurrentState()
const
{
return
m_state;}
49
50
protected
:
51
void
FirstPut(
const
byte *inString);
52
void
LastPut(
const
byte *inString,
size_t
length);
53
54
State m_state;
55
56
private
:
57
void
CheckKey(
const
byte *salt,
const
byte *keyCheck);
58
59
SecByteBlock
m_passphrase;
60
CBC_Mode<Default_BlockCipher>::Decryption
m_cipher;
61
member_ptr<FilterWithBufferedInput>
m_decryptor;
62
bool
m_throwException;
63
};
64
65
//! Password-Based Encryptor using DES-EDE2 and HMAC/SHA-1
66
class
DefaultEncryptorWithMAC
:
public
ProxyFilter
67
{
68
public
:
69
DefaultEncryptorWithMAC
(
const
char
*passphrase,
BufferedTransformation
*attachment = NULL);
70
DefaultEncryptorWithMAC
(
const
byte *passphrase,
size_t
passphraseLength,
BufferedTransformation
*attachment = NULL);
71
72
protected
:
73
void
FirstPut(
const
byte *inString) {}
74
void
LastPut(
const
byte *inString,
size_t
length);
75
76
private
:
77
member_ptr<DefaultMAC>
m_mac;
78
};
79
80
//! Password-Based Decryptor using DES-EDE2 and HMAC/SHA-1
81
class
DefaultDecryptorWithMAC
:
public
ProxyFilter
82
{
83
public
:
84
class
MACBadErr
:
public
DefaultDecryptor::Err
{
public
:
MACBadErr
() :
DefaultDecryptor::Err
(
"DefaultDecryptorWithMAC: MAC check failed"
) {}};
85
86
DefaultDecryptorWithMAC
(
const
char
*passphrase,
BufferedTransformation
*attachment = NULL,
bool
throwException=
true
);
87
DefaultDecryptorWithMAC
(
const
byte *passphrase,
size_t
passphraseLength,
BufferedTransformation
*attachment = NULL,
bool
throwException=
true
);
88
89
DefaultDecryptor::State CurrentState()
const
;
90
bool
CheckLastMAC()
const
;
91
92
protected
:
93
void
FirstPut(
const
byte *inString) {}
94
void
LastPut(
const
byte *inString,
size_t
length);
95
96
private
:
97
member_ptr<DefaultMAC>
m_mac;
98
HashVerifier
*m_hashVerifier;
99
bool
m_throwException;
100
};
101
102
NAMESPACE_END
103
104
#endif
Generated on Sat Apr 6 2013 00:42:58 for Crypto++ by
1.8.1.1