|
1 /* |
|
2 * Copyright (c) 1998-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 #include "tactiondecodepkcs5.h" |
|
20 #include "t_input.h" |
|
21 #include <asnpkcs.h> |
|
22 #include <pbedata.h> |
|
23 #include <pbe.h> |
|
24 #include <asn1enc.h> |
|
25 |
|
26 _LIT8(KInputStart, "<input>"); |
|
27 |
|
28 |
|
29 CTestAction* CActionDecodePKCS5::NewL(RFs& aFs, |
|
30 CConsoleBase& aConsole, |
|
31 Output& aOut, |
|
32 const TTestActionSpec& aTestActionSpec) |
|
33 { |
|
34 CActionDecodePKCS5* self = new(ELeave) CActionDecodePKCS5(aFs, aConsole, aOut); |
|
35 CleanupStack::PushL(self); |
|
36 self->ConstructL(aTestActionSpec); |
|
37 CleanupStack::Pop(); |
|
38 return self; |
|
39 } |
|
40 |
|
41 CActionDecodePKCS5::~CActionDecodePKCS5() |
|
42 { |
|
43 delete iInput; |
|
44 delete iOutput; |
|
45 } |
|
46 |
|
47 CActionDecodePKCS5::CActionDecodePKCS5(RFs& aFs, |
|
48 CConsoleBase& aConsole, |
|
49 Output& aOut) |
|
50 |
|
51 : CTestAction(aConsole, aOut), iFs(aFs) |
|
52 { |
|
53 } |
|
54 |
|
55 void CActionDecodePKCS5::ConstructL(const TTestActionSpec& aTestActionSpec) |
|
56 { |
|
57 CTestAction::ConstructL(aTestActionSpec); |
|
58 |
|
59 iInput = Input::ParseElementHexL(aTestActionSpec.iActionBody, KInputStart); |
|
60 iOutput = HBufC8::NewL(iInput->Length()+100); //so we detect errors in |
|
61 //encoding not panics in descriptors |
|
62 } |
|
63 |
|
64 void CActionDecodePKCS5::DoReportAction(void) |
|
65 { |
|
66 } |
|
67 |
|
68 void CActionDecodePKCS5::DoCheckResult(TInt) |
|
69 { |
|
70 } |
|
71 |
|
72 void CActionDecodePKCS5::PerformAction(TRequestStatus& aStatus) |
|
73 { |
|
74 TRequestStatus* status = &aStatus; |
|
75 iResult = EFalse; |
|
76 |
|
77 CPBEncryptParms* parms = TASN1DecPKCS5::DecodeDERL(*iInput); |
|
78 CleanupStack::PushL(parms); |
|
79 CASN1EncSequence* seq = TASN1EncPKCS5::EncodeDERL(*parms); |
|
80 CleanupStack::PushL(seq); |
|
81 |
|
82 iOutput->Des().SetLength(seq->LengthDER()); |
|
83 TUint length=0; |
|
84 TPtr8 iOutputTemp = iOutput->Des(); |
|
85 seq->WriteDERL(iOutputTemp, length); |
|
86 |
|
87 if(*iOutput == *iInput) |
|
88 { |
|
89 iResult = ETrue; |
|
90 } |
|
91 |
|
92 CleanupStack::PopAndDestroy(2); //seq, parms |
|
93 User::RequestComplete(status, KErrNone); |
|
94 iActionState = CTestAction::EPostrequisite; |
|
95 } |