|
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 * ARC4 shim classes definition |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalComponent |
|
23 @released |
|
24 */ |
|
25 |
|
26 #ifndef ARC4SHIM_H |
|
27 #define ARC4SHIM_H |
|
28 |
|
29 #include <arc4.h> |
|
30 |
|
31 namespace CryptoSpi |
|
32 { |
|
33 class CCryptoParams; |
|
34 class CSymmetricCipher; |
|
35 class CKey; |
|
36 } |
|
37 |
|
38 NONSHARABLE_CLASS(CArc4Shim) : public CARC4 |
|
39 { |
|
40 public: |
|
41 /** |
|
42 Creates a CArc4Shim object which has the same interface as CARC4 |
|
43 but delegates all work to a Crypto SPI plug-in. |
|
44 @param aKey The key to use. aKey must be less |
|
45 than or equal to KRC4MaxKeySizeBytes. |
|
46 @param aDiscardBytes The number of bytes to drop from the |
|
47 beginning of the key stream. |
|
48 @return A pointer to a CArc4Shim instance |
|
49 @leave KErrKeyNotWeakEnough If the key size is larger than that |
|
50 allowed by the cipher strength |
|
51 restrictions of the crypto library. |
|
52 See TCrypto::IsSymmetricWeakEnoughL() |
|
53 */ |
|
54 static CArc4Shim* NewL(const TDesC8& aKey, TUint aDiscardBytes); |
|
55 |
|
56 /** |
|
57 Creates a CArc4Shim object which has the same interface as CARC4, |
|
58 and leave it on the cleanup stack. but delegates all work to a |
|
59 Crypto SPI plug-in. |
|
60 @param aKey The key to use. aKey must be less |
|
61 than or equal to KRC4MaxKeySizeBytes. |
|
62 @param aDiscardBytes The number of bytes to drop from the |
|
63 beginning of the key stream. |
|
64 @return A pointer to a CArc4Shim instance |
|
65 @leave KErrKeyNotWeakEnough If the key size is larger than that |
|
66 allowed by the cipher strength |
|
67 restrictions of the crypto library. |
|
68 See TCrypto::IsSymmetricWeakEnoughL() |
|
69 */ |
|
70 static CArc4Shim* NewLC(const TDesC8& aKey, TUint aDiscardBytes); |
|
71 |
|
72 /** |
|
73 Destructor |
|
74 */ |
|
75 ~CArc4Shim(); |
|
76 |
|
77 // From CSymmetricCipher class |
|
78 void Reset(); |
|
79 TInt BlockSize() const; |
|
80 TInt KeySize() const; |
|
81 void Process(const TDesC8& aInput, TDes8& aOutput); |
|
82 void ProcessFinalL(const TDesC8& aInput, TDes8& aOutput); |
|
83 TInt MaxOutputLength(TInt aInputLength) const; |
|
84 TInt MaxFinalOutputLength(TInt aInputLength) const; |
|
85 |
|
86 private: |
|
87 /** |
|
88 Constructor |
|
89 */ |
|
90 CArc4Shim(); |
|
91 |
|
92 /** |
|
93 Second Phase Constructor |
|
94 */ |
|
95 void ConstructL(const TDesC8& aKey, TUint aDiscardBytes); |
|
96 |
|
97 private: |
|
98 /// SPI delegate |
|
99 CryptoSpi::CSymmetricCipher* iSymmetricCipherImpl; |
|
100 |
|
101 /// SPI requires all key to passed as key-objects |
|
102 CryptoSpi::CKey* iKey; |
|
103 |
|
104 CryptoSpi::CCryptoParams* iAlgorithmParams; |
|
105 }; |
|
106 |
|
107 #endif // ARC4SHIM_H |