|
1 /* |
|
2 * Copyright (c) 2006-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 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __CBCMODESHIM_H__ |
|
20 #define __CBCMODESHIM_H__ |
|
21 |
|
22 #include <cbcmode.h> |
|
23 |
|
24 /** |
|
25 @file |
|
26 @internalComponent |
|
27 @released |
|
28 */ |
|
29 |
|
30 namespace CryptoSpi |
|
31 { |
|
32 class CSymmetricCipher; |
|
33 } |
|
34 |
|
35 /** |
|
36 CBC mode encryptor shim class that delegates all work to CModeCBCEncryptor. |
|
37 This should only be instantiated by CModeCBCEncryptor::NewLC |
|
38 */ |
|
39 NONSHARABLE_CLASS(CModeCBCEncryptorShim) : public CModeCBCEncryptor |
|
40 { |
|
41 public: |
|
42 /** |
|
43 Creates a new CModeCBCEncryptorShim. If the block transfer |
|
44 @param aBT A pointer to the block transform object. |
|
45 @param aIV The initialisation vector to use. |
|
46 @return A pointer to a CModeCBCEncryptorShim instance or NULL if the block transform |
|
47 does not support SPI or the SPI plug-in does not support CBC mode |
|
48 */ |
|
49 static CModeCBCEncryptorShim* NewL(CBlockTransformation* aBT, const TDesC8& aIV); |
|
50 |
|
51 // From CBase |
|
52 TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1); |
|
53 |
|
54 // From CBlockTransformation |
|
55 void Reset(); |
|
56 TInt BlockSize() const; |
|
57 TInt KeySize() const; |
|
58 void Transform(TDes8& aBlock); |
|
59 |
|
60 // From CBlockChainingMode |
|
61 void SetIV(const TDesC8& aIv); |
|
62 |
|
63 private: |
|
64 /// Constructor |
|
65 CModeCBCEncryptorShim(CryptoSpi::CSymmetricCipher* aSymmetricCipherImpl); |
|
66 |
|
67 // Just invokes ContructL in super-class |
|
68 void ConstructL(CBlockTransformation* aBT, const TDesC8& aIv); |
|
69 |
|
70 // owned by block transform - iBT |
|
71 CryptoSpi::CSymmetricCipher* iSymmetricCipherImpl; |
|
72 }; |
|
73 |
|
74 /** |
|
75 CBC mode decryptor shim class that delegates all work to CModeCBCDecryptor. |
|
76 This should only be instantiated by CModeCBCDecryptor::NewLC |
|
77 */ |
|
78 NONSHARABLE_CLASS(CModeCBCDecryptorShim) : public CModeCBCDecryptor |
|
79 { |
|
80 public: |
|
81 /** |
|
82 Creates a new CModeCBCEncryptorShim. |
|
83 @param aBT A pointer to the block transform object. |
|
84 @param aIV The initialisation vector to use. |
|
85 @return A pointer to a CModeCBCDecryptorShim instance or NULL if the block transform |
|
86 does not support SPI or the SPI plug-in does not support CBC mode |
|
87 */ |
|
88 static CModeCBCDecryptorShim* NewL(CBlockTransformation* aBT, const TDesC8& aIV); |
|
89 |
|
90 // From CBase |
|
91 TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1); |
|
92 |
|
93 // From CBlockTransformation |
|
94 void Reset(); |
|
95 TInt BlockSize() const; |
|
96 TInt KeySize() const; |
|
97 void Transform(TDes8& aBlock); |
|
98 |
|
99 // From CBlockChainingMode |
|
100 void SetIV(const TDesC8& aIv); |
|
101 |
|
102 private: |
|
103 /// Constructor |
|
104 CModeCBCDecryptorShim(CryptoSpi::CSymmetricCipher* aSymmetricCipherImpl); |
|
105 |
|
106 // Just invokes ContructL in super-class |
|
107 void ConstructL(CBlockTransformation* aBT, const TDesC8& aIv); |
|
108 |
|
109 // owned by block transform - iBT |
|
110 CryptoSpi::CSymmetricCipher* iSymmetricCipherImpl; |
|
111 }; |
|
112 |
|
113 #endif // __CBCMODESHIM_H__ |