First public contribution.
2 * Copyright (c) 2005-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.
28 EXPORT_C CASN1EncEncoding::~CASN1EncEncoding()
33 // Set arbitrary initial values for tag type and class because they will be
34 // inited in ConstructL().
35 EXPORT_C CASN1EncEncoding::CASN1EncEncoding() :
36 CASN1EncBase(EASN1EOC, EUniversal)
40 EXPORT_C CASN1EncEncoding* CASN1EncEncoding::NewLC(const TDesC8& aEncoding)
42 CASN1EncEncoding* self = new (ELeave) CASN1EncEncoding;
43 CleanupStack::PushL(self);
44 self->ConstructL(aEncoding);
48 EXPORT_C CASN1EncEncoding* CASN1EncEncoding::NewL(const TDesC8& aEncoding)
50 CASN1EncEncoding* self = NewLC(aEncoding);
51 CleanupStack::Pop(self);
55 EXPORT_C CASN1EncEncoding* CASN1EncEncoding::NewLC(const TDesC8& aEncoding, TTagType aType, TASN1Class aClass)
57 CASN1EncEncoding* self = new (ELeave) CASN1EncEncoding;
58 CleanupStack::PushL(self);
59 self->ConstructL(aEncoding, aType, aClass);
63 void CASN1EncEncoding::ConstructL(const TDesC8& aEncoding)
65 // Use decoder to get information about the outer wrapper of the passed
67 TASN1DecGeneric decoder(aEncoding);
69 iClass = decoder.Class();
71 // Set this information so that the base class knows how to write
74 // Copy just the contents of the passed encoding.
75 iContents = decoder.GetContentDER().AllocL();
76 // Save this for base class writing functions.
77 iContentsLengthDER = iContents->Length();
78 // This is base class' method which initializes length of length
79 // encoding for proper DER writing.
80 CalculateLengthLengthDER();
83 void CASN1EncEncoding::ConstructL(const TDesC8& aEncoding, TTagType aType, TASN1Class aClass)
85 // Use decoder to get information about the outer wrapper of the passed
87 TASN1DecGeneric decoder(aEncoding);
91 // Set this information so that the base class knows how to write
93 SetTag(aType, aClass);
94 // Copy just the contents of the passed encoding.
95 iContents = decoder.GetContentDER().AllocL();
96 // Save this for base class writing functions.
97 iContentsLengthDER = iContents->Length();
98 // This is base class' method which initializes length of length
99 // encoding for proper DER writing.
100 CalculateLengthLengthDER();
104 // This method is not called but is necessary because it overrides a
105 // pure virtual function of the base class. The variable is properly
106 // initialized in ConstructL().
107 void CASN1EncEncoding::CalculateContentsLengthDER()
109 iContentsLengthDER = iContents->Length();
112 TBool CASN1EncEncoding::IsConstructed() const
117 // When this method is called by the base class write helper, the tag
118 // and length are already written.
119 void CASN1EncEncoding::WriteContentsDERL(TDes8& aBuf) const
121 aBuf.Copy(*iContents);