os/security/cryptoservices/certificateandkeymgmt/pkcs7/pkcs7asn1.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 #include "pkcs7asn1.h"
    20 #include <asn1dec.h>
    21 
    22 CArrayPtr<TASN1DecGeneric>* PKCS7ASN1::DecodeSequenceLC(const TDesC8& aRawData)
    23 	{
    24 	CArrayPtr<TASN1DecGeneric>* items = NULL;
    25 	
    26 	// Check we've got a sequence
    27 	TASN1DecGeneric decGen(aRawData);
    28 	decGen.InitL();
    29 	if(decGen.Tag() != EASN1Sequence && decGen.Tag() != EASN1Set)
    30 		{
    31 		User::Leave(KErrArgument);
    32 		}
    33 	else
    34 		{
    35 		// Decode the sequence		
    36 		TASN1DecSequence decSeq;
    37 		items = decSeq.DecodeDERLC(decGen);
    38 		}
    39 	return items;
    40 	}
    41 
    42 CArrayPtr<TASN1DecGeneric>* PKCS7ASN1::DecodeSequenceLC(const TDesC8& aRawData,
    43 															const TInt aMinTerms,
    44 															const TInt aMaxTerms)
    45 	{
    46 	CArrayPtr<TASN1DecGeneric>* items = DecodeSequenceLC(aRawData);
    47 	TInt count = items->Count();
    48 	if(count < aMinTerms || count > aMaxTerms)
    49 		{
    50 		User::Leave(KErrArgument);
    51 		}
    52 
    53 	return items;
    54 	}