|
1 /* |
|
2 * Copyright (c) 2007-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 __DSAKEYPAIRGENIMPL_H__ |
|
20 #define __DSAKEYPAIRGENIMPL_H__ |
|
21 |
|
22 /** |
|
23 @file |
|
24 @internalComponent |
|
25 @released |
|
26 */ |
|
27 |
|
28 #include <e32base.h> |
|
29 #include <e32cmn.h> |
|
30 #include "keypairgenimpl.h" |
|
31 //#include <asymmetrickeys.h> |
|
32 |
|
33 /** |
|
34 * Implementation of DSA key pair generation. |
|
35 */ |
|
36 namespace SoftwareCrypto |
|
37 { |
|
38 NONSHARABLE_CLASS(CDSAPrimeCertificate) : public CBase |
|
39 { |
|
40 public: |
|
41 /** |
|
42 Creates a new DSA prime certificate from a specified |
|
43 seed and counter value. |
|
44 |
|
45 @param aSeed The seed from a DSA key generation process |
|
46 @param aCounter The counter value from a DSA key generation process |
|
47 @return A pointer to a CDSAPrimeCertificate instance |
|
48 */ |
|
49 static CDSAPrimeCertificate* NewL(const TDesC8& aSeed, TUint aCounter); |
|
50 |
|
51 /** |
|
52 Creates a new DSA prime certificate from a specified |
|
53 seed and counter value. |
|
54 |
|
55 The returned pointer is put onto the cleanup stack. |
|
56 |
|
57 @param aSeed The seed from a DSA key generation process |
|
58 @param aCounter The counter value from a DSA key generation process |
|
59 @return A pointer to a CDSAPrimeCertificate instance |
|
60 */ |
|
61 static CDSAPrimeCertificate* NewLC(const TDesC8& aSeed, TUint aCounter); |
|
62 |
|
63 /** |
|
64 Gets the seed of the DSA prime certificate |
|
65 @return The seed |
|
66 */ |
|
67 const TDesC8& Seed() const; |
|
68 |
|
69 /** |
|
70 Gets the counter value of the DSA prime certificate |
|
71 |
|
72 @return The counter's value |
|
73 */ |
|
74 TUint Counter() const; |
|
75 |
|
76 /** |
|
77 Destructor |
|
78 */ |
|
79 ~CDSAPrimeCertificate(); |
|
80 |
|
81 protected: |
|
82 /** |
|
83 Constructor |
|
84 @param aCounter The DSA key generation counter |
|
85 */ |
|
86 CDSAPrimeCertificate(TUint aCounter); |
|
87 |
|
88 /** |
|
89 Default constructor |
|
90 */ |
|
91 CDSAPrimeCertificate(); |
|
92 |
|
93 void ConstructL(const TDesC8& aSeed); |
|
94 |
|
95 protected: |
|
96 /** |
|
97 The DSA key generation seed |
|
98 */ |
|
99 const HBufC8* iSeed; |
|
100 /** |
|
101 The DSA key generation counter |
|
102 */ |
|
103 TUint iCounter; |
|
104 private: |
|
105 CDSAPrimeCertificate(const CDSAPrimeCertificate&); |
|
106 CDSAPrimeCertificate& operator=(const CDSAPrimeCertificate&); |
|
107 }; |
|
108 |
|
109 NONSHARABLE_CLASS(CDSAKeyPairGenImpl) : public CKeyPairGenImpl |
|
110 { |
|
111 public: |
|
112 |
|
113 static CDSAKeyPairGenImpl* NewL(); |
|
114 static CDSAKeyPairGenImpl* NewLC(); |
|
115 |
|
116 // from MPlugin |
|
117 void Reset(); |
|
118 |
|
119 // from MKeyPairGenerator |
|
120 void GenerateKeyPairL(TInt aKeySize, const CCryptoParams& aKeyParameters, CKeyPair*& aKeyPair); |
|
121 |
|
122 // Override CKeyPairGenImpl virtual functions |
|
123 TUid ImplementationUid() const; |
|
124 |
|
125 const CExtendedCharacteristics* GetExtendedCharacteristicsL(); |
|
126 static CExtendedCharacteristics* CreateExtendedCharacteristicsL(); |
|
127 |
|
128 // Destructor |
|
129 ~CDSAKeyPairGenImpl(); |
|
130 |
|
131 static TBool GeneratePrimesL(const TDesC8& aSeed, |
|
132 TUint& aCounter, |
|
133 RInteger& aP, |
|
134 TUint aL, |
|
135 RInteger& aQ, |
|
136 TBool aUseInputCounter=EFalse); |
|
137 |
|
138 static TBool ValidPrimeLength(TUint aPrimeBits); |
|
139 |
|
140 private: |
|
141 /** |
|
142 Constructor |
|
143 */ |
|
144 CDSAKeyPairGenImpl(); |
|
145 |
|
146 /// second phase of construction |
|
147 void ConstructL(); |
|
148 |
|
149 CDSAPrimeCertificate* iPrimeCertificate; |
|
150 }; |
|
151 } |
|
152 |
|
153 #endif // __DSAKEYPAIRGENIMPL_H__ |