cms/src/CCMSRecipientInfo.cpp
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2004 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 "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 FILES
       
    20 #include    "CCMSRecipientInfo.h"
       
    21 #include "CCMSX509AlgorithmIdentifier.h"
       
    22 
       
    23 // ============================ MEMBER FUNCTIONS ===============================
       
    24 
       
    25 // -----------------------------------------------------------------------------
       
    26 // CCMSRecipientInfo::CCMSRecipientInfo
       
    27 // C++ default constructor can NOT contain any code, that
       
    28 // might leave.
       
    29 // -----------------------------------------------------------------------------
       
    30 //
       
    31 CCMSRecipientInfo::CCMSRecipientInfo( TInt aVersion )
       
    32     : iVersion( aVersion )
       
    33     {
       
    34     }
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // CCMSRecipientInfo::BaseConstructL
       
    38 // Constructs the member variables. Makes a copy of aKeyEncryptionAlgorithm.
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 void CCMSRecipientInfo::BaseConstructL(
       
    42     const CCMSX509AlgorithmIdentifier& aKeyEncryptionAlgorithm )
       
    43     {
       
    44     SetKeyEncryptionAlgorithmL( aKeyEncryptionAlgorithm );
       
    45     }
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // CCMSRecipientInfo::AddVersionL
       
    49 // Adds version encoding to root sequence
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 void CCMSRecipientInfo::AddVersionL( CASN1EncSequence* aRoot ) const
       
    53     {
       
    54     CASN1EncInt* version = CASN1EncInt::NewLC( iVersion );
       
    55     aRoot->AddAndPopChildL( version );
       
    56     }
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CCMSRecipientInfo::AddKeyEncryptionAlgorithmL
       
    60 // Adds KeyEncryptionAlgorithm encoding to root sequence
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 void CCMSRecipientInfo::AddKeyEncryptionAlgorithmL( CASN1EncSequence* aRoot ) const
       
    64     {
       
    65     HBufC8* encodedKeyEncryptionAlgorithm = NULL;
       
    66     iKeyEncryptionAlgorithm->EncodeL( encodedKeyEncryptionAlgorithm );
       
    67     CleanupStack::PushL( encodedKeyEncryptionAlgorithm );
       
    68     CASN1EncEncoding* keyEncryptionAlgorithm =
       
    69         CASN1EncEncoding::NewLC( *encodedKeyEncryptionAlgorithm );
       
    70     aRoot->AddAndPopChildL( keyEncryptionAlgorithm );
       
    71     CleanupStack::PopAndDestroy( encodedKeyEncryptionAlgorithm );
       
    72     }
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // CCMSRecipientInfo::~CCMSRecipientInfo
       
    76 // Destructor
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 CCMSRecipientInfo::~CCMSRecipientInfo()
       
    80     {
       
    81     delete iKeyEncryptionAlgorithm;
       
    82     }
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CCMSRecipientInfo::Version
       
    86 // Version getter
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 EXPORT_C TInt CCMSRecipientInfo::Version() const
       
    90     {
       
    91     return iVersion;
       
    92     }
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 // CCMSRecipientInfo::KeyEncryptionAlgorithm
       
    96 // KeyEncryptionAlgorithm getter
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 EXPORT_C const CCMSX509AlgorithmIdentifier&
       
   100 CCMSRecipientInfo::KeyEncryptionAlgorithm() const
       
   101     {
       
   102     return *iKeyEncryptionAlgorithm;
       
   103     }
       
   104 
       
   105 // -----------------------------------------------------------------------------
       
   106 // CCMSRecipientInfo::SetKeyEncryptionAlgorithmL
       
   107 // KeyEncryptionAlgorithm setter
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 EXPORT_C void CCMSRecipientInfo::SetKeyEncryptionAlgorithmL(
       
   111     const CCMSX509AlgorithmIdentifier& aKeyEncryptionAlgorithm )
       
   112     {
       
   113     CCMSX509AlgorithmIdentifier* algorithmIdentifier =
       
   114         CCMSX509AlgorithmIdentifier::NewL(
       
   115             aKeyEncryptionAlgorithm.AlgorithmIdentifier() );
       
   116     CleanupStack::PushL( algorithmIdentifier );
       
   117     const CAlgorithmIdentifier* digestAlgorithm =
       
   118         aKeyEncryptionAlgorithm.DigestAlgorithm();
       
   119     if( digestAlgorithm )
       
   120         {
       
   121         algorithmIdentifier->SetDigestAlgorithmL( digestAlgorithm );
       
   122         }
       
   123     CleanupStack::Pop( algorithmIdentifier );
       
   124     delete iKeyEncryptionAlgorithm;
       
   125     iKeyEncryptionAlgorithm = algorithmIdentifier;
       
   126     }
       
   127 
       
   128 
       
   129 //  End of File