sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
* RC2 shim classes definition
|
sl@0
|
16 |
*
|
sl@0
|
17 |
*/
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
/**
|
sl@0
|
21 |
@file
|
sl@0
|
22 |
@internalComponent
|
sl@0
|
23 |
@released
|
sl@0
|
24 |
*/
|
sl@0
|
25 |
|
sl@0
|
26 |
#ifndef __RC2SHIM_H__
|
sl@0
|
27 |
#define __RC2SHIM_H__
|
sl@0
|
28 |
|
sl@0
|
29 |
#include <rc2.h>
|
sl@0
|
30 |
|
sl@0
|
31 |
namespace CryptoSpi
|
sl@0
|
32 |
{
|
sl@0
|
33 |
class CCryptoParams;
|
sl@0
|
34 |
class CSymmetricCipher;
|
sl@0
|
35 |
class CKey;
|
sl@0
|
36 |
}
|
sl@0
|
37 |
|
sl@0
|
38 |
NONSHARABLE_CLASS(CRC2EncryptorShim) : public CRC2Encryptor
|
sl@0
|
39 |
{
|
sl@0
|
40 |
public:
|
sl@0
|
41 |
/**
|
sl@0
|
42 |
Creates an CRC2EncryptorShim object which has the same interface
|
sl@0
|
43 |
as RC2 Encryptor but delegates all work to a Crypto SPI plug-in.
|
sl@0
|
44 |
|
sl@0
|
45 |
@param aKey The encryption key
|
sl@0
|
46 |
@return A pointer to a CRC2EncryptorShim instance
|
sl@0
|
47 |
*/
|
sl@0
|
48 |
static CRC2EncryptorShim* NewL(const TDesC8& aKey, TInt aEffectiveKeyLenBits);
|
sl@0
|
49 |
|
sl@0
|
50 |
/**
|
sl@0
|
51 |
Creates an CRC2EncryptorShim object which has the same interface
|
sl@0
|
52 |
as RC2 Encryptor but delegates all work to a Crypto SPI plug-in.
|
sl@0
|
53 |
|
sl@0
|
54 |
A pointer to the new object is placed on the cleanup stack
|
sl@0
|
55 |
|
sl@0
|
56 |
@param aKey The encryption key
|
sl@0
|
57 |
@return A pointer to a CRC2EncryptorShim instance
|
sl@0
|
58 |
*/
|
sl@0
|
59 |
static CRC2EncryptorShim* NewLC(const TDesC8& aKey, TInt aEffectiveKeyLenBits);
|
sl@0
|
60 |
|
sl@0
|
61 |
// From CBlockTransform
|
sl@0
|
62 |
TInt BlockSize() const;
|
sl@0
|
63 |
void Transform(TDes8& aBlock);
|
sl@0
|
64 |
void Reset(void);
|
sl@0
|
65 |
TInt KeySize(void) const;
|
sl@0
|
66 |
|
sl@0
|
67 |
/// Destructor
|
sl@0
|
68 |
~CRC2EncryptorShim();
|
sl@0
|
69 |
|
sl@0
|
70 |
private:
|
sl@0
|
71 |
/// Constructor
|
sl@0
|
72 |
CRC2EncryptorShim();
|
sl@0
|
73 |
void ConstructL(const TDesC8& aKey, TInt aEffectiveKeyLenBits);
|
sl@0
|
74 |
|
sl@0
|
75 |
// From CBase
|
sl@0
|
76 |
TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);
|
sl@0
|
77 |
|
sl@0
|
78 |
private:
|
sl@0
|
79 |
/// SPI delegate
|
sl@0
|
80 |
CryptoSpi::CSymmetricCipher* iSymmetricCipherImpl;
|
sl@0
|
81 |
|
sl@0
|
82 |
/// SPI requires all key to passed as key-objects
|
sl@0
|
83 |
CryptoSpi::CKey* iKey;
|
sl@0
|
84 |
|
sl@0
|
85 |
/// Temporary output block, SPI does not overwrite input
|
sl@0
|
86 |
/// RC2 uses 64bit blocks
|
sl@0
|
87 |
TBuf8<16> iOutputBlock;
|
sl@0
|
88 |
|
sl@0
|
89 |
/// The effective key length is passed as an algorithm
|
sl@0
|
90 |
/// parameter. This allows it to be externalised.
|
sl@0
|
91 |
CryptoSpi::CCryptoParams* iAlgorithmParams;
|
sl@0
|
92 |
};
|
sl@0
|
93 |
|
sl@0
|
94 |
NONSHARABLE_CLASS(CRC2DecryptorShim) : public CRC2Decryptor
|
sl@0
|
95 |
{
|
sl@0
|
96 |
public:
|
sl@0
|
97 |
/**
|
sl@0
|
98 |
Creates an CRC2DecryptorShim object which has the same interface
|
sl@0
|
99 |
as RC2 Decryptor but delegates all work to a Crypto SPI plug-in.
|
sl@0
|
100 |
|
sl@0
|
101 |
@param aKey The decryption key
|
sl@0
|
102 |
@return A pointer to a CRC2DecryptorShim instance
|
sl@0
|
103 |
*/
|
sl@0
|
104 |
static CRC2DecryptorShim* NewL(const TDesC8& aKey, TInt aEffectiveKeyLenBits);
|
sl@0
|
105 |
|
sl@0
|
106 |
/**
|
sl@0
|
107 |
Creates an CRC2DecryptorShim object which has the same interface
|
sl@0
|
108 |
as RC2 Decryptor but delegates all work to a Crypto SPI plug-in.
|
sl@0
|
109 |
|
sl@0
|
110 |
A pointer to the new object is placed on the cleanup stack
|
sl@0
|
111 |
|
sl@0
|
112 |
@param aKey The decryption key
|
sl@0
|
113 |
@return A pointer to a CRC2DecryptorShim instance
|
sl@0
|
114 |
*/
|
sl@0
|
115 |
static CRC2DecryptorShim* NewLC(const TDesC8& aKey, TInt aEffectiveKeyLenBits);
|
sl@0
|
116 |
|
sl@0
|
117 |
// From CBlockTransform
|
sl@0
|
118 |
TInt BlockSize() const;
|
sl@0
|
119 |
void Transform(TDes8& aBlock);
|
sl@0
|
120 |
void Reset(void);
|
sl@0
|
121 |
TInt KeySize(void) const;
|
sl@0
|
122 |
|
sl@0
|
123 |
/// Destructor
|
sl@0
|
124 |
~CRC2DecryptorShim();
|
sl@0
|
125 |
|
sl@0
|
126 |
private:
|
sl@0
|
127 |
/// Constructor
|
sl@0
|
128 |
CRC2DecryptorShim();
|
sl@0
|
129 |
void ConstructL(const TDesC8& aKey, TInt aEffectiveKeyLenBits);
|
sl@0
|
130 |
|
sl@0
|
131 |
/**
|
sl@0
|
132 |
From CBase, to allow CBufferedTransform & CBlockChainingMode
|
sl@0
|
133 |
to determine whether the functionality may be delegated to
|
sl@0
|
134 |
the SPI object.
|
sl@0
|
135 |
*/
|
sl@0
|
136 |
TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);
|
sl@0
|
137 |
|
sl@0
|
138 |
private:
|
sl@0
|
139 |
/// SPI delegate
|
sl@0
|
140 |
CryptoSpi::CSymmetricCipher* iSymmetricCipherImpl;
|
sl@0
|
141 |
|
sl@0
|
142 |
/// SPI requires all key to passed as key-objects
|
sl@0
|
143 |
CryptoSpi::CKey* iKey;
|
sl@0
|
144 |
|
sl@0
|
145 |
/// Temporary output block, SPI does not overwrite input
|
sl@0
|
146 |
/// RC2 uses 64bit blocks
|
sl@0
|
147 |
TBuf8<16> iOutputBlock;
|
sl@0
|
148 |
|
sl@0
|
149 |
/// The effective key length is passed as an algorithm
|
sl@0
|
150 |
/// parameter. This allows it to be externalised.
|
sl@0
|
151 |
CryptoSpi::CCryptoParams* iAlgorithmParams;
|
sl@0
|
152 |
};
|
sl@0
|
153 |
|
sl@0
|
154 |
#endif // __RC2SHIM_H__
|