首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法读写FIDO2特性

无法读写FIDO2特性
EN

Stack Overflow用户
提问于 2019-06-11 07:53:36
回答 3查看 504关注 0票数 2

我正在为FIDO2构建一个Android认证器。我一直坚持读/写的特点。我正在研制75.Chrome可以检测到我的Android BLE认证器。在检测到我的BLE身份验证器后,将从身份验证方调用onCharacteristicReadRequest()。在onCharacteristicReadRequest()内部,我使用了下面编写的代码,但之后没有来自客户端的响应。

我尝试过0b01000000版本的U2F。它很好用。当我移动FIDO2版本0b100000时,我面临着这个问题。我是广告fido服务和设备信息服务的认证者。这两个服务都添加了Thread.sleep(1000)间隔。我不能按顺序添加这两个服务。当我按顺序添加这两个服务时,我将得到ArrayIndexOutofBoundException

我不知道这两个问题是否相互关联。如果我做错了什么,请纠正我。

代码语言:javascript
复制
{
...
}else if (characteristic.getUuid().equals(FidoUUIDConstants.FIDO_SERVICE_REVISION_BITFIELD)) {
    status = BluetoothGatt.GATT_SUCCESS;
    ByteBuffer bb = ByteBuffer.allocate(1);
    bb.order(ByteOrder.BIG_ENDIAN);
    bb.put((byte) (1 << 5));
    bytes = bb.array();
}
mGattServer.sendResponse(device, requestId, status, 0, bytes);

客户端应在预期fidoServiceBitFieldversion之后读取/写入特性。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2019-06-15 10:30:39

我同意包的关心。根据CTAP规范,您应该使用读/写权限定义对应于每个特征的描述符。注意,每个描述符的UUID都需要有效的UUID 128位格式。所有描述符都具有读写权限。例如:

代码语言:javascript
复制
UUID CONTROL_POINT_DESCRIPTOR_UUID = UUID.fromString("00002901-0000-1000-8000-00805f9b34fb");
BluetoothGattDescriptor controlPointDescriptor = new BluetoothGattDescriptor(
    CONTROL_POINT_DESCRIPTOR_UUID,
    BluetoothGattDescriptor.PERMISSION_READ | BluetoothGattDescriptor.PERMISSION_WRITE
);
票数 2
EN

Stack Overflow用户

发布于 2019-06-11 16:52:49

我不能按顺序添加这两个服务

我认为您可以像下面这样添加device info service

代码语言:javascript
复制
gattServer = bleManager.openGattServer(this, new BluetoothGattServerCallback() {
    @Override
    public void onServiceAdded(int status, BluetoothGattService service) {
        if (service.getUuid().equals(FidoUUIDConstants.FIDO2_GATT_SERVICE)) {
            gattServer.addService(deviceInfoService);
        }
    }
});
gattServer.addService(fido2GattService)

对于特征fidoServiceRevisionBitfield,我只是简单地遵循了a device that only supports FIDO2 Rev 1 will only have a fidoServiceRevisionBitfield characteristic of length 1 with value 0x20.在索引8.3.5.1. FIDO Service of CTAP文件上的语句。因此,我的执行是:

代码语言:javascript
复制
if(characteristic.getUuid().equals(FIDO2GattService.SERVICE_REVISION_BITFIELD)) {
    status = BluetoothGatt.GATT_SUCCESS;
    bytes = new byte[] {0x20}
}
gattServer.sendResponse(device, requestId, status, 0, bytes);
票数 2
EN

Stack Overflow用户

发布于 2019-06-12 14:41:17

您应该覆盖BluetoothGattServerCallback的所有方法

我认为您缺少了onDescriptorReadRequest、onDescriptorWriteRequest工具。

代码语言:javascript
复制
@Override
public void onDescriptorReadRequest(BluetoothDevice device, int requestId, int offset, BluetoothGattDescriptor descriptor) {
    if (descriptor.getCharacteristic().getUuid().equals(FIDO2GattService.CONTROL_POINT_UUID) &&
            descriptor.getUuid().equals(FIDO2GattService.CONTROL_POINT_DESCRIPTOR_UUID)) {
        gattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, new byte[] {0x31, 0x2e, 0x32});
    } else {
        gattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, new byte[] {0x00, 0x00});
    }
}
@Override
public void onDescriptorWriteRequest(BluetoothDevice device, int requestId, BluetoothGattDescriptor descriptor, boolean preparedWrite, boolean responseNeeded, int offset, byte[] value) {
    gattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, value);
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56538947

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档