sl@0: /* sl@0: * Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * Implementation for testing null object encoding/decoding sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include "testnull.h" sl@0: #include "tasn1normaltest.h" sl@0: #include sl@0: #include sl@0: sl@0: #include sl@0: sl@0: CTestNull* CTestNull::NewL(CASN1NormalTest &aASN1Action) sl@0: { sl@0: CTestNull* test = new (ELeave) CTestNull(aASN1Action); sl@0: return test; sl@0: } sl@0: sl@0: CTestNull::CTestNull(CASN1NormalTest &aASN1Action) : CTestBase(aASN1Action) sl@0: { sl@0: }; sl@0: sl@0: void CTestNull::GetName(TDes& aBuf) sl@0: { sl@0: aBuf.Copy(_L("Test Null")); sl@0: } sl@0: sl@0: TBool CTestNull::PerformTestsL(CConsoleBase& aConsole) sl@0: { sl@0: // Get the encoder and decoder sl@0: CASN1EncNull* encoder = CASN1EncNull::NewLC(); sl@0: TASN1DecNull decoder; sl@0: sl@0: // Prepare a buffer sl@0: TInt totalLength = encoder->LengthDER(); sl@0: HBufC8* buf = HBufC8::NewMaxLC(totalLength); sl@0: TPtr8 tBuf = buf->Des(); sl@0: sl@0: // Write into the buffer sl@0: TUint writeLength = 0; sl@0: encoder->WriteDERL(tBuf, writeLength); sl@0: sl@0: // Read it out again + check lengths sl@0: TInt readLength = 0; sl@0: decoder.DecodeDERL(tBuf, readLength); sl@0: sl@0: if (writeLength != STATIC_CAST(TUint, readLength)) sl@0: { sl@0: aConsole.Write(_L("ERROR!\n")); sl@0: iASN1Action.ReportProgressL(KErrASN1EncodingError, 1, 1); sl@0: CleanupStack::PopAndDestroy(2); // buf, encoder sl@0: return(EFalse); sl@0: } sl@0: else sl@0: { sl@0: iASN1Action.ReportProgressL(KErrNone, 1, 1); sl@0: CleanupStack::PopAndDestroy(2); // buf, encoder sl@0: return(ETrue); sl@0: } sl@0: } sl@0: