|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "mcesecureinsession.h" |
|
22 #include "mcemanager.h" |
|
23 #include "mceclientserver.h" |
|
24 #include "mceserial.h" |
|
25 #include "mceclilogs.h" |
|
26 |
|
27 #include "mcecomsession.h" |
|
28 #include "mceitcsender.h" |
|
29 |
|
30 #define _FLAT_DATA static_cast<CMceComSession*>( iFlatData ) |
|
31 #define FLAT_DATA( data ) _FLAT_DATA->data |
|
32 |
|
33 // ============================ MEMBER FUNCTIONS =============================== |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CMceSecureInSession::NewL |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CMceSecureInSession* CMceSecureInSession::NewL( RReadStream& aReadStream, |
|
40 CMceManager& aManager, |
|
41 TUint32 aProfileId, |
|
42 TBool aUpdateSession ) |
|
43 { |
|
44 CMceSecureInSession* self = |
|
45 new ( ELeave ) CMceSecureInSession( &aManager, aProfileId ); |
|
46 CleanupStack::PushL( self ); |
|
47 |
|
48 MMceComSerializationContext serCtx( aReadStream ); |
|
49 CleanupClosePushL( serCtx ); |
|
50 |
|
51 self->InitializeInSessionL( serCtx, aUpdateSession ); |
|
52 CleanupStack::PopAndDestroy(); // serCtx |
|
53 |
|
54 self->InitializeL(); |
|
55 CleanupStack::Pop( self ); |
|
56 return self; |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CMceSecureInSession::NewL |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 |
|
64 CMceSecureInSession* CMceSecureInSession::NewL() |
|
65 { |
|
66 CMceSecureInSession* self = new (ELeave) CMceSecureInSession( NULL, NULL ); |
|
67 CleanupStack::PushL( self ); |
|
68 self->ConstructL( KNullDesC8, KNullDesC8 ); |
|
69 CleanupStack::Pop( self ); |
|
70 return self; |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // CMceSecureInSession::~CMceSecureInSession |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 EXPORT_C CMceSecureInSession::~CMceSecureInSession() |
|
78 { |
|
79 iTemp.Close(); |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CMceSecureInSession::Type |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 TMceSessionType CMceSecureInSession::Type() const |
|
87 { |
|
88 return KMceSessionSecure; |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CMceSecureInSession::SupportedCryptoContextsL |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 const RArray<TMceCryptoContext>& |
|
96 CMceSecureInSession::SupportedCryptoContextsL() const |
|
97 { |
|
98 return iTemp; |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CMceSecureInSession::CryptoContexts |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 const RArray<TMceCryptoContext>& CMceSecureInSession::CryptoContexts() const |
|
106 { |
|
107 return FLAT_DATA( iClientCryptoSuites ); |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CMceSecureInSession::SetCryptoContextsL |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 void CMceSecureInSession::SetCryptoContextsL( |
|
115 const RArray<TMceCryptoContext>& aArray ) |
|
116 { |
|
117 MCECLI_DEBUG( "CMceSecureInSession::SetCryptoContextsL, Entry" ) |
|
118 TBool equal( ETrue ); |
|
119 TInt index = 0; |
|
120 TInt count = aArray.Count(); |
|
121 if ( count != FLAT_DATA( iClientCryptoSuites ).Count() ) |
|
122 { |
|
123 equal = !equal; |
|
124 } |
|
125 else |
|
126 { |
|
127 for ( index = 0; index < count; index ++ ) |
|
128 { |
|
129 if ( aArray[ index ] != FLAT_DATA( iClientCryptoSuites )[ index ] ) |
|
130 { |
|
131 equal = !equal; |
|
132 } |
|
133 } |
|
134 } |
|
135 if ( !equal ) |
|
136 { |
|
137 MCECLI_DEBUG( "CMceSecureInSession::SetCryptoContextsL, setting" ) |
|
138 |
|
139 FLAT_DATA( iClientCryptoSuites ).Reset(); |
|
140 for ( index = 0; index < count; index++ ) |
|
141 { |
|
142 FLAT_DATA( iClientCryptoSuites ).InsertL( aArray[ index ], index ); |
|
143 } |
|
144 } |
|
145 |
|
146 MCECLI_DEBUG( "CMceSecureInSession::SetCryptoContextsL, Exit" ) |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CMceSecureInSession::CMceSecureInSession |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 CMceSecureInSession::CMceSecureInSession( CMceManager* aManager, |
|
154 TUint32 aProfileId ) : |
|
155 CMceInSession( aManager, aProfileId ) |
|
156 { |
|
157 } |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // CMceSecureInSession::ConstructL |
|
161 // ----------------------------------------------------------------------------- |
|
162 // |
|
163 void CMceSecureInSession::ConstructL( const TDesC8& aOriginator, |
|
164 const TDesC8& aRecipient ) |
|
165 { |
|
166 CMceInSession::ConstructL( aOriginator, aRecipient ); |
|
167 FLAT_DATA( iClientCryptoSuites ).InsertL( EAES_CM_128_HMAC_SHA1_80, 0 ); |
|
168 FLAT_DATA( iClientCryptoSuites ).InsertL( EAES_CM_128_HMAC_SHA1_32, 1 ); |
|
169 iTemp.Reset(); |
|
170 |
|
171 User::LeaveIfError( iTemp.Append(EAES_CM_128_HMAC_SHA1_80 ) ); |
|
172 User::LeaveIfError( iTemp.Append(EAES_CM_128_HMAC_SHA1_32 ) ); |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // CMceSecureInSession::InitializeInSessionL |
|
177 // ----------------------------------------------------------------------------- |
|
178 // |
|
179 void CMceSecureInSession:: InitializeInSessionL( |
|
180 MMceComSerializationContext& aSerCtx, |
|
181 TBool aUpdateSession ) |
|
182 { |
|
183 CMceInSession::InitializeInSessionL( aSerCtx, aUpdateSession ); |
|
184 iTemp.Reset(); |
|
185 User::LeaveIfError( iTemp.Append( EAES_CM_128_HMAC_SHA1_80 ) ); |
|
186 User::LeaveIfError( iTemp.Append( EAES_CM_128_HMAC_SHA1_32 ) ); |
|
187 } |