|
1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #ifndef SECMAN_H |
|
22 #define SECMAN_H |
|
23 |
|
24 #include <es_prot.h> |
|
25 #include <bt_sock.h> |
|
26 #include <btmanclient.h> |
|
27 #include <btextnotifiers.h> |
|
28 #include <bluetooth/hcicommandqueueclient.h> |
|
29 |
|
30 #include "notification.h" |
|
31 #include "SecManNotifiers.h" |
|
32 |
|
33 #include "btaccessrequesterstatemachine.h" |
|
34 #include <btextnotifierspartner.h> |
|
35 |
|
36 //forward decs |
|
37 class CBTSecMan; |
|
38 class CPairingServer; |
|
39 class CBTAccessRequester; |
|
40 class CBTAuthorisor; |
|
41 class CPhysicalLink; |
|
42 class CPhysicalLinksManager; |
|
43 class CLinkMgrProtocol; |
|
44 class CBTInquiryMgr; |
|
45 class CBTHostResolver; |
|
46 class CBTAccessRequesterStateFactory; |
|
47 class MHCICommandQueue; |
|
48 class THCICommandCompleteEvent; |
|
49 |
|
50 class COobDataManager; |
|
51 class CSimplePairingResultList; |
|
52 class CAuthenticationResultList; |
|
53 |
|
54 // used in physicallinks.cpp |
|
55 const TInt KDeviceNotObtained = KMaxTInt; |
|
56 |
|
57 /** |
|
58 Interface for a class that is making an access request - typically a SAP |
|
59 **/ |
|
60 enum TBTSecurityClearance |
|
61 { |
|
62 EBTSecManAccessGranted, |
|
63 EBTSecManAccessDenied, |
|
64 EBTSecManAccessDeferred, |
|
65 }; |
|
66 |
|
67 /** |
|
68 Security Notifier Update Class |
|
69 Handles the updating of the Bluetooth Notifiers |
|
70 **/ |
|
71 template <class T> |
|
72 NONSHARABLE_CLASS(CSecNotifierUpdateAO) : public CActive |
|
73 { |
|
74 public: |
|
75 static CSecNotifierUpdateAO<T>* NewL(RNotifier& aNotifier, TUid aNotifierUid); |
|
76 static CSecNotifierUpdateAO<T>* NewLC(RNotifier& aNotifier, TUid aNotifierUid); |
|
77 ~CSecNotifierUpdateAO(); |
|
78 |
|
79 void DoUpdate(const T& aPckg); |
|
80 void DoUpdateSynchronous(const T& aPckg); |
|
81 |
|
82 private: // from CActive |
|
83 void DoCancel(); |
|
84 void RunL(); |
|
85 TInt RunError(TInt aError); |
|
86 |
|
87 private: |
|
88 CSecNotifierUpdateAO(); |
|
89 void ConstructL(RNotifier& aNotifier, TUid aNotifierUid); |
|
90 |
|
91 private: |
|
92 RNotifier iNotifier; |
|
93 TUid iNotifierUid; |
|
94 TBuf8<1> iAnswer; |
|
95 T iPckg; |
|
96 RArray<T> iPckgQueue; |
|
97 }; |
|
98 |
|
99 |
|
100 /** |
|
101 Base class that makes requests using RNotifier. |
|
102 This is used by the security manager to queue the notifier requests. |
|
103 **/ |
|
104 NONSHARABLE_CLASS(CSecNotifierRequester) : public CActive, public MResolverNotify |
|
105 { |
|
106 public: |
|
107 virtual void DoRequest() = 0; |
|
108 virtual void DoUpdateNotifier() = 0; |
|
109 virtual void HandleTimeout(); |
|
110 |
|
111 ~CSecNotifierRequester(); |
|
112 protected: |
|
113 CSecNotifierRequester(CBTSecMan& aSecMgr); |
|
114 void ConstructL(const TBTDevAddr& aAddr); |
|
115 void QueryComplete(TInt aResult); |
|
116 void RemoveMyselfFromQue(); |
|
117 protected: |
|
118 const TDesC8* iDeviceName; //non-owned; points to InqMgr result |
|
119 TBTDevAddr iDevAddr; |
|
120 TBool iIsAddedToNotifierQue; |
|
121 RNotifier iNotifier; |
|
122 CBTHostResolver* iHR; |
|
123 TNameRecord* iHRNameRecord; |
|
124 CBTInquiryMgr& iInquiryMgr; |
|
125 CBTSecMan& iSecMgr; |
|
126 }; |
|
127 |
|
128 NONSHARABLE_CLASS(CSecNotifierRequesterTimer) |
|
129 : public CTimer |
|
130 { |
|
131 public: |
|
132 static CSecNotifierRequesterTimer* NewL(CSecNotifierRequester& aObserver); |
|
133 ~CSecNotifierRequesterTimer(); |
|
134 void Start(TTimeIntervalMicroSeconds32 aTimeout); |
|
135 |
|
136 private: |
|
137 CSecNotifierRequesterTimer(CSecNotifierRequester& aObserver); |
|
138 void ConstructL(); |
|
139 void RunL(); |
|
140 |
|
141 private: |
|
142 CSecNotifierRequester& iObserver; |
|
143 }; |
|
144 |
|
145 |
|
146 /** |
|
147 This class handles CBTSecMan commands to and from the HCI |
|
148 It is owned, constructed and destructed by CBTSecMan |
|
149 **/ |
|
150 NONSHARABLE_CLASS(CSecManCommandController) |
|
151 : public CBase |
|
152 , public MHCICommandQueueClient |
|
153 { |
|
154 public: |
|
155 ~CSecManCommandController(); |
|
156 static CSecManCommandController* NewL(CBTSecMan& aSecMan); |
|
157 static CSecManCommandController* NewLC(CBTSecMan& aSecMan); |
|
158 |
|
159 void SetHCICommandQueue(MHCICommandQueue& aCommandQueue); |
|
160 void ClearHCICommandQueue(); |
|
161 |
|
162 public: // command functions |
|
163 void WriteSimplePairingModeL(TUint8 aSimplePairingMode); |
|
164 void WriteSimplePairingDebugModeL(TUint8 aSimplePairingDebugMode); |
|
165 void IOCapabilityRequestReplyL(const TBTDevAddr& aBDADDR, THCIIoCapability aIOCapability, THCIOobDataPresence aOOBDataPresent, THCIAuthenticationRequirement aAuthenticationRequirements); |
|
166 void IOCapabilityRequestNegativeReplyL(const TBTDevAddr& aBDADDR, TUint8 aReason); |
|
167 void UserConfirmationRequestReplyL(const TBTDevAddr& aBDADDR); |
|
168 void UserConfirmationRequestNegativeReplyL(const TBTDevAddr& aBDADDR); |
|
169 void RemoteOOBDataRequestReplyL(const TBTDevAddr& aBDADDR, const TBluetoothSimplePairingHash& aC, const TBluetoothSimplePairingRandomizer& aR); |
|
170 void RemoteOOBDataRequestNegativeReplyL(const TBTDevAddr& aBDADDR); |
|
171 |
|
172 private: // events from MHCICommandQueueClient |
|
173 void MhcqcCommandEventReceived(const THCIEventBase& aEvent, const CHCICommandBase* aRelatedCommand); |
|
174 void MhcqcCommandErrored(TInt aErrorCode, const CHCICommandBase* aCommand); |
|
175 |
|
176 private: |
|
177 CSecManCommandController(CBTSecMan& aSecMan); |
|
178 void ConstructL(); |
|
179 |
|
180 MHCICommandQueue& CommandQueue() const; |
|
181 |
|
182 void CommandCompleteEvent(const THCIEventBase& aEvent); |
|
183 |
|
184 void CommandStatusEvent(const THCIEventBase& aEvent); |
|
185 void IOCapabilityRequestEvent(const THCIEventBase& aEvent); |
|
186 void IOCapabilityResponseEvent(const THCIEventBase& aEvent); |
|
187 void UserConfirmationRequestEvent(const THCIEventBase& aEvent); |
|
188 void UserPasskeyNotificationEvent(const THCIEventBase& aEvent); |
|
189 void RemoteOOBDataRequestEvent(const THCIEventBase& aEvent); |
|
190 void SimplePairingCompleteEvent(const THCIEventBase& aEvent); |
|
191 void KeypressNotificationEvent(const THCIEventBase& aEvent); |
|
192 |
|
193 void WriteSimplePairingModeOpcode(const THCICommandCompleteEvent& aCompleteEvent); |
|
194 void RemoteOOBDataRequestReplyOpcode(const THCICommandCompleteEvent& aCompleteEvent); |
|
195 void RemoteOOBDataRequestNegativeReplyOpcode(const THCICommandCompleteEvent& aCompleteEvent); |
|
196 void WriteSimplePairingDebugModeOpcode(const THCICommandCompleteEvent& aCompleteEvent); |
|
197 |
|
198 private: // checking cast functions. |
|
199 static THCIIoCapability CastToIoCapability(TUint8 aIOCapability); |
|
200 static THCIOobDataPresence CastToOobDataPresence(TUint8 aOOBDataPresent); |
|
201 static THCIAuthenticationRequirement CastToAuthenticationRequirements(TUint8 aAuthenticationRequirements); |
|
202 |
|
203 private: |
|
204 CBTSecMan& iSecMan; |
|
205 MHCICommandQueue* iCommandQueue; |
|
206 }; |
|
207 |
|
208 enum TAccessType |
|
209 { |
|
210 EGeneralBonding, |
|
211 EGeneralBondingSecurityMode4Outgoing, |
|
212 EDedicatedBonding, |
|
213 }; |
|
214 |
|
215 /** |
|
216 BT Security Manager. |
|
217 Provides access to all functionality of the security manager. |
|
218 **/ |
|
219 NONSHARABLE_CLASS(CBTSecMan) : public CBase |
|
220 { |
|
221 public: |
|
222 static CBTSecMan* NewL(); |
|
223 static CBTSecMan* NewLC(); |
|
224 ~CBTSecMan(); |
|
225 |
|
226 void SetLocalSimplePairingMode(TBool aEnabled); |
|
227 TBool LocalSimplePairingMode() const; |
|
228 |
|
229 void SimplePairingSupportDetermined(const TBTDevAddr& aBDAddr); |
|
230 |
|
231 void SetPhysicalLinksMgr(const CPhysicalLinksManager& aConnectionsMgr); |
|
232 void ClearPhysicalLinksMgr(); |
|
233 void SetLinksMgrProtocol(CLinkMgrProtocol& aLinkMgrProtocol); |
|
234 void ClearLinksMgrProtocol(); |
|
235 void SetHCICommandQueue(MHCICommandQueue& aCommandQueue); |
|
236 void ClearHCICommandQueue(); |
|
237 CPhysicalLinksManager& ConnectionsManager() const; |
|
238 COobDataManager& OobDataManager() const; |
|
239 |
|
240 TBool DebugMode() const; |
|
241 void SetDebugMode(TBool aOn); |
|
242 void ClearDebugMode(); |
|
243 void DebugModeChanged(TBool aOn); |
|
244 |
|
245 void AccessRequestL(const TBTServiceSecurity& aSecurity, |
|
246 const TBTServiceSecurityPerDevice* const aOverride, |
|
247 const TBTDevAddr& aBDAddr, |
|
248 TAccessType aAccessType, |
|
249 MAccessRequestResponseHandler& aRequester); |
|
250 |
|
251 void AccessRequestComplete(CBTAccessRequester* aRequester, TInt aResult); |
|
252 |
|
253 void AddNotifierRequestToQueL(CSecNotifierRequester& aRequest); |
|
254 void RemoveNotifierRequestFromQue(CSecNotifierRequester& aRequest); |
|
255 |
|
256 void CancelRequest(MAccessRequestResponseHandler& aRequester); |
|
257 void DeleteLinkKeyL(const TBTDevAddr& aAddr); |
|
258 |
|
259 void GetPassKeyLengthAndOriginator(const TBTDevAddr& aAddr, TUint& aPasskeyMinLength, |
|
260 TBool& aLocallyInitiatedAuthentication, |
|
261 TBool& aStrongKeyRequired); |
|
262 |
|
263 void AuthenticationInProgress(); |
|
264 void IOCapabilityRequestFromRemote(const TBTDevAddr& aAddr); |
|
265 void IOCapabilityAskForResponse(const TBTDevAddr& aAddr, THCIIoCapability aIOCapability, THCIOobDataPresence aOOBDataPresent, THCIAuthenticationRequirement aAuthentication_Requirements); |
|
266 void RemoteOOBDataRequest(const TBTDevAddr& aAddr); |
|
267 void RemoteOOBDataRequestComplete(const TBTDevAddr& aAddr); |
|
268 void UserConfirmationRequest(const TBTDevAddr& aAddr, TUint32 aNumericValue); |
|
269 void UserConfirmationComplete(const TBTDevAddr& aAddr, TBool aResult, TInt aError); |
|
270 void PasskeyNotification(const TBTDevAddr& aAddr, TUint32 aPasskey); |
|
271 void PasskeyNotificationComplete(const TBTDevAddr& aAddr, TInt aError); |
|
272 void KeypressNotification(const TBTDevAddr& aAddr, TUint8 aNotificationType); |
|
273 void SimplePairingComplete(const TBTDevAddr& aAddr, THCIErrorCode aError); |
|
274 void AuthenticationComplete(const TBTDevAddr& aAddr, THCIErrorCode aError); |
|
275 |
|
276 TBool IsDedicatedBondingAttempted(const TBTDevAddr& aAddr); |
|
277 TBool IsOutboundAccessRequest(const TBTDevAddr& aAddr); |
|
278 |
|
279 CBTAccessRequesterStateFactory* StateMachine(); |
|
280 |
|
281 inline MHCICommandQueueClient& HCIEventHandler() const { return *iCommandController; } |
|
282 inline CSecManCommandController& CommandController() const { return *iCommandController; } |
|
283 CBTAccessRequester* FindActiveAccessRequester(const TBTDevAddr& aAddr) const; |
|
284 |
|
285 private: |
|
286 MAccessRequestResponseHandler& FinishAccessRequest(CBTAccessRequester* aAccessRequester); |
|
287 |
|
288 private: |
|
289 static TBool CompareAccessRequesterByBDAddr(const TBTDevAddr* aKey, const CBTAccessRequester& aAccessRequester); |
|
290 static TBool CompareAccessRequesterByRequester(const MAccessRequestResponseHandler* aKey, const CBTAccessRequester& aAccessRequester); |
|
291 |
|
292 private: |
|
293 CSecManCommandController* iCommandController; |
|
294 |
|
295 private: |
|
296 CPairingServer* iPairingServer; |
|
297 COobDataManager* iOobDataManager; |
|
298 CSimplePairingResultList* iSimplePairingResultList; |
|
299 CAuthenticationResultList* iAuthenticationResultList; |
|
300 |
|
301 private: |
|
302 CBTSecMan(); |
|
303 void ConstructL(); |
|
304 private: |
|
305 CPhysicalLinksManager* iPhysicalLinksManager; |
|
306 RPointerArray<CBTAccessRequester> iAccessRequesters; |
|
307 RPointerArray<CBTAccessRequester> iPendingAccessRequesters; |
|
308 RPointerArray<CSecNotifierRequester> iNotifierRequesters; |
|
309 CSecNotifierRequester* iActiveNotifierRequester; |
|
310 TBool iLocalSimplePairingMode; |
|
311 TBool iDebugMode; |
|
312 CBTAccessRequesterStateFactory* iStateMachine; |
|
313 }; |
|
314 |
|
315 |
|
316 /** |
|
317 Enforces security policy and answers access requests. |
|
318 An object of this class is created when an access request is first made from a particular device to a |
|
319 particular service. It is destroyed when the request may be answered with "accepted" or "denied". |
|
320 **/ |
|
321 NONSHARABLE_CLASS(CBTAccessRequester) |
|
322 : public CBase |
|
323 , public MPhysicalLinkObserver |
|
324 , public MBluetoothPrefetchNotifier |
|
325 { |
|
326 public: |
|
327 static CBTAccessRequester* NewLC(CPhysicalLink& aConnection, |
|
328 const TBTServiceSecurity& aSecurity, |
|
329 const TBTServiceSecurityPerDevice* const aOverride, |
|
330 MAccessRequestResponseHandler& aRequester, |
|
331 TAccessType aAccessType, |
|
332 CBTSecMan& aParent); |
|
333 ~CBTAccessRequester(); |
|
334 |
|
335 void Start(); |
|
336 TBool SendEvent( TBTSecEvent& aEvent ); |
|
337 |
|
338 public: // State machine actions |
|
339 void Ready( TBTSecEvent& aEvent ); |
|
340 void AuthenticationRequested( TBTSecEvent& aEvent ); |
|
341 void RequestAuthentication( TBTSecEvent& aEvent ); |
|
342 void AuthenticationComplete( TBTSecEvent& aEvent ); |
|
343 void EncryptionChangePending( TBTSecEvent& aEvent ); |
|
344 void EncryptionChangeComplete( TBTSecEvent& aEvent ); |
|
345 void AuthorisationRequested( TBTSecEvent& aEvent ); |
|
346 void RequestAuthorisation( TBTSecEvent& aEvent ); |
|
347 void AuthorisationComplete( TBTSecEvent& aEvent ); |
|
348 |
|
349 void IOCapsResponse( TBTSecEvent& aEvent ); |
|
350 void IOCapsRequested( TBTSecEvent& aEvent ); |
|
351 void UserConfirmation( TBTSecEvent& aEvent ); |
|
352 void PasskeyEntry( TBTSecEvent& aEvent ); |
|
353 void RemoteOOBDataRequest( TBTSecEvent& aEvent ); |
|
354 void SimplePairingPending( TBTSecEvent& aEvent ); |
|
355 |
|
356 const MAccessRequestResponseHandler& ServiceRequester() const; |
|
357 const TBTDevAddr& DeviceAddress() const; |
|
358 |
|
359 TBool IsAuthenticationReqPending(const TBTDevAddr& aAddr, TUint& aPasskeyMinLength, TBluetoothMitmProtection& aMitmLevel); |
|
360 TBool AuthenticationRequired() const; |
|
361 TBool EncryptionRequired() const; |
|
362 TBool AuthenticationInProgress() const; |
|
363 TBool UnableToBond() const; |
|
364 TBool BasebandConnected() const; |
|
365 |
|
366 void CompleteRequest(TInt aReason); |
|
367 void SetCurrentState(TBTAccessRequesterState aState); |
|
368 TBool RequirementsDenied(); |
|
369 TAccessType AccessType() const; |
|
370 |
|
371 private: |
|
372 NONSHARABLE_CLASS(CAuthenticationTimer) |
|
373 : public CTimer |
|
374 { |
|
375 private: |
|
376 static const TInt KAuthenticationRequestTimeout = 60000000; // 60 seconds in microseconds |
|
377 |
|
378 public: |
|
379 static CAuthenticationTimer* NewL(CBTAccessRequester& aObserver); |
|
380 ~CAuthenticationTimer(); |
|
381 void Start(); |
|
382 |
|
383 private: |
|
384 CAuthenticationTimer(CBTAccessRequester& aObserver); |
|
385 void ConstructL(); |
|
386 void RunL(); |
|
387 |
|
388 private: |
|
389 CBTAccessRequester& iObserver; |
|
390 }; |
|
391 |
|
392 private: |
|
393 CBTAccessRequester(CPhysicalLink& aConnection, |
|
394 const TBTServiceSecurity& aServiceSecurity, |
|
395 const TBTServiceSecurityPerDevice* const aOverride, |
|
396 MAccessRequestResponseHandler& aRequester, |
|
397 TAccessType aDedicatedBonding, |
|
398 CBTSecMan& aParent); |
|
399 void ConstructL(); |
|
400 void SubscribeToLinkObserver(); |
|
401 |
|
402 TBTAccessRequirements OverallRequirements(const TBTServiceSecurity& aServiceSecurity, |
|
403 const TBTNamelessDevice& aDevice); |
|
404 |
|
405 void PhysicalLinkChange(const TBTBasebandEventNotification & aEvent); |
|
406 void QueryComplete(TInt aErr); |
|
407 void SetDeviceName(); |
|
408 |
|
409 TBool LinkKeyGoodEnough() const; |
|
410 TBool AuthenticationRecommended() const; |
|
411 |
|
412 void SetAuthenticationInProgress(); |
|
413 |
|
414 void AuthenticationTimerElapsed(); |
|
415 void LinkError(TInt aError); |
|
416 |
|
417 private: //from MPhysicalLinkObserver |
|
418 void PhysicalLinkChange(const TBTBasebandEventNotification & aEvent, CPhysicalLink& aPhysicalLink); |
|
419 TPhysicalLinkObserverQLink& ObserverQLink(); |
|
420 |
|
421 private: // from MBluetoothPrefetchNotifier |
|
422 TPrefetchNotifierQLink& MbpnQueLink(); |
|
423 void MbpnPrefetchComplete(TInt aError); |
|
424 |
|
425 private: |
|
426 MAccessRequestResponseHandler& iRequester; //< the SAP who instructed us to check sec |
|
427 CBTSecMan& iSecMan; //< our parent |
|
428 CPhysicalLink* iBaseband; //< the baseband we're operating on |
|
429 TBTDevAddr iDevAddr; //< Bluetooth device address we are representing. |
|
430 |
|
431 CBTAuthorisor* iAuthorisor; //< looks after authorisation UI/state |
|
432 |
|
433 |
|
434 const TBTServiceSecurity iServiceRequirements; //< the security required by our service |
|
435 TBTAccessRequirements iRequirements; //< the requirements of device and service and its UID |
|
436 |
|
437 const TBTServiceSecurityPerDevice* const iOverride; //< any overrides the service has |
|
438 TBool iIsSubscribedToConnection; |
|
439 TBool iDeviceRetrievedFromRegistry; |
|
440 |
|
441 const TDesC8* iDeviceName; //< non-owned; points to InqMgr result |
|
442 TPhysicalLinkObserverQLink iQueLink; |
|
443 TPrefetchNotifierQLink iPrefetchQueueLink; |
|
444 TBool iAuthenticationInProgress; //< If authentication is in progress |
|
445 |
|
446 TAccessType iAccessType; |
|
447 |
|
448 TBool iDedicatedBondingNotAvailable; //< Remote IOCapabilitiesResponse says no dedicated bonding |
|
449 THCIIoCapability iRemoteIOCapability; |
|
450 THCIOobDataPresence iRemoteOOBDataPresence; |
|
451 |
|
452 CAuthenticationTimer* iTimer; |
|
453 |
|
454 TBTAccessRequesterState iCurrentState; |
|
455 }; |
|
456 |
|
457 |
|
458 /** |
|
459 Prompts the user for permission for a particular connection to proceed. |
|
460 Uses the RNotifier framework to produce a dialog containing information |
|
461 about the remote device and the local service in question. |
|
462 **/ |
|
463 NONSHARABLE_CLASS(CBTAuthorisor) : public CSecNotifierRequester |
|
464 { |
|
465 public: |
|
466 static CBTAuthorisor* NewL(CBTAccessRequester& aAccessRequester, CBTSecMan& aSecMan, TUid aServiceUID); |
|
467 static CBTAuthorisor* NewLC(CBTAccessRequester& aAccessRequester, CBTSecMan& aSecMan, TUid aServiceUID); |
|
468 ~CBTAuthorisor(); |
|
469 |
|
470 private: // from CActive |
|
471 void DoCancel(); |
|
472 void RunL(); |
|
473 TInt RunError(TInt aError); |
|
474 |
|
475 private: // from CSecNotifierRequester |
|
476 void DoRequest(); |
|
477 void DoUpdateNotifier(); |
|
478 |
|
479 private: |
|
480 CBTAuthorisor(CBTAccessRequester& aAccessRequester, CBTSecMan& aSecMan, TUid aServiceUID); |
|
481 |
|
482 private: |
|
483 CSecNotifierUpdateAO<TBTNotifierUpdateParamsPckg>* iUpdateNotifierAO; |
|
484 CBTAccessRequester& iAccessRequester; |
|
485 TBTAuthorisationParamsPckg iAuthorisationParamsPckg; |
|
486 TPckgBuf<TBool> iResultPckg; |
|
487 }; |
|
488 |
|
489 /** |
|
490 RNotifier Pin Provider. |
|
491 Uses an RNotifier plugin to get a pin from the user. |
|
492 Generally owned by physical link to cope with passive authentication |
|
493 **/ |
|
494 NONSHARABLE_CLASS(CBTPinRequester) |
|
495 : public CSecNotifierRequester |
|
496 { |
|
497 public: |
|
498 static CBTPinRequester* NewL(const TBTDevAddr& aAddr, |
|
499 MPINCodeResponseHandler& aHandler, |
|
500 CBTSecMan& aSecMan, |
|
501 TUint aPasskeyMinLength, |
|
502 TBool aInternallyInitiated, |
|
503 TBool aStrongKeyRequired, |
|
504 TUint aRecommendedPasskeyMinLength); |
|
505 |
|
506 static CBTPinRequester* NewLC(const TBTDevAddr& aAddr, |
|
507 MPINCodeResponseHandler& aHandler, |
|
508 CBTSecMan& aSecMan, |
|
509 TUint aPasskeyMinLength, |
|
510 TBool aInternallyInitiated, |
|
511 TBool aStrongKeyRequired, |
|
512 TUint aRecommendedPasskeyMinLength); |
|
513 |
|
514 ~CBTPinRequester(); |
|
515 |
|
516 void UpdateHandler(MPINCodeResponseHandler& aNewHandler); |
|
517 |
|
518 void RequestPinL(const TBTDevAddr& aDevAddr, const TDesC8* aDeviceName); |
|
519 virtual void FriendlyNameRetrieved(const TDesC& aName, TInt aResult); |
|
520 |
|
521 private: // from CActive |
|
522 void RunL(); |
|
523 void DoCancel(); |
|
524 TInt RunError(TInt aError); |
|
525 |
|
526 private: //from CSecNotifierRequester |
|
527 virtual void DoRequest(); |
|
528 virtual void DoUpdateNotifier(); |
|
529 virtual void HandleTimeout(); |
|
530 |
|
531 private: |
|
532 static const TInt KPinRequesterTimeout = 60000000; // 60 seconds in microseconds |
|
533 private: |
|
534 CBTPinRequester(MPINCodeResponseHandler& aRequester, |
|
535 CBTSecMan& aSecMan, |
|
536 TUint aPasskeyMinLength, |
|
537 TBool aInternallyInitiated, |
|
538 TBool aStrongKeyRequired, |
|
539 TUint aRecommendedPasskeyMinLength); |
|
540 void ConstructL(const TBTDevAddr& aAddr); |
|
541 |
|
542 void HandleSspAwareNotifierL(); |
|
543 void HandleLegacyNotifierL(); |
|
544 |
|
545 void UpdateSspAwareNotifier(); |
|
546 void UpdateLegacyNotifier(); |
|
547 |
|
548 private: |
|
549 enum TNotifierTypeInUse |
|
550 { |
|
551 EInvalid, |
|
552 ESspAwareNotifier, |
|
553 ELegacyNotifier, |
|
554 }; |
|
555 |
|
556 private: |
|
557 MPINCodeResponseHandler* iHandler; |
|
558 CBTSecMan& iSecMan; |
|
559 |
|
560 TNotifierTypeInUse iNotifierType; |
|
561 |
|
562 TBTPinCodeEntryNotifierParamsPckg iPinCodeEntryParamsPckg; |
|
563 TBTPasskeyNotifierParamsPckg iLegacyPinCodeParamsPckg; |
|
564 |
|
565 union |
|
566 { |
|
567 CSecNotifierUpdateAO<TBTNotifierUpdateParamsPckg>* iLegacyUpdater; |
|
568 CSecNotifierUpdateAO<TBTDeviceNameUpdateParamsPckg>* iNameUpdater; |
|
569 } iUpdateNotifier; |
|
570 |
|
571 CSecNotifierRequesterTimer* iTimer; |
|
572 |
|
573 TUint iPasskeyMinLength; |
|
574 TBool iInternallyInitiated; |
|
575 TBool iStrongKeyRequired; |
|
576 TUint iRecommendedPasskeyMinLength; |
|
577 |
|
578 TBTPinCode iPassKey; |
|
579 }; |
|
580 |
|
581 /** |
|
582 Prompts the user to confirm whether or not the supplied numeric value is the same |
|
583 as that of the remote device. |
|
584 Uses the RNotifier framework to produce a dialog containing information |
|
585 about the remote device and the numeric value to be compared. |
|
586 **/ |
|
587 NONSHARABLE_CLASS(CBTNumericComparator) |
|
588 : public CSecNotifierRequester |
|
589 { |
|
590 public: |
|
591 static CBTNumericComparator* NewL(const TBTDevAddr aAddr, |
|
592 CBTSecMan& aSecMan, |
|
593 TUint32 aNumericValue, |
|
594 TBTNumericComparisonParams::TComparisonScenario aComparisonScenario, |
|
595 TBool aInternallyInitiated); |
|
596 static CBTNumericComparator* NewLC(const TBTDevAddr aAddr, |
|
597 CBTSecMan& aSecMan, |
|
598 TUint32 aNumericValue, |
|
599 TBTNumericComparisonParams::TComparisonScenario aComparisonScenario, |
|
600 TBool aInternallyInitiated); |
|
601 ~CBTNumericComparator(); |
|
602 |
|
603 private: // from CActive |
|
604 void DoCancel(); |
|
605 void RunL(); |
|
606 TInt RunError(TInt aError); |
|
607 |
|
608 private: //from CSecNotifierRequester |
|
609 virtual void DoRequest(); |
|
610 virtual void DoUpdateNotifier(); |
|
611 |
|
612 private: |
|
613 CBTNumericComparator(CBTSecMan& aSecMan, |
|
614 TUint32 aNumericValue, |
|
615 TBTNumericComparisonParams::TComparisonScenario aComparisonScenario, |
|
616 TBool aInternallyInitiated); |
|
617 |
|
618 private: |
|
619 CSecNotifierUpdateAO<TBTDeviceNameUpdateParamsPckg>* iNameUpdater; |
|
620 CBTSecMan& iSecMan; |
|
621 TUint32 iNumericValue; |
|
622 TBTNumericComparisonParams::TComparisonScenario iComparisonScenario; |
|
623 TBool iInternallyInitiated; |
|
624 TBTNumericComparisonParamsPckg iNumericComparisonParamsPckg; |
|
625 TPckgBuf<TBool> iResultPckg; |
|
626 }; |
|
627 |
|
628 /** |
|
629 Prompts the user to enter the supplied numeric value on the remote device |
|
630 Uses the RNotifier framework to produce a dialog containing information |
|
631 about the remote device and the numeric value to be compared. |
|
632 **/ |
|
633 NONSHARABLE_CLASS(CBTPasskeyEntry) : public CSecNotifierRequester |
|
634 { |
|
635 public: |
|
636 static CBTPasskeyEntry* NewL(const TBTDevAddr aAddr, |
|
637 CBTSecMan& aSecMan, |
|
638 TUint32 aNumericValue, |
|
639 TBool aInternallyInitiated); |
|
640 static CBTPasskeyEntry* NewLC(const TBTDevAddr aAddr, |
|
641 CBTSecMan& aSecMan, |
|
642 TUint32 aNumericValue, |
|
643 TBool aInternallyInitiated); |
|
644 ~CBTPasskeyEntry(); |
|
645 |
|
646 void KeyPressed(THCIPasskeyEntryNotificationType aKey); |
|
647 |
|
648 private: // from CActive |
|
649 void DoCancel(); |
|
650 void RunL(); |
|
651 TInt RunError(TInt aError); |
|
652 |
|
653 private: // from CSecNotifierRequester |
|
654 virtual void DoRequest(); |
|
655 virtual void DoUpdateNotifier(); |
|
656 |
|
657 private: |
|
658 CBTPasskeyEntry(CBTSecMan& aSecMan, TUint32 aNumericValue, TBool aInternallyInitiated); |
|
659 private: |
|
660 CSecNotifierUpdateAO<TBTPasskeyDisplayUpdateParamsPckg>* iKeypressUpdater; |
|
661 CSecNotifierUpdateAO<TBTDeviceNameUpdateParamsPckg>* iNameUpdater; |
|
662 |
|
663 CBTSecMan& iSecMan; |
|
664 TUint32 iNumericValue; |
|
665 TBool iInternallyInitiated; |
|
666 TBTPasskeyDisplayParamsPckg iPasskeyDisplayParamsPckg; |
|
667 TBTDeviceNameUpdateParamsPckg iDeviceNameUpdateParamsPckg; |
|
668 TBuf8<1> iResultPckg; |
|
669 }; |
|
670 |
|
671 |
|
672 _LIT(KBTSecPanic, "BT Security"); |
|
673 enum TBTSecPanic |
|
674 { |
|
675 EBTSecBadAuthorisationRequest, |
|
676 EBTSecBadNotifierArray, |
|
677 EBTSecPinRequesterAlreadyExists, |
|
678 EBTSecPINRequestedTwice, |
|
679 EBTSecAuthorisationRequestAlreadyExists, |
|
680 EBTSecBadNotifierUpdate, |
|
681 EBTSecBadDeviceAddress, |
|
682 EBTSecUnexpectedSecurityResponse, |
|
683 EBTSecUnexpectedStateMachineEventId, |
|
684 EBTSecUnexpectedStateMachineError, |
|
685 EBTSecBadStateMachineEvent, |
|
686 EBTSecConnectionNumericComparisonTwice, |
|
687 EBTSecConnectionPasskeyNotificationTwice, |
|
688 EBTSecNullPhysicalLinksManager, |
|
689 EBTSecPhysicalLinkMissing, |
|
690 EBTSecBadUserPasskeyRequest, |
|
691 EBTSecNotImplemented, |
|
692 EBTSecEncryptionRequestForDedicatedBond, |
|
693 EBTSecUnexpectedIoCapability, |
|
694 EBTSecUnexpectedOobDataPresence, |
|
695 EBTSecUnexpectedAuthenticationRequirements, |
|
696 EBTSecCommandQueueAlreadyProvided, |
|
697 EBTSecCommandQueueNotAvailable, |
|
698 EBTSecDebugModeTurnedOff, |
|
699 EBTSecNoCommandAssociatedWithErrorEvent, |
|
700 EBTSecUnknownHCIEvent, |
|
701 EBTSecUnknownHCICommandCompleteOpcode, |
|
702 EBTSecMultipleActiveAccessRequestersForService, |
|
703 EBTSecMultiplePendingAccessRequestersForService, |
|
704 EBTSecServiceTryingToQueueMultipleAccessRequesters, |
|
705 EBTSecAccessRequesterCompletedWhenNotActive, |
|
706 EBTSecEncryptionRequiredOnUnauthenticatedLink, |
|
707 EBTSecCouldNotFindStateTransition, |
|
708 EBTSecAccessRequesterShouldHaveNotBeenFound, |
|
709 EBTSecAccessRequesterShouldHaveBeenFound, |
|
710 EBTSecNotifierRequesterUsingTimerWithoutHandling, |
|
711 }; |
|
712 |
|
713 |
|
714 #endif // SECMAN_H |
|
715 |