|
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 * crypto key agreement application interface |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @publishedPartner |
|
23 @released |
|
24 */ |
|
25 |
|
26 #ifndef __CRYPTOAPI_KEYAGREEMENTAPI_H__ |
|
27 #define __CRYPTOAPI_KEYAGREEMENTAPI_H__ |
|
28 |
|
29 #include <e32base.h> |
|
30 #include <cryptospi/cryptobaseapi.h> |
|
31 |
|
32 namespace CryptoSpi |
|
33 { |
|
34 class MKeyAgreement; |
|
35 class MAsyncKeyAgreement; |
|
36 class CKey; |
|
37 class CCryptoParams; |
|
38 |
|
39 /** |
|
40 Synchronous Key Agreement, which wraps a synchronous Key Agreement plugin implementation |
|
41 */ |
|
42 NONSHARABLE_CLASS(CKeyAgreement) : public CCryptoBase |
|
43 { |
|
44 public: |
|
45 |
|
46 /** |
|
47 * @internalComponent |
|
48 * |
|
49 * Create a CKeyAgreement instance from the given MKeyAgreement instance |
|
50 * @param aKeyAgreement The key agreement plugin instance |
|
51 * @return A pointer to a CKeyAgreement instance |
|
52 */ |
|
53 static CKeyAgreement* NewL(MKeyAgreement* aKeyAgreement, TInt aHandle); |
|
54 |
|
55 /** |
|
56 Destructor |
|
57 */ |
|
58 IMPORT_C ~CKeyAgreement(); |
|
59 |
|
60 /** |
|
61 Set the private key for this keyagreement. Reset() is called to reinitialized the keyAgreement |
|
62 @param aSelfPrivateKey The private key of one of the parties |
|
63 @param aParams The parameters shared between both parties |
|
64 */ |
|
65 IMPORT_C void SetKeyL(const CKey& aSelfPrivateKey, const CCryptoParams* aParams); |
|
66 |
|
67 /** |
|
68 Performs the key agreement operation. |
|
69 @param aOtherPublicKey The public key of the other party |
|
70 @param aParams The parameters shared between both parties |
|
71 @return A pointer to a CKey instance containing the agreed key |
|
72 */ |
|
73 IMPORT_C CKey* AgreeL(const CKey& aOtherPublicKey, const CCryptoParams* aParams); |
|
74 |
|
75 private: |
|
76 /** |
|
77 Constructor |
|
78 */ |
|
79 CKeyAgreement(MKeyAgreement* aKeyAgreement, TInt aHandle); |
|
80 }; |
|
81 |
|
82 /** |
|
83 Asynchronous Key Agreement, which wraps a asynchronous Key Agreement plugin implementation |
|
84 */ |
|
85 NONSHARABLE_CLASS(CAsyncKeyAgreement) : public CCryptoBase |
|
86 { |
|
87 public: |
|
88 /** |
|
89 * @internalComponent |
|
90 * |
|
91 * Create a CKeyAgreement instance from the given MKeyAgreement instance |
|
92 * @param aKeyAgreement The async key agreement plugin instance |
|
93 * @return A pointer to a CKeyAgreement instance |
|
94 */ |
|
95 static CAsyncKeyAgreement* NewL(MAsyncKeyAgreement* aKeyAgreement, TInt aHandle); |
|
96 |
|
97 /** |
|
98 Destructor |
|
99 */ |
|
100 IMPORT_C ~CAsyncKeyAgreement(); |
|
101 |
|
102 /** |
|
103 Set the private key for this keyagreement. Reset() is called to reinitialized the keyAgreement |
|
104 @param aSelfPrivateKey The private key of one of the parties |
|
105 @param aParams The parameters shared between both parties |
|
106 */ |
|
107 IMPORT_C void SetKeyL(const CKey& aSelfPrivateKey, const CCryptoParams* aParams); |
|
108 |
|
109 |
|
110 /** |
|
111 Performs the key agreement operation. |
|
112 @param aOtherPublicKey The public key of the other party |
|
113 @param aKey A pointer to a CKey instance containing the agreed key |
|
114 @param aParams The parameters shared between both parties |
|
115 @param aRequestStatus |
|
116 */ |
|
117 IMPORT_C void AgreeL(const CKey& aOtherPublicKey, CKey& aKey, const CCryptoParams* aParams, TRequestStatus& aRequestStatus); |
|
118 |
|
119 private: |
|
120 /** |
|
121 Constructor |
|
122 */ |
|
123 CAsyncKeyAgreement(MAsyncKeyAgreement* aKeyAgreement, TInt aHandle); |
|
124 }; |
|
125 |
|
126 /** |
|
127 the Factory to create synchronous and asynchronous keyagreement instances |
|
128 */ |
|
129 class CKeyAgreementFactory |
|
130 { |
|
131 public: |
|
132 /** |
|
133 Creates a new instance of a key agreement system. |
|
134 |
|
135 @param aKeyAgreement A reference to a pointer that should be set to point to the new key agreement object. |
|
136 @param aAlgorithmUid The algorithm to use |
|
137 @param aPrivateKey The private key to combine with the other parties public key during the agreement. |
|
138 @param aAlgorithmParams The parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. |
|
139 @return KErrNone if successful; otherwise, a system wide error code. |
|
140 */ |
|
141 IMPORT_C static void CreateKeyAgreementL(CKeyAgreement*& aKeyAgreement, |
|
142 TUid aAlgorithmUid, |
|
143 const CKey& aPrivateKey, |
|
144 const CCryptoParams* aAlgorithmParams); |
|
145 |
|
146 /** |
|
147 Creates a new asynchronous instance of a key agreement system. |
|
148 |
|
149 @param aKeyAgreement A reference to a pointer that should be set to point to the new key agreement object. |
|
150 @param aAlgorithmUid The algorithm to use |
|
151 @param aPrivateKey The private key to combine with the other parties public key during the agreement. |
|
152 @param aAlgorithmParams The parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. |
|
153 @return KErrNone if successful; otherwise, a system wide error code. |
|
154 */ |
|
155 IMPORT_C static void CreateAsyncKeyAgreementL(CAsyncKeyAgreement*& aKeyAgreement, |
|
156 TUid aAlgorithmUid, |
|
157 const CKey& aPrivateKey, |
|
158 const CCryptoParams* aAlgorithmParams); |
|
159 }; |
|
160 } |
|
161 |
|
162 #endif //__CRYPTOAPI_KEYAGREEMENTAPI_H__ |