cryptoservices/certificateandkeymgmt/pkcs7/pkcs7excert.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 <pkcs7excert.h>
       
    22 #include "pkcs7asn1.h"
       
    23 #include <asn1dec.h>
       
    24 #include <x509cert.h>
       
    25 #include <asn1enc.h>
       
    26 
       
    27 //Implementation of PKCS7 Extended Certificate Set
       
    28 
       
    29 CPKCS7ExtendedCertificateOrCertificate* CPKCS7ExtendedCertificateOrCertificate::NewL(const TDesC8& aRawData)
       
    30 	{
       
    31 	CPKCS7ExtendedCertificateOrCertificate* self = new (ELeave) CPKCS7ExtendedCertificateOrCertificate();
       
    32 	CleanupStack::PushL(self);
       
    33 	self->ConstructL(aRawData);
       
    34 	CleanupStack::Pop(self);
       
    35 	return self;
       
    36 	}
       
    37 
       
    38 CPKCS7ExtendedCertificateOrCertificate::~CPKCS7ExtendedCertificateOrCertificate()
       
    39 	{
       
    40 	delete iCertificate;
       
    41 	}
       
    42 
       
    43 CPKCS7ExtendedCertificateOrCertificate::CPKCS7ExtendedCertificateOrCertificate()
       
    44 	{
       
    45 	}
       
    46 
       
    47 void CPKCS7ExtendedCertificateOrCertificate::ConstructL(const TDesC8& aRawData)
       
    48 	{
       
    49 	TASN1DecGeneric decGen(aRawData);
       
    50 	decGen.InitL();
       
    51 		
       
    52 	if (decGen.Tag()==EASN1Sequence && decGen.Class()==EUniversal)
       
    53 		{
       
    54 		// x509 certificates
       
    55 		iCertificate = CX509Certificate::NewL(aRawData);
       
    56 		}
       
    57 	else if (decGen.Tag()==0 && decGen.Class()==EContextSpecific)
       
    58 			{
       
    59 			// extended certificates not supported
       
    60 			User::Leave(KErrNotSupported);
       
    61 			}
       
    62 		else
       
    63 			{
       
    64 			User::Leave(KErrArgument);	
       
    65 			}		
       
    66 	}
       
    67 
       
    68 EXPORT_C const CX509Certificate& CPKCS7ExtendedCertificateOrCertificate::Certificate(void) const
       
    69 	{
       
    70 	return *iCertificate;
       
    71 	}