secsrv_plat/cms_api/inc/CCMSX509Signed.h
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 #ifndef CCMSX509Signed_H
       
    20 #define CCMSX509Signed_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include 	"CCMSSequence.h"
       
    24 
       
    25 // FORWARD DECLARATIONS
       
    26 class CCMSX509AlgorithmIdentifier;
       
    27 
       
    28 // CLASS DECLARATION
       
    29 /**
       
    30 *  Base class for X.509 SIGNED -type modules
       
    31 *
       
    32 *  ASN.1 notation:
       
    33 *
       
    34 * SIGNATURE{ToBeSigned} ::= SEQUENCE {
       
    35 *  algorithmIdentifier  AlgorithmIdentifier,
       
    36 *  encrypted            ENCRYPTED-HASH{ToBeSigned}
       
    37 * }
       
    38 * 
       
    39 * SIGNED{ToBeSigned} ::= SEQUENCE {
       
    40 *   toBeSigned  ToBeSigned,
       
    41 *   COMPONENTS OF SIGNATURE{ToBeSigned}
       
    42 * }
       
    43 *
       
    44 *  @lib cms.lib
       
    45 *  @since 2.8
       
    46 */
       
    47 class CCMSX509Signed : public CCMSSequence
       
    48     {
       
    49 
       
    50     public: // Destructor
       
    51 
       
    52         /**
       
    53         * Destructor.
       
    54         */
       
    55         virtual ~CCMSX509Signed();
       
    56         
       
    57     public: // New functions
       
    58 
       
    59         /**
       
    60          * Getter for algorithmIdentifier
       
    61          * @since 2.8
       
    62          * @return Algorithm identifier
       
    63          */
       
    64         IMPORT_C const CCMSX509AlgorithmIdentifier&
       
    65         AlgorithmIdentifier() const;
       
    66 
       
    67         /**
       
    68          * Getter for encrypted
       
    69          * @since 2.8
       
    70          * @return encrypted (BIT STRING in a descriptor)
       
    71          */
       
    72         IMPORT_C const TDesC8& Encrypted() const;
       
    73         
       
    74         /**
       
    75          * Setter for algorithmIdentifier. Makes a copy.
       
    76          * @since 2.8
       
    77          * @param aAlgorithmIdentifier Algorithm identifier
       
    78          */
       
    79         IMPORT_C void SetAlgorithmIdentifierL(
       
    80             const CCMSX509AlgorithmIdentifier& aAlgorithmIdentifier );
       
    81 
       
    82         /**
       
    83          * Setter for encrypted. Makes a copy.
       
    84          * @since 2.8
       
    85          * @param aEncrypted bit string
       
    86          */
       
    87         IMPORT_C void SetEncryptedL( const TDesC8& aEncrypted );
       
    88         
       
    89     protected:  // New functions
       
    90        /**
       
    91         * C++ default constructor.
       
    92         */
       
    93         CCMSX509Signed( );
       
    94 
       
    95         /**
       
    96          * Constructs the member variables. Makes a copy of
       
    97          * the parameters
       
    98          */
       
    99         void BaseConstructL(
       
   100             const CCMSX509AlgorithmIdentifier& aAlgorithmIdentifier,
       
   101             const TDesC8& aEncrypted );
       
   102 
       
   103         /**
       
   104          * Creates a signed encoder.
       
   105          * @param aToBeSigned ToBeSigned (see the ASN.1 notation). The
       
   106          * object is popped from the cleanup stack.
       
   107          * @return signed sequence, left in the cleanup stack. 
       
   108          */
       
   109         CASN1EncSequence* SignAndPopLC( CASN1EncBase* aToBeSigned ) const;
       
   110 
       
   111         /**
       
   112          * Decodes algorithmIdentifier and encrypted parts from the
       
   113          * raw data.
       
   114          * @param aRawData data to be decoded
       
   115          * @param aAlgorithmIdentifier decoded algorithmIdentifier is
       
   116          * stored here
       
   117          * @param aEncrypted decoded encrypted is stored here
       
   118          * @return ToBeSigned in a generic decoder.
       
   119          */
       
   120         TASN1DecGeneric DecodeSignatureL(
       
   121             const TDesC8& aRawData,
       
   122             CCMSX509AlgorithmIdentifier*& aAlgorithmIdentifier,
       
   123             HBufC8*& aEncrypted ) const;
       
   124 
       
   125         /**
       
   126          * Decodes algorithmIdentifier and encrypted parts from an
       
   127          * array of items. The first item is returned, and the second
       
   128          * and third items are used in decoding process.
       
   129          * @param aItemArray array of items
       
   130          * @param aAlgorithmIdentifier decoded algorithmIdentifier is
       
   131          * stored here
       
   132          * @param aEncrypted decoded encrypted is stored here
       
   133          * @return ToBeSigned in a generic decoder.
       
   134          */
       
   135         TASN1DecGeneric DecodeSignatureArrayL(
       
   136             CArrayPtr< TASN1DecGeneric >& aItemArray,
       
   137             CCMSX509AlgorithmIdentifier*& aAlgorithmIdentifier,
       
   138             HBufC8*& aEncrypted ) const;
       
   139 
       
   140         
       
   141         
       
   142     protected: // Data
       
   143 
       
   144         // algorithmIdentifier, owned
       
   145         CCMSX509AlgorithmIdentifier* iAlgorithmIdentifier;
       
   146 
       
   147         // encrypted, owned
       
   148         HBufC8* iEncrypted;
       
   149         
       
   150     };
       
   151 
       
   152 #endif      // CCMSX509Signed_H
       
   153 
       
   154 // End of File