sl@0: /* sl@0: * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * This file contains the implementation of the BMPString ASN1 object. sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #include sl@0: sl@0: sl@0: EXPORT_C TASN1DecBMPString::TASN1DecBMPString(void) sl@0: { sl@0: } sl@0: sl@0: EXPORT_C TInt TASN1DecBMPString::CheckValid(const TDesC8& /*aString*/) sl@0: { sl@0: return KErrNone; sl@0: } sl@0: sl@0: /** sl@0: Decodes an ASN.1 format BMP string. sl@0: @param aSource ASN.1 BMP string to be decoded. sl@0: @param aPos Offset in aSource from where decoding starts. sl@0: @return On return, a pointer to a buffer containing the decoded BMP string. sl@0: */ sl@0: EXPORT_C HBufC* TASN1DecBMPString::DecodeDERL(const TDesC8& aSource,TInt& aPos) sl@0: { sl@0: TPtrC8 Source=aSource.Mid(aPos); sl@0: TASN1DecGeneric gen(Source); sl@0: gen.InitL(); sl@0: HBufC* res = DecodeContentsL(gen.GetContentDER()); sl@0: return res; sl@0: } sl@0: sl@0: /** sl@0: Decodes an ASN.1 format BMP string. sl@0: @param aSource ASN.1 BMP string to be decoded. sl@0: @return On return, a pointer to a buffer containing the decoded BMP string. sl@0: */ sl@0: EXPORT_C HBufC* TASN1DecBMPString::DecodeDERL(const TASN1DecGeneric& aSource) sl@0: { sl@0: return DecodeContentsL(aSource.GetContentDER()); sl@0: } sl@0: sl@0: HBufC* TASN1DecBMPString::DecodeContentsL(const TDesC8& aSource) sl@0: { sl@0: TInt len = aSource.Length()/2; sl@0: HBufC* res = HBufC::NewL(len); sl@0: const TUint16* data16 = reinterpret_cast(aSource.Ptr()); sl@0: TPtr pRes = res->Des(); sl@0: pRes.Copy(data16, len); sl@0: return res; sl@0: }