BluetoothWin32AuthenticationEx.cs :  » Business-Application » 32feet.NET » InTheHand » Net » Bluetooth » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Business Application » 32feet.NET 
32feet.NET » InTheHand » Net » Bluetooth » BluetoothWin32AuthenticationEx.cs
// 32feet.NET - Personal Area Networking for .NET
//
// InTheHand.Net.Bluetooth.BLUETOOTH_AUTHENTICATE_RESPONSE
// 
// Copyright (c) 2003-2010 In The Hand Ltd, All rights reserved.
// This source code is licensed under the In The Hand Community License - see License.txt

#if WinXP
using System;
using System.Runtime.InteropServices;
using InTheHand.Net.Sockets;

namespace InTheHand.Net.Bluetooth{
    /// <summary>
    /// The BLUETOOTH_AUTHENTICATION_METHOD enumeration defines the supported authentication types during device pairing.
    /// </summary>
    internal enum BLUETOOTH_AUTHENTICATION_METHOD : int
    {
        /// <summary>
        /// The Bluetooth device supports authentication via a PIN.
        /// </summary>
        LEGACY = 0x1,
        /// <summary>
        /// The Bluetooth device supports authentication via out-of-band data.
        /// </summary>
        OOB,
        /// <summary>
        /// The Bluetooth device supports authentication via numeric comparison.
        /// </summary>
        NUMERIC_COMPARISON,
        /// <summary>
        /// The Bluetooth device supports authentication via passkey notification.
        /// </summary>
        PASSKEY_NOTIFICATION,
        /// <summary>
        /// The Bluetooth device supports authentication via passkey.
        /// </summary>
        PASSKEY
    }

    /// <summary>
    /// The BLUETOOTH_IO_CAPABILITY enumeration defines the input/output capabilities of a Bluetooth Device.
    /// </summary>
    internal enum BLUETOOTH_IO_CAPABILITY : int
    {
        /// <summary>
        /// The Bluetooth device is capable of output via display only.
        /// </summary>
        DISPLAYONLY = 0x00,
        /// <summary>
        /// The Bluetooth device is capable of output via a display, 
        /// and has the additional capability to presenting a yes/no question to the user.
        /// </summary>
        DISPLAYYESNO = 0x01,
        /// <summary>
        /// The Bluetooth device is capable of input via keyboard.
        /// </summary>
        KEYBOARDONLY = 0x02,
        /// <summary>
        /// The Bluetooth device is not capable of input/output.
        /// </summary>
        NOINPUTNOOUTPUT = 0x03,
        /// <summary>
        /// The input/output capabilities for the Bluetooth device are undefined.
        /// </summary>
        UNDEFINED = 0xff
    }

    /// <summary>
    /// The AUTHENTICATION_REQUIREMENTS enumeration specifies the 'Man in the Middle' protection required for authentication.
    /// </summary>
    internal enum AUTHENTICATION_REQUIREMENTS : int
    {
        /// <summary>
        /// Protection against a "Man in the Middle" attack is not required for authentication.
        /// </summary>
        MITMProtectionNotRequired = 0,
        /// <summary>
        /// Protection against a "Man in the Middle" attack is required for authentication.
        /// </summary>
        MITMProtectionRequired = 0x1,
        /// <summary>
        /// Protection against a "Man in the Middle" attack is not required for bonding.
        /// </summary>
        MITMProtectionNotRequiredBonding = 0x2,
        /// <summary>
        /// Protection against a "Man in the Middle" attack is required for bonding.
        /// </summary>
        MITMProtectionRequiredBonding = 0x3,
        /// <summary>
        /// Protection against a "Man in the Middle" attack is not required for General Bonding.
        /// </summary>
        MITMProtectionNotRequiredGeneralBonding = 0x4,
        /// <summary>
        /// Protection against a "Man in the Middle" attack is required for General Bonding.
        /// </summary>
        MITMProtectionRequiredGeneralBonding = 0x5,
        /// <summary>
        /// Protection against "Man in the Middle" attack is not defined.
        /// </summary>
        MITMProtectionNotDefined = 0xff
    }

    /// <summary>
    /// The BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS structure contains specific configuration information about the Bluetooth device responding to an authentication request.
    /// </summary>
    [StructLayout(LayoutKind.Sequential)]
    internal struct BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS
    {
        /// <summary>
        /// A BLUETOOTH_DEVICE_INFO structure that contains information about a Bluetooth device.
        /// </summary>
        internal BLUETOOTH_DEVICE_INFO deviceInfo;
        /// <summary>
        /// A BLUETOOTH_AUTHENTICATION_METHOD enumeration that defines the authentication method utilized by the Bluetooth device.
        /// </summary>
        internal BLUETOOTH_AUTHENTICATION_METHOD authenticationMethod;
        /// <summary>
        /// A BLUETOOTH_IO_CAPABILITY enumeration that defines the input/output capabilities of the Bluetooth device.
        /// </summary>
        internal BLUETOOTH_IO_CAPABILITY ioCapability;
        /// <summary>
        /// A AUTHENTICATION_REQUIREMENTS specifies the 'Man in the Middle' protection required for authentication.
        /// </summary>
        internal AUTHENTICATION_REQUIREMENTS authenticationRequirements;

        //union{
        //    ULONG   Numeric_Value;
        //    ULONG   Passkey;
        //};
        /// <summary>
        /// A ULONG value used for Numeric Comparison authentication.
        /// or
        /// A ULONG value used as the passkey used for authentication.
        /// </summary>
        internal UInt32 Numeric_Value_Passkey;

        private void ShutupCompiler()
        {
            deviceInfo = new BLUETOOTH_DEVICE_INFO();
            authenticationMethod = BLUETOOTH_AUTHENTICATION_METHOD.LEGACY;
            ioCapability = BLUETOOTH_IO_CAPABILITY.UNDEFINED;
            authenticationRequirements = AUTHENTICATION_REQUIREMENTS.MITMProtectionNotDefined;
            Numeric_Value_Passkey = 0;
        }
    }

    /*[StructLayout(LayoutKind.Sequential)]
    internal struct BLUETOOTH_AUTHENTICATE_RESPONSE
    {
        internal Int64 bthAddressRemote; //BLUETOOTH_ADDRESS bthAddressRemote;
        internal BLUETOOTH_AUTHENTICATION_METHOD authMethod;
        
        //union{
        //    BLUETOOTH_PIN_INFO pinInfo;
        //    BLUETOOTH_OOB_DATA_INFO oobInfo;
        //    BLUETOOTH_NUMERIC_COMPARISON_INFO numericCompInfo;
        //    BLUETOOTH_PASSKEY_INFO passkeyInfo;
        //};
        //[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
        //public byte[] union;

        public int negativeResponse;

        private void ShutupCompiler()
        {
            bthAddressRemote = 0;
            authMethod = BLUETOOTH_AUTHENTICATION_METHOD.Legacy;
            //union = null;
            negativeResponse = 0;
        }
    }*/

    [StructLayout(LayoutKind.Sequential)]
    internal struct BLUETOOTH_AUTHENTICATE_RESPONSE__PIN_INFO // see above
    {
        internal Int64 bthAddressRemote;
        internal BLUETOOTH_AUTHENTICATION_METHOD authMethod;
        internal BLUETOOTH_PIN_INFO pinInfo;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
        private byte[] _padding;
        internal byte negativeResponse;
    }

    [StructLayout(LayoutKind.Sequential)]
    internal struct BLUETOOTH_AUTHENTICATE_RESPONSE__OOB_DATA_INFO // see above
    {
        internal Int64 bthAddressRemote;
        internal BLUETOOTH_AUTHENTICATION_METHOD authMethod;
        internal BLUETOOTH_OOB_DATA_INFO oobInfo;
        internal byte negativeResponse;
    }

    [StructLayout(LayoutKind.Sequential)]
    internal struct BLUETOOTH_AUTHENTICATE_RESPONSE__NUMERIC_COMPARISON_PASSKEY_INFO // see above
    {
        internal Int64 bthAddressRemote;
        internal BLUETOOTH_AUTHENTICATION_METHOD authMethod;
        internal UInt32 numericComp_passkey;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 28)]
        private byte[] _padding;
        internal byte negativeResponse;
    }
    
    /// <summary>
    /// The BLUETOOTH_PIN_INFO structure contains information used for authentication via PIN.
    /// </summary>
    [StructLayout(LayoutKind.Sequential, Size = 20)]
    internal struct BLUETOOTH_PIN_INFO
    {
        internal const int BTH_MAX_PIN_SIZE = 16;

        [MarshalAs(UnmanagedType.ByValArray, SizeConst = BTH_MAX_PIN_SIZE)]
        internal byte[] pin;
        internal Int32 pinLength;
    }

    /// <summary>
    /// The BLUETOOTH_OOB_DATA_INFO structure contains data used to authenticate prior to establishing an Out-of-Band device pairing.
    /// </summary>
    [StructLayout(LayoutKind.Sequential, Size = 32)]
    internal struct BLUETOOTH_OOB_DATA_INFO
    {
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
        internal byte[] C;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
        internal byte[] R;

        private void ShutupCompiler()
        {
            C = R = null;
        }
    }

    // These are so simple that well use one outer struct with a UInt32 which can be used by both methods
    /*
    /// <summary>
    /// The BLUETOOTH_NUMERIC_COMPARISON_INFO structure contains the numeric value used for authentication via numeric comparison. 
    /// </summary>
    [StructLayout(LayoutKind.Sequential, Size = 4)]
    internal struct BLUETOOTH_NUMERIC_COMPARISON_INFO
    {
        internal UInt32 NumericValue;

        private void ShutupCompiler()
        {
            NumericValue = 0;
        }
    }
    
    /// <summary>
    /// The BLUETOOTH_PASSKEY_INFO structure contains the passkey used for authentication via passkey.
    /// </summary>
    [StructLayout(LayoutKind.Sequential, Size = 4)]
    internal struct BLUETOOTH_PASSKEY_INFO
    {
        internal UInt32 passkey;

        private void ShutupCompiler()
        {
            passkey = 0;
        }
    }*/

}
#endif
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.