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