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