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.
21 EXPORT_C TASN1DecGeneric::TASN1DecGeneric(const TDesC8& aSource):
26 EXPORT_C void TASN1DecGeneric::InitL()
30 if(iEncoding.Length() < KASN1ObjectMinLength)
32 User::Leave(KErrArgument);
40 TInt LengthOfLength=1;
43 TInt encodingLength = iEncoding.Length();
45 if ((iEncoding[Pos]&0x1f)==0x1f)
47 // tag greater than 30
49 if (encodingLength <= Pos+1)
51 User::Leave(KErrArgument);
53 while (iEncoding[Pos]>=128)
56 T+=(TUint8)(iEncoding[Pos]&127); // this raises warning if TTagType is TUint8
58 if (encodingLength <= Pos+1)
60 User::Leave(KErrArgument);
64 T+=(TUint8)iEncoding[Pos];
68 T=(TUint8)(iEncoding[Pos]&0x1f);
73 TUint8 l = iEncoding[Pos];
76 // this is a length of length
77 if (encodingLength <= Pos+1)
79 User::Leave(KErrArgument);
81 LengthOfLength=iEncoding[Pos++]&127;
83 while (LengthOfLength)
85 if (encodingLength <= Pos+1)
87 User::Leave(KErrArgument);
90 Length+=iEncoding[Pos++];
96 //this is constructed, indefinite length: we don't support this
97 User::Leave(KErrNotSupported);
101 //this is a straight length
102 Length = iEncoding[Pos++];
104 if (((Length+Pos)>encodingLength) || (Length < 0))
106 User::Leave(KErrArgument);
108 iStartOfContents = Pos;
112 EXPORT_C TPtrC8 TASN1DecGeneric::GetContentDER(void) const
114 return iEncoding.Mid(iStartOfContents, iLength);
117 EXPORT_C TInt TASN1DecGeneric::LengthDER(void) const
119 return iLength+iStartOfContents;
122 EXPORT_C TInt TASN1DecGeneric::LengthDERContent(void) const
127 EXPORT_C TInt TASN1DecGeneric::LengthDERHeader() const
129 return LengthDER() - LengthDERContent();
132 EXPORT_C TPtrC8 TASN1DecGeneric::Encoding() const
134 return iEncoding.Left(LengthDER());
137 EXPORT_C TTagType TASN1DecGeneric::Tag() const
138 // we can inline this
143 EXPORT_C TASN1Class TASN1DecGeneric::Class() const
144 // we can inline this