os/security/cryptoservices/certificateandkeymgmt/x509/x509keys.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 1998-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 <x509keys.h>
    20 #include <asn1dec.h>
    21 #include <asn1enc.h>
    22 #include <x509cert.h>
    23 #include "x509keyencoder.h"
    24 
    25 // TX509KeyEncoder Class Implementation
    26 
    27 TX509KeyEncoder::TX509KeyEncoder(TAlgorithmId aDigestAlg)
    28     : iDigestAlg(aDigestAlg)
    29 	{
    30 	}
    31 
    32 EXPORT_C  CASN1EncSequence* TX509KeyEncoder::EncodeDigestAlgorithmLC() const
    33 	{
    34 	CASN1EncSequence* digestAlgId = CASN1EncSequence::NewLC();
    35 
    36 	CASN1EncObjectIdentifier* oid = NULL;
    37 	
    38 	switch (iDigestAlg)
    39 		{
    40 		case EMD2:
    41 			oid = CASN1EncObjectIdentifier::NewLC(KMD2);
    42 			break;
    43 
    44 		case EMD5:
    45 			oid = CASN1EncObjectIdentifier::NewLC(KMD5);
    46 			break;
    47 
    48 		case ESHA1:
    49 			oid = CASN1EncObjectIdentifier::NewLC(KSHA1);
    50 			break;
    51 					
    52 		default:
    53 			User::Leave(KErrNotSupported);
    54 			break;			
    55 		}
    56 	digestAlgId->AddAndPopChildL(oid);
    57 	
    58 	// No parameters : NULL
    59 	CASN1EncNull* nullparams = CASN1EncNull::NewLC();
    60 	digestAlgId->AddAndPopChildL(nullparams);
    61 
    62 	return digestAlgId;
    63 	}