drm_plat/roap_api/inc/RoapEng.h
changeset 0 95b198f216e5
equal deleted inserted replaced
-1:000000000000 0:95b198f216e5
       
     1 /*
       
     2 * Copyright (c) 2002-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:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef ROAP_ENG_H
       
    20 #define ROAP_ENG_H
       
    21 
       
    22 // INCLUDES
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <hash.h>
       
    26 
       
    27 #include <RoapMessage.h>
       
    28 #include <RoapEngBase.h>
       
    29 #include <Oma2Agent.h>
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class CDrmProtectedRoParser;
       
    33 class RDRMClockClient;
       
    34 class CDcfRep;
       
    35 class CX509Certificate;
       
    36 class COCSPResponse;
       
    37 
       
    38 namespace Roap
       
    39 {
       
    40 class CRoapParser;
       
    41 class CRoapSigner;
       
    42 class CRIHello;
       
    43 class CRegistrationResp;
       
    44 class CRightsResp;
       
    45 class CJoinDomainResp;
       
    46 class CLeaveDomainResp;
       
    47 class RRoapStorageClient;
       
    48 
       
    49 
       
    50 // CLASS DECLARATION
       
    51 class CRoapEng: public CRoapEngBase
       
    52     {
       
    53 
       
    54     public:     // Constructors and destructor
       
    55 
       
    56          /**
       
    57         * Two-phased constructor.
       
    58         */
       
    59         IMPORT_C static CRoapEng* NewL( );
       
    60         
       
    61         /**
       
    62         * Destructor.
       
    63         */
       
    64         IMPORT_C ~CRoapEng();
       
    65 
       
    66     protected:
       
    67     
       
    68         // Needed in trigger parsing phase
       
    69 
       
    70         CRoapTrigger* ParseTriggerL( const TDesC8& aXmlTrigger );
       
    71 
       
    72         void GetRIContextL( TBool& aRegistered, const TDesC8& aRiId );
       
    73         
       
    74         void  GetDomainContextL( TBool& aIsJoined,
       
    75                                  TBool& aIsValidGeneration,
       
    76                                  const TDesC8& aDomainId );
       
    77 
       
    78         
       
    79         
       
    80         // For creating ROAP requests
       
    81         
       
    82         void CreateReqMessageL();
       
    83         
       
    84         CRoapMessage* CreateDeviceHelloL();
       
    85         
       
    86         CRoapMessage* CreateRegistrationRequestL();
       
    87         
       
    88         CRoapMessage* CreateRightsRequestL();
       
    89         
       
    90         CRoapMessage* CreateJoinDomainRequestL();
       
    91         
       
    92         CRoapMessage* CreateLeaveDomainRequestL();
       
    93         
       
    94         CRoapMessage* CreateMeteringReportRequestL();
       
    95         
       
    96         
       
    97         // For handling ROAP responses
       
    98         
       
    99         void HandleRoapResponseL( const TDesC8& aXmlResponse );
       
   100         
       
   101         void HandleRIHelloPduL( const TDesC8& aRiHello );
       
   102         
       
   103         void HandleReqResponsePduL( const TDesC8& aRegResp );
       
   104         
       
   105         void HandleRightsResponsePduL( const TDesC8& aRightsResp, TBool aOnePass );
       
   106         
       
   107         void HandleJoinDomainResponsePduL( const TDesC8& aJoinResp );
       
   108         
       
   109         void HandleLeaveDomainResponsePduL( const TDesC8& aLeaveResp );
       
   110         
       
   111         void HandleMeteringReportResponsePduL( const TDesC8& aMeteringResp );
       
   112                  
       
   113         void HandleMultipartL();
       
   114         
       
   115         
       
   116         // For signing and certificate checking
       
   117         
       
   118         HBufC8* SignMessageL( const TDesC8& aMessage ) const;
       
   119         
       
   120         TBool VerifySignatureL( const TDesC8& aMessage,
       
   121                                 const TDesC8& aSignature,
       
   122                                 const RPointerArray< HBufC8 >& aCertificateChain ) const;
       
   123                                 
       
   124         TBool VerifyTriggerSignatureL( const TDesC8& aXmlTrigger,
       
   125                                          const CRoapTrigger& aTrigger  ) const;
       
   126                                 
       
   127         TBool VerifyCertificateChainL( const RPointerArray< HBufC8 >& aCertificateChain,
       
   128                                        const RPointerArray< HBufC8 >& aOcspResponses ) const;
       
   129                                        
       
   130         TBool VerifyOcspResponsesL( const RPointerArray< HBufC8 >& aOcspResponses,
       
   131                                     const TDesC8& aRiCaCert,
       
   132                                     const RPointerArray< HBufC8 >& aCertSerialNums ) const;
       
   133                                     
       
   134         TBool VerifyOcspCertChainL( COCSPResponse& aResponse,
       
   135                                     const TDesC8& aRootCert,
       
   136                                     CX509Certificate*& aOcspCert ) const;
       
   137                                     
       
   138         TBool ValidateRiCertificateL( const CX509Certificate* aCert );
       
   139 
       
   140 
       
   141         // For fetching data for ROAP requests
       
   142         
       
   143 		RPointerArray<HBufC8> GetCertificateChainL() const;
       
   144 		
       
   145 		RPointerArray<HBufC8> GetSupportedAlgorithmsL() const;
       
   146 		
       
   147 		void GetDeviceDetailsL( HBufC8*& aManufacturer,
       
   148                                 HBufC8*& aModel,
       
   149                                 HBufC8*& aVersion );
       
   150                                          
       
   151         HBufC8* GetOCSPResponderKeyHashL() const;
       
   152                                 
       
   153         
       
   154         // For transaction tracking
       
   155         
       
   156         void FetchTransactionIDL( RPointerArray<HBufC8>& aTransIDs,
       
   157                                   RPointerArray<HBufC8>& aContentIDs );
       
   158         
       
   159         void InsertTransactionIDL( RPointerArray<HBufC8>& aTransIDs,
       
   160                                    RPointerArray<HBufC8>& aContentIDs );
       
   161 
       
   162         
       
   163         // For fetching and setting DRM Time
       
   164         
       
   165         TTime GetDrmTimeL();
       
   166         
       
   167         void SetDrmTimeSecureL();
       
   168         
       
   169         void AdjustDrmTimeL(  const RPointerArray< HBufC8 >& aOcspResponses,
       
   170                              TDesC8& aRegReqNonce ) const;
       
   171                              
       
   172                              
       
   173         // For storing a Domain RO in implicit Join Domain case
       
   174         void StoreDomainRightsL();
       
   175         
       
   176         // Inserting domain ROs after receiving                     
       
   177         void InsertDomainRosL();
       
   178 
       
   179         // For mapping ROAP status to error code
       
   180         TInt MapStatusL();
       
   181         
       
   182         // For checking is the root certificate issued by CMLA
       
   183         void IsTimeUpdateAllowedL( const RPointerArray<HBufC8>& aCertChain,
       
   184                                    const RPointerArray<HBufC8>& aOcspResponses,
       
   185                                    TBool& aIsAllowed ) const;
       
   186       
       
   187           
       
   188         TBool ValidateRiIdL( TDesC8& aRiId, TDesC8& aCertBuf );
       
   189    
       
   190                 // Update the status of transaction tracking variable	     
       
   191         void UpdateTransactionTrackingStatusL();
       
   192         
       
   193         // Creates list of device IDs for Multi-PKI
       
   194         TInt CreateDeviceIdHashArrayL( RPointerArray<TDesC8>& aIdArray);
       
   195           
       
   196     private:
       
   197 
       
   198         CRoapEng();
       
   199         
       
   200         void ConstructL();
       
   201         
       
   202         enum TTransStatus
       
   203             {
       
   204             ENotAsked,
       
   205             EForbidden,
       
   206             EAllowed
       
   207             };
       
   208         
       
   209     private:
       
   210     
       
   211     	CRoapParser* iParser;
       
   212     	CRoapSigner* iSigner;
       
   213     	RRoapStorageClient* iStorageClient;
       
   214     	RDRMClockClient* iClockClient;
       
   215     	CDcfRep* iDcfRep;
       
   216     	TInt iRoapStatus;
       
   217     	CDrmProtectedRoParser* iRoParser;  	
       
   218     	TBool iCertNeeded;
       
   219     	TBool iRiSupportsCertCaching;
       
   220     	HBufC8* iDeviceId;
       
   221     	TTransStatus iTransStatus;
       
   222     	TKeyTransportScheme iSelectedAlgorithms;
       
   223     	TBuf8< SHA1_HASH > iSelectedRoot;
       
   224     	TBuf8< KDomainIdLength > iDomainId;
       
   225     	TBuf8< SHA1_HASH > iRiId;
       
   226         TBuf8< KMaxRoapVersionLength > iRiVersion;
       
   227         RPointerArray< HBufC8 > iRiAlgorithms;
       
   228         TBool iDeviceTimeError;
       
   229         TBuf8< KDeviceNonceLength > iRegReqNonce; // for DRM Time sync
       
   230         TBool iSecureTime;
       
   231         TInt iZone;
       
   232     };
       
   233 }
       
   234 
       
   235 #endif /* def ROAP_ENG_H */