summaryrefslogtreecommitdiff
path: root/lib/crypto/CipherAES.h
blob: d2c9ed65295c8d792d9a2621fd6d017108a26426 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// --------------------------------------------------------------------------
//
// File
//		Name:    CipherAES.h
//		Purpose: AES cipher description
//		Created: 27/4/04
//
// --------------------------------------------------------------------------

#ifndef CIPHERAES__H
#define CIPHERAES__H

// Only available in new versions of openssl
#ifndef HAVE_OLD_SSL

#include "CipherDescription.h"

// --------------------------------------------------------------------------
//
// Class
//		Name:    CipherAES
//		Purpose: AES cipher description
//		Created: 27/4/04
//
// --------------------------------------------------------------------------
class CipherAES : public CipherDescription
{
public:
	CipherAES(CipherDescription::CipherMode Mode, const void *pKey, unsigned int KeyLength, const void *pInitialisationVector = 0);
	CipherAES(const CipherAES &rToCopy);
	virtual ~CipherAES();
	CipherAES &operator=(const CipherAES &rToCopy);
	
	// Return OpenSSL cipher object
	virtual const EVP_CIPHER *GetCipher() const;
	
	// Setup any other parameters
	virtual void SetupParameters(EVP_CIPHER_CTX *pCipherContext) const;

	virtual std::string GetCipherName() const
	{
		std::ostringstream out;
		out << "AES";
		out << mKeyLength;
		return out.str();
	}
	virtual CipherMode GetCipherMode() const { return mMode; }

private:
	CipherDescription::CipherMode mMode;
	const void *mpKey;
	unsigned int mKeyLength;
	const void *mpInitialisationVector;
};

#endif // n HAVE_OLD_SSL

#endif // CIPHERAES__H