adaptationlayer/tsy/nokiatsy_dll/src/cmmcustommesshandler.cpp
changeset 5 8ccc39f9d787
parent 0 63b37f68c1ce
child 7 fa67e03b87df
equal deleted inserted replaced
4:510c70acdbf6 5:8ccc39f9d787
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description: 
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    30 
    30 
    31 #include <tisi.h>
    31 #include <tisi.h>
    32 #include <call_modemisi.h>
    32 #include <call_modemisi.h>
    33 #include <csdisi.h>
    33 #include <csdisi.h>
    34 #include <gssisi.h>
    34 #include <gssisi.h>
    35 
       
    36 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
       
    37 // Removed for Bridge camp!
       
    38 #include <mtcisi.h>
       
    39 #endif
       
    40 
       
    41 #include <infoisi.h>
    35 #include <infoisi.h>
    42 #include <net_modemisi.h>
    36 #include <net_modemisi.h>
    43 #include <uiccisi.h>
    37 #include <uiccisi.h>
    44 #include <ss_wmisi.h>
    38 #include <ss_wmisi.h>
    45 // #include <permisi.h> To be done in CPS
    39 // #include <permisi.h> To be done in CPS
    50 #include <ctsy/serviceapi/mmtsy_ipcdefs.h>
    44 #include <ctsy/serviceapi/mmtsy_ipcdefs.h>
    51 
    45 
    52 #include <ctsy/serviceapi/gsmerror.h>
    46 #include <ctsy/serviceapi/gsmerror.h>
    53 #include <etelmmerr.h>
    47 #include <etelmmerr.h>
    54 
    48 
    55 #include "osttracedefinitions.h"
    49 #include "OstTraceDefinitions.h"
    56 #ifdef OST_TRACE_COMPILER_IN_USE
    50 #ifdef OST_TRACE_COMPILER_IN_USE
    57 #include "cmmcustommesshandlertraces.h"
    51 #include "cmmcustommesshandlerTraces.h"
    58 #endif
    52 #endif
    59 
    53 
    60 // EXTERNAL DATA STRUCTURES
    54 // EXTERNAL DATA STRUCTURES
    61     //None
    55     //None
    62 
    56 
   281     aPhoNetReceiver->RegisterL(
   275     aPhoNetReceiver->RegisterL(
   282         customMessHandler,
   276         customMessHandler,
   283         PN_GSS,
   277         PN_GSS,
   284         GSS_HSXPA_USER_SETTING_IND );
   278         GSS_HSXPA_USER_SETTING_IND );
   285 
   279 
   286 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
       
   287     // MTC
       
   288     // Removed for Bridge camp
       
   289     aPhoNetReceiver->RegisterL(
       
   290         customMessHandler,
       
   291         PN_MTC,
       
   292         MTC_RAT_QUERY_RESP );
       
   293 #endif
       
   294 
       
   295     // PMM
   280     // PMM
   296     /* To be done in CPS
   281     /* To be done in CPS
   297     aPhoNetReceiver->RegisterL( customMessHandler,
   282     aPhoNetReceiver->RegisterL( customMessHandler,
   298         PN_PERMANENT_DATA,
   283         PN_PERMANENT_DATA,
   299         PERM_PM_RECORD_READ_RESP );
   284         PERM_PM_RECORD_READ_RESP );
   342     iECIDInfo.iCID = 0; // Cell identity
   327     iECIDInfo.iCID = 0; // Cell identity
   343     iECIDInfo.iLAC = 0; // Location area code
   328     iECIDInfo.iLAC = 0; // Location area code
   344 
   329 
   345     // Initialize Call Life Timer value.
   330     // Initialize Call Life Timer value.
   346     iCallLifeTimer = KCallLifeTimerNotSet;
   331     iCallLifeTimer = KCallLifeTimerNotSet;
   347     
   332 
   348     // initialize ISim application activation status
   333     // initialize ISim application activation status
   349     iIsimApplActivated = EFalse;
   334     iIsimApplActivated = EFalse;
   350     }
   335     }
   351 
   336 
   352 // -----------------------------------------------------------------------------
   337 // -----------------------------------------------------------------------------
   508                     }
   493                     }
   509                 }
   494                 }
   510             break;
   495             break;
   511             }
   496             }
   512 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
   497 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
   513         // Removed for Bridge camp
       
   514         case PN_MTC:
       
   515             {
       
   516             switch( messageId )
       
   517                 {
       
   518                 case MTC_RAT_QUERY_RESP:
       
   519                     {
       
   520                     MtcRatQueryResp( aIsiMessage );
       
   521                     break;
       
   522                     }
       
   523                 default:
       
   524                     {
       
   525 TFLOGSTRING("TSY: CMmCustomMessHandler::ReceiveMessageL - switch resource - case PN_MTC, switch messageId - default");
       
   526 OstTrace0( TRACE_NORMAL, DUP5_CMMCUSTOMMESSHANDLER_RECEIVEMESSAGEL, "CMmCustomMessHandler::ReceiveMessageL- switch resource - case PN_MTC, switch messageId - default" );
       
   527                     break;
       
   528                     }
       
   529                 }
       
   530             break;
       
   531             }
       
   532 #endif /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
   533 
       
   534 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
       
   535         case PN_INFO:
   498         case PN_INFO:
   536 #else /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
   499 #else /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
   537         case PN_MODEM_INFO:
   500         case PN_MODEM_INFO:
   538 #endif /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
   501 #endif /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
   539             {
   502             {
  2017       0 : &telNumber );
  1980       0 : &telNumber );
  2018 
  1981 
  2019   // packed parameter: TBool result
  1982   // packed parameter: TBool result
  2020   CMmDataPackage dataPackage;
  1983   CMmDataPackage dataPackage;
  2021   dataPackage.PackData( &result );
  1984   dataPackage.PackData( &result );
  2022   
  1985 
  2023   TFLOGSTRING2( "TSY: TSY: CMmCustomMessHandler::CallEmergencyNbrCheckResp status: %d", status);
  1986   TFLOGSTRING2( "TSY: TSY: CMmCustomMessHandler::CallEmergencyNbrCheckResp status: %d", status);
  2024   TFLOGSTRING2( "TSY: TSY: CMmCustomMessHandler::CallEmergencyNbrCheckResp emergency number: %S", &telNumber);
  1987   TFLOGSTRING2( "TSY: TSY: CMmCustomMessHandler::CallEmergencyNbrCheckResp emergency number: %S", &telNumber);
  2025     //we complete with KErrNone as there is always a value to return
  1988     //we complete with KErrNone as there is always a value to return
  2026   iMessageRouter->Complete( ECustomCheckEmergencyNumberIPC, &dataPackage,
  1989   iMessageRouter->Complete( ECustomCheckEmergencyNumberIPC, &dataPackage,
  2027     KErrNone );
  1990     KErrNone );
  2869     }
  2832     }
  2870 
  2833 
  2871 // -----------------------------------------------------------------------------
  2834 // -----------------------------------------------------------------------------
  2872 // CMmCustomMessHandler::GssCsServiceResp
  2835 // CMmCustomMessHandler::GssCsServiceResp
  2873 // Breaks a GSS_CS_SERVICE_RESP ISI message.
  2836 // Breaks a GSS_CS_SERVICE_RESP ISI message.
  2874 // completes ECustomSetSystemNetworkModeIPC, ECustomSetBandSelectionIPC or
  2837 // completes ECustomSetSystemNetworkModeIPC,
       
  2838 // ECustomGetCurrentSystemNetworkModesIPC, ECustomSetBandSelectionIPC or
  2875 // ECustomGetBandSelectionIPC with KErrNone to SOS layer.
  2839 // ECustomGetBandSelectionIPC with KErrNone to SOS layer.
  2876 // (other items were commented in a header).
  2840 // (other items were commented in a header).
  2877 // -----------------------------------------------------------------------------
  2841 // -----------------------------------------------------------------------------
  2878 //
  2842 //
  2879 void CMmCustomMessHandler::GssCsServiceResp (
  2843 void CMmCustomMessHandler::GssCsServiceResp (
  2880         const TIsiReceiveC& aIsiMessage ) // Received isi message
  2844         const TIsiReceiveC& aIsiMessage ) // Received isi message
  2881     {
  2845     {
  2882     TFLOGSTRING( "TSY: CMmCustomMessHandler::GssCsServiceResp" );
  2846 TFLOGSTRING( "TSY: CMmCustomMessHandler::GssCsServiceResp" );
  2883 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_GSSCSSERVICERESP, "CMmCustomMessHandler::GssCsServiceResp" );
  2847 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_GSSCSSERVICERESP, "CMmCustomMessHandler::GssCsServiceResp" );
  2884 
  2848 
  2885     TUint8 transactId ( aIsiMessage.Get8bit(
  2849     TUint8 transactId ( aIsiMessage.Get8bit(
  2886         ISI_HEADER_SIZE + GSS_CS_SERVICE_RESP_OFFSET_TRANSID ) );
  2850         ISI_HEADER_SIZE + GSS_CS_SERVICE_RESP_OFFSET_TRANSID ) );
  2887 
  2851 
  2888     TUint8 operation ( aIsiMessage.Get8bit(
  2852     if ( KCustomTransId == transactId )
  2889         ISI_HEADER_SIZE + GSS_CS_SERVICE_RESP_OFFSET_OPERATION ) );
  2853         {
  2890 
  2854         TUint8 operation ( aIsiMessage.Get8bit(
  2891     // GSS_SELECTED_RAT_WRITE (0x0E)
  2855             ISI_HEADER_SIZE + GSS_CS_SERVICE_RESP_OFFSET_OPERATION ) );
  2892     if ( KCustomTransId == transactId && GSS_SELECTED_RAT_WRITE == operation )
  2856 
  2893         {
  2857         // GSS_SELECTED_RAT_WRITE (0x0E)
  2894         //completion ResetGssServer method (no packed parameters)
  2858         if ( GSS_SELECTED_RAT_WRITE == operation )
  2895         TFLOGSTRING("TSY: CMmCustomMessHandler::GssCsServiceResp - Complete ECustomSetSystemNetworkModeIPC");
  2859             {
       
  2860 TFLOGSTRING("TSY: CMmCustomMessHandler::GssCsServiceResp - Complete ECustomSetSystemNetworkModeIPC");
  2896 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_GSSCSSERVICERESP, "CMmCustomMessHandler::GssCsServiceResp - Complete ECustomSetSystemNetworkModeIPC" );
  2861 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_GSSCSSERVICERESP, "CMmCustomMessHandler::GssCsServiceResp - Complete ECustomSetSystemNetworkModeIPC" );
  2897         iMessageRouter->Complete( ECustomSetSystemNetworkModeIPC, KErrNone );
  2862             //completion ResetGssServer method (no packed parameters)
  2898         }
  2863             iMessageRouter->Complete( ECustomSetSystemNetworkModeIPC, KErrNone );
  2899 
  2864             }
  2900 // not suppoted for S60 ver 3.2
  2865         // GSS_SELECTED_RAT_READ (0x9C)
       
  2866         else if ( GSS_SELECTED_RAT_READ == operation )
       
  2867             {
       
  2868 TFLOGSTRING("TSY: CMmCustomMessHandler::GssCsServiceResp - Complete ECustomGetCurrentSystemNetworkModesIPC");
       
  2869 OstTrace0( TRACE_NORMAL, DUP3_CMMCUSTOMMESSHANDLER_GSSCSSERVICERESP, "CMmCustomMessHandler::GssCsServiceResp - Complete ECustomGetCurrentSystemNetworkModesIPC" );
       
  2870             TInt err( KErrNone );
       
  2871             TUint32 ratMode ( RMmCustomAPI::KCapsNetworkModeDual );
       
  2872             TUint subblockOffset( 0 );
       
  2873             if ( KErrNone == aIsiMessage.FindSubBlockOffsetById(
       
  2874                 ISI_HEADER_SIZE + SIZE_GSS_CS_SERVICE_RESP,
       
  2875                 GSS_RAT_INFO,
       
  2876                 EIsiSubBlockTypeId8Len8,
       
  2877                 subblockOffset ) )
       
  2878                 {
       
  2879                 TUint8 mode = aIsiMessage.Get8bit( subblockOffset +
       
  2880                     GSS_RAT_INFO_OFFSET_FUNCTION );
       
  2881                 switch ( mode )
       
  2882                     {
       
  2883                     case GSS_GSM_RAT:
       
  2884                         {
       
  2885                         ratMode = RMmCustomAPI::KCapsNetworkModeGsm;
       
  2886                         break;
       
  2887                         }
       
  2888                     case GSS_UMTS_RAT:
       
  2889                         {
       
  2890                         ratMode = RMmCustomAPI::KCapsNetworkModeUmts;
       
  2891                         break;
       
  2892                         }
       
  2893                     case GSS_DUAL_RAT:
       
  2894                         {
       
  2895                         ratMode = RMmCustomAPI::KCapsNetworkModeDual;
       
  2896                         break;
       
  2897                         }
       
  2898                     default:
       
  2899                         {
       
  2900 TFLOGSTRING("TSY: CMmCustomMessHandler::GssCsServiceResp - Unrecognized RAT");
       
  2901 OstTrace0( TRACE_NORMAL, DUP4_CMMCUSTOMMESSHANDLER_GSSCSSERVICERESP, "CMmCustomMessHandler::GssCsServiceResp - Unrecognized RAT" );
       
  2902                         err = KErrGeneral;
       
  2903                         break;
       
  2904                         }
       
  2905                     }
       
  2906                 }
       
  2907             else
       
  2908                 {
       
  2909                 err = KErrGeneral;
       
  2910                 }
       
  2911             CMmDataPackage dataPackage;
       
  2912             dataPackage.PackData( &ratMode );
       
  2913             //completion ResetNetServer method (packed parameters)
       
  2914             iMessageRouter->Complete( ECustomGetCurrentSystemNetworkModesIPC,
       
  2915                 &dataPackage, err );
       
  2916             }
       
  2917     // not suppoted for S60 ver 3.2
  2901 #if ( NCP_COMMON_S60_VERSION_SUPPORT != S60_VERSION_32 )
  2918 #if ( NCP_COMMON_S60_VERSION_SUPPORT != S60_VERSION_32 )
  2902 
  2919         // GSS_SELECTED_BANDS_WRITE (0x9D)
  2903     // GSS_SELECTED_BANDS_WRITE (0x9D)
  2920         else if ( GSS_SELECTED_BANDS_WRITE == operation )
  2904     else if ( GSS_SELECTED_BANDS_WRITE == operation )
  2921             {
  2905         {
  2922 TFLOGSTRING("TSY: CMmCustomMessHandler::GssCsServiceResp - Complete ECustomSetBandSelectionIPC");
  2906         TFLOGSTRING("TSY: CMmCustomMessHandler::GssCsServiceResp - Complete ECustomSetBandSelectionIPC");
       
  2907 OstTrace0( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_GSSCSSERVICERESP, "CMmCustomMessHandler::GssCsServiceResp - Complete ECustomSetBandSelectionIPC" );
  2923 OstTrace0( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_GSSCSSERVICERESP, "CMmCustomMessHandler::GssCsServiceResp - Complete ECustomSetBandSelectionIPC" );
  2908         iMessageRouter->Complete( ECustomSetBandSelectionIPC, KErrNone );
  2924             iMessageRouter->Complete( ECustomSetBandSelectionIPC, KErrNone );
  2909         }
  2925             }
  2910     // GSS_SELECTED_BANDS_READ (0x9E)
  2926         // GSS_SELECTED_BANDS_READ (0x9E)
  2911     else if ( GSS_SELECTED_BANDS_READ == operation )
  2927         else if ( GSS_SELECTED_BANDS_READ == operation )
  2912         {
  2928             {
  2913         CompleteGetBandSelection( aIsiMessage );
  2929             CompleteGetBandSelection( aIsiMessage );
  2914         }
  2930             }
  2915 #endif // NCP_COMMON_S60_VERSION_SUPPORT
  2931 #endif // NCP_COMMON_S60_VERSION_SUPPORT
       
  2932         }
  2916     }
  2933     }
  2917 
  2934 
  2918 // -----------------------------------------------------------------------------
  2935 // -----------------------------------------------------------------------------
  2919 // CMmCustomMessHandler::GssCsServiceFailResp
  2936 // CMmCustomMessHandler::GssCsServiceFailResp
  2920 // Breaks a GSS_CS_SERVICE_FAIL_RESP ISI message.
  2937 // Breaks a GSS_CS_SERVICE_FAIL_RESP ISI message.
  3114     return iPhoNetSender->Send( PN_GSS, aTransId, GSS_CS_SERVICE_REQ, messageData );
  3131     return iPhoNetSender->Send( PN_GSS, aTransId, GSS_CS_SERVICE_REQ, messageData );
  3115 
  3132 
  3116     }
  3133     }
  3117 
  3134 
  3118 // -----------------------------------------------------------------------------
  3135 // -----------------------------------------------------------------------------
       
  3136 // CMmCustomMessHandler::GssCsServiceReq
       
  3137 // Constructs GSS_CS_SERVICE_REQ ISI message from input parameters and
       
  3138 // sends it through phonet.
       
  3139 // (other items were commented in a header).
       
  3140 // -----------------------------------------------------------------------------
       
  3141 //
       
  3142 TInt CMmCustomMessHandler::GssCsServiceReq
       
  3143         (
       
  3144         TUint8 aTransId   //transaction Id
       
  3145         )
       
  3146     {
       
  3147 TFLOGSTRING( "TSY: CMmCustomMessHandler::GssCsServiceReq" );
       
  3148 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_GSSCSSERVICEREQ, "CMmCustomMessHandler::GssCsServiceReq" );
       
  3149 
       
  3150     TBuf8<KTwo> messageData;
       
  3151 
       
  3152     messageData.Append( GSS_SELECTED_RAT_READ );
       
  3153     messageData.Append( 0 ); // number of subblocks
       
  3154 
       
  3155     // Sending message to phonet
       
  3156     return iPhoNetSender->Send( PN_GSS, aTransId, GSS_CS_SERVICE_REQ, messageData );
       
  3157     }
       
  3158 
       
  3159 // -----------------------------------------------------------------------------
  3119 // CMmCustomMessHandler::ExtFuncL
  3160 // CMmCustomMessHandler::ExtFuncL
  3120 // Forwards requests coming from the Symbian OS layer to the
  3161 // Forwards requests coming from the Symbian OS layer to the
  3121 // specific method.
  3162 // specific method.
  3122 // -----------------------------------------------------------------------------
  3163 // -----------------------------------------------------------------------------
  3123 //
  3164 //
  3303             RMmCustomAPI::TNetworkModeCaps networkModeCaps;
  3344             RMmCustomAPI::TNetworkModeCaps networkModeCaps;
  3304             aDataPackage->UnPackData( networkModeCaps );
  3345             aDataPackage->UnPackData( networkModeCaps );
  3305             ret = GssCsServiceReq( transId, networkModeCaps  );
  3346             ret = GssCsServiceReq( transId, networkModeCaps  );
  3306             break;
  3347             break;
  3307             }
  3348             }
  3308 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
       
  3309         // Current network modes
  3349         // Current network modes
  3310         // Removed for Bridge camp!
       
  3311         case ECustomGetCurrentSystemNetworkModesIPC:
  3350         case ECustomGetCurrentSystemNetworkModesIPC:
  3312             {
  3351             {
  3313             ret = MtcRatQueryReq( transId );
  3352             ret = GssCsServiceReq( transId );
  3314             break;
  3353             break;
  3315             }
  3354             }
  3316 #endif /*  INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
  3317 
       
  3318         // Get GSM/WCDMA cell info
  3355         // Get GSM/WCDMA cell info
  3319         case ECustomGetCellInfoIPC:
  3356         case ECustomGetCellInfoIPC:
  3320             {
  3357             {
  3321             iECIDInfoRequested = ETrue;
  3358             iECIDInfoRequested = ETrue;
  3322             ret = NetNeighbourCellsReq( transId );
  3359             ret = NetNeighbourCellsReq( transId );
  3502 // -----------------------------------------------------------------------------
  3539 // -----------------------------------------------------------------------------
  3503 //
  3540 //
  3504 TInt CMmCustomMessHandler::ProcessUiccMsg(
  3541 TInt CMmCustomMessHandler::ProcessUiccMsg(
  3505     TInt aTraId,
  3542     TInt aTraId,
  3506     TInt aStatus,
  3543     TInt aStatus,
       
  3544     TUint8 /*aDetails*/,
  3507     const TDesC8& aFileData )
  3545     const TDesC8& aFileData )
  3508     {
  3546     {
  3509 TFLOGSTRING3("TSY: CMmCustomMessHandler::ProcessUiccMsg, transaction ID: %d, status: %d", aTraId, aStatus );
  3547 TFLOGSTRING3("TSY: CMmCustomMessHandler::ProcessUiccMsg, transaction ID: %d, status: %d", aTraId, aStatus );
  3510 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_PROCESSUICCMSG, "CMmCustomMessHandler::ProcessUiccMsg" );
  3548 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_PROCESSUICCMSG, "CMmCustomMessHandler::ProcessUiccMsg" );
  3511 
  3549 
  3673             break;
  3711             break;
  3674             }
  3712             }
  3675         }
  3713         }
  3676     return ret;
  3714     return ret;
  3677     }
  3715     }
  3678 
       
  3679 // -----------------------------------------------------------------------------
       
  3680 // CMmCustomMessHandler::MtcRatQueryReq
       
  3681 // Constructs MTC_RAT_QUERY_REQ ISI message from input parameters and
       
  3682 // sends it through phonet.
       
  3683 // (other items were commented in a header).
       
  3684 // -----------------------------------------------------------------------------
       
  3685 //
       
  3686 #ifdef INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING
       
  3687 // Removed for Bridge camp
       
  3688 TInt CMmCustomMessHandler::MtcRatQueryReq
       
  3689         (
       
  3690         TUint8 aTransId   //transaction Id
       
  3691         )
       
  3692     {
       
  3693     TFLOGSTRING("TSY: CMmCustomMessHandler::MtcRatQueryReq.\n" );
       
  3694 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_MTCRATQUERYREQ, "CMmCustomMessHandler::MtcRatQueryReq" );
       
  3695 
       
  3696     TBuf8<KTwo> messageData;
       
  3697 
       
  3698     //append padding bytes
       
  3699     messageData.Append( 0 );
       
  3700     messageData.Append( 0 );
       
  3701 
       
  3702     // Sending message to phonet
       
  3703     return iPhoNetSender->Send( PN_MTC, aTransId, MTC_RAT_QUERY_REQ, messageData );
       
  3704     }
       
  3705 
       
  3706 // -----------------------------------------------------------------------------
       
  3707 // CMmCustomMessHandler::MtcRatQueryResp
       
  3708 // Breaks a MTC_RAT_QUERY_RESP ISI message.
       
  3709 // This method get the ratMode and complete the request with error value
       
  3710 // to SOS layer.
       
  3711 // (other items were commented in a header).
       
  3712 // -----------------------------------------------------------------------------
       
  3713 //
       
  3714 // Removed for Bridge camp
       
  3715 void CMmCustomMessHandler::MtcRatQueryResp
       
  3716         (
       
  3717         const TIsiReceiveC& aIsiMessage // Received isi message
       
  3718         )
       
  3719     {
       
  3720     TInt ret ( KErrNone );
       
  3721 
       
  3722     TUint32 ratMode ( RMmCustomAPI::KCapsNetworkModeDual );
       
  3723     TUint8 mode = aIsiMessage.Get8bit( ISI_HEADER_SIZE + MTC_RAT_QUERY_RESP_OFFSET_RAT );
       
  3724 
       
  3725 TFLOGSTRING3("TSY: CMmCustomMessHandler::MtcRatQueryResp. RatMode:%d, mode:%d", ratMode, mode);
       
  3726 OstTraceExt2( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_MTCRATQUERYRESP, "CMmCustomMessHandler::MtcRatQueryResp;mode=%hhu;ratMode=%u", mode, ratMode );
       
  3727 
       
  3728     switch ( mode )
       
  3729         {
       
  3730         case MTC_GSM_RAT:
       
  3731             {
       
  3732             ratMode = RMmCustomAPI::KCapsNetworkModeGsm;
       
  3733             break;
       
  3734             }
       
  3735         case MTC_UMTS_RAT:
       
  3736             {
       
  3737             ratMode = RMmCustomAPI::KCapsNetworkModeUmts;
       
  3738             break;
       
  3739             }
       
  3740         case MTC_NO_RAT_SELECTION: //this means dual mode
       
  3741             {
       
  3742             //value already initalized to dual
       
  3743             break;
       
  3744             }
       
  3745         default: // MTC_UNKNOWN_RAT
       
  3746             {
       
  3747             TFLOGSTRING("TSY: CMmCustomMessHandler::MtcRatQueryResp, switch mode - default.\n" );
       
  3748 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_MTCRATQUERYRESP, "CMmCustomMessHandler::MtcRatQueryResp, switch mode - default" );
       
  3749             ret = KErrGeneral;
       
  3750             break;
       
  3751             }
       
  3752         }
       
  3753 
       
  3754     CMmDataPackage dataPackage;
       
  3755     dataPackage.PackData( &ratMode );
       
  3756 
       
  3757     //completion ResetNetServer method (packed parameters)
       
  3758     iMessageRouter->Complete( ECustomGetCurrentSystemNetworkModesIPC,
       
  3759         &dataPackage, ret );
       
  3760 
       
  3761     }
       
  3762 #endif /* INTERNAL_TESTING_OLD_IMPLEMENTATION_FOR_UICC_TESTING */
       
  3763 
  3716 
  3764 // -----------------------------------------------------------------------------
  3717 // -----------------------------------------------------------------------------
  3765 // CMmCustomMessHandler::UiccReadViagHomeZoneParametersReq
  3718 // CMmCustomMessHandler::UiccReadViagHomeZoneParametersReq
  3766 // Read home zone parameters from UICC
  3719 // Read home zone parameters from UICC
  3767 // -----------------------------------------------------------------------------
  3720 // -----------------------------------------------------------------------------
  5959 // -----------------------------------------------------------------------------
  5912 // -----------------------------------------------------------------------------
  5960 // CMmCustomMessHandler::UiccSendAuthenticateApdu
  5913 // CMmCustomMessHandler::UiccSendAuthenticateApdu
  5961 // Constructs and sends AUTHENTICATE APDU to the UICC server
  5914 // Constructs and sends AUTHENTICATE APDU to the UICC server
  5962 // -----------------------------------------------------------------------------
  5915 // -----------------------------------------------------------------------------
  5963 //
  5916 //
  5964 TInt CMmCustomMessHandler::UiccSendAuthenticateApdu( 
  5917 TInt CMmCustomMessHandler::UiccSendAuthenticateApdu(
  5965     const CMmDataPackage& aDataPackage )
  5918     const CMmDataPackage& aDataPackage )
  5966     {
  5919     {
  5967 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccSendAuthenticateApdu.\n" );
  5920 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccSendAuthenticateApdu.\n" );
  5968 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCSENDAUTHENTICATEAPDU, "CMmCustomMessHandler::UiccSendAuthenticateApdu" );
  5921 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCSENDAUTHENTICATEAPDU, "CMmCustomMessHandler::UiccSendAuthenticateApdu" );
  5969 
  5922 
  6022                 apduSendNeeded = ETrue;
  5975                 apduSendNeeded = ETrue;
  6023                 }
  5976                 }
  6024             else if( UICC_CARD_TYPE_UICC == cardType )
  5977             else if( UICC_CARD_TYPE_UICC == cardType )
  6025                 {
  5978                 {
  6026                 // In 3G we need to send command AUTHENTICATE to the UICC
  5979                 // In 3G we need to send command AUTHENTICATE to the UICC
  6027                 UiccCreate3GSecurityContextApdu( 
  5980                 UiccCreate3GSecurityContextApdu(
  6028                     params, 
  5981                     params,
  6029                     eapAka.iRandomParameters, 
  5982                     eapAka.iRandomParameters,
  6030                     eapAka.iAUTN,
  5983                     eapAka.iAUTN,
  6031                     ETrIdEEapAkaAuthenticate );
  5984                     ETrIdEEapAkaAuthenticate );
  6032                 apduSendNeeded = ETrue;
  5985                 apduSendNeeded = ETrue;
  6033                 }
  5986                 }
  6034             break;
  5987             break;
  6035             }
  5988             }
  6036         case RMmCustomAPI::TSimAuthenticationBase::EGbaBootstrap:
  5989         case RMmCustomAPI::TSimAuthenticationBase::EGbaBootstrap:
  6037             {
  5990             {
  6038             serviceStatus = iMmUiccMessHandler->GetServiceStatus( KServiceGBA );
  5991             serviceStatus = iMmUiccMessHandler->GetServiceStatus( KServiceGBA );
  6039 
  5992 
  6040             if( UICC_CARD_TYPE_UICC == cardType && 
  5993             if( UICC_CARD_TYPE_UICC == cardType &&
  6041                 EFalse != serviceStatus )
  5994                 EFalse != serviceStatus )
  6042                 {
  5995                 {
  6043                 UiccCreateGBABootstrappingApdu( params, aDataPackage );
  5996                 UiccCreateGBABootstrappingApdu( params, aDataPackage );
  6044                 apduSendNeeded = ETrue;
  5997                 apduSendNeeded = ETrue;
  6045                 }
  5998                 }
  6054             }
  6007             }
  6055         case RMmCustomAPI::TSimAuthenticationBase::EGbaBootstrapUpdate:
  6008         case RMmCustomAPI::TSimAuthenticationBase::EGbaBootstrapUpdate:
  6056             {
  6009             {
  6057             serviceStatus = iMmUiccMessHandler->GetServiceStatus( KServiceGBA );
  6010             serviceStatus = iMmUiccMessHandler->GetServiceStatus( KServiceGBA );
  6058 
  6011 
  6059             if( UICC_CARD_TYPE_UICC == cardType && 
  6012             if( UICC_CARD_TYPE_UICC == cardType &&
  6060                 EFalse != serviceStatus )
  6013                 EFalse != serviceStatus )
  6061                 {
  6014                 {
  6062                 UiccGBABootstrapUpdate( aDataPackage );
  6015                 UiccGBABootstrapUpdate( aDataPackage );
  6063                 }
  6016                 }
  6064             else
  6017             else
  6072               }
  6025               }
  6073         case RMmCustomAPI::TSimAuthenticationBase::EGbaBootstrapNafDerivation:
  6026         case RMmCustomAPI::TSimAuthenticationBase::EGbaBootstrapNafDerivation:
  6074             {
  6027             {
  6075             serviceStatus = iMmUiccMessHandler->GetServiceStatus( KServiceGBA );
  6028             serviceStatus = iMmUiccMessHandler->GetServiceStatus( KServiceGBA );
  6076 
  6029 
  6077             if( UICC_CARD_TYPE_UICC == cardType && 
  6030             if( UICC_CARD_TYPE_UICC == cardType &&
  6078                 EFalse != serviceStatus )
  6031                 EFalse != serviceStatus )
  6079                 {
  6032                 {
  6080                 UiccCreateGBABootstrapNafDerivationApdu( params, aDataPackage );
  6033                 UiccCreateGBABootstrapNafDerivationApdu( params, aDataPackage );
  6081                 apduSendNeeded = ETrue;
  6034                 apduSendNeeded = ETrue;
  6082                 }
  6035                 }
  6091             }
  6044             }
  6092         case RMmCustomAPI::TSimAuthenticationBase::EMgvMskUpdate:
  6045         case RMmCustomAPI::TSimAuthenticationBase::EMgvMskUpdate:
  6093             {
  6046             {
  6094             serviceStatus = iMmUiccMessHandler->GetServiceStatus( KServiceMBMSsecurity );
  6047             serviceStatus = iMmUiccMessHandler->GetServiceStatus( KServiceMBMSsecurity );
  6095 
  6048 
  6096             if( UICC_CARD_TYPE_UICC == cardType && 
  6049             if( UICC_CARD_TYPE_UICC == cardType &&
  6097                 EFalse != serviceStatus )
  6050                 EFalse != serviceStatus )
  6098                 {
  6051                 {
  6099                 UiccCreateMbmsMskUpdateApdu( params, aDataPackage );
  6052                 UiccCreateMbmsMskUpdateApdu( params, aDataPackage );
  6100                 apduSendNeeded = ETrue;
  6053                 apduSendNeeded = ETrue;
  6101                 }
  6054                 }
  6110             }
  6063             }
  6111         case RMmCustomAPI::TSimAuthenticationBase::EMgvMtkGeneration:
  6064         case RMmCustomAPI::TSimAuthenticationBase::EMgvMtkGeneration:
  6112             {
  6065             {
  6113             serviceStatus = iMmUiccMessHandler->GetServiceStatus( KServiceMBMSsecurity );
  6066             serviceStatus = iMmUiccMessHandler->GetServiceStatus( KServiceMBMSsecurity );
  6114 
  6067 
  6115             if( UICC_CARD_TYPE_UICC == cardType && 
  6068             if( UICC_CARD_TYPE_UICC == cardType &&
  6116                 EFalse != serviceStatus )
  6069                 EFalse != serviceStatus )
  6117                 {
  6070                 {
  6118                 UiccCreateMbmsMtkGenerationApdu( params, aDataPackage );
  6071                 UiccCreateMbmsMtkGenerationApdu( params, aDataPackage );
  6119                 apduSendNeeded = ETrue;
  6072                 apduSendNeeded = ETrue;
  6120                 }
  6073                 }
  6129             }
  6082             }
  6130         case RMmCustomAPI::TSimAuthenticationBase::EMgvMskDeletion:
  6083         case RMmCustomAPI::TSimAuthenticationBase::EMgvMskDeletion:
  6131             {
  6084             {
  6132             serviceStatus = iMmUiccMessHandler->GetServiceStatus( KServiceMBMSsecurity );
  6085             serviceStatus = iMmUiccMessHandler->GetServiceStatus( KServiceMBMSsecurity );
  6133 
  6086 
  6134             if( UICC_CARD_TYPE_UICC == cardType && 
  6087             if( UICC_CARD_TYPE_UICC == cardType &&
  6135                 EFalse != serviceStatus )
  6088                 EFalse != serviceStatus )
  6136                 {
  6089                 {
  6137                 UiccCreateMbmsMskDeletionApdu( params, aDataPackage );
  6090                 UiccCreateMbmsMskDeletionApdu( params, aDataPackage );
  6138                 apduSendNeeded = ETrue;
  6091                 apduSendNeeded = ETrue;
  6139                 }
  6092                 }
  6155         }
  6108         }
  6156 
  6109 
  6157     if( EFalse != apduSendNeeded )
  6110     if( EFalse != apduSendNeeded )
  6158         {
  6111         {
  6159         // send the apdu to the UICC server
  6112         // send the apdu to the UICC server
  6160         ret = iMmUiccMessHandler->CreateUiccApplCmdReq( params ); 
  6113         ret = iMmUiccMessHandler->CreateUiccApplCmdReq( params );
  6161         }
  6114         }
  6162     else
  6115     else
  6163         {
  6116         {
  6164 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccSendAuthenticateApdu: APDU not sent\n" );
  6117 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccSendAuthenticateApdu: APDU not sent\n" );
  6165 OstTrace0( TRACE_NORMAL, DUP8_CMMCUSTOMMESSHANDLER_UICCSENDAUTHENTICATEAPDU, "CMmCustomMessHandler::UiccSendAuthenticateApduu: APDU not sent" );
  6118 OstTrace0( TRACE_NORMAL, DUP8_CMMCUSTOMMESSHANDLER_UICCSENDAUTHENTICATEAPDU, "CMmCustomMessHandler::UiccSendAuthenticateApduu: APDU not sent" );
  6171 // -----------------------------------------------------------------------------
  6124 // -----------------------------------------------------------------------------
  6172 // CMmCustomMessHandler::UiccCreateRunGsmAlgorithmApdu
  6125 // CMmCustomMessHandler::UiccCreateRunGsmAlgorithmApdu
  6173 // Constructs GSM context AUTHENTICATE APDU
  6126 // Constructs GSM context AUTHENTICATE APDU
  6174 // -----------------------------------------------------------------------------
  6127 // -----------------------------------------------------------------------------
  6175 //
  6128 //
  6176 void CMmCustomMessHandler::UiccCreateRunGsmAlgorithmApdu( 
  6129 void CMmCustomMessHandler::UiccCreateRunGsmAlgorithmApdu(
  6177     TUiccSendApdu& aParams, 
  6130     TUiccSendApdu& aParams,
  6178     const TDesC8& aRand,
  6131     const TDesC8& aRand,
  6179     TUiccTrId aTraId )
  6132     TUiccTrId aTraId )
  6180     {
  6133     {
  6181 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCreateRunGsmAlgorithmApdu.\n" );
  6134 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCreateRunGsmAlgorithmApdu.\n" );
  6182 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCREATERUNGSMALGORITHMAPDU, "CMmCustomMessHandler::UiccCreateRunGsmAlgorithmApdu" );
  6135 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCREATERUNGSMALGORITHMAPDU, "CMmCustomMessHandler::UiccCreateRunGsmAlgorithmApdu" );
  6267             }
  6220             }
  6268         else if( KCmdNotAllowedSecurityStatusNotSatisfied == result )
  6221         else if( KCmdNotAllowedSecurityStatusNotSatisfied == result )
  6269             {
  6222             {
  6270 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccRunGsmAlgorithmApduResp: Security conditions not satisfied\n" );
  6223 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccRunGsmAlgorithmApduResp: Security conditions not satisfied\n" );
  6271 OstTrace0( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_UICCRUNGSMALGORITHMAPDURESP, "CMmCustomMessHandler::UiccRunGsmAlgorithmApduResp: Security conditions not satisfied" );
  6224 OstTrace0( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_UICCRUNGSMALGORITHMAPDURESP, "CMmCustomMessHandler::UiccRunGsmAlgorithmApduResp: Security conditions not satisfied" );
  6272             ret = CMmStaticUtility::EpocErrorCode( 
  6225             ret = CMmStaticUtility::EpocErrorCode(
  6273                 KErrAccessDenied, 
  6226                 KErrAccessDenied,
  6274                 KErrGsm0707SimPin1Required );
  6227                 KErrGsm0707SimPin1Required );
  6275             }
  6228             }
  6276         else
  6229         else
  6277             {
  6230             {
  6278 TFLOGSTRING2("TSY: CMmCustomMessHandler::UiccRunGsmAlgorithmApduResp. unknown result: 0x%X\n", result );
  6231 TFLOGSTRING2("TSY: CMmCustomMessHandler::UiccRunGsmAlgorithmApduResp. unknown result: 0x%X\n", result );
  6319 // -----------------------------------------------------------------------------
  6272 // -----------------------------------------------------------------------------
  6320 // CMmCustomMessHandler::UiccCreateGsmSecurityContextApdu
  6273 // CMmCustomMessHandler::UiccCreateGsmSecurityContextApdu
  6321 // Constructs GSM context AUTHENTICATE APDU
  6274 // Constructs GSM context AUTHENTICATE APDU
  6322 // -----------------------------------------------------------------------------
  6275 // -----------------------------------------------------------------------------
  6323 //
  6276 //
  6324 void CMmCustomMessHandler::UiccCreateGsmSecurityContextApdu( 
  6277 void CMmCustomMessHandler::UiccCreateGsmSecurityContextApdu(
  6325     TUiccSendApdu& params, 
  6278     TUiccSendApdu& params,
  6326     const CMmDataPackage& aDataPackage )
  6279     const CMmDataPackage& aDataPackage )
  6327     {
  6280     {
  6328 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCreateGsmSecurityContextApdu.\n" );
  6281 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCreateGsmSecurityContextApdu.\n" );
  6329 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCREATEGSMSECURITYCONTEXTAPDU, "CMmCustomMessHandler::UiccCreateGsmSecurityContextApdu" );
  6282 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCREATEGSMSECURITYCONTEXTAPDU, "CMmCustomMessHandler::UiccCreateGsmSecurityContextApdu" );
  6330 
  6283 
  6422 // -----------------------------------------------------------------------------
  6375 // -----------------------------------------------------------------------------
  6423 // CMmCustomMessHandler::UiccCreate3GSecurityContextApdu
  6376 // CMmCustomMessHandler::UiccCreate3GSecurityContextApdu
  6424 // Constructs 3G security context AUTHENTICATE APDU
  6377 // Constructs 3G security context AUTHENTICATE APDU
  6425 // -----------------------------------------------------------------------------
  6378 // -----------------------------------------------------------------------------
  6426 //
  6379 //
  6427 void CMmCustomMessHandler::UiccCreate3GSecurityContextApdu( 
  6380 void CMmCustomMessHandler::UiccCreate3GSecurityContextApdu(
  6428     TUiccSendApdu& aParams, 
  6381     TUiccSendApdu& aParams,
  6429     const TDesC8& aRand, 
  6382     const TDesC8& aRand,
  6430     const TDesC8& aAuth,
  6383     const TDesC8& aAuth,
  6431     TUiccTrId aTraId )
  6384     TUiccTrId aTraId )
  6432     {
  6385     {
  6433 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCreate3GSecurityContextApdu.\n" );
  6386 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCreate3GSecurityContextApdu.\n" );
  6434 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCREATE3GSECURITYCONTEXTAPDU, "CMmCustomMessHandler::UiccCreate3GSecurityContextApdu" );
  6387 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCREATE3GSECURITYCONTEXTAPDU, "CMmCustomMessHandler::UiccCreate3GSecurityContextApdu" );
  6435 
  6388 
  6436     // len of data is sizeof RAND + sizeof AUTN + two length fields 
  6389     // len of data is sizeof RAND + sizeof AUTN + two length fields
  6437     // (one for RAND len and one for AUTN len)
  6390     // (one for RAND len and one for AUTN len)
  6438     TUint8 lc( aRand.Size() + aAuth.Size() + 2 );
  6391     TUint8 lc( aRand.Size() + aAuth.Size() + 2 );
  6439 
  6392 
  6440     aParams.trId = aTraId;
  6393     aParams.trId = aTraId;
  6441     aParams.apdu.Append( KClaNoSm );             // CLA
  6394     aParams.apdu.Append( KClaNoSm );             // CLA
  6442     aParams.apdu.Append( KEvenInstructionCode ); // INS
  6395     aParams.apdu.Append( KEvenInstructionCode ); // INS
  6443     aParams.apdu.Append( 0 ); // P1 is set to 0 in case of even instruction
  6396     aParams.apdu.Append( 0 ); // P1 is set to 0 in case of even instruction
  6444     aParams.apdu.Append( K3GAuthenticationContext ); // P2
  6397     aParams.apdu.Append( K3GAuthenticationContext ); // P2
  6445     aParams.apdu.Append( lc );                       // Lc 
  6398     aParams.apdu.Append( lc );                       // Lc
  6446     aParams.apdu.Append( aRand.Size() ); // len of RAND
  6399     aParams.apdu.Append( aRand.Size() ); // len of RAND
  6447     aParams.apdu.Append( aRand );        // RAND
  6400     aParams.apdu.Append( aRand );        // RAND
  6448     aParams.apdu.Append( aAuth.Size() );             // len of AUTN
  6401     aParams.apdu.Append( aAuth.Size() );             // len of AUTN
  6449     aParams.apdu.Append( aAuth );                    // AUTN
  6402     aParams.apdu.Append( aAuth );                    // AUTN
  6450     aParams.apdu.Append( KMaximumLenOfDataExpected );       // Le
  6403     aParams.apdu.Append( KMaximumLenOfDataExpected );       // Le
  6501                         // get the IK
  6454                         // get the IK
  6502                         len = aFileData[index++];
  6455                         len = aFileData[index++];
  6503                         eapAka.iIK.Copy( aFileData.Mid( index, len ) );
  6456                         eapAka.iIK.Copy( aFileData.Mid( index, len ) );
  6504                         index += len;
  6457                         index += len;
  6505 
  6458 
  6506                         // Kc is not supported at the moment because of 
  6459                         // Kc is not supported at the moment because of
  6507                         // RMmCustomAPI::TSimAuthenticationEapAka doesn't
  6460                         // RMmCustomAPI::TSimAuthenticationEapAka doesn't
  6508                         // have parameter for that
  6461                         // have parameter for that
  6509                         }
  6462                         }
  6510                     else
  6463                     else
  6511                         {
  6464                         {
  6548                 {
  6501                 {
  6549 TFLOGSTRING("TSY: CMmCustomMessHandler::Uicc3GSecurityContextApduResp: APDU validation failed\n" );
  6502 TFLOGSTRING("TSY: CMmCustomMessHandler::Uicc3GSecurityContextApduResp: APDU validation failed\n" );
  6550 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_UICC3GSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::Uicc3GSecurityContextApduResp: APDU validation failed" );
  6503 OstTrace0( TRACE_NORMAL, DUP1_CMMCUSTOMMESSHANDLER_UICC3GSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::Uicc3GSecurityContextApduResp: APDU validation failed" );
  6551                 ret = KErrMMEtelAuthenticateFailed;
  6504                 ret = KErrMMEtelAuthenticateFailed;
  6552                 }
  6505                 }
  6553             }            
  6506             }
  6554         else if( KAppAuthErrorIncorrectMac == result )
  6507         else if( KAppAuthErrorIncorrectMac == result )
  6555             {
  6508             {
  6556 TFLOGSTRING("TSY: CMmCustomMessHandler::Uicc3GSecurityContextApduResp: incorrect MAC\n" );
  6509 TFLOGSTRING("TSY: CMmCustomMessHandler::Uicc3GSecurityContextApduResp: incorrect MAC\n" );
  6557 OstTrace0( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_UICC3GSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::Uicc3GSecurityContextApduResp: incorrect MAC" );
  6510 OstTrace0( TRACE_NORMAL, DUP2_CMMCUSTOMMESSHANDLER_UICC3GSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::Uicc3GSecurityContextApduResp: incorrect MAC" );
  6558             // no parameters in this case
  6511             // no parameters in this case
  6560             }
  6513             }
  6561         else if( KCmdNotAllowedSecurityStatusNotSatisfied == result )
  6514         else if( KCmdNotAllowedSecurityStatusNotSatisfied == result )
  6562             {
  6515             {
  6563 TFLOGSTRING("TSY: CMmCustomMessHandler::Uicc3GSecurityContextApduResp: Security conditions not satisfied\n" );
  6516 TFLOGSTRING("TSY: CMmCustomMessHandler::Uicc3GSecurityContextApduResp: Security conditions not satisfied\n" );
  6564 OstTrace0( TRACE_NORMAL, DUP3_CMMCUSTOMMESSHANDLER_UICC3GSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::Uicc3GSecurityContextApduResp: Security conditions not satisfied" );
  6517 OstTrace0( TRACE_NORMAL, DUP3_CMMCUSTOMMESSHANDLER_UICC3GSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::Uicc3GSecurityContextApduResp: Security conditions not satisfied" );
  6565             ret = CMmStaticUtility::EpocErrorCode( 
  6518             ret = CMmStaticUtility::EpocErrorCode(
  6566                 KErrAccessDenied, 
  6519                 KErrAccessDenied,
  6567                 KErrGsm0707SimPin1Required );
  6520                 KErrGsm0707SimPin1Required );
  6568             }
  6521             }
  6569         else
  6522         else
  6570             {
  6523             {
  6571 TFLOGSTRING("TSY: CMmCustomMessHandler::Uicc3GSecurityContextApduResp: unknown result\n" );
  6524 TFLOGSTRING("TSY: CMmCustomMessHandler::Uicc3GSecurityContextApduResp: unknown result\n" );
  6578 TFLOGSTRING2("TSY: CMmCustomMessHandler::Uicc3GSecurityContextApduResp: UICC status not ok: 0x%x\n", aStatus );
  6531 TFLOGSTRING2("TSY: CMmCustomMessHandler::Uicc3GSecurityContextApduResp: UICC status not ok: 0x%x\n", aStatus );
  6579 OstTrace1( TRACE_NORMAL, DUP5_CMMCUSTOMMESSHANDLER_UICC3GSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::Uicc3GSecurityContextApduResp: UICC status not ok: 0x%x", aStatus );
  6532 OstTrace1( TRACE_NORMAL, DUP5_CMMCUSTOMMESSHANDLER_UICC3GSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::Uicc3GSecurityContextApduResp: UICC status not ok: 0x%x", aStatus );
  6580         ret = ETrIdEEapAkaAuthenticateIms == aTraId ? KErrGeneral : KErrMMEtelAuthenticateFailed;
  6533         ret = ETrIdEEapAkaAuthenticateIms == aTraId ? KErrGeneral : KErrMMEtelAuthenticateFailed;
  6581         }
  6534         }
  6582 
  6535 
  6583     if( KErrNone == ret || 
  6536     if( KErrNone == ret ||
  6584         KErrMMEtelSqnVerificationFailed == ret || 
  6537         KErrMMEtelSqnVerificationFailed == ret ||
  6585         KErrMMEtelMacVerificationFailed == ret )
  6538         KErrMMEtelMacVerificationFailed == ret )
  6586         {
  6539         {
  6587         CMmDataPackage dataPackage;
  6540         CMmDataPackage dataPackage;
  6588 
  6541 
  6589         if( ETrIdEEapAkaAuthenticate == aTraId )
  6542         if( ETrIdEEapAkaAuthenticate == aTraId )
  6596             }
  6549             }
  6597 
  6550 
  6598         iMessageRouter->Complete(
  6551         iMessageRouter->Complete(
  6599             ipc,
  6552             ipc,
  6600             &dataPackage,
  6553             &dataPackage,
  6601             ret );	
  6554             ret );
  6602         }
  6555         }
  6603     else
  6556     else
  6604         {
  6557         {
  6605         iMessageRouter->Complete(
  6558         iMessageRouter->Complete(
  6606             ipc,
  6559             ipc,
  6613 // CMmCustomMessHandler::UiccCreateGBABootstrappingApdu
  6566 // CMmCustomMessHandler::UiccCreateGBABootstrappingApdu
  6614 // Constructs GBA security context AUTHENTICATE APDU (bootstrapping mode)
  6567 // Constructs GBA security context AUTHENTICATE APDU (bootstrapping mode)
  6615 // -----------------------------------------------------------------------------
  6568 // -----------------------------------------------------------------------------
  6616 //
  6569 //
  6617 void CMmCustomMessHandler::UiccCreateGBABootstrappingApdu(
  6570 void CMmCustomMessHandler::UiccCreateGBABootstrappingApdu(
  6618     TUiccSendApdu& aParams, 
  6571     TUiccSendApdu& aParams,
  6619     const CMmDataPackage& aDataPackage )
  6572     const CMmDataPackage& aDataPackage )
  6620     {
  6573     {
  6621 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCreateGBABootstrappingApdu.\n" );
  6574 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCreateGBABootstrappingApdu.\n" );
  6622 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCREATEGBABOOTSTRAPPINGAPDU, "CMmCustomMessHandler::UiccCreateGBABootstrappingApdu" );
  6575 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCREATEGBABOOTSTRAPPINGAPDU, "CMmCustomMessHandler::UiccCreateGBABootstrappingApdu" );
  6623 
  6576 
  6624     RMmCustomAPI::TSimAuthenticationGbaBootstrap gbaBootstrap;
  6577     RMmCustomAPI::TSimAuthenticationGbaBootstrap gbaBootstrap;
  6625     aDataPackage.UnPackData( gbaBootstrap );
  6578     aDataPackage.UnPackData( gbaBootstrap );
  6626 
  6579 
  6627     // len of data is GBA bootstrapping mode tag (1 byte) + sizeof RAND 
  6580     // len of data is GBA bootstrapping mode tag (1 byte) + sizeof RAND
  6628     // + sizeof AUTN + two length fields (one for RAND len and one for AUTN len)
  6581     // + sizeof AUTN + two length fields (one for RAND len and one for AUTN len)
  6629     TUint8 lc( 1 + gbaBootstrap.iRandomParameters.Size() + gbaBootstrap.iAUTN.Size() + 2 );
  6582     TUint8 lc( 1 + gbaBootstrap.iRandomParameters.Size() + gbaBootstrap.iAUTN.Size() + 2 );
  6630 
  6583 
  6631     aParams.trId = ETrIdEGbaBootstrap;
  6584     aParams.trId = ETrIdEGbaBootstrap;
  6632     aParams.apdu.Append( KClaNoSm );             // CLA
  6585     aParams.apdu.Append( KClaNoSm );             // CLA
  6633     aParams.apdu.Append( KEvenInstructionCode ); // INS
  6586     aParams.apdu.Append( KEvenInstructionCode ); // INS
  6634     aParams.apdu.Append( 0 ); // P1 is set to 0 in case of even instruction
  6587     aParams.apdu.Append( 0 ); // P1 is set to 0 in case of even instruction
  6635     aParams.apdu.Append( KGBAAuthenticationContext ); // P2
  6588     aParams.apdu.Append( KGBAAuthenticationContext ); // P2
  6636     aParams.apdu.Append( lc );                        // Lc 
  6589     aParams.apdu.Append( lc );                        // Lc
  6637     aParams.apdu.Append( KGBABootstappingModeTag );   // GBA bootstrapping mode tag
  6590     aParams.apdu.Append( KGBABootstappingModeTag );   // GBA bootstrapping mode tag
  6638     aParams.apdu.Append( gbaBootstrap.iRandomParameters.Size() ); // len of RAND
  6591     aParams.apdu.Append( gbaBootstrap.iRandomParameters.Size() ); // len of RAND
  6639     aParams.apdu.Append( gbaBootstrap.iRandomParameters );        // RAND
  6592     aParams.apdu.Append( gbaBootstrap.iRandomParameters );        // RAND
  6640     aParams.apdu.Append( gbaBootstrap.iAUTN.Size() );             // len of AUTN
  6593     aParams.apdu.Append( gbaBootstrap.iAUTN.Size() );             // len of AUTN
  6641     aParams.apdu.Append( gbaBootstrap.iAUTN );                    // AUTN
  6594     aParams.apdu.Append( gbaBootstrap.iAUTN );                    // AUTN
  6642     aParams.apdu.Append( KMaximumLenOfDataExpected );             // Le
  6595     aParams.apdu.Append( KMaximumLenOfDataExpected );             // Le
  6643     }
  6596     }
  6644 
  6597 
  6645 // -----------------------------------------------------------------------------
  6598 // -----------------------------------------------------------------------------
  6646 // CMmCustomMessHandler::UiccGBABootstrappingApduResp
  6599 // CMmCustomMessHandler::UiccGBABootstrappingApduResp
  6647 // Handles response APDU for GBA security context AUTHENTICATE APDU 
  6600 // Handles response APDU for GBA security context AUTHENTICATE APDU
  6648 // (bootstrapping mode)
  6601 // (bootstrapping mode)
  6649 // -----------------------------------------------------------------------------
  6602 // -----------------------------------------------------------------------------
  6650 //
  6603 //
  6651 void CMmCustomMessHandler::UiccGBABootstrappingApduResp(
  6604 void CMmCustomMessHandler::UiccGBABootstrappingApduResp(
  6652     TInt aTraId,
  6605     TInt aTraId,
  6719 TFLOGSTRING2("TSY: CMmCustomMessHandler::UiccGBABootstrappingApduResp: UICC status not ok: 0x%x\n", aStatus );
  6672 TFLOGSTRING2("TSY: CMmCustomMessHandler::UiccGBABootstrappingApduResp: UICC status not ok: 0x%x\n", aStatus );
  6720 OstTrace1( TRACE_NORMAL, DUP4_CMMCUSTOMMESSHANDLER_UICCGBABOOTSTRAPPINGAPDURESP, "CMmCustomMessHandler::UiccGBABootstrappingApduResp: UICC status not ok: 0x%x", aStatus );
  6673 OstTrace1( TRACE_NORMAL, DUP4_CMMCUSTOMMESSHANDLER_UICCGBABOOTSTRAPPINGAPDURESP, "CMmCustomMessHandler::UiccGBABootstrappingApduResp: UICC status not ok: 0x%x", aStatus );
  6721         ret = KErrMMEtelAuthenticateFailed;
  6674         ret = KErrMMEtelAuthenticateFailed;
  6722         }
  6675         }
  6723 
  6676 
  6724     if( KErrNone == ret || 
  6677     if( KErrNone == ret ||
  6725         KErrMMEtelSqnVerificationFailed == ret || 
  6678         KErrMMEtelSqnVerificationFailed == ret ||
  6726         KErrMMEtelMacVerificationFailed == ret )
  6679         KErrMMEtelMacVerificationFailed == ret )
  6727         {
  6680         {
  6728         CMmDataPackage dataPackage;
  6681         CMmDataPackage dataPackage;
  6729         dataPackage.PackData( &gbaBootstrap );
  6682         dataPackage.PackData( &gbaBootstrap );
  6730 
  6683 
  6731         iMessageRouter->Complete(
  6684         iMessageRouter->Complete(
  6732             ECustomGetSimAuthenticationDataIPC,
  6685             ECustomGetSimAuthenticationDataIPC,
  6733             &dataPackage,
  6686             &dataPackage,
  6734             ret );	
  6687             ret );
  6735         }
  6688         }
  6736     else
  6689     else
  6737         {
  6690         {
  6738         iMessageRouter->Complete(
  6691         iMessageRouter->Complete(
  6739             ECustomGetSimAuthenticationDataIPC,
  6692             ECustomGetSimAuthenticationDataIPC,
  6783     // File id path
  6736     // File id path
  6784     params.filePath.Append( KMasterFileId >> 8 );
  6737     params.filePath.Append( KMasterFileId >> 8 );
  6785     params.filePath.Append( KMasterFileId );
  6738     params.filePath.Append( KMasterFileId );
  6786     params.filePath.Append( iMmUiccMessHandler->GetApplicationFileId() );
  6739     params.filePath.Append( iMmUiccMessHandler->GetApplicationFileId() );
  6787 
  6740 
  6788     iMmUiccMessHandler->CreateUiccApplCmdReq( params ); 
  6741     iMmUiccMessHandler->CreateUiccApplCmdReq( params );
  6789     }
  6742     }
  6790 
  6743 
  6791 // -----------------------------------------------------------------------------
  6744 // -----------------------------------------------------------------------------
  6792 // CMmCustomMessHandler::UiccGBABootstrapReadResp
  6745 // CMmCustomMessHandler::UiccGBABootstrapReadResp
  6793 // Handles response to elementary file EFgba read operation
  6746 // Handles response to elementary file EFgba read operation
  6794 // -----------------------------------------------------------------------------
  6747 // -----------------------------------------------------------------------------
  6795 //  
  6748 //
  6796 void CMmCustomMessHandler::UiccGBABootstrapReadResp(
  6749 void CMmCustomMessHandler::UiccGBABootstrapReadResp(
  6797     TInt aStatus,
  6750     TInt aStatus,
  6798     const TDesC8& aFileData )
  6751     const TDesC8& aFileData )
  6799     {
  6752     {
  6800 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccGBABootstrapReadResp.\n" );
  6753 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccGBABootstrapReadResp.\n" );
  6806         {
  6759         {
  6807         // Get the rand len
  6760         // Get the rand len
  6808         TUint32 index( 0 );
  6761         TUint32 index( 0 );
  6809         TUint8 randLen( aFileData[index++] );
  6762         TUint8 randLen( aFileData[index++] );
  6810 
  6763 
  6811         if( aFileData.Length() >= randLen + 
  6764         if( aFileData.Length() >= randLen +
  6812             iBTidBuf.Length() + 
  6765             iBTidBuf.Length() +
  6813             iKeyLifetimeBuf.Length() + 
  6766             iKeyLifetimeBuf.Length() +
  6814             3 )
  6767             3 )
  6815             {
  6768             {
  6816             // store rand temporarily so that we can complete it
  6769             // store rand temporarily so that we can complete it
  6817             // when B-Tid and keylifetime is updated to the EFgba.
  6770             // when B-Tid and keylifetime is updated to the EFgba.
  6818             iRandBuf.Copy( aFileData.Mid( index, randLen ) );
  6771             iRandBuf.Copy( aFileData.Mid( index, randLen ) );
  6903 // CMmCustomMessHandler::UiccCreateGBABootstrapNafDerivationApdu
  6856 // CMmCustomMessHandler::UiccCreateGBABootstrapNafDerivationApdu
  6904 // Constructs GBA security context AUTHENTICATE APDU (NAF derivation mode)
  6857 // Constructs GBA security context AUTHENTICATE APDU (NAF derivation mode)
  6905 // -----------------------------------------------------------------------------
  6858 // -----------------------------------------------------------------------------
  6906 //
  6859 //
  6907 void CMmCustomMessHandler::UiccCreateGBABootstrapNafDerivationApdu(
  6860 void CMmCustomMessHandler::UiccCreateGBABootstrapNafDerivationApdu(
  6908     TUiccSendApdu& aParams, 
  6861     TUiccSendApdu& aParams,
  6909     const CMmDataPackage& aDataPackage )
  6862     const CMmDataPackage& aDataPackage )
  6910     {
  6863     {
  6911 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCreateGBABootstrapNafDerivationApdu.\n" );
  6864 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCreateGBABootstrapNafDerivationApdu.\n" );
  6912 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCREATEGBABOOTSTRAPNAFDERIVATIONAPDU, "CMmCustomMessHandler::UiccCreateGBABootstrapNafDerivationApdu" );
  6865 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCREATEGBABOOTSTRAPNAFDERIVATIONAPDU, "CMmCustomMessHandler::UiccCreateGBABootstrapNafDerivationApdu" );
  6913 
  6866 
  6914     RMmCustomAPI::TSimAuthenticationGbaNafDerivation gbaBootstrapNafDerivation;
  6867     RMmCustomAPI::TSimAuthenticationGbaNafDerivation gbaBootstrapNafDerivation;
  6915     aDataPackage.UnPackData( gbaBootstrapNafDerivation );
  6868     aDataPackage.UnPackData( gbaBootstrapNafDerivation );
  6916 
  6869 
  6917     // len of data is GBA NAF derivation mode tag (1 byte) + sizeof NAFId 
  6870     // len of data is GBA NAF derivation mode tag (1 byte) + sizeof NAFId
  6918     // + sizeof IMPI + two length fields (one for NAFId len and one for IMPI len)
  6871     // + sizeof IMPI + two length fields (one for NAFId len and one for IMPI len)
  6919     TUint8 lc( 1 + 
  6872     TUint8 lc( 1 +
  6920                gbaBootstrapNafDerivation.iNafId.Size() + 
  6873                gbaBootstrapNafDerivation.iNafId.Size() +
  6921                gbaBootstrapNafDerivation.iImpi.Size() + 
  6874                gbaBootstrapNafDerivation.iImpi.Size() +
  6922                2 );
  6875                2 );
  6923 
  6876 
  6924     aParams.trId = ETrIdEGbaNafDerivation;
  6877     aParams.trId = ETrIdEGbaNafDerivation;
  6925     aParams.apdu.Append( KClaNoSm );             // CLA
  6878     aParams.apdu.Append( KClaNoSm );             // CLA
  6926     aParams.apdu.Append( KEvenInstructionCode ); // INS
  6879     aParams.apdu.Append( KEvenInstructionCode ); // INS
  6927     aParams.apdu.Append( 0 ); // P1 is set to 0 in case of even instruction
  6880     aParams.apdu.Append( 0 ); // P1 is set to 0 in case of even instruction
  6928     aParams.apdu.Append( KGBAAuthenticationContext ); // P2
  6881     aParams.apdu.Append( KGBAAuthenticationContext ); // P2
  6929     aParams.apdu.Append( lc );                        // Lc 
  6882     aParams.apdu.Append( lc );                        // Lc
  6930     aParams.apdu.Append( KGBANAFDerivationModeTag );   // GBA bootstrapping mode tag
  6883     aParams.apdu.Append( KGBANAFDerivationModeTag );   // GBA bootstrapping mode tag
  6931     aParams.apdu.Append( gbaBootstrapNafDerivation.iNafId.Size() ); // len of NAFId
  6884     aParams.apdu.Append( gbaBootstrapNafDerivation.iNafId.Size() ); // len of NAFId
  6932     aParams.apdu.Append( gbaBootstrapNafDerivation.iNafId );        // NAFId
  6885     aParams.apdu.Append( gbaBootstrapNafDerivation.iNafId );        // NAFId
  6933     aParams.apdu.Append( gbaBootstrapNafDerivation.iImpi.Size() );  // len of IMPI
  6886     aParams.apdu.Append( gbaBootstrapNafDerivation.iImpi.Size() );  // len of IMPI
  6934     aParams.apdu.Append( gbaBootstrapNafDerivation.iImpi );         // IMPI
  6887     aParams.apdu.Append( gbaBootstrapNafDerivation.iImpi );         // IMPI
  6936     }
  6889     }
  6937 
  6890 
  6938 
  6891 
  6939 // -----------------------------------------------------------------------------
  6892 // -----------------------------------------------------------------------------
  6940 // CMmCustomMessHandler::UiccGBABootstrapNafDerivationApduResp
  6893 // CMmCustomMessHandler::UiccGBABootstrapNafDerivationApduResp
  6941 // Handles response APDU for GBA security context AUTHENTICATE APDU 
  6894 // Handles response APDU for GBA security context AUTHENTICATE APDU
  6942 // (NAF derivation mode)
  6895 // (NAF derivation mode)
  6943 // -----------------------------------------------------------------------------
  6896 // -----------------------------------------------------------------------------
  6944 //
  6897 //
  6945 void CMmCustomMessHandler::UiccGBANafDerivationApduResp(
  6898 void CMmCustomMessHandler::UiccGBANafDerivationApduResp(
  6946     TInt aTraId,
  6899     TInt aTraId,
  6964         if( KNormalCommandEnding == result )
  6917         if( KNormalCommandEnding == result )
  6965             {
  6918             {
  6966             if( KApduOk == ValidateReceivedAuthenticateApdu( aTraId, aFileData ) )
  6919             if( KApduOk == ValidateReceivedAuthenticateApdu( aTraId, aFileData ) )
  6967                 {
  6920                 {
  6968                 // Let's skip "Successful GBA operation" tag
  6921                 // Let's skip "Successful GBA operation" tag
  6969                 // and start with Length of Length of Ks ext NAF 
  6922                 // and start with Length of Length of Ks ext NAF
  6970                 TUint32 index( 1 );
  6923                 TUint32 index( 1 );
  6971 
  6924 
  6972                 // get the Ks ext NAF
  6925                 // get the Ks ext NAF
  6973                 TUint8 len( aFileData[index++] );
  6926                 TUint8 len( aFileData[index++] );
  6974                 gbaNafDerivation.iKsExtNaf.Copy( aFileData.Mid( index, len ) );
  6927                 gbaNafDerivation.iKsExtNaf.Copy( aFileData.Mid( index, len ) );
  7004         dataPackage.PackData( &gbaNafDerivation );
  6957         dataPackage.PackData( &gbaNafDerivation );
  7005 
  6958 
  7006         iMessageRouter->Complete(
  6959         iMessageRouter->Complete(
  7007             ECustomGetSimAuthenticationDataIPC,
  6960             ECustomGetSimAuthenticationDataIPC,
  7008             &dataPackage,
  6961             &dataPackage,
  7009             ret );	
  6962             ret );
  7010         }
  6963         }
  7011     else
  6964     else
  7012         {
  6965         {
  7013         iMessageRouter->Complete(
  6966         iMessageRouter->Complete(
  7014             ECustomGetSimAuthenticationDataIPC,
  6967             ECustomGetSimAuthenticationDataIPC,
  7021 // CMmCustomMessHandler::UiccCreateMbmsMskUpdateApdu
  6974 // CMmCustomMessHandler::UiccCreateMbmsMskUpdateApdu
  7022 // Constructs MBMS security context AUTHENTICATE APDU (MSK Update Mode)
  6975 // Constructs MBMS security context AUTHENTICATE APDU (MSK Update Mode)
  7023 // -----------------------------------------------------------------------------
  6976 // -----------------------------------------------------------------------------
  7024 //
  6977 //
  7025 void CMmCustomMessHandler::UiccCreateMbmsMskUpdateApdu(
  6978 void CMmCustomMessHandler::UiccCreateMbmsMskUpdateApdu(
  7026     TUiccSendApdu& params, 
  6979     TUiccSendApdu& params,
  7027     const CMmDataPackage& aDataPackage )
  6980     const CMmDataPackage& aDataPackage )
  7028     {
  6981     {
  7029 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCreateMbmsMskUpdateApdu.\n" );
  6982 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCreateMbmsMskUpdateApdu.\n" );
  7030 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCREATEMBMSMSKUPDATEAPDU, "CMmCustomMessHandler::UiccCreateMbmsMskUpdateApdu" );
  6983 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCREATEMBMSMSKUPDATEAPDU, "CMmCustomMessHandler::UiccCreateMbmsMskUpdateApdu" );
  7031 
  6984 
  7032     // Note. MBMS functionality is not tested in real hardware and in real environmen
  6985     // Note. MBMS functionality is not tested in real hardware and in real environmen
  7033     //  because of there is no users for this authentication type. So this is implemented
  6986     //  because of there is no users for this authentication type. So this is implemented
  7034     // with the best knowledge at the moment and it can contain some bugs which 
  6987     // with the best knowledge at the moment and it can contain some bugs which
  7035     // can be found when this is tested in real environment.
  6988     // can be found when this is tested in real environment.
  7036 
  6989 
  7037     RMmCustomAPI::TSimAuthenticationMgvMskUpdate mskUpdate;
  6990     RMmCustomAPI::TSimAuthenticationMgvMskUpdate mskUpdate;
  7038     aDataPackage.UnPackData( mskUpdate );
  6991     aDataPackage.UnPackData( mskUpdate );
  7039 
  6992 
  7045     params.trId = ETrIdEMbmsMskUpdate;
  6998     params.trId = ETrIdEMbmsMskUpdate;
  7046     params.apdu.Append( KClaNoSm );             // CLA
  6999     params.apdu.Append( KClaNoSm );             // CLA
  7047     params.apdu.Append( KOddInstructionCode );  // INS
  7000     params.apdu.Append( KOddInstructionCode );  // INS
  7048     params.apdu.Append( KFirstBlockOfAuthenticationData ); // P1
  7001     params.apdu.Append( KFirstBlockOfAuthenticationData ); // P1
  7049     params.apdu.Append( KMBMSAuthenticationContext ); // P2
  7002     params.apdu.Append( KMBMSAuthenticationContext ); // P2
  7050     params.apdu.Append( lc );                         // Lc 
  7003     params.apdu.Append( lc );                         // Lc
  7051     params.apdu.Append( KMBMSDataObjectTag );          // MBMS Data object tag
  7004     params.apdu.Append( KMBMSDataObjectTag );          // MBMS Data object tag
  7052     params.apdu.Append( mskUpdate.iMikey.Size() + 1 ); // MBMS data obj len
  7005     params.apdu.Append( mskUpdate.iMikey.Size() + 1 ); // MBMS data obj len
  7053     params.apdu.Append( KMskUpdateMode );              // MBMS Security Context Mode
  7006     params.apdu.Append( KMskUpdateMode );              // MBMS Security Context Mode
  7054     params.apdu.Append( mskUpdate.iMikey );            // Mikey
  7007     params.apdu.Append( mskUpdate.iMikey );            // Mikey
  7055     }
  7008     }
  7056 
  7009 
  7057 
  7010 
  7058 // -----------------------------------------------------------------------------
  7011 // -----------------------------------------------------------------------------
  7059 // CMmCustomMessHandler::UiccMbmsMskUpdateApduResp
  7012 // CMmCustomMessHandler::UiccMbmsMskUpdateApduResp
  7060 // Handles response APDU for MBMS security context AUTHENTICATE APDU 
  7013 // Handles response APDU for MBMS security context AUTHENTICATE APDU
  7061 // (MSK Update Mode)
  7014 // (MSK Update Mode)
  7062 // -----------------------------------------------------------------------------
  7015 // -----------------------------------------------------------------------------
  7063 //
  7016 //
  7064 void CMmCustomMessHandler::UiccMbmsMskUpdateApduResp(
  7017 void CMmCustomMessHandler::UiccMbmsMskUpdateApduResp(
  7065     TInt aStatus,
  7018     TInt aStatus,
  7067     {
  7020     {
  7068 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccMbmsMskUpdateApduResp.\n" );
  7021 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccMbmsMskUpdateApduResp.\n" );
  7069 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCMBMSMSKUPDATEAPDURESP, "CMmCustomMessHandler::UiccMbmsMskUpdateApduResp" );
  7022 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCMBMSMSKUPDATEAPDURESP, "CMmCustomMessHandler::UiccMbmsMskUpdateApduResp" );
  7070 
  7023 
  7071     // Note. MBMS functionality is not tested in real hardware and in real environment
  7024     // Note. MBMS functionality is not tested in real hardware and in real environment
  7072     // because of at the moment there is no users for this authentication type. 
  7025     // because of at the moment there is no users for this authentication type.
  7073     // So this is implemented with the best knowledge at the moment and it can contain 
  7026     // So this is implemented with the best knowledge at the moment and it can contain
  7074     // some bugs which can be found when this is tested in real environment.
  7027     // some bugs which can be found when this is tested in real environment.
  7075 
  7028 
  7076     TInt ret( KErrGeneral );
  7029     TInt ret( KErrGeneral );
  7077     RMmCustomAPI::TSimAuthenticationMgvMskUpdate mskUpdate;
  7030     RMmCustomAPI::TSimAuthenticationMgvMskUpdate mskUpdate;
  7078     TBool completeNeeded( ETrue );
  7031     TBool completeNeeded( ETrue );
  7161             dataPackage.PackData( &mskUpdate );
  7114             dataPackage.PackData( &mskUpdate );
  7162 
  7115 
  7163             iMessageRouter->Complete(
  7116             iMessageRouter->Complete(
  7164                 ECustomGetSimAuthenticationDataIPC,
  7117                 ECustomGetSimAuthenticationDataIPC,
  7165                 &dataPackage,
  7118                 &dataPackage,
  7166                 ret );	
  7119                 ret );
  7167             }
  7120             }
  7168         else
  7121         else
  7169             {
  7122             {
  7170             iMessageRouter->Complete(
  7123             iMessageRouter->Complete(
  7171                 ECustomGetSimAuthenticationDataIPC,
  7124                 ECustomGetSimAuthenticationDataIPC,
  7189 
  7142 
  7190     TUint8 index( 0 );
  7143     TUint8 index( 0 );
  7191     TUint32 objLen( aMbmsData.Length() );
  7144     TUint32 objLen( aMbmsData.Length() );
  7192 
  7145 
  7193     if( KSuccessfullMbmsOperationTag == aMbmsData[index] &&
  7146     if( KSuccessfullMbmsOperationTag == aMbmsData[index] &&
  7194         1 <= objLen && 
  7147         1 <= objLen &&
  7195         ( KMaxMbmsMikeyLen + 1 ) >= objLen  ) // + 1 for 0xDB TLV tag
  7148         ( KMaxMbmsMikeyLen + 1 ) >= objLen  ) // + 1 for 0xDB TLV tag
  7196         {
  7149         {
  7197         index++;
  7150         index++;
  7198 
  7151 
  7199         // len of MIKEY is obj len - 1 because of 
  7152         // len of MIKEY is obj len - 1 because of
  7200         // obj data contains 1 byte for 
  7153         // obj data contains 1 byte for
  7201         // Successfull Mbms Operation Tag
  7154         // Successfull Mbms Operation Tag
  7202         TUint8 mikeyLen = objLen - 1;
  7155         TUint8 mikeyLen = objLen - 1;
  7203         if( 0 < mikeyLen )
  7156         if( 0 < mikeyLen )
  7204             {
  7157             {
  7205             aMskUpdate.iMikey.Copy( aMbmsData.Mid( index, mikeyLen ) );
  7158             aMskUpdate.iMikey.Copy( aMbmsData.Mid( index, mikeyLen ) );
  7211 // -----------------------------------------------------------------------------
  7164 // -----------------------------------------------------------------------------
  7212 // CMmCustomMessHandler::UiccMskUpdateHandleMbmsOperationData
  7165 // CMmCustomMessHandler::UiccMskUpdateHandleMbmsOperationData
  7213 // Handles OMA BCAST operation data from authenticate APDU
  7166 // Handles OMA BCAST operation data from authenticate APDU
  7214 // -----------------------------------------------------------------------------
  7167 // -----------------------------------------------------------------------------
  7215 //
  7168 //
  7216 void CMmCustomMessHandler::UiccMskUpdateHandleOMABcastOperationData( 
  7169 void CMmCustomMessHandler::UiccMskUpdateHandleOMABcastOperationData(
  7217                 RMmCustomAPI::TSimAuthenticationMgvMskUpdate& aMskUpdate,
  7170                 RMmCustomAPI::TSimAuthenticationMgvMskUpdate& aMskUpdate,
  7218                 TDesC8& aMbmsData )
  7171                 TDesC8& aMbmsData )
  7219     {
  7172     {
  7220 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccMskUpdateHandleOMABcastOperationData.\n" );
  7173 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccMskUpdateHandleOMABcastOperationData.\n" );
  7221 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCMSKUPDATEHANDLEOMABCASTOPERATIONDATA, "CMmCustomMessHandler::UiccMskUpdateHandleOMABcastOperationData" );
  7174 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCMSKUPDATEHANDLEOMABCASTOPERATIONDATA, "CMmCustomMessHandler::UiccMskUpdateHandleOMABcastOperationData" );
  7254 // CMmCustomMessHandler::UiccCreateMbmsMtkGenerationApdu
  7207 // CMmCustomMessHandler::UiccCreateMbmsMtkGenerationApdu
  7255 // Constructs MBMS security context AUTHENTICATE APDU (MTK Generation Mode)
  7208 // Constructs MBMS security context AUTHENTICATE APDU (MTK Generation Mode)
  7256 // -----------------------------------------------------------------------------
  7209 // -----------------------------------------------------------------------------
  7257 //
  7210 //
  7258 void CMmCustomMessHandler::UiccCreateMbmsMtkGenerationApdu(
  7211 void CMmCustomMessHandler::UiccCreateMbmsMtkGenerationApdu(
  7259     TUiccSendApdu& params, 
  7212     TUiccSendApdu& params,
  7260     const CMmDataPackage& aDataPackage )
  7213     const CMmDataPackage& aDataPackage )
  7261     {
  7214     {
  7262 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCreateMbmsMtkGenerationApdu.\n" );
  7215 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCreateMbmsMtkGenerationApdu.\n" );
  7263 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCREATEMBMSMTKGENERATIONAPDU, "CMmCustomMessHandler::UiccCreateMbmsMtkGenerationApdu" );
  7216 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCREATEMBMSMTKGENERATIONAPDU, "CMmCustomMessHandler::UiccCreateMbmsMtkGenerationApdu" );
  7264 
  7217 
  7265     // Note. MBMS functionality is not tested in real hardware and in real environment
  7218     // Note. MBMS functionality is not tested in real hardware and in real environment
  7266     // because of at the moment there is no users for this authentication type. 
  7219     // because of at the moment there is no users for this authentication type.
  7267     // So this is implemented with the best knowledge at the moment and it can contain 
  7220     // So this is implemented with the best knowledge at the moment and it can contain
  7268     // some bugs which can be found when this is tested in real environment.
  7221     // some bugs which can be found when this is tested in real environment.
  7269 
  7222 
  7270     RMmCustomAPI::TSimAuthenticationMgvMtkGeneration mtkGen;
  7223     RMmCustomAPI::TSimAuthenticationMgvMtkGeneration mtkGen;
  7271     aDataPackage.UnPackData( mtkGen );
  7224     aDataPackage.UnPackData( mtkGen );
  7272 
  7225 
  7278     params.trId = ETrIdEMbmsMtkGeneration;
  7231     params.trId = ETrIdEMbmsMtkGeneration;
  7279     params.apdu.Append( KClaNoSm );             // CLA
  7232     params.apdu.Append( KClaNoSm );             // CLA
  7280     params.apdu.Append( KOddInstructionCode );  // INS
  7233     params.apdu.Append( KOddInstructionCode );  // INS
  7281     params.apdu.Append( KFirstBlockOfAuthenticationData ); // P1
  7234     params.apdu.Append( KFirstBlockOfAuthenticationData ); // P1
  7282     params.apdu.Append( KMBMSAuthenticationContext ); // P2
  7235     params.apdu.Append( KMBMSAuthenticationContext ); // P2
  7283     params.apdu.Append( lc );                         // Lc 
  7236     params.apdu.Append( lc );                         // Lc
  7284     params.apdu.Append( KMBMSDataObjectTag );          // MBMS Data object tag
  7237     params.apdu.Append( KMBMSDataObjectTag );          // MBMS Data object tag
  7285     params.apdu.Append( mtkGen.iMikey.Size() + 1 ); // MBMS data obj len
  7238     params.apdu.Append( mtkGen.iMikey.Size() + 1 ); // MBMS data obj len
  7286     params.apdu.Append( KMtkGenerationMode );          // MBMS Security Context Mode
  7239     params.apdu.Append( KMtkGenerationMode );          // MBMS Security Context Mode
  7287     params.apdu.Append( mtkGen.iMikey );            // Mikey
  7240     params.apdu.Append( mtkGen.iMikey );            // Mikey
  7288     }
  7241     }
  7289 
  7242 
  7290 
  7243 
  7291 // -----------------------------------------------------------------------------
  7244 // -----------------------------------------------------------------------------
  7292 // CMmCustomMessHandler::UiccMbmsMtkGenerationApduResp
  7245 // CMmCustomMessHandler::UiccMbmsMtkGenerationApduResp
  7293 // Handles response APDU for MBMS security context AUTHENTICATE APDU 
  7246 // Handles response APDU for MBMS security context AUTHENTICATE APDU
  7294 // (MTK Generation Mode)
  7247 // (MTK Generation Mode)
  7295 // -----------------------------------------------------------------------------
  7248 // -----------------------------------------------------------------------------
  7296 //
  7249 //
  7297 void CMmCustomMessHandler::UiccMbmsMtkGenerationApduResp(
  7250 void CMmCustomMessHandler::UiccMbmsMtkGenerationApduResp(
  7298     TInt aStatus,
  7251     TInt aStatus,
  7300     {
  7253     {
  7301 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccMbmsMtkGenerationApduResp.\n" );
  7254 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccMbmsMtkGenerationApduResp.\n" );
  7302 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCMBMSMTKGENERATIONAPDURESP, "CMmCustomMessHandler::UiccMbmsMtkGenerationApduResp" );
  7255 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCMBMSMTKGENERATIONAPDURESP, "CMmCustomMessHandler::UiccMbmsMtkGenerationApduResp" );
  7303 
  7256 
  7304     // Note. MBMS functionality is not tested in real hardware and in real environment
  7257     // Note. MBMS functionality is not tested in real hardware and in real environment
  7305     // because of at the moment there is no users for this authentication type. 
  7258     // because of at the moment there is no users for this authentication type.
  7306     // So this is implemented with the best knowledge at the moment and it can contain 
  7259     // So this is implemented with the best knowledge at the moment and it can contain
  7307     // some bugs which can be found when this is tested in real environment.
  7260     // some bugs which can be found when this is tested in real environment.
  7308 
  7261 
  7309     TInt ret( KErrGeneral );
  7262     TInt ret( KErrGeneral );
  7310     RMmCustomAPI::TSimAuthenticationMgvMtkGeneration mtkGen;
  7263     RMmCustomAPI::TSimAuthenticationMgvMtkGeneration mtkGen;
  7311     TBool completeNeeded( ETrue );
  7264     TBool completeNeeded( ETrue );
  7323             case KNormalCommandEnding:
  7276             case KNormalCommandEnding:
  7324             case KWarningMoreDataAvailable:
  7277             case KWarningMoreDataAvailable:
  7325                 {
  7278                 {
  7326                 TBuf8<KMaxApduSize> mbmsOperationData;
  7279                 TBuf8<KMaxApduSize> mbmsOperationData;
  7327 
  7280 
  7328                 if( FindTlvObject( KMbmsOperationResponseTag53, aFileData.Mid( 0, aFileData.Length() - 2 ), mbmsOperationData ) || 
  7281                 if( FindTlvObject( KMbmsOperationResponseTag53, aFileData.Mid( 0, aFileData.Length() - 2 ), mbmsOperationData ) ||
  7329                     FindTlvObject( KMbmsOperationResponseTag73, aFileData.Mid( 0, aFileData.Length() - 2 ), mbmsOperationData ) )
  7282                     FindTlvObject( KMbmsOperationResponseTag73, aFileData.Mid( 0, aFileData.Length() - 2 ), mbmsOperationData ) )
  7330                     {
  7283                     {
  7331                     ret = KErrNone;
  7284                     ret = KErrNone;
  7332                     if( KSuccessfullMbmsOperationTag == mbmsOperationData[0] )
  7285                     if( KSuccessfullMbmsOperationTag == mbmsOperationData[0] )
  7333                         {
  7286                         {
  7388             dataPackage.PackData( &mtkGen );
  7341             dataPackage.PackData( &mtkGen );
  7389 
  7342 
  7390             iMessageRouter->Complete(
  7343             iMessageRouter->Complete(
  7391                 ECustomGetSimAuthenticationDataIPC,
  7344                 ECustomGetSimAuthenticationDataIPC,
  7392                 &dataPackage,
  7345                 &dataPackage,
  7393                 ret );	
  7346                 ret );
  7394             }
  7347             }
  7395         else
  7348         else
  7396             {
  7349             {
  7397             iMessageRouter->Complete(
  7350             iMessageRouter->Complete(
  7398                 ECustomGetSimAuthenticationDataIPC,
  7351                 ECustomGetSimAuthenticationDataIPC,
  7405 // -----------------------------------------------------------------------------
  7358 // -----------------------------------------------------------------------------
  7406 // CMmCustomMessHandler::UiccMtkGenHandleMbmsOperationData
  7359 // CMmCustomMessHandler::UiccMtkGenHandleMbmsOperationData
  7407 // Handles MBMS operation data from MTK Generation authenticate APDU
  7360 // Handles MBMS operation data from MTK Generation authenticate APDU
  7408 // -----------------------------------------------------------------------------
  7361 // -----------------------------------------------------------------------------
  7409 //
  7362 //
  7410 void CMmCustomMessHandler::UiccMtkGenHandleMbmsOperationData( 
  7363 void CMmCustomMessHandler::UiccMtkGenHandleMbmsOperationData(
  7411     RMmCustomAPI::TSimAuthenticationMgvMtkGeneration& aMtkGen,
  7364     RMmCustomAPI::TSimAuthenticationMgvMtkGeneration& aMtkGen,
  7412     TDesC8& aMbmsData )
  7365     TDesC8& aMbmsData )
  7413     {
  7366     {
  7414 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccMtkGenHandleMbmsOperationData.\n" );
  7367 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccMtkGenHandleMbmsOperationData.\n" );
  7415 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCMTKGENHANDLEMBMSOPERATIONDATA, "CMmCustomMessHandler::UiccMtkGenHandleMbmsOperationData" );
  7368 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCMTKGENHANDLEMBMSOPERATIONDATA, "CMmCustomMessHandler::UiccMtkGenHandleMbmsOperationData" );
  7416 
  7369 
  7417     TUint8 index( 0 );
  7370     TUint8 index( 0 );
  7418     TUint32 objLen( aMbmsData.Length() );
  7371     TUint32 objLen( aMbmsData.Length() );
  7419 
  7372 
  7420     if( KSuccessfullMbmsOperationTag == aMbmsData[index] &&
  7373     if( KSuccessfullMbmsOperationTag == aMbmsData[index] &&
  7421         1 <= objLen && 
  7374         1 <= objLen &&
  7422         ( KMaxMbmsSaltLen + 1 ) >= objLen  ) // + 1 for 0xDB TLV tag
  7375         ( KMaxMbmsSaltLen + 1 ) >= objLen  ) // + 1 for 0xDB TLV tag
  7423         {
  7376         {
  7424         index++;
  7377         index++;
  7425 
  7378 
  7426         // len of SALT is obj len - 1 because of 
  7379         // len of SALT is obj len - 1 because of
  7427         // obj data contains 1 byte for 
  7380         // obj data contains 1 byte for
  7428         // Successfull Mbms Operation Tag
  7381         // Successfull Mbms Operation Tag
  7429         TUint8 saltLen( objLen - 1 );
  7382         TUint8 saltLen( objLen - 1 );
  7430         if( 0 < saltLen )
  7383         if( 0 < saltLen )
  7431             {
  7384             {
  7432             aMtkGen.iMtkSalt.Copy( aMbmsData.Mid( index, saltLen ) );
  7385             aMtkGen.iMtkSalt.Copy( aMbmsData.Mid( index, saltLen ) );
  7438 // -----------------------------------------------------------------------------
  7391 // -----------------------------------------------------------------------------
  7439 // CMmCustomMessHandler::UiccMtkGenHandleOMABcastOperationData
  7392 // CMmCustomMessHandler::UiccMtkGenHandleOMABcastOperationData
  7440 // Handles OMA BCAST operation data from authenticate APDU
  7393 // Handles OMA BCAST operation data from authenticate APDU
  7441 // -----------------------------------------------------------------------------
  7394 // -----------------------------------------------------------------------------
  7442 //
  7395 //
  7443 void CMmCustomMessHandler::UiccMtkGenHandleOMABcastOperationData( 
  7396 void CMmCustomMessHandler::UiccMtkGenHandleOMABcastOperationData(
  7444          RMmCustomAPI::TSimAuthenticationMgvMtkGeneration& aMtkGen,
  7397          RMmCustomAPI::TSimAuthenticationMgvMtkGeneration& aMtkGen,
  7445          TDesC8& aMbmsData )
  7398          TDesC8& aMbmsData )
  7446     {
  7399     {
  7447 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccMtkGenHandleOMABcastOperationData.\n" );
  7400 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccMtkGenHandleOMABcastOperationData.\n" );
  7448 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCMTKGENHANDLEOMABCASTOPERATIONDATA, "CMmCustomMessHandler::UiccMtkGenHandleOMABcastOperationData" );
  7401 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCMTKGENHANDLEOMABCASTOPERATIONDATA, "CMmCustomMessHandler::UiccMtkGenHandleOMABcastOperationData" );
  7464             {
  7417             {
  7465             aMtkGen.iTrafficEncryptionKey.Copy( tekData );
  7418             aMtkGen.iTrafficEncryptionKey.Copy( tekData );
  7466             }
  7419             }
  7467         if( FindTlvObject( KParentalControlTag, omaBcastData, parentalControlData ) )
  7420         if( FindTlvObject( KParentalControlTag, omaBcastData, parentalControlData ) )
  7468             {
  7421             {
  7469             // first parameter of parental control data is "key reference for second 
  7422             // first parameter of parental control data is "key reference for second
  7470             // application PIN defined for parental contol" but it's not supported 
  7423             // application PIN defined for parental contol" but it's not supported
  7471             // at the moment
  7424             // at the moment
  7472             aMtkGen.iParentalControl.Append( parentalControlData[1] ); // rating type
  7425             aMtkGen.iParentalControl.Append( parentalControlData[1] ); // rating type
  7473             aMtkGen.iParentalControl.Append( parentalControlData[2] ); // rating value
  7426             aMtkGen.iParentalControl.Append( parentalControlData[2] ); // rating value
  7474             aMtkGen.iParentalControl.Append( parentalControlData[3] ); // level granted value
  7427             aMtkGen.iParentalControl.Append( parentalControlData[3] ); // level granted value
  7475             }
  7428             }
  7485 // CMmCustomMessHandler::UiccCreateMbmsMskDeletionApdu
  7438 // CMmCustomMessHandler::UiccCreateMbmsMskDeletionApdu
  7486 // Constructs MBMS security context AUTHENTICATE APDU (MSK Deletion Mode)
  7439 // Constructs MBMS security context AUTHENTICATE APDU (MSK Deletion Mode)
  7487 // -----------------------------------------------------------------------------
  7440 // -----------------------------------------------------------------------------
  7488 //
  7441 //
  7489 void CMmCustomMessHandler::UiccCreateMbmsMskDeletionApdu(
  7442 void CMmCustomMessHandler::UiccCreateMbmsMskDeletionApdu(
  7490     TUiccSendApdu& params, 
  7443     TUiccSendApdu& params,
  7491     const CMmDataPackage& aDataPackage )
  7444     const CMmDataPackage& aDataPackage )
  7492     {
  7445     {
  7493 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCreateMbmsMskDeletionApdu.\n" );
  7446 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccCreateMbmsMskDeletionApdu.\n" );
  7494 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCREATEMBMSMSKDELETIONAPDU, "CMmCustomMessHandler::UiccCreateMbmsMskDeletionApdu" );
  7447 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCCREATEMBMSMSKDELETIONAPDU, "CMmCustomMessHandler::UiccCreateMbmsMskDeletionApdu" );
  7495     
  7448 
  7496     // Note. MBMS functionality is not tested in real hardware and in real environment
  7449     // Note. MBMS functionality is not tested in real hardware and in real environment
  7497     // because of at the moment there is no users for this authentication type. 
  7450     // because of at the moment there is no users for this authentication type.
  7498     // So this is implemented with the best knowledge at the moment and it can contain 
  7451     // So this is implemented with the best knowledge at the moment and it can contain
  7499     // some bugs which can be found when this is tested in real environment.
  7452     // some bugs which can be found when this is tested in real environment.
  7500 
  7453 
  7501     RMmCustomAPI::TSimAuthenticationMgvMskDeletion mskDel;
  7454     RMmCustomAPI::TSimAuthenticationMgvMskDeletion mskDel;
  7502     aDataPackage.UnPackData( mskDel );
  7455     aDataPackage.UnPackData( mskDel );
  7503 
  7456 
  7504     // len of data is MBMS Data Object tag (1 byte) +
  7457     // len of data is MBMS Data Object tag (1 byte) +
  7505     // MBMS Data Object length (1 byte) +
  7458     // MBMS Data Object length (1 byte) +
  7506     // MBMS Security Context Mode (1 byte) + 
  7459     // MBMS Security Context Mode (1 byte) +
  7507     // size of Key Domain Id + size of Key Group Id Part
  7460     // size of Key Domain Id + size of Key Group Id Part
  7508     TUint8 lc( 1 + 
  7461     TUint8 lc( 1 +
  7509                1 + 
  7462                1 +
  7510                1 + 
  7463                1 +
  7511                mskDel.iKeyDomainId.Size() + 
  7464                mskDel.iKeyDomainId.Size() +
  7512                mskDel.iKeyGroupIdPart.Size() );
  7465                mskDel.iKeyGroupIdPart.Size() );
  7513 
  7466 
  7514     // data size in MBMS Data Object Tag is:
  7467     // data size in MBMS Data Object Tag is:
  7515     // MBMS Security Context Mode (1 byte) + 
  7468     // MBMS Security Context Mode (1 byte) +
  7516     // size of Key Domain Id + size of Key Group Id Part
  7469     // size of Key Domain Id + size of Key Group Id Part
  7517     TUint8 dataSize( 1 + 
  7470     TUint8 dataSize( 1 +
  7518                      mskDel.iKeyDomainId.Size() + 
  7471                      mskDel.iKeyDomainId.Size() +
  7519                      mskDel.iKeyGroupIdPart.Size() );
  7472                      mskDel.iKeyGroupIdPart.Size() );
  7520 
  7473 
  7521     params.trId = ETrIdEMbmsMskDeletion;
  7474     params.trId = ETrIdEMbmsMskDeletion;
  7522     params.apdu.Append( KClaNoSm );             // CLA
  7475     params.apdu.Append( KClaNoSm );             // CLA
  7523     params.apdu.Append( KOddInstructionCode );  // INS
  7476     params.apdu.Append( KOddInstructionCode );  // INS
  7524     params.apdu.Append( KFirstBlockOfAuthenticationData ); // P1
  7477     params.apdu.Append( KFirstBlockOfAuthenticationData ); // P1
  7525     params.apdu.Append( KMBMSAuthenticationContext ); // P2
  7478     params.apdu.Append( KMBMSAuthenticationContext ); // P2
  7526     params.apdu.Append( lc );                         // Lc 
  7479     params.apdu.Append( lc );                         // Lc
  7527     params.apdu.Append( KMBMSDataObjectTag );       // MBMS Data object tag
  7480     params.apdu.Append( KMBMSDataObjectTag );       // MBMS Data object tag
  7528     params.apdu.Append( dataSize );                 // MBMS data obj len
  7481     params.apdu.Append( dataSize );                 // MBMS data obj len
  7529     params.apdu.Append( KMskDeletionMode );         // MBMS Security Context Mode
  7482     params.apdu.Append( KMskDeletionMode );         // MBMS Security Context Mode
  7530     params.apdu.Append( mskDel.iKeyDomainId );      // Key Domain Id
  7483     params.apdu.Append( mskDel.iKeyDomainId );      // Key Domain Id
  7531     params.apdu.Append( mskDel.iKeyGroupIdPart );   // Key Group Id
  7484     params.apdu.Append( mskDel.iKeyGroupIdPart );   // Key Group Id
  7532     }
  7485     }
  7533 
  7486 
  7534 
  7487 
  7535 // -----------------------------------------------------------------------------
  7488 // -----------------------------------------------------------------------------
  7536 // CMmCustomMessHandler::UiccMbmsMskDeletionApduResp
  7489 // CMmCustomMessHandler::UiccMbmsMskDeletionApduResp
  7537 // Handles response APDU for MBMS security context AUTHENTICATE APDU 
  7490 // Handles response APDU for MBMS security context AUTHENTICATE APDU
  7538 // (MSK Deletion Mode)
  7491 // (MSK Deletion Mode)
  7539 // -----------------------------------------------------------------------------
  7492 // -----------------------------------------------------------------------------
  7540 //
  7493 //
  7541 void CMmCustomMessHandler::UiccMbmsMskDeletionApduResp(
  7494 void CMmCustomMessHandler::UiccMbmsMskDeletionApduResp(
  7542     TInt aStatus,
  7495     TInt aStatus,
  7544     {
  7497     {
  7545 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccMbmsMskDeletionApduResp.\n" );
  7498 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccMbmsMskDeletionApduResp.\n" );
  7546 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCMBMSMSKDELETIONAPDURESP, "CMmCustomMessHandler::UiccMbmsMskDeletionApduResp" );
  7499 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCMBMSMSKDELETIONAPDURESP, "CMmCustomMessHandler::UiccMbmsMskDeletionApduResp" );
  7547 
  7500 
  7548     // Note. MBMS functionality is not tested in real hardware and in real environment
  7501     // Note. MBMS functionality is not tested in real hardware and in real environment
  7549     // because of at the moment there is no users for this authentication type. 
  7502     // because of at the moment there is no users for this authentication type.
  7550     // So this is implemented with the best knowledge at the moment and it can contain 
  7503     // So this is implemented with the best knowledge at the moment and it can contain
  7551     // some bugs which can be found when this is tested in real environment.
  7504     // some bugs which can be found when this is tested in real environment.
  7552 
  7505 
  7553     TInt ret( KErrGeneral );
  7506     TInt ret( KErrGeneral );
  7554     RMmCustomAPI::TSimAuthenticationMgvMskDeletion mskDel;
  7507     RMmCustomAPI::TSimAuthenticationMgvMskDeletion mskDel;
  7555     TBool completeNeeded( ETrue );
  7508     TBool completeNeeded( ETrue );
  7610             dataPackage.PackData( &mskDel );
  7563             dataPackage.PackData( &mskDel );
  7611 
  7564 
  7612             iMessageRouter->Complete(
  7565             iMessageRouter->Complete(
  7613                 ECustomGetSimAuthenticationDataIPC,
  7566                 ECustomGetSimAuthenticationDataIPC,
  7614                 &dataPackage,
  7567                 &dataPackage,
  7615                 ret );	
  7568                 ret );
  7616             }
  7569             }
  7617         else
  7570         else
  7618             {
  7571             {
  7619             iMessageRouter->Complete(
  7572             iMessageRouter->Complete(
  7620                 ECustomGetSimAuthenticationDataIPC,
  7573                 ECustomGetSimAuthenticationDataIPC,
  7648     params.trId = aTrId;
  7601     params.trId = aTrId;
  7649     params.apdu.Append( KClaNoSm );             // CLA
  7602     params.apdu.Append( KClaNoSm );             // CLA
  7650     params.apdu.Append( KOddInstructionCode );  // INS
  7603     params.apdu.Append( KOddInstructionCode );  // INS
  7651     params.apdu.Append( KFirstBlockOfAuthenticationResponseData ); // P1
  7604     params.apdu.Append( KFirstBlockOfAuthenticationResponseData ); // P1
  7652     params.apdu.Append( 0x00 ); // P2
  7605     params.apdu.Append( 0x00 ); // P2
  7653     params.apdu.Append( 0x00 ); // Le 
  7606     params.apdu.Append( 0x00 ); // Le
  7654 
  7607 
  7655     iMmUiccMessHandler->CreateUiccApplCmdReq( params ); 
  7608     iMmUiccMessHandler->CreateUiccApplCmdReq( params );
  7656     }
  7609     }
  7657 
  7610 
  7658 
  7611 
  7659 // -----------------------------------------------------------------------------
  7612 // -----------------------------------------------------------------------------
  7660 // CMmCustomMessHandler::MapSw1Sw2ToAuthenticateResult
  7613 // CMmCustomMessHandler::MapSw1Sw2ToAuthenticateResult
  7661 // Maps sw1 and sw2 from response authenticate apdu to result 
  7614 // Maps sw1 and sw2 from response authenticate apdu to result
  7662 // -----------------------------------------------------------------------------
  7615 // -----------------------------------------------------------------------------
  7663 //
  7616 //
  7664 TUint8 CMmCustomMessHandler::MapSw1Sw2ToAuthenticateResult( TUint8 sw1, TUint8 sw2 )
  7617 TUint8 CMmCustomMessHandler::MapSw1Sw2ToAuthenticateResult( TUint8 sw1, TUint8 sw2 )
  7665     {
  7618     {
  7666 TFLOGSTRING3("TSY: CMmCustomMessHandler::MapSw1Sw2ToAuthenticateResult. sw1: 0x%x sw2: 0x%x\n", sw1, sw2 );
  7619 TFLOGSTRING3("TSY: CMmCustomMessHandler::MapSw1Sw2ToAuthenticateResult. sw1: 0x%x sw2: 0x%x\n", sw1, sw2 );
  7682             {
  7635             {
  7683             if( 0x00 == sw2 )
  7636             if( 0x00 == sw2 )
  7684                 {
  7637                 {
  7685                 ret = KNormalCommandEnding;
  7638                 ret = KNormalCommandEnding;
  7686                 }
  7639                 }
  7687             else if( 0xF1 == sw2 || 
  7640             else if( 0xF1 == sw2 ||
  7688                      0xF2 == sw2 )
  7641                      0xF2 == sw2 )
  7689                 {
  7642                 {
  7690                 ret = KWarningMoreDataAvailable;
  7643                 ret = KWarningMoreDataAvailable;
  7691                 }
  7644                 }
  7692             else if( 0xF3 == sw2 )
  7645             else if( 0xF3 == sw2 )
  7753 // -----------------------------------------------------------------------------
  7706 // -----------------------------------------------------------------------------
  7754 // CMmCustomMessHandler::ValidateReceivedAuthenticateApdu
  7707 // CMmCustomMessHandler::ValidateReceivedAuthenticateApdu
  7755 // Validates received apdu
  7708 // Validates received apdu
  7756 // -----------------------------------------------------------------------------
  7709 // -----------------------------------------------------------------------------
  7757 //
  7710 //
  7758 TUint8 CMmCustomMessHandler::ValidateReceivedAuthenticateApdu( 
  7711 TUint8 CMmCustomMessHandler::ValidateReceivedAuthenticateApdu(
  7759     TInt aTraId, 
  7712     TInt aTraId,
  7760     const TDesC8& aApdu )
  7713     const TDesC8& aApdu )
  7761     {
  7714     {
  7762     TUint8 ret( KApduOk );
  7715     TUint8 ret( KApduOk );
  7763 
  7716 
  7764     switch( aTraId )
  7717     switch( aTraId )
  7811     {
  7764     {
  7812 TFLOGSTRING("TSY: CMmCustomMessHandler::ValidateGsmSecurityContextApduResp.\n" );
  7765 TFLOGSTRING("TSY: CMmCustomMessHandler::ValidateGsmSecurityContextApduResp.\n" );
  7813 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_VALIDATEGSMSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::ValidateGsmSecurityContextApduResp" );
  7766 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_VALIDATEGSMSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::ValidateGsmSecurityContextApduResp" );
  7814     TUint8 ret( KApduNok );
  7767     TUint8 ret( KApduNok );
  7815 
  7768 
  7816     // apdu len is len of aApdu - 2 (because of 
  7769     // apdu len is len of aApdu - 2 (because of
  7817     // aApdu contains sw1 and sw2)
  7770     // aApdu contains sw1 and sw2)
  7818     TUint apduLen( aApdu.Length() - 2 );
  7771     TUint apduLen( aApdu.Length() - 2 );
  7819     TUint32 index( 0 );
  7772     TUint32 index( 0 );
  7820 
  7773 
  7821     index += aApdu[index] + 1;
  7774     index += aApdu[index] + 1;
  7839 TFLOGSTRING("TSY: CMmCustomMessHandler::Validate3GSecurityContextApduResp.\n" );
  7792 TFLOGSTRING("TSY: CMmCustomMessHandler::Validate3GSecurityContextApduResp.\n" );
  7840 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_VALIDATE3GSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::Validate3GSecurityContextApduResp" );
  7793 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_VALIDATE3GSECURITYCONTEXTAPDURESP, "CMmCustomMessHandler::Validate3GSecurityContextApduResp" );
  7841 
  7794 
  7842     TUint8 ret( KApduOk );
  7795     TUint8 ret( KApduOk );
  7843 
  7796 
  7844     // Let's calculate total APDU data len in aApdu. Length is 
  7797     // Let's calculate total APDU data len in aApdu. Length is
  7845     // decremented by 2 because of aApdu contains also sw1 and sw2
  7798     // decremented by 2 because of aApdu contains also sw1 and sw2
  7846     // and these are total 2 bytes long.
  7799     // and these are total 2 bytes long.
  7847     TUint8 apduLen( aApdu.Length() - 2 );
  7800     TUint8 apduLen( aApdu.Length() - 2 );
  7848     TUint32 index( 0 );
  7801     TUint32 index( 0 );
  7849     TUint8 tag( aApdu[index++] );
  7802     TUint8 tag( aApdu[index++] );
  7973 TFLOGSTRING("TSY: CMmCustomMessHandler::ValidateGBABootstrappingApduResp.\n" );
  7926 TFLOGSTRING("TSY: CMmCustomMessHandler::ValidateGBABootstrappingApduResp.\n" );
  7974 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_VALIDATEGBABOOTSTRAPPINGAPDURESP, "CMmCustomMessHandler::ValidateGBABootstrappingApduResp" );
  7927 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_VALIDATEGBABOOTSTRAPPINGAPDURESP, "CMmCustomMessHandler::ValidateGBABootstrappingApduResp" );
  7975 
  7928 
  7976     TUint8 ret( KApduNok );
  7929     TUint8 ret( KApduNok );
  7977 
  7930 
  7978     // Let's calculate total APDU data len in aApdu. Length is 
  7931     // Let's calculate total APDU data len in aApdu. Length is
  7979     // decremented by 2 because of aApdu contains also sw1 and sw2
  7932     // decremented by 2 because of aApdu contains also sw1 and sw2
  7980     // and these are total 2 bytes long.
  7933     // and these are total 2 bytes long.
  7981     TUint8 apduLen( aApdu.Length() - 2 );
  7934     TUint8 apduLen( aApdu.Length() - 2 );
  7982     TUint32 index( 0 );
  7935     TUint32 index( 0 );
  7983     TUint8 tag( aApdu[index++] );
  7936     TUint8 tag( aApdu[index++] );
  8007 TFLOGSTRING("TSY: CMmCustomMessHandler::ValidateGBANafDerivationApduResp.\n" );
  7960 TFLOGSTRING("TSY: CMmCustomMessHandler::ValidateGBANafDerivationApduResp.\n" );
  8008 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_VALIDATEGBANAFDERIVATIONAPDURESP, "CMmCustomMessHandler::ValidateGBANafDerivationApduResp" );
  7961 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_VALIDATEGBANAFDERIVATIONAPDURESP, "CMmCustomMessHandler::ValidateGBANafDerivationApduResp" );
  8009 
  7962 
  8010     TUint8 ret = KApduNok;
  7963     TUint8 ret = KApduNok;
  8011 
  7964 
  8012     // Let's calculate total APDU data len in aApdu. Length is 
  7965     // Let's calculate total APDU data len in aApdu. Length is
  8013     // decremented by 2 because of aApdu contains also sw1 and sw2
  7966     // decremented by 2 because of aApdu contains also sw1 and sw2
  8014     // and these are total 2 bytes long.
  7967     // and these are total 2 bytes long.
  8015     TUint8 apduLen( aApdu.Length() - 2 );
  7968     TUint8 apduLen( aApdu.Length() - 2 );
  8016     TUint32 index( 0 );
  7969     TUint32 index( 0 );
  8017     TUint8 tag( aApdu[index++] );
  7970     TUint8 tag( aApdu[index++] );
  8018 
  7971 
  8019     if( apduLen > 1 )
  7972     if( apduLen > 1 )
  8020         {
  7973         {
  8021         if( KSuccessfull3GAuthTag == tag )
  7974         if( KSuccessfull3GAuthTag == tag )
  8022             {
  7975             {
  8023             // response apdu contains only parameter Ks Ext NAF 
  7976             // response apdu contains only parameter Ks Ext NAF
  8024             // so, let's check that apdu len contains parameter
  7977             // so, let's check that apdu len contains parameter
  8025             // correctly. So apduLen should be len of Ks Ext NAF
  7978             // correctly. So apduLen should be len of Ks Ext NAF
  8026             // + 2 ("Successful GBA operation" field + 
  7979             // + 2 ("Successful GBA operation" field +
  8027             // Length of Ks_ext_NAF field)
  7980             // Length of Ks_ext_NAF field)
  8028             if( apduLen == aApdu[index] + 2 )
  7981             if( apduLen == aApdu[index] + 2 )
  8029                 {
  7982                 {
  8030                 ret = KApduOk;
  7983                 ret = KApduOk;
  8031                 }
  7984                 }
  8056 
  8009 
  8057 // -----------------------------------------------------------------------------
  8010 // -----------------------------------------------------------------------------
  8058 // CMmCustomMessHandler::FindTlvObject
  8011 // CMmCustomMessHandler::FindTlvObject
  8059 // Finds TLV object
  8012 // Finds TLV object
  8060 // -----------------------------------------------------------------------------
  8013 // -----------------------------------------------------------------------------
  8061 //  
  8014 //
  8062 TBool CMmCustomMessHandler::FindTlvObject(
  8015 TBool CMmCustomMessHandler::FindTlvObject(
  8063     TUint8 aTlvTag,
  8016     TUint8 aTlvTag,
  8064     const TDesC8& aBerTlv,
  8017     const TDesC8& aBerTlv,
  8065     TDes8& aTlvObject )
  8018     TDes8& aTlvObject )
  8066     {
  8019     {
  8076         {
  8029         {
  8077         tag = aBerTlv[index++];
  8030         tag = aBerTlv[index++];
  8078         tlvLength = aBerTlv[index++];
  8031         tlvLength = aBerTlv[index++];
  8079 
  8032 
  8080         // let's check if len of tlv object is coded
  8033         // let's check if len of tlv object is coded
  8081         // with one or two bytes        
  8034         // with one or two bytes
  8082         if( 0x81 == tlvLength ||
  8035         if( 0x81 == tlvLength ||
  8083             0x82 == tlvLength )
  8036             0x82 == tlvLength )
  8084             {
  8037             {
  8085             TUint8 byteCount( tlvLength & 0x7F );
  8038             TUint8 byteCount( tlvLength & 0x7F );
  8086             TUint8 ind( 0 );
  8039             TUint8 ind( 0 );
  8133 
  8086 
  8134 // -----------------------------------------------------------------------------
  8087 // -----------------------------------------------------------------------------
  8135 // CMmCustomMessHandler::DeriveCkFromKc
  8088 // CMmCustomMessHandler::DeriveCkFromKc
  8136 // derives Ck from Kc
  8089 // derives Ck from Kc
  8137 // -----------------------------------------------------------------------------
  8090 // -----------------------------------------------------------------------------
  8138 //  
  8091 //
  8139 void CMmCustomMessHandler::DeriveCkFromKc(
  8092 void CMmCustomMessHandler::DeriveCkFromKc(
  8140     TDes8& aCk,
  8093     TDes8& aCk,
  8141     const TDesC8& aKc )
  8094     const TDesC8& aKc )
  8142     {
  8095     {
  8143 TFLOGSTRING("TSY: CMmCustomMessHandler::DeriveCkFromKc.\n" );
  8096 TFLOGSTRING("TSY: CMmCustomMessHandler::DeriveCkFromKc.\n" );
  8215 // -----------------------------------------------------------------------------
  8168 // -----------------------------------------------------------------------------
  8216 // CMmCustomMessHandler::DeriveIkFromKc
  8169 // CMmCustomMessHandler::DeriveIkFromKc
  8217 // derives Ck from Kc
  8170 // derives Ck from Kc
  8218 // -----------------------------------------------------------------------------
  8171 // -----------------------------------------------------------------------------
  8219 //
  8172 //
  8220 TInt CMmCustomMessHandler::UiccHandleImsAuthentication( 
  8173 TInt CMmCustomMessHandler::UiccHandleImsAuthentication(
  8221     const CMmDataPackage& aDataPackage )
  8174     const CMmDataPackage& aDataPackage )
  8222     {
  8175     {
  8223 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccHandleImsAuthentication.\n" );
  8176 TFLOGSTRING("TSY: CMmCustomMessHandler::UiccHandleImsAuthentication.\n" );
  8224 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCHANDLEIMSAUTHENTICATION, "CMmCustomMessHandler::UiccHandleImsAuthentication" );
  8177 OstTrace0( TRACE_NORMAL, CMMCUSTOMMESSHANDLER_UICCHANDLEIMSAUTHENTICATION, "CMmCustomMessHandler::UiccHandleImsAuthentication" );
  8225     TInt ret( KErrNone );
  8178     TInt ret( KErrNone );
  8249 
  8202 
  8250     TUint8 cardType( iMmUiccMessHandler->GetCardType() );
  8203     TUint8 cardType( iMmUiccMessHandler->GetCardType() );
  8251 
  8204 
  8252     if( UICC_CARD_TYPE_ICC == cardType )
  8205     if( UICC_CARD_TYPE_ICC == cardType )
  8253         {
  8206         {
  8254         // no need to activate ISIM application, 
  8207         // no need to activate ISIM application,
  8255         // let's just send the authentication APDU
  8208         // let's just send the authentication APDU
  8256         UiccCreateRunGsmAlgorithmApdu(
  8209         UiccCreateRunGsmAlgorithmApdu(
  8257             params,
  8210             params,
  8258             authenticationData.iRAND,
  8211             authenticationData.iRAND,
  8259             ETrIdRunGsmAlgorithmIms );
  8212             ETrIdRunGsmAlgorithmIms );
  8270         if( iMmUiccMessHandler->IsIsimApplicationFound() )
  8223         if( iMmUiccMessHandler->IsIsimApplicationFound() )
  8271             {
  8224             {
  8272             // let's check is ISIM application already tried to activate
  8225             // let's check is ISIM application already tried to activate
  8273             if( iIsimApplActivated )
  8226             if( iIsimApplActivated )
  8274                 {
  8227                 {
  8275                 UiccCreate3GSecurityContextApdu( 
  8228                 UiccCreate3GSecurityContextApdu(
  8276                     params, 
  8229                     params,
  8277                     authenticationData.iRAND, 
  8230                     authenticationData.iRAND,
  8278                     authenticationData.iAUTN,
  8231                     authenticationData.iAUTN,
  8279                     ETrIdEEapAkaAuthenticateIms );
  8232                     ETrIdEEapAkaAuthenticateIms );
  8280 
  8233 
  8281                 ret = iMmUiccMessHandler->CreateUiccApplCmdReq( params, UICC_APPL_TYPE_UICC_ISIM );
  8234                 ret = iMmUiccMessHandler->CreateUiccApplCmdReq( params, UICC_APPL_TYPE_UICC_ISIM );
  8282                 }
  8235                 }
  8335     params.fileIdSfi = UICC_SFI_NOT_PRESENT;
  8288     params.fileIdSfi = UICC_SFI_NOT_PRESENT;
  8336     params.filePath.Append( KMasterFileId >> 8 );
  8289     params.filePath.Append( KMasterFileId >> 8 );
  8337     params.filePath.Append( KMasterFileId );
  8290     params.filePath.Append( KMasterFileId );
  8338     params.filePath.Append( iMmUiccMessHandler->GetApplicationFileId() );
  8291     params.filePath.Append( iMmUiccMessHandler->GetApplicationFileId() );
  8339 
  8292 
  8340     UiccCreate3GSecurityContextApdu( 
  8293     UiccCreate3GSecurityContextApdu(
  8341         params, 
  8294         params,
  8342         iRandBuf, 
  8295         iRandBuf,
  8343         iAutnBuf,
  8296         iAutnBuf,
  8344         ETrIdEEapAkaAuthenticateIms );
  8297         ETrIdEEapAkaAuthenticateIms );
  8345 
  8298 
  8346     if( UICC_STATUS_OK == aStatus )
  8299     if( UICC_STATUS_OK == aStatus )
  8347         {
  8300         {
  8351         // to the ISim application
  8304         // to the ISim application
  8352         iMmUiccMessHandler->CreateUiccApplCmdReq( params, UICC_APPL_TYPE_UICC_ISIM );
  8305         iMmUiccMessHandler->CreateUiccApplCmdReq( params, UICC_APPL_TYPE_UICC_ISIM );
  8353         }
  8306         }
  8354     else
  8307     else
  8355         {
  8308         {
  8356         // ISim application activation fails, le'ts send authentication apdu 
  8309         // ISim application activation fails, le'ts send authentication apdu
  8357         // to the USim application
  8310         // to the USim application
  8358         iMmUiccMessHandler->CreateUiccApplCmdReq( params );
  8311         iMmUiccMessHandler->CreateUiccApplCmdReq( params );
  8359         }
  8312         }
  8360     }
  8313     }
  8361 
  8314