First public contribution.
2 * Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * This file contains the implementation of the ASN1 integer class.
16 * As noted in Notes.txt there are two approaches to the storage of data by
17 * this class, it can either hold a copy of the data or a pointer to something
18 * else which holds a copy of the data.
19 * The object contained within this file encapsulates the ASN1 integer object
20 * as described in X208 section 14 and the encoding described in X209 section
29 EXPORT_C TASN1DecInteger::TASN1DecInteger()
34 EXPORT_C TInt TASN1DecInteger::DecodeDERShortL(const TDesC8& aSource,TInt& aPos)
36 TPtrC8 Source=aSource.Mid(aPos);
37 TASN1DecGeneric gen(Source);
39 TInt res = DecodeDERShortL(gen);
40 aPos+=gen.LengthDER();
44 EXPORT_C TInt TASN1DecInteger::DecodeDERShortL(const TASN1DecGeneric& aSource)
47 TPtrC8 ptr(aSource.GetContentDER());
48 //stop stupid compiler warning
49 TUint length = (TUint)(ptr.Length());
50 if (length == 0) // DEF055722
52 User::Leave(KErrArgument);
54 if (length > sizeof(TInt))
56 User::Leave(KErrTooBig);
63 for (i=0;i<ptr.Length();i++)
71 EXPORT_C RInteger TASN1DecInteger::DecodeDERLongL(const TDesC8& aSource,TInt& aPos)
73 TPtrC8 Source=aSource.Right(aSource.Length() - aPos);
74 TASN1DecGeneric gen(Source);
76 RInteger res = DecodeDERLongL(gen);
77 aPos+=gen.LengthDER();
81 EXPORT_C RInteger TASN1DecInteger::DecodeDERLongL(const TASN1DecGeneric& aSource)
83 const TDesC8& data = aSource.GetContentDER();
84 // JCS 14/03/2003: Changed call to NewL from NewSignedL() because current
85 // problem in RInteger for signed code means this sometimes returns incorrect
86 // results causing failure in certstore testcode. However, making this change
87 // does cause problems in TASN1 now (posted defect DEF021796).
88 RInteger res = RInteger::NewL(data);//aSource.GetContentDER());