sl@0: /* sl@0: * Copyright (c) 1998-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: * This file contains the implementation of the ASN1 integer class. sl@0: * As noted in Notes.txt there are two approaches to the storage of data by sl@0: * this class, it can either hold a copy of the data or a pointer to something sl@0: * else which holds a copy of the data. sl@0: * The object contained within this file encapsulates the ASN1 integer object sl@0: * as described in X208 section 14 and the encoding described in X209 section sl@0: * 8. sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include "asn1dec.h" sl@0: #include sl@0: sl@0: EXPORT_C TASN1DecInteger::TASN1DecInteger() sl@0: sl@0: { sl@0: } sl@0: sl@0: EXPORT_C TInt TASN1DecInteger::DecodeDERShortL(const TDesC8& aSource,TInt& aPos) sl@0: { sl@0: TPtrC8 Source=aSource.Mid(aPos); sl@0: TASN1DecGeneric gen(Source); sl@0: gen.InitL(); sl@0: TInt res = DecodeDERShortL(gen); sl@0: aPos+=gen.LengthDER(); sl@0: return res; sl@0: } sl@0: sl@0: EXPORT_C TInt TASN1DecInteger::DecodeDERShortL(const TASN1DecGeneric& aSource) sl@0: { sl@0: TInt res = 0; sl@0: TPtrC8 ptr(aSource.GetContentDER()); sl@0: //stop stupid compiler warning sl@0: TUint length = (TUint)(ptr.Length()); sl@0: if (length == 0) // DEF055722 sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: if (length > sizeof(TInt)) sl@0: { sl@0: User::Leave(KErrTooBig); sl@0: } sl@0: TInt8 i; sl@0: if (ptr[0]&128) sl@0: { sl@0: res = -1; sl@0: } sl@0: for (i=0;i