First public contribution.
2 * Copyright (c) 2000-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 directory string ASN1 object
24 This file contains the implementation of the following ASN1 data structures:
26 DirectoryString ::= CHOICE {
27 teletexString TeletexString (SIZE (1..MAX)),
28 printableString PrintableString (SIZE (1..MAX)),
29 universalString UniversalString (SIZE (1..MAX)),
30 utf8String UTF8String (SIZE (1..MAX)),
31 bmpString BMPString (SIZE(1..MAX)) }
35 TASN1DecX500DirectoryString::TASN1DecX500DirectoryString(void):
40 HBufC* TASN1DecX500DirectoryString::DecodeDERL(const TDesC8& aSource,TInt& aPos, TInt aMaxLength)
43 TPtrC8 Ptr=aSource.Right(aSource.Length()-aPos);
44 TASN1DecGeneric gen(Ptr);
46 aPos+=gen.LengthDER();
47 HBufC* Object=DecodeContentsL(gen, aMaxLength);
51 HBufC* TASN1DecX500DirectoryString::DecodeDERL(const TASN1DecGeneric& aSource, TInt aMaxLength)
54 return DecodeContentsL(aSource, aMaxLength);
57 HBufC* TASN1DecX500DirectoryString::DecodeContentsL(const TASN1DecGeneric& aSource, TInt aMaxLength)
60 switch (aSource.Tag())
62 case EASN1TeletexString:
64 TASN1DecTeletexString tStr;
65 res = tStr.DecodeDERL(aSource);
68 case EASN1PrintableString:
70 TASN1DecPrintableString pStr;
71 res = pStr.DecodeDERL(aSource);
76 TASN1DecIA5String pStr;
77 res = pStr.DecodeDERL(aSource);
82 TASN1DecUTF8String pStr;
83 res = pStr.DecodeDERL(aSource);
88 TASN1DecBMPString pStr;
89 res = pStr.DecodeDERL(aSource);
94 User::Leave(KErrNotSupported);
98 if (res->Length() > aMaxLength)
101 User::Leave(KErrArgument);
106 void TASN1DecX500DirectoryString::SetMaxLength(TInt aLength)
107 // perhaps this should have some kind of testing to make sure the current
108 // contents are valid...this is not as easy as it might first appear, the
109 // contents might be eight or sixteen bits.