|
1 /* |
|
2 * Copyright (c) 2006 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 "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: Container store encryption. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __CONTAINER_STORE_ENCRYPTION_H__ |
|
21 #define __CONTAINER_STORE_ENCRYPTION_H__ |
|
22 |
|
23 // ======== |
|
24 // INCLUDES |
|
25 // ======== |
|
26 |
|
27 #include <e32base.h> |
|
28 #include <s32strm.h> |
|
29 //<cmail> |
|
30 #include "DebugLogMacros.h" |
|
31 //</cmail> |
|
32 |
|
33 #include "ContainerStoreGeneralTable.h" |
|
34 |
|
35 class CCryptoBase; |
|
36 |
|
37 // ======= |
|
38 // CLASSES |
|
39 // ======= |
|
40 |
|
41 // ================================ |
|
42 // CLASS: CContainerStoreEncryption |
|
43 // ================================ |
|
44 class CContainerStoreEncryption : public CBase |
|
45 { |
|
46 public: |
|
47 |
|
48 // ============== |
|
49 // PUBLIC METHODS |
|
50 // ============== |
|
51 |
|
52 static CContainerStoreEncryption* NewL(); |
|
53 |
|
54 virtual ~CContainerStoreEncryption(); |
|
55 |
|
56 TBool Authenticated(); |
|
57 |
|
58 void ClearAuthentication(); |
|
59 |
|
60 void CreateAuthenticationBufferL( const TDesC& aPassword, RBuf8& aAuthenticationBuffer ); |
|
61 |
|
62 TBool AuthenticateL( const TDesC& aPassword, const TDesC8& aAuthenticationBuffer ); |
|
63 |
|
64 // Leaves if the store isn't authenticated |
|
65 void CheckForAuthenticationL(); |
|
66 |
|
67 //This variable is kept in this class for performance |
|
68 TBool IsAuthenticationRequired() { return iAuthenticationRequired; }; |
|
69 |
|
70 void SetAuthenticationRequired( TBool aFlag ) { iAuthenticationRequired = aFlag; }; |
|
71 |
|
72 TBool IsEncryptionOn(){ return iEncryptionFlag; } ; |
|
73 |
|
74 void SetEncryptionFlag( TBool aFlag ) { iEncryptionFlag = aFlag; }; |
|
75 |
|
76 void DecryptL( const TDesC8& aEncryptedBuffer, |
|
77 TDes8& aUnencryptedBuffer ); |
|
78 |
|
79 void EncryptL( const TDesC8& aUnencryptedBuffer, |
|
80 TDes8& aEncryptedBuffer ); |
|
81 |
|
82 void AddPaddingL( TDes8& aBuffer, |
|
83 TInt aBlockLength ); |
|
84 |
|
85 void RemovePaddingL( TDes8& aBuffer ); |
|
86 |
|
87 // All input buffers must be a multiple of this block size. |
|
88 TInt BlockSizeL(); |
|
89 |
|
90 private: |
|
91 |
|
92 // =============== |
|
93 // PRIVATE METHODS |
|
94 // =============== |
|
95 |
|
96 CContainerStoreEncryption(); |
|
97 |
|
98 void PasswordToEncryptionKeyL( const TDesC& aPassword, RBuf8& aEncryptionKey ); |
|
99 |
|
100 // ================== |
|
101 // PRIVATE ATTRIBUTES |
|
102 // ================== |
|
103 |
|
104 CCryptoBase* iCryptoLibrary; |
|
105 |
|
106 TBool iAuthenticationRequired; |
|
107 TBool iEncryptionFlag; //encryption on/off |
|
108 |
|
109 __LOG_DECLARATION |
|
110 |
|
111 }; // end class CContainerStoreEncryption |
|
112 |
|
113 #endif |