|
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 __RSAIMPL_H__ |
|
20 #define __RSAIMPL_H__ |
|
21 |
|
22 /** |
|
23 @file |
|
24 @internalComponent |
|
25 @released |
|
26 */ |
|
27 |
|
28 #include <e32base.h> |
|
29 #include <e32cmn.h> |
|
30 #include "keys.h" |
|
31 #include "asymmetriccipherimpl.h" |
|
32 |
|
33 /** |
|
34 * Implementation of RSA encryption as described in PKCS#1 v1.5. |
|
35 */ |
|
36 namespace SoftwareCrypto |
|
37 { |
|
38 using namespace CryptoSpi; |
|
39 |
|
40 NONSHARABLE_CLASS(CRSAImpl) : public CAsymmetricCipherImpl |
|
41 { |
|
42 public: |
|
43 /** |
|
44 Creates an instance of an RSA asymmetric cipher plug-in. |
|
45 @param aKey The key |
|
46 @param aCryptoMode Whether to encrypt or decrypt |
|
47 @param aPadding The padding scheme to use None, SSLv3, PKCS#7 |
|
48 @return A pointer to a CRSAImpl instance |
|
49 */ |
|
50 static CRSAImpl* NewL(const CKey& aKey, |
|
51 TUid aCryptoMode, TUid aPadding); |
|
52 |
|
53 /** |
|
54 Creates an instance of an RSA asymmetric cipher plug-in. |
|
55 A pointer to the plug-in instance is placed on the cleanup stack. |
|
56 @param aKey The key |
|
57 @param aCryptoMode Whether to encrypt or decrypt |
|
58 @param aPadding The padding scheme to use None, SSLv3, PKCS#7 |
|
59 @return A pointer to a CRSAImpl instance |
|
60 */ |
|
61 static CRSAImpl* NewLC(const CKey& aKey, |
|
62 TUid aCryptoMode, TUid aPadding); |
|
63 |
|
64 // Override CAsymmetricCipherImpl virtual functions |
|
65 TUid ImplementationUid() const; |
|
66 TBool IsValidKeyLengthL(TInt aKeyBytes) const; |
|
67 TInt GetMaximumInputLengthL() const; |
|
68 TInt GetMaximumOutputLengthL() const; |
|
69 void ProcessL(const TDesC8& aInput, TDes8& aOutput); |
|
70 // End of CAsymmetricCipherImpl |
|
71 |
|
72 const CExtendedCharacteristics* GetExtendedCharacteristicsL(); |
|
73 static CExtendedCharacteristics* CreateExtendedCharacteristicsL(); |
|
74 |
|
75 // Destructor |
|
76 ~CRSAImpl(); |
|
77 |
|
78 private: |
|
79 /** |
|
80 Constructor |
|
81 @param aCryptoMode Whether to encrypt or decrypt |
|
82 @param aPaddingMode The padding mode to use. None, SSL, PKCS#7 |
|
83 */ |
|
84 CRSAImpl(TUid aCryptoMode, TUid aPaddingMode); |
|
85 |
|
86 /// second phase of construction |
|
87 void ConstructL(const CKey& aKey); |
|
88 |
|
89 /// for internal usage, called from ProcessL |
|
90 void EncryptL(const TDesC8& aInput, TDes8& aOutput) const; |
|
91 void DecryptL(const TDesC8& aInput, TDes8& aOutput) const; |
|
92 |
|
93 }; |
|
94 } |
|
95 |
|
96 #endif // __RSAIMPL_H__ |