First public contribution.
2 * Copyright (c) 2001-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 * Implementation for TASN1EncBase128 class.
20 #include "base128enc.h"
23 TASN1EncBase128DER::TASN1EncBase128DER(TUint aInt) : iInt(aInt), iLengthDER(0)
29 TUint TASN1EncBase128DER::LengthDER() const
35 void TASN1EncBase128DER::CalculateLengthDER()
46 void TASN1EncBase128DER::WriteDERL(TDes8& aBuf, TUint& aPos) const
48 __ASSERT_DEBUG(aBuf.Length() - aPos >= STATIC_CAST(TUint8, iLengthDER),
49 User::Leave(KErrBadDescriptor));
51 TInt last = aPos + iLengthDER - 1;
53 for (TUint cursor = last; cursor >= aPos; --cursor)
55 // Cast takes least significant 8 bits only (actually, we only need 7)
56 aBuf[cursor] = STATIC_CAST(TUint8, working);
57 aBuf[cursor] |= 0x80; // Top bit always set to 1...
60 // ...except top bit on last byte is 0