// 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
|