williamr@4: // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). williamr@4: // All rights reserved. williamr@4: // This component and the accompanying materials are made available williamr@4: // under the terms of "Eclipse Public License v1.0" williamr@4: // which accompanies this distribution, and is available williamr@4: // at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@4: // williamr@4: // Initial Contributors: williamr@4: // Nokia Corporation - initial contribution. williamr@4: // williamr@4: // Contributors: williamr@4: // williamr@4: // Description: williamr@4: // williamr@4: williamr@4: #ifndef BTSECURITY_H williamr@4: #define BTSECURITY_H williamr@4: williamr@4: /** williamr@4: @file williamr@4: @publishedAll williamr@4: @released williamr@4: */ williamr@4: williamr@4: #include williamr@4: williamr@4: /** williamr@4: An enumeration to represent the possible levels of Man-in-the-Middle protection williamr@4: that a Bluetooth service may specify. williamr@4: */ williamr@4: enum TBluetoothMitmProtection williamr@4: { williamr@4: EMitmNotRequired = 0x0, /*!< No Man-in-the-Middle protection is required. */ williamr@4: EMitmDesired = 0x1, /*!< Man-in-the-Middle protection should be used where possible. */ williamr@4: EMitmRequired = 0x2 /*!< Man-in-the-Middle protection is required. */ williamr@4: }; williamr@4: williamr@4: NONSHARABLE_CLASS(TBTAccessRequirements) williamr@4: /** The access requirements set up by a bluetooth service. williamr@4: williamr@4: An incoming connection must satisfy these criteria before the connection may proceed. williamr@4: Not spectacularly useful for applications; mainly used by other Bluetooth libraries williamr@4: @publishedAll williamr@4: @released williamr@4: */ williamr@4: { williamr@4: public: williamr@4: IMPORT_C TBTAccessRequirements(); williamr@4: IMPORT_C void SetAuthentication(TBool aPreference); williamr@4: IMPORT_C void SetAuthorisation(TBool aPreference); williamr@4: IMPORT_C void SetEncryption(TBool aPreference); williamr@4: IMPORT_C void SetDenied(TBool aPreference); williamr@4: IMPORT_C void SetAuthentication(TBluetoothMitmProtection aPreference); williamr@4: IMPORT_C TInt SetPasskeyMinLength(TUint aPasskeyMinLength); williamr@4: IMPORT_C TBool AuthenticationRequired() const; williamr@4: IMPORT_C TBool AuthorisationRequired() const; williamr@4: IMPORT_C TBool EncryptionRequired() const; williamr@4: IMPORT_C TBool Denied() const; williamr@4: IMPORT_C TUint PasskeyMinLength() const; williamr@4: IMPORT_C TBool operator==(const TBTAccessRequirements& aRequirements) const; williamr@4: IMPORT_C TBluetoothMitmProtection MitmProtection() const; williamr@4: williamr@4: private: williamr@4: TUint8 iRequirements; williamr@4: TUint iPasskeyMinLength; williamr@4: williamr@4: private: williamr@4: enum TBTServiceSecuritySettings williamr@4: { williamr@4: EAuthenticate = 0x01, williamr@4: EAuthorise = 0x02, williamr@4: EEncrypt = 0x04, williamr@4: EDenied = 0x08, williamr@4: EMitm = 0x30, // 2 bit field for MITM williamr@4: }; williamr@4: williamr@4: enum TBTAccessRequirementsMitmProtection williamr@4: { williamr@4: EAccessRequirementsMitmUndefined = 0x00, williamr@4: EAccessRequirementsMitmNotRequired = 0x10, williamr@4: EAccessRequirementsMitmDesired = 0x20, williamr@4: EAccessRequirementsMitmRequired = 0x30 williamr@4: }; williamr@4: }; williamr@4: williamr@4: NONSHARABLE_CLASS(TBTServiceSecurity) williamr@4: /** The security settings of a bluetooth service. williamr@4: williamr@4: Contains information regarding the service UID and the access requirements. williamr@4: @publishedAll williamr@4: @released williamr@4: */ williamr@4: { williamr@4: public: williamr@4: IMPORT_C TBTServiceSecurity(const TBTServiceSecurity& aService); williamr@4: IMPORT_C TBTServiceSecurity(); williamr@4: IMPORT_C void SetUid(TUid aUid); williamr@4: IMPORT_C void SetAuthentication(TBool aPreference); williamr@4: IMPORT_C void SetAuthorisation(TBool aPreference); williamr@4: IMPORT_C void SetEncryption(TBool aPreference); williamr@4: IMPORT_C void SetDenied(TBool aPreference); williamr@4: IMPORT_C void SetAuthentication(TBluetoothMitmProtection aPreference); williamr@4: IMPORT_C TInt SetPasskeyMinLength(TUint aPasskeyMinLength); williamr@4: IMPORT_C TBool AuthorisationRequired() const; williamr@4: IMPORT_C TBool EncryptionRequired() const; williamr@4: IMPORT_C TBool AuthenticationRequired() const; williamr@4: IMPORT_C TBool Denied() const; williamr@4: IMPORT_C TUint PasskeyMinLength() const; williamr@4: IMPORT_C TUid Uid() const; williamr@4: IMPORT_C TBluetoothMitmProtection MitmProtection() const; williamr@4: williamr@4: private: williamr@4: TUid iUid; // TBTServiceSecurityPckg; /*!< Package definition for securty settings */ williamr@4: williamr@4: williamr@4: #endif // BTSECURITY_H