|
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 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 /** |
|
24 @file |
|
25 @publishedPartner |
|
26 @released |
|
27 */ |
|
28 |
|
29 #ifndef __MODE_H__ |
|
30 #define __MODE_H__ |
|
31 |
|
32 #include "blocktransformation.h" |
|
33 |
|
34 /** |
|
35 * Abstract class defining the use of block transformation objects as block |
|
36 * chaining modes. |
|
37 * |
|
38 * It is initialised with a subclass of CBlockTransformation, |
|
39 * which it subsequently owns. Calls to its Transform() function will call the |
|
40 * Transform() function in the underlying CBlockTransformation object, and perform |
|
41 * the additional transformation for block chaining in that mode. This all means |
|
42 * that if you want to do, say, AES encryption in CBC mode, you need to construct |
|
43 * a CAESEncryptor object, then pass it to the CModeCBCEncryptor subclass of |
|
44 * CBlockChainingMode, and subsequently use the CModeCBCEncryptor object to call |
|
45 * Transform(). |
|
46 * |
|
47 * @publishedPartner |
|
48 * @released |
|
49 */ |
|
50 class CBlockChainingMode : public CBlockTransformation |
|
51 { |
|
52 public: |
|
53 virtual void Reset(); |
|
54 virtual TInt BlockSize() const; |
|
55 virtual TInt KeySize() const; |
|
56 public: |
|
57 /** |
|
58 * Sets the initialization vector. |
|
59 * |
|
60 * @param aIV The initialization vector. The length of this descriptor must be |
|
61 * the same as the underlying cipher's block size. |
|
62 */ |
|
63 virtual void SetIV(const TDesC8& aIV); |
|
64 protected: |
|
65 /** Default constructor */ |
|
66 IMPORT_C CBlockChainingMode(); |
|
67 /** |
|
68 * Second phase constructor |
|
69 * |
|
70 * This should be called last by derived classes' ContructL()s . |
|
71 * |
|
72 * @param aBT A block transformation object |
|
73 * @param aIV Initialization vector, the length of this descriptor must be |
|
74 * the same as the underlying cipher's block size. |
|
75 */ |
|
76 IMPORT_C void ConstructL(CBlockTransformation* aBT, const TDesC8& aIV); |
|
77 |
|
78 /** The destructor frees all resources owned by the object, prior to its destruction. */ |
|
79 IMPORT_C virtual ~CBlockChainingMode(); |
|
80 protected: |
|
81 /** A block transformation object */ |
|
82 CBlockTransformation* iBT; |
|
83 |
|
84 /** |
|
85 * A buffer containing the feedback register |
|
86 * |
|
87 * This must equal the underlying cipher's block size in length. |
|
88 * Initially this register is filled with the initialization vector. |
|
89 */ |
|
90 HBufC8* iRegisterBuf; |
|
91 |
|
92 /** Encapsulates a pointer to iRegisterBuf */ |
|
93 TPtr8 iRegister; |
|
94 |
|
95 /** |
|
96 * A buffer containing the Initialisation Vector (IV) |
|
97 * |
|
98 * This must equal the underlying cipher's block size in length. |
|
99 */ |
|
100 HBufC8* iIVBuf; |
|
101 |
|
102 /** Encapsulates a pointer to iIVBuf */ |
|
103 TPtr8 iIV; |
|
104 }; |
|
105 |
|
106 #endif // __MODE_H__ |