我有一个 Windows 7 应用程序,它使用Stollmann SDK成功地将 PC 与 Android 绑定。蓝牙 MAC 地址、哈希和随机器的双向交换通过 NFC在带外进行:
遗憾的是,Windows 应用程序的源代码无法在此处共享。在 Android 端,不需要任何应用程序,一旦收到 NDEF 消息,操作系统(由HandoverManager ?)执行安全简单配对。application/vnd.bluetooth.ep.oob
现在我正在尝试创建一个 Android 应用程序,它将使用单向身份验证通过扫描的 QR 码(而不是 NFC)执行 OOB 配对。
自定义二维码将显示在 PC 屏幕上(由ZXing.Net生成)并包含蓝牙 MAC 地址、哈希和随机数。
然而,OOB 绑定似乎尚未在 Android 中实现 -
/**
* Read the local Out of Band Pairing Data
* <p>Requires {@link android.Manifest.permission#BLUETOOTH}
*
* @return Pair<byte[], byte[]> of Hash and Randomizer
*
* @hide
*/
public Pair<byte[], byte[]> readOutOfBandData() {
if (getState() != STATE_ON) return null;
//TODO(BT
/*
try {
byte[] hash;
byte[] randomizer;
byte[] ret = mService.readOutOfBandData();
if (ret == null || ret.length != 32) return null;
hash = Arrays.copyOfRange(ret, 0, 16);
randomizer = Arrays.copyOfRange(ret, 16, 32);
if (DBG) {
Log.d(TAG, "readOutOfBandData:" + Arrays.toString(hash) +
":" + Arrays.toString(randomizer));
}
return new Pair<byte[], byte[]>(hash, randomizer);
} catch (RemoteException e) {Log.e(TAG, "", e);}*/
return null;
}
/**
* Start the bonding (pairing) process with the remote device using the
* Out Of Band mechanism.
*
* <p>This is an asynchronous call, it will return immediately. Register
* for {@link #ACTION_BOND_STATE_CHANGED} intents to be notified when
* the bonding process completes, and its result.
*
* <p>Android system services will handle the necessary user interactions
* to confirm and complete the bonding process.
*
* <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}.
*
* @param hash - Simple Secure pairing hash
* @param randomizer - The random key obtained using OOB
* @return false on immediate error, true if bonding will begin
*
* @hide
*/
public boolean createBondOutOfBand(byte[] hash, byte[] randomizer) {
//TODO(BT)
/*
try {
return sService.createBondOutOfBand(this, hash, randomizer);
} catch (RemoteException e) {Log.e(TAG, "", e);}*/
return false;
}
/**
* Set the Out Of Band data for a remote device to be used later
* in the pairing mechanism. Users can obtain this data through other
* trusted channels
*
* <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}.
*
* @param hash Simple Secure pairing hash
* @param randomizer The random key obtained using OOB
* @return false on error; true otherwise
*
* @hide
*/
public boolean setDeviceOutOfBandData(byte[] hash, byte[] randomizer) {
//TODO(BT)
/*
try {
return sService.setDeviceOutOfBandData(this, hash, randomizer);
} catch (RemoteException e) {Log.e(TAG, "", e);} */
return false;
}
我的问题:
由于 OOB 蓝牙配对在 Android 上的 NFC 上运行良好 - 你认为有一种(hackish)方法可以通过 QR 码来做同样的事情吗?
也许(疯狂的想法)通过HandoverManager
提供虚假的 NDEF 消息?