62 delete iImportFileName; |
65 delete iImportFileName; |
63 if (iKeyInfo != NULL) |
66 if (iKeyInfo != NULL) |
64 { |
67 { |
65 iKeyInfo->Release(); |
68 iKeyInfo->Release(); |
66 } |
69 } |
|
70 #if (defined(SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT) && defined(SYMBIAN_ENABLE_SDP_ECC)) |
|
71 if(iImportHardwareType) |
|
72 { |
|
73 delete iPublicKey; |
|
74 delete iPrivateKey; |
|
75 } |
|
76 #endif // SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT && SYMBIAN_ENABLE_SDP_ECC |
67 } |
77 } |
68 |
78 |
69 CImportKey::CImportKey(RFs& aFs,CConsoleBase& aConsole, Output& aOut) : |
79 CImportKey::CImportKey(RFs& aFs,CConsoleBase& aConsole, Output& aOut) : |
70 CKeyStoreTestAction(aFs, aConsole, aOut), iState(EImportKey) |
80 CKeyStoreTestAction(aFs, aConsole, aOut), iState(EImportKey) |
71 { |
81 { |
80 TInt pos = 0; |
90 TInt pos = 0; |
81 |
91 |
82 iImportFileName = HBufC8::NewL(256); // Reasonable max length of a file name |
92 iImportFileName = HBufC8::NewL(256); // Reasonable max length of a file name |
83 TPtr8 temp(iImportFileName->Des()); |
93 TPtr8 temp(iImportFileName->Des()); |
84 temp.Copy(Input::ParseElement(aTestActionSpec.iActionBody, KImportDataFile, KImportDataFileEnd, pos, err)); |
94 temp.Copy(Input::ParseElement(aTestActionSpec.iActionBody, KImportDataFile, KImportDataFileEnd, pos, err)); |
|
95 #if (defined(SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT) && defined(SYMBIAN_ENABLE_SDP_ECC)) |
|
96 if(iHardwareType) |
|
97 { |
|
98 TPtrC8 buffer; |
|
99 buffer.Set(Input::ParseElement(aTestActionSpec.iActionBody, KPublicKeyStart, KPublicKeyEnd, pos, err)); |
|
100 iPublicKey = HBufC8::NewMaxL(buffer.Length()); |
|
101 TPtr8 publicKeyPtr = iPublicKey->Des(); |
|
102 publicKeyPtr.Copy(buffer); |
|
103 buffer.Set(Input::ParseElement(aTestActionSpec.iActionBody, KPrivateKeyStart, KPrivateKeyEnd, pos, err)); |
|
104 iPrivateKey = HBufC8::NewMaxL(buffer.Length()); |
|
105 TPtr8 privateKeyPtr = iPrivateKey->Des(); |
|
106 privateKeyPtr.Copy(buffer); |
|
107 } |
|
108 #endif // SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT && SYMBIAN_ENABLE_SDP_ECC |
85 } |
109 } |
86 |
110 |
87 void CImportKey::SetKeyDataFileL(const TDesC8& aDes) |
111 void CImportKey::SetKeyDataFileL(const TDesC8& aDes) |
88 { |
112 { |
89 RFs theFs; |
113 RFs theFs; |
135 { |
159 { |
136 switch (iState) |
160 switch (iState) |
137 { |
161 { |
138 case EImportKey: |
162 case EImportKey: |
139 { |
163 { |
140 TRAPD(result, SetKeyDataFileL(*iImportFileName)); |
164 TInt result = KErrNone; |
|
165 #if (defined(SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT) && defined(SYMBIAN_ENABLE_SDP_ECC)) |
|
166 if(iHardwareType == 0) |
|
167 { |
|
168 #endif // SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT && SYMBIAN_ENABLE_SDP_ECC |
|
169 TRAP(result, SetKeyDataFileL(*iImportFileName)); |
|
170 #if (defined(SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT) && defined(SYMBIAN_ENABLE_SDP_ECC)) |
|
171 } |
|
172 #endif // SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT && SYMBIAN_ENABLE_SDP_ECC |
141 if (KErrNone != result) |
173 if (KErrNone != result) |
142 { |
174 { |
143 iState = EFinished; |
175 iState = EFinished; |
144 TRequestStatus *status = &aStatus; |
176 TRequestStatus *status = &aStatus; |
145 User::RequestComplete(status,result); |
177 User::RequestComplete(status,result); |
146 break; |
178 break; |
147 } |
179 } |
148 |
180 |
149 CUnifiedKeyStore* keyStore = CSharedKeyStores::TheUnifiedKeyStores().operator[](iKeystore); |
181 CUnifiedKeyStore* keyStore = CSharedKeyStores::TheUnifiedKeyStores().operator[](iKeystore); |
150 #ifdef SYMBIAN_AUTH_SERVER |
182 if(iKeyStoreImplLabel.Length() != 0) |
151 if(iUseNewApi) |
183 { |
152 { |
184 SetKeyStoreIndex(keyStore); |
153 keyStore->ImportKey(0, iKeyData->Des(), iUsage, *iLabel, iAccessType, |
185 } |
154 TTime(0), TTime(0), *iAuthExpression, iFreshness, iKeyInfo, aStatus); |
186 |
|
187 #if (defined(SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT) && defined(SYMBIAN_ENABLE_SDP_ECC)) |
|
188 if(iHardwareType) |
|
189 { |
|
190 MCTToken* token = NULL; |
|
191 CCryptoTokenHai* cryptoTokenHai = NULL; |
|
192 TRAP(result, cryptoTokenHai = CCryptoTokenHai::NewL(token)); |
|
193 if (KErrNone != result) |
|
194 { |
|
195 iState = EFinished; |
|
196 TRequestStatus *status = &aStatus; |
|
197 User::RequestComplete(status,result); |
|
198 break; |
|
199 } |
|
200 TRAP(result, cryptoTokenHai->ImportKeyL(iLabel->Des(),iPrivateKey->Des(),iPublicKey->Des())); |
|
201 |
|
202 TRequestStatus *status = &aStatus; |
|
203 if (KErrNone != result) |
|
204 { |
|
205 User::RequestComplete(status,result); |
|
206 } |
|
207 else |
|
208 { |
|
209 User::RequestComplete(status, aStatus.Int()); |
|
210 } |
155 } |
211 } |
156 else |
212 else |
157 #endif // SYMBIAN_AUTH_SERVER |
213 #endif // SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT && SYMBIAN_ENABLE_SDP_ECC |
158 { |
214 { |
159 keyStore->ImportKey(0, iKeyData->Des(), iUsage, *iLabel, iAccessType, |
215 #ifdef SYMBIAN_AUTH_SERVER |
160 TTime(0), TTime(0), iKeyInfo, aStatus); |
216 if(iUseNewApi) |
161 } |
217 { |
|
218 keyStore->ImportKey(iKeyStoreImplIndex, iKeyData->Des(), iUsage, *iLabel, iAccessType, |
|
219 TTime(0), TTime(0), *iAuthExpression, iFreshness, iKeyInfo, aStatus); |
|
220 } |
|
221 else |
|
222 #endif // SYMBIAN_AUTH_SERVER |
|
223 { |
|
224 keyStore->ImportKey(iKeyStoreImplIndex, iKeyData->Des(), iUsage, *iLabel, iAccessType, |
|
225 TTime(0), TTime(0), iKeyInfo, aStatus); |
|
226 } |
|
227 } // else |
162 iState = EFinished; |
228 iState = EFinished; |
163 } |
229 } |
164 break; |
230 break; |
165 |
231 |
166 case EFinished: |
232 case EFinished: |