cryptoservices/certificateandkeymgmt/pkcs7/pkcs7asn1.cpp
changeset 0 2c201484c85f
child 8 35751d3474b7
equal deleted inserted replaced
-1:000000000000 0:2c201484c85f
       
     1 /*
       
     2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     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".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "pkcs7asn1.h"
       
    22 #include <asn1dec.h>
       
    23 
       
    24 CArrayPtr<TASN1DecGeneric>* PKCS7ASN1::DecodeSequenceLC(const TDesC8& aRawData)
       
    25 	{
       
    26 	CArrayPtr<TASN1DecGeneric>* items = NULL;
       
    27 	
       
    28 	// Check we've got a sequence
       
    29 	TASN1DecGeneric decGen(aRawData);
       
    30 	decGen.InitL();
       
    31 	if(decGen.Tag() != EASN1Sequence && decGen.Tag() != EASN1Set)
       
    32 		{
       
    33 		User::Leave(KErrArgument);
       
    34 		}
       
    35 	else
       
    36 		{
       
    37 		// Decode the sequence		
       
    38 		TASN1DecSequence decSeq;
       
    39 		items = decSeq.DecodeDERLC(decGen);
       
    40 		}
       
    41 	return items;
       
    42 	}
       
    43 
       
    44 CArrayPtr<TASN1DecGeneric>* PKCS7ASN1::DecodeSequenceLC(const TDesC8& aRawData,
       
    45 															const TInt aMinTerms,
       
    46 															const TInt aMaxTerms)
       
    47 	{
       
    48 	CArrayPtr<TASN1DecGeneric>* items = DecodeSequenceLC(aRawData);
       
    49 	TInt count = items->Count();
       
    50 	if(count < aMinTerms || count > aMaxTerms)
       
    51 		{
       
    52 		User::Leave(KErrArgument);
       
    53 		}
       
    54 
       
    55 	return items;
       
    56 	}