os/security/cryptoservices/asnpkcs/test/tactiondecodepkcs5.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/cryptoservices/asnpkcs/test/tactiondecodepkcs5.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,95 @@
     1.4 +/*
     1.5 +* Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#include "tactiondecodepkcs5.h"
    1.23 +#include "t_input.h"
    1.24 +#include <asnpkcs.h>
    1.25 +#include <pbedata.h>
    1.26 +#include <pbe.h>
    1.27 +#include <asn1enc.h>
    1.28 +
    1.29 +_LIT8(KInputStart, "<input>");
    1.30 +
    1.31 +
    1.32 +CTestAction* CActionDecodePKCS5::NewL(RFs& aFs,
    1.33 +									   CConsoleBase& aConsole,
    1.34 +									   Output& aOut, 
    1.35 +									   const TTestActionSpec& aTestActionSpec)
    1.36 +	{
    1.37 +	CActionDecodePKCS5* self = new(ELeave) CActionDecodePKCS5(aFs, aConsole, aOut);
    1.38 +	CleanupStack::PushL(self);
    1.39 +	self->ConstructL(aTestActionSpec);
    1.40 +	CleanupStack::Pop();
    1.41 +	return self;
    1.42 +	}
    1.43 +
    1.44 +CActionDecodePKCS5::~CActionDecodePKCS5()
    1.45 +	{
    1.46 +	delete iInput;
    1.47 +	delete iOutput;
    1.48 +	}
    1.49 +
    1.50 +CActionDecodePKCS5::CActionDecodePKCS5(RFs& aFs, 
    1.51 +								 CConsoleBase& aConsole,
    1.52 +								 Output& aOut)
    1.53 +								 
    1.54 +: CTestAction(aConsole, aOut), iFs(aFs)
    1.55 +	{
    1.56 +	}
    1.57 +
    1.58 +void CActionDecodePKCS5::ConstructL(const TTestActionSpec& aTestActionSpec)
    1.59 +	{
    1.60 +	CTestAction::ConstructL(aTestActionSpec);
    1.61 +
    1.62 +	iInput = Input::ParseElementHexL(aTestActionSpec.iActionBody, KInputStart);
    1.63 +	iOutput = HBufC8::NewL(iInput->Length()+100); //so we detect errors in
    1.64 +	//encoding not panics in descriptors
    1.65 +	}
    1.66 +
    1.67 +void CActionDecodePKCS5::DoReportAction(void)
    1.68 +	{
    1.69 +	}
    1.70 +
    1.71 +void CActionDecodePKCS5::DoCheckResult(TInt)
    1.72 +	{
    1.73 +	}
    1.74 +
    1.75 +void CActionDecodePKCS5::PerformAction(TRequestStatus& aStatus)
    1.76 +	{
    1.77 +	TRequestStatus* status = &aStatus;
    1.78 +	iResult = EFalse;
    1.79 +	
    1.80 +	CPBEncryptParms* parms = TASN1DecPKCS5::DecodeDERL(*iInput);
    1.81 +	CleanupStack::PushL(parms);
    1.82 +	CASN1EncSequence* seq = TASN1EncPKCS5::EncodeDERL(*parms);
    1.83 +	CleanupStack::PushL(seq);
    1.84 +
    1.85 +	iOutput->Des().SetLength(seq->LengthDER());
    1.86 +	TUint length=0;
    1.87 +	TPtr8 iOutputTemp = iOutput->Des();
    1.88 +	seq->WriteDERL(iOutputTemp, length);
    1.89 +
    1.90 +	if(*iOutput == *iInput)
    1.91 +		{
    1.92 +		iResult = ETrue;
    1.93 +		}
    1.94 +
    1.95 +	CleanupStack::PopAndDestroy(2); //seq, parms
    1.96 +	User::RequestComplete(status, KErrNone);
    1.97 +	iActionState = CTestAction::EPostrequisite;
    1.98 +	}