sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
* ** IMPORTANT ** PublishedPartner API's in this file are published to 3rd party developers via the
|
sl@0
|
16 |
* Symbian website. Changes to these API's should be treated as PublishedAll API changes and the Security TA should be consulted.
|
sl@0
|
17 |
* CBC mode encryptor and decryptor implementation
|
sl@0
|
18 |
*
|
sl@0
|
19 |
*/
|
sl@0
|
20 |
|
sl@0
|
21 |
|
sl@0
|
22 |
/**
|
sl@0
|
23 |
@file
|
sl@0
|
24 |
@publishedPartner
|
sl@0
|
25 |
@released
|
sl@0
|
26 |
*/
|
sl@0
|
27 |
|
sl@0
|
28 |
#ifndef __CBCMODE_H__
|
sl@0
|
29 |
#define __CBCMODE_H__
|
sl@0
|
30 |
|
sl@0
|
31 |
#include <mode.h>
|
sl@0
|
32 |
|
sl@0
|
33 |
/**
|
sl@0
|
34 |
* Concrete subclass of CBlockChainingMode implementing CBC mode block chaining
|
sl@0
|
35 |
* for encryption.
|
sl@0
|
36 |
*
|
sl@0
|
37 |
*/
|
sl@0
|
38 |
class CModeCBCEncryptor : public CBlockChainingMode
|
sl@0
|
39 |
{
|
sl@0
|
40 |
public:
|
sl@0
|
41 |
/**
|
sl@0
|
42 |
* Creates an object of this class for CBC mode encryption.
|
sl@0
|
43 |
*
|
sl@0
|
44 |
* @param aBT An appropriate CBlockTransformation derived encryptor.
|
sl@0
|
45 |
* @param aIV Initialization vector, the length of this descriptor must be
|
sl@0
|
46 |
* the same as the underlying cipher's block size.
|
sl@0
|
47 |
* @return A pointer to the new CModeCBCEncryptor object
|
sl@0
|
48 |
*/
|
sl@0
|
49 |
IMPORT_C static CModeCBCEncryptor* NewL(CBlockTransformation* aBT,
|
sl@0
|
50 |
const TDesC8& aIV);
|
sl@0
|
51 |
|
sl@0
|
52 |
/**
|
sl@0
|
53 |
* Creates an object of this class for CBC mode encryption.
|
sl@0
|
54 |
*
|
sl@0
|
55 |
* The returned pointer is put onto the cleanup stack.
|
sl@0
|
56 |
*
|
sl@0
|
57 |
* @param aBT An appropriate CBlockTransformation derived encryptor.
|
sl@0
|
58 |
* @param aIV Initialization vector, the length of this descriptor must be
|
sl@0
|
59 |
* the same as the underlying cipher's block size.
|
sl@0
|
60 |
* @return A pointer to the new CModeCBCEncryptor object
|
sl@0
|
61 |
*/
|
sl@0
|
62 |
IMPORT_C static CModeCBCEncryptor* NewLC(CBlockTransformation* aBT,
|
sl@0
|
63 |
const TDesC8& aIV);
|
sl@0
|
64 |
virtual void Transform(TDes8& aBlock);
|
sl@0
|
65 |
protected:
|
sl@0
|
66 |
/**
|
sl@0
|
67 |
* @internalAll
|
sl@0
|
68 |
*/
|
sl@0
|
69 |
CModeCBCEncryptor();
|
sl@0
|
70 |
private:
|
sl@0
|
71 |
const CModeCBCEncryptor& operator=(const CModeCBCEncryptor&);
|
sl@0
|
72 |
};
|
sl@0
|
73 |
|
sl@0
|
74 |
/**
|
sl@0
|
75 |
* Concrete subclass of CBlockChainingMode implementing CBC mode block chaining
|
sl@0
|
76 |
* for decryption.
|
sl@0
|
77 |
*
|
sl@0
|
78 |
*/
|
sl@0
|
79 |
class CModeCBCDecryptor : public CBlockChainingMode
|
sl@0
|
80 |
{
|
sl@0
|
81 |
public:
|
sl@0
|
82 |
/**
|
sl@0
|
83 |
* Creates an object of this class for CBC mode decryption.
|
sl@0
|
84 |
*
|
sl@0
|
85 |
* @param aBT An appropriate CBlockTransformation derived decryptor.
|
sl@0
|
86 |
* @param aIV Initialization vector, the length of this descriptor must be
|
sl@0
|
87 |
* the same as the underlying cipher's block size.
|
sl@0
|
88 |
* @return A pointer to the CModeCBCDecryptor new object.
|
sl@0
|
89 |
*/
|
sl@0
|
90 |
IMPORT_C static CModeCBCDecryptor* NewL(CBlockTransformation* aBT,
|
sl@0
|
91 |
const TDesC8& aIV);
|
sl@0
|
92 |
|
sl@0
|
93 |
/**
|
sl@0
|
94 |
* Creates an object of this class for CBC mode decryption.
|
sl@0
|
95 |
*
|
sl@0
|
96 |
* The returned pointer is put onto the cleanup stack.
|
sl@0
|
97 |
*
|
sl@0
|
98 |
* @param aBT An appropriate CBlockTransformation derived decryptor.
|
sl@0
|
99 |
* @param aIV Initialization vector, the length of this descriptor must be
|
sl@0
|
100 |
* the same as the underlying cipher's block size.
|
sl@0
|
101 |
* @return A pointer to the CModeCBCDecryptor new object.
|
sl@0
|
102 |
*/
|
sl@0
|
103 |
IMPORT_C static CModeCBCDecryptor* NewLC(CBlockTransformation* aBT,
|
sl@0
|
104 |
const TDesC8& aIV);
|
sl@0
|
105 |
virtual ~CModeCBCDecryptor(void);
|
sl@0
|
106 |
public:
|
sl@0
|
107 |
virtual void Transform(TDes8& aBlock);
|
sl@0
|
108 |
protected:
|
sl@0
|
109 |
/** @internalAll */
|
sl@0
|
110 |
CModeCBCDecryptor();
|
sl@0
|
111 |
/** @internalAll */
|
sl@0
|
112 |
void ConstructL(CBlockTransformation* aBT, const TDesC8& aIV);
|
sl@0
|
113 |
private:
|
sl@0
|
114 |
HBufC8* iIVBakBuf;
|
sl@0
|
115 |
TPtr8 iIVBak;
|
sl@0
|
116 |
private:
|
sl@0
|
117 |
const CModeCBCDecryptor& operator=(const CModeCBCDecryptor&);
|
sl@0
|
118 |
};
|
sl@0
|
119 |
|
sl@0
|
120 |
#endif // __CBCMODE_H__
|