williamr@4
|
1 |
// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@4
|
2 |
// All rights reserved.
|
williamr@4
|
3 |
// This component and the accompanying materials are made available
|
williamr@4
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
williamr@4
|
5 |
// which accompanies this distribution, and is available
|
williamr@4
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
williamr@4
|
7 |
//
|
williamr@4
|
8 |
// Initial Contributors:
|
williamr@4
|
9 |
// Nokia Corporation - initial contribution.
|
williamr@4
|
10 |
//
|
williamr@4
|
11 |
// Contributors:
|
williamr@4
|
12 |
//
|
williamr@4
|
13 |
// Description:
|
williamr@4
|
14 |
//
|
williamr@4
|
15 |
|
williamr@4
|
16 |
#ifndef BTSECURITY_H
|
williamr@4
|
17 |
#define BTSECURITY_H
|
williamr@4
|
18 |
|
williamr@4
|
19 |
/**
|
williamr@4
|
20 |
@file
|
williamr@4
|
21 |
@publishedAll
|
williamr@4
|
22 |
@released
|
williamr@4
|
23 |
*/
|
williamr@4
|
24 |
|
williamr@4
|
25 |
#include <e32base.h>
|
williamr@4
|
26 |
|
williamr@4
|
27 |
/**
|
williamr@4
|
28 |
An enumeration to represent the possible levels of Man-in-the-Middle protection
|
williamr@4
|
29 |
that a Bluetooth service may specify.
|
williamr@4
|
30 |
*/
|
williamr@4
|
31 |
enum TBluetoothMitmProtection
|
williamr@4
|
32 |
{
|
williamr@4
|
33 |
EMitmNotRequired = 0x0, /*!< No Man-in-the-Middle protection is required. */
|
williamr@4
|
34 |
EMitmDesired = 0x1, /*!< Man-in-the-Middle protection should be used where possible. */
|
williamr@4
|
35 |
EMitmRequired = 0x2 /*!< Man-in-the-Middle protection is required. */
|
williamr@4
|
36 |
};
|
williamr@4
|
37 |
|
williamr@4
|
38 |
NONSHARABLE_CLASS(TBTAccessRequirements)
|
williamr@4
|
39 |
/** The access requirements set up by a bluetooth service.
|
williamr@4
|
40 |
|
williamr@4
|
41 |
An incoming connection must satisfy these criteria before the connection may proceed.
|
williamr@4
|
42 |
Not spectacularly useful for applications; mainly used by other Bluetooth libraries
|
williamr@4
|
43 |
@publishedAll
|
williamr@4
|
44 |
@released
|
williamr@4
|
45 |
*/
|
williamr@4
|
46 |
{
|
williamr@4
|
47 |
public:
|
williamr@4
|
48 |
IMPORT_C TBTAccessRequirements();
|
williamr@4
|
49 |
IMPORT_C void SetAuthentication(TBool aPreference);
|
williamr@4
|
50 |
IMPORT_C void SetAuthorisation(TBool aPreference);
|
williamr@4
|
51 |
IMPORT_C void SetEncryption(TBool aPreference);
|
williamr@4
|
52 |
IMPORT_C void SetDenied(TBool aPreference);
|
williamr@4
|
53 |
IMPORT_C void SetAuthentication(TBluetoothMitmProtection aPreference);
|
williamr@4
|
54 |
IMPORT_C TInt SetPasskeyMinLength(TUint aPasskeyMinLength);
|
williamr@4
|
55 |
IMPORT_C TBool AuthenticationRequired() const;
|
williamr@4
|
56 |
IMPORT_C TBool AuthorisationRequired() const;
|
williamr@4
|
57 |
IMPORT_C TBool EncryptionRequired() const;
|
williamr@4
|
58 |
IMPORT_C TBool Denied() const;
|
williamr@4
|
59 |
IMPORT_C TUint PasskeyMinLength() const;
|
williamr@4
|
60 |
IMPORT_C TBool operator==(const TBTAccessRequirements& aRequirements) const;
|
williamr@4
|
61 |
IMPORT_C TBluetoothMitmProtection MitmProtection() const;
|
williamr@4
|
62 |
|
williamr@4
|
63 |
private:
|
williamr@4
|
64 |
TUint8 iRequirements;
|
williamr@4
|
65 |
TUint iPasskeyMinLength;
|
williamr@4
|
66 |
|
williamr@4
|
67 |
private:
|
williamr@4
|
68 |
enum TBTServiceSecuritySettings
|
williamr@4
|
69 |
{
|
williamr@4
|
70 |
EAuthenticate = 0x01,
|
williamr@4
|
71 |
EAuthorise = 0x02,
|
williamr@4
|
72 |
EEncrypt = 0x04,
|
williamr@4
|
73 |
EDenied = 0x08,
|
williamr@4
|
74 |
EMitm = 0x30, // 2 bit field for MITM
|
williamr@4
|
75 |
};
|
williamr@4
|
76 |
|
williamr@4
|
77 |
enum TBTAccessRequirementsMitmProtection
|
williamr@4
|
78 |
{
|
williamr@4
|
79 |
EAccessRequirementsMitmUndefined = 0x00,
|
williamr@4
|
80 |
EAccessRequirementsMitmNotRequired = 0x10,
|
williamr@4
|
81 |
EAccessRequirementsMitmDesired = 0x20,
|
williamr@4
|
82 |
EAccessRequirementsMitmRequired = 0x30
|
williamr@4
|
83 |
};
|
williamr@4
|
84 |
};
|
williamr@4
|
85 |
|
williamr@4
|
86 |
NONSHARABLE_CLASS(TBTServiceSecurity)
|
williamr@4
|
87 |
/** The security settings of a bluetooth service.
|
williamr@4
|
88 |
|
williamr@4
|
89 |
Contains information regarding the service UID and the access requirements.
|
williamr@4
|
90 |
@publishedAll
|
williamr@4
|
91 |
@released
|
williamr@4
|
92 |
*/
|
williamr@4
|
93 |
{
|
williamr@4
|
94 |
public:
|
williamr@4
|
95 |
IMPORT_C TBTServiceSecurity(const TBTServiceSecurity& aService);
|
williamr@4
|
96 |
IMPORT_C TBTServiceSecurity();
|
williamr@4
|
97 |
IMPORT_C void SetUid(TUid aUid);
|
williamr@4
|
98 |
IMPORT_C void SetAuthentication(TBool aPreference);
|
williamr@4
|
99 |
IMPORT_C void SetAuthorisation(TBool aPreference);
|
williamr@4
|
100 |
IMPORT_C void SetEncryption(TBool aPreference);
|
williamr@4
|
101 |
IMPORT_C void SetDenied(TBool aPreference);
|
williamr@4
|
102 |
IMPORT_C void SetAuthentication(TBluetoothMitmProtection aPreference);
|
williamr@4
|
103 |
IMPORT_C TInt SetPasskeyMinLength(TUint aPasskeyMinLength);
|
williamr@4
|
104 |
IMPORT_C TBool AuthorisationRequired() const;
|
williamr@4
|
105 |
IMPORT_C TBool EncryptionRequired() const;
|
williamr@4
|
106 |
IMPORT_C TBool AuthenticationRequired() const;
|
williamr@4
|
107 |
IMPORT_C TBool Denied() const;
|
williamr@4
|
108 |
IMPORT_C TUint PasskeyMinLength() const;
|
williamr@4
|
109 |
IMPORT_C TUid Uid() const;
|
williamr@4
|
110 |
IMPORT_C TBluetoothMitmProtection MitmProtection() const;
|
williamr@4
|
111 |
|
williamr@4
|
112 |
private:
|
williamr@4
|
113 |
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.
|
williamr@4
|
114 |
TBTAccessRequirements iSecurityRequirements; //<Whether the service requires authentication, authorisation, encryption or min passkey len.
|
williamr@4
|
115 |
};
|
williamr@4
|
116 |
|
williamr@4
|
117 |
typedef TPckgBuf<TBTServiceSecurity> TBTServiceSecurityPckg; /*!< Package definition for securty settings */
|
williamr@4
|
118 |
|
williamr@4
|
119 |
|
williamr@4
|
120 |
#endif // BTSECURITY_H
|