cryptoservices/certificateandkeymgmt/x509/X509time.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 "X509time.h"
       
    20 
       
    21 TASN1DecX509Time::TASN1DecX509Time()
       
    22 
       
    23 	{
       
    24 	}
       
    25 
       
    26 TTime TASN1DecX509Time::DecodeDERL(const TDesC8& aSource,TInt& aPos)
       
    27 
       
    28 	{
       
    29 	TPtrC8 Source=aSource.Mid(aPos);
       
    30 	TASN1DecGeneric Gen(Source);
       
    31 	Gen.InitL();
       
    32 	aPos+=Gen.LengthDER();
       
    33 	TTime t = TASN1DecX509Time::DecodeContentsL(Gen);
       
    34 	return t;
       
    35 	}
       
    36 
       
    37 TTime TASN1DecX509Time::DecodeDERL(const TASN1DecGeneric& aSource)
       
    38 	{
       
    39 	return DecodeContentsL(aSource);
       
    40 	}
       
    41 
       
    42 TTime TASN1DecX509Time::DecodeContentsL(const TASN1DecGeneric& aSource)
       
    43 	{
       
    44 	TTime result;
       
    45 	result.HomeTime();
       
    46 
       
    47 	switch (aSource.Tag())
       
    48 		{
       
    49 	case EASN1UTCTime:
       
    50 		{
       
    51 		TASN1DecUTCTime encT;
       
    52 		result = encT.DecodeDERL(aSource);
       
    53 		break;
       
    54 		}
       
    55 	case EASN1GeneralizedTime:
       
    56 		{
       
    57 		TASN1DecGeneralizedTime encT;
       
    58 		result = encT.DecodeDERL(aSource);
       
    59 		break;
       
    60 		}
       
    61 	default:
       
    62 		User::Leave(KErrArgument);
       
    63 		break;
       
    64 		}
       
    65 
       
    66 	return result;
       
    67 	}