1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/btsecurity.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -0,0 +1,120 @@
1.4 +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef BTSECURITY_H
1.20 +#define BTSECURITY_H
1.21 +
1.22 +/**
1.23 + @file
1.24 + @publishedAll
1.25 + @released
1.26 +*/
1.27 +
1.28 +#include <e32base.h>
1.29 +
1.30 +/**
1.31 +An enumeration to represent the possible levels of Man-in-the-Middle protection
1.32 +that a Bluetooth service may specify.
1.33 +*/
1.34 +enum TBluetoothMitmProtection
1.35 + {
1.36 + EMitmNotRequired = 0x0, /*!< No Man-in-the-Middle protection is required. */
1.37 + EMitmDesired = 0x1, /*!< Man-in-the-Middle protection should be used where possible. */
1.38 + EMitmRequired = 0x2 /*!< Man-in-the-Middle protection is required. */
1.39 + };
1.40 +
1.41 +NONSHARABLE_CLASS(TBTAccessRequirements)
1.42 +/** The access requirements set up by a bluetooth service.
1.43 +
1.44 +An incoming connection must satisfy these criteria before the connection may proceed.
1.45 +Not spectacularly useful for applications; mainly used by other Bluetooth libraries
1.46 +@publishedAll
1.47 +@released
1.48 +*/
1.49 + {
1.50 +public:
1.51 + IMPORT_C TBTAccessRequirements();
1.52 + IMPORT_C void SetAuthentication(TBool aPreference);
1.53 + IMPORT_C void SetAuthorisation(TBool aPreference);
1.54 + IMPORT_C void SetEncryption(TBool aPreference);
1.55 + IMPORT_C void SetDenied(TBool aPreference);
1.56 + IMPORT_C void SetAuthentication(TBluetoothMitmProtection aPreference);
1.57 + IMPORT_C TInt SetPasskeyMinLength(TUint aPasskeyMinLength);
1.58 + IMPORT_C TBool AuthenticationRequired() const;
1.59 + IMPORT_C TBool AuthorisationRequired() const;
1.60 + IMPORT_C TBool EncryptionRequired() const;
1.61 + IMPORT_C TBool Denied() const;
1.62 + IMPORT_C TUint PasskeyMinLength() const;
1.63 + IMPORT_C TBool operator==(const TBTAccessRequirements& aRequirements) const;
1.64 + IMPORT_C TBluetoothMitmProtection MitmProtection() const;
1.65 +
1.66 +private:
1.67 + TUint8 iRequirements;
1.68 + TUint iPasskeyMinLength;
1.69 +
1.70 +private:
1.71 + enum TBTServiceSecuritySettings
1.72 + {
1.73 + EAuthenticate = 0x01,
1.74 + EAuthorise = 0x02,
1.75 + EEncrypt = 0x04,
1.76 + EDenied = 0x08,
1.77 + EMitm = 0x30, // 2 bit field for MITM
1.78 + };
1.79 +
1.80 + enum TBTAccessRequirementsMitmProtection
1.81 + {
1.82 + EAccessRequirementsMitmUndefined = 0x00,
1.83 + EAccessRequirementsMitmNotRequired = 0x10,
1.84 + EAccessRequirementsMitmDesired = 0x20,
1.85 + EAccessRequirementsMitmRequired = 0x30
1.86 + };
1.87 + };
1.88 +
1.89 +NONSHARABLE_CLASS(TBTServiceSecurity)
1.90 +/** The security settings of a bluetooth service.
1.91 +
1.92 +Contains information regarding the service UID and the access requirements.
1.93 +@publishedAll
1.94 +@released
1.95 +*/
1.96 + {
1.97 +public:
1.98 + IMPORT_C TBTServiceSecurity(const TBTServiceSecurity& aService);
1.99 + IMPORT_C TBTServiceSecurity();
1.100 + IMPORT_C void SetUid(TUid aUid);
1.101 + IMPORT_C void SetAuthentication(TBool aPreference);
1.102 + IMPORT_C void SetAuthorisation(TBool aPreference);
1.103 + IMPORT_C void SetEncryption(TBool aPreference);
1.104 + IMPORT_C void SetDenied(TBool aPreference);
1.105 + IMPORT_C void SetAuthentication(TBluetoothMitmProtection aPreference);
1.106 + IMPORT_C TInt SetPasskeyMinLength(TUint aPasskeyMinLength);
1.107 + IMPORT_C TBool AuthorisationRequired() const;
1.108 + IMPORT_C TBool EncryptionRequired() const;
1.109 + IMPORT_C TBool AuthenticationRequired() const;
1.110 + IMPORT_C TBool Denied() const;
1.111 + IMPORT_C TUint PasskeyMinLength() const;
1.112 + IMPORT_C TUid Uid() const;
1.113 + IMPORT_C TBluetoothMitmProtection MitmProtection() const;
1.114 +
1.115 +private:
1.116 + TUid iUid; //<The UID of the service. Will be used by the UI to work out the name of the service when prompting the user.
1.117 + TBTAccessRequirements iSecurityRequirements; //<Whether the service requires authentication, authorisation, encryption or min passkey len.
1.118 + };
1.119 +
1.120 +typedef TPckgBuf<TBTServiceSecurity> TBTServiceSecurityPckg; /*!< Package definition for securty settings */
1.121 +
1.122 +
1.123 +#endif // BTSECURITY_H