cryptoservices/certificateandkeymgmt/x509/x509keys.cpp
changeset 0 2c201484c85f
child 8 35751d3474b7
equal deleted inserted replaced
-1:000000000000 0:2c201484c85f
       
     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 
       
    24 // TX509KeyEncoder Class Implementation
       
    25 
       
    26 TX509KeyEncoder::TX509KeyEncoder(TAlgorithmId aDigestAlg)
       
    27     : iDigestAlg(aDigestAlg)
       
    28 	{
       
    29 	}
       
    30 
       
    31 EXPORT_C  CASN1EncSequence* TX509KeyEncoder::EncodeDigestAlgorithmLC() const
       
    32 	{
       
    33 	CASN1EncSequence* digestAlgId = CASN1EncSequence::NewLC();
       
    34 
       
    35 	CASN1EncObjectIdentifier* oid = NULL;
       
    36 	
       
    37 	switch (iDigestAlg)
       
    38 		{
       
    39 		case EMD2:
       
    40 			oid = CASN1EncObjectIdentifier::NewLC(KMD2);
       
    41 			break;
       
    42 
       
    43 		case EMD5:
       
    44 			oid = CASN1EncObjectIdentifier::NewLC(KMD5);
       
    45 			break;
       
    46 
       
    47 		case ESHA1:
       
    48 			oid = CASN1EncObjectIdentifier::NewLC(KSHA1);
       
    49 			break;
       
    50 					
       
    51 		default:
       
    52 			User::Leave(KErrNotSupported);
       
    53 			break;			
       
    54 		}
       
    55 	digestAlgId->AddAndPopChildL(oid);
       
    56 	
       
    57 	// No parameters : NULL
       
    58 	CASN1EncNull* nullparams = CASN1EncNull::NewLC();
       
    59 	digestAlgId->AddAndPopChildL(nullparams);
       
    60 
       
    61 	return digestAlgId;
       
    62 	}