bluetooth/btstack/secman/btaccessrequester.cpp
branchRCL_3
changeset 56 015fa7494bd2
parent 18 f8503e232b0c
equal deleted inserted replaced
49:10183c6d2913 56:015fa7494bd2
    49 CBTAccessRequester* CBTAccessRequester::NewLC(CPhysicalLink& aConnection,
    49 CBTAccessRequester* CBTAccessRequester::NewLC(CPhysicalLink& aConnection,
    50 											  const TBTServiceSecurity& aSecurityRequired,
    50 											  const TBTServiceSecurity& aSecurityRequired,
    51 											  const TBTServiceSecurityPerDevice* const aOverride,
    51 											  const TBTServiceSecurityPerDevice* const aOverride,
    52 											  MAccessRequestResponseHandler& aRequester,
    52 											  MAccessRequestResponseHandler& aRequester,
    53 											  TAccessType aAccessType,
    53 											  TAccessType aAccessType,
       
    54 											  TBool aNoSecurityRequired,
    54 											  CBTSecMan& aParent)
    55 											  CBTSecMan& aParent)
    55 	{
    56 	{
    56 	LOG_STATIC_FUNC
    57 	LOG_STATIC_FUNC
    57 	CBTAccessRequester* s = new(ELeave) CBTAccessRequester(aConnection, aSecurityRequired, aOverride, aRequester, aAccessType, aParent);
    58 	CBTAccessRequester* s = new(ELeave) CBTAccessRequester(aConnection, aSecurityRequired, aOverride, aRequester, aAccessType, aNoSecurityRequired, aParent);
    58 	CleanupStack::PushL(s);
    59 	CleanupStack::PushL(s);
    59 	s->ConstructL();
    60 	s->ConstructL();
    60 	return s;
    61 	return s;
    61 	}
    62 	}
    62 
    63 
    64 CBTAccessRequester::CBTAccessRequester(CPhysicalLink& aConnection,
    65 CBTAccessRequester::CBTAccessRequester(CPhysicalLink& aConnection,
    65 									   const TBTServiceSecurity& aServiceSecurity,
    66 									   const TBTServiceSecurity& aServiceSecurity,
    66 									   const TBTServiceSecurityPerDevice* const aOverride,
    67 									   const TBTServiceSecurityPerDevice* const aOverride,
    67 									   MAccessRequestResponseHandler& aRequester,
    68 									   MAccessRequestResponseHandler& aRequester,
    68 									   TAccessType aAccessType,
    69 									   TAccessType aAccessType,
       
    70 									   TBool aNoSecurityRequired,
    69 									   CBTSecMan& aParent)
    71 									   CBTSecMan& aParent)
    70 	: iRequester(aRequester)
    72 	: iRequester(aRequester)
    71 	, iSecMan(aParent)
    73 	, iSecMan(aParent)
    72 	, iBaseband(&aConnection)
    74 	, iBaseband(&aConnection)
    73 	, iDevAddr(aConnection.BDAddr())
    75 	, iDevAddr(aConnection.BDAddr())
    79 	, iPrefetchQueueLink(this)
    81 	, iPrefetchQueueLink(this)
    80 	, iAuthenticationInProgress(EFalse)
    82 	, iAuthenticationInProgress(EFalse)
    81 	, iAccessType(aAccessType)
    83 	, iAccessType(aAccessType)
    82 	, iRemoteIndicatedNoBonding(EFalse)
    84 	, iRemoteIndicatedNoBonding(EFalse)
    83 	, iCurrentState(EBTUninitialised)
    85 	, iCurrentState(EBTUninitialised)
       
    86 	, iNoSecurityRequired(aNoSecurityRequired)
    84 	{
    87 	{
    85 	LOG_FUNC
    88 	LOG_FUNC
    86 	// try to get name for UI dialogs
    89 	// try to get name for UI dialogs
    87 	SetDeviceName();
    90 	SetDeviceName();
    88 	}
    91 	}
   909 	ASSERT_DEBUG(iBaseband->SimplePairingMode() != EPhySimplePairingUndefined);
   912 	ASSERT_DEBUG(iBaseband->SimplePairingMode() != EPhySimplePairingUndefined);
   910 	
   913 	
   911 	// Here we determine if authentication is required on the link.
   914 	// Here we determine if authentication is required on the link.
   912 	TBool authenticationRequired = EFalse;
   915 	TBool authenticationRequired = EFalse;
   913 	
   916 	
   914 	if(iBaseband->SimplePairingMode() == EPhySimplePairingEnabled)
   917 	if (iNoSecurityRequired)
       
   918 		{
       
   919 		// This is used for Security Mode 4 "no security required", e.g. SDP, 
       
   920 		// which we never authenticate
       
   921 		// <NOP> // authenticationRequired is already EFalse
       
   922 		}
       
   923 	else if(iBaseband->SimplePairingMode() == EPhySimplePairingEnabled)
   915 		{
   924 		{
   916 		// If operating in simple pairing mode then authentication is always required
   925 		// If operating in simple pairing mode then authentication is always required
   917 		// due to security mode 4.
   926 		// due to security mode 4.
   918 		authenticationRequired = ETrue;
   927 		authenticationRequired = ETrue;
   919 		}
   928 		}
   946 
   955 
   947 TBool CBTAccessRequester::AuthenticationRecommended() const
   956 TBool CBTAccessRequester::AuthenticationRecommended() const
   948 	{
   957 	{
   949 	LOG_FUNC
   958 	LOG_FUNC
   950 	TBool authenticationRecommended = AuthenticationRequired();
   959 	TBool authenticationRecommended = AuthenticationRequired();
   951 	if(!authenticationRecommended && LinkKeyGoodEnough())
   960 	if(!authenticationRecommended && LinkKeyGoodEnough() && !iNoSecurityRequired)
   952 		{
   961 		{
   953 		// If the current link key is good enough then we should be able to use that
   962 		// If the current link key is good enough then we should be able to use that
   954 		// if it is available.
   963 		// if it is available.
   955 		if(iSecMan.ConnectionsManager().LinkManagerProtocol().IsSecureSimplePairingSupportedLocally())
   964 		if(iSecMan.ConnectionsManager().LinkManagerProtocol().IsSecureSimplePairingSupportedLocally())
   956 			{
   965 			{
   982 		}
   991 		}
   983 	else if(iAccessType != EDedicatedBonding)
   992 	else if(iAccessType != EDedicatedBonding)
   984 		{
   993 		{
   985 		// Otherwise dedicated bonding is incidental...so only for general bonding accesses
   994 		// Otherwise dedicated bonding is incidental...so only for general bonding accesses
   986 		// do we consider enabling encryption.
   995 		// do we consider enabling encryption.
   987 		if(iBaseband->SimplePairingMode() == EPhySimplePairingEnabled)
   996 		if(iBaseband->SimplePairingMode() == EPhySimplePairingEnabled && !iNoSecurityRequired)
   988 			{
   997 			{
   989 			// If the link is SSP capable then for security mode 4 we must encrypt the link
   998 			// If the link is SSP capable then for security mode 4 we must encrypt the link
   990 			// for general bonding requests.
   999 			// for general bonding requests.
   991 			encryptionRequired = ETrue;
  1000 			encryptionRequired = ETrue;
   992 			}
  1001 			}