set password protection on nt3h211 2k through i2c (ntag i2c plus from nxp) - nfc

what is the procedure for setting password protection on nt3h211 2k using the i2c
interface?
i have to set password for the write operation only from the nfc perspective,
so do i need to to do the password authentication when writing data to nfc tag
from the i2c interface?
how to change the password or remove the password through i2c?
do i a have to send LSBytes first when writing password and pack through the i2c?
how to authenticate password through the i2c?

Related

How do I pass SCSI (CDB) commands through a USB connection

I am trying to talk to a MSC USB device (interface class 8, subclass 6, protocol 0x50) via a plain USB API with endpoints (all set up for me).
Provided I have a valid CDB, such as for "Test Unit Ready", how to I send that over the USB interface?
Where can I find examples or docs for how this is done?
Background: The actual platform is macOS, which doesn't provide SCSI-passthrough for block devices, and the native SCSI API is also not available in this case.
I have, however, been able to initiate communication on the USB level with the device, and am now trying to circumvent the blocked SCSI device level access by talking thru USB directly.
Most such devices implement the so-called “Bulk Only” protocol, which is specified here: https://usb.org/document-library/mass-storage-bulk-only-10
Essentially, you send a 31-byte “Command Block Wrapper”, which includes the CDB and is specified in section 5.1 of the spec, to the device via the bulk out endpoint. You then read or write the data to be transferred from the input bulk endpoint or to the output bulk endpoint and finally read the 13-byte command status wrapper from the bulk in pipe.
However, note that you’ll need to make sure the OS hasn’t already loaded a driver for the device - from user space, the system won’t give you access to the endpoints when a kernel driver has claimed them anyway, but if you were to attempt to use the same pipes as the default driver from a kext, you’d get unpredictable results.

In Bluetooth LE GATT, is there any way to detect when Long Term Keys are invalid?

I am using Windows Bluetooth LE GATT library to connect to and pair with a BLE-supporting device, D. Since D has a limited amount of storage space, if more than N Clients bond with it, then it will remove the first Long Term Key pair that was created during bonding.
Let's say that the device for which this key-pair was removed was a Windows Enabled machine. Let's call this W. The next time W attempts to connect with D, when it receives the LTK_Request_Event from W, it responds with Long_Term_Key_Requested_Negative_Reply, and W terminates the connection.
But here's where things get really exasperating. Even though the Windows BLE Stack seems to be aware of this response (because it disconnects), this does not seem to be communicated downstream to applications using the Bluetooth LE GATT library. In fact, from the application's side, a pairing request will return with "Already Paired", and does not indicate that anything went wrong. Of course, once the application tries to access protected characteristics, it won't be able to, and that, so far, is the only indication that Pairing was not successful. Even worse, the errors it receives aren't consistent. Sometimes, it gets "Unreachable". Sometimes, it gets protocol errors. Other times, it receives ABORTs.
Now, as a heuristic, I could use detection of this case as criteria for attempting to re-pair. Unfortunately, this is not ideal, since none of these errors actually imply that the device no longer honored the LTKs, and could, instead, indicate other issues, like that the device is out of range.
Is there any way to detect that existing LTKs have been rejected by the device?
Let's see what the Bluetooth specification says about this.
Bluetooth Core version 5.2, Vol 3 (Host), Part C (Generic Access Profile)
Section 10.3.2 Initiating a service request:
In this section the local device is the device initiating a service request to a
remote device. In the L2CAP protocol the local device sends the connection
request and the remote device sends the connection response. In GATT, the
local device is the GATT client and the remote device is the GATT server.
When a local device initiates a service request to a remote device it shall
behave according to the following rules:
[...]
If an LTK is available and encryption is required (LE security mode 1) then
encryption shall be enabled before the service request proceeds as defined proceed. If encryption fails either the bond no longer exists on the remote
device, or the wrong device has been connected. The local device must,
after user interaction to confirm the remote device, re-bond, perform service
discovery and re-configure the remote device. [...]
If Windows's BLE stack doesn't allow for what the specification mandates, it is not specification compliant, in my eyes, so please file an issue report at Microsoft.
The reason for requiring user interaction and not blindly re-bond is to avoid a situation where a hacker can simply spoof the bluetooth device address, indicate it has lost the bond and automatically re-bond without the user noticing anything.
EDIT:
The Security Manager chapter also has a table of actions to do when encryption fails due to deleted keys. See section 2.4.4.2 of Vol 3, Part H.
It specifically says when the devices were bonded before that the action to take when enabling encryption fails is to "Notify user of security failure."

Bluetooth pairing between Win32 and Bluemod+SR - passkey entry

I am developing a Win32 application for a Windows 10 tablet that shall connect to a embedded device via Bluetooth. The embedded device uses the Telit BlueMod+SR as bluetooth module.
In Windows, I use the interface from "bluetoothapis.h" for Connection and Pairing and winsock2 for communication.
I have to implement pairing using passkey entry between the devices, initiated by the Windows tablet. The tablet provides passkey entry, the embedded device is display-only.
The way it works at the moment is that:
Windows creats a non-blocking socket and configures it as requiring authentication by setting SO_BTH_AUTHENTICATE.
Windows passes my Authentication Callback to BluetoothRegisterForAuthenticationEx().
Windows calls ConnectEx() on the remote BT device.
If successful, the Authentication Callback is executed, giving me the passkey (which is displayed by the embedded device).
The user is asked to input the passkey on the tablet which then compares the input with the passkey from the Authentication callback.
My problem is, although it works, I think that this is not the way the passkey entry is intended. It doesn't feel like a valid way to establish a secure connection since the embedded device seems to transmit the passkey via Bluetooth to the tablet.
Should the passkey be openly transmitted via Bluetooth from the remote device to the initiating device?
Or should the user be the only one that gives the passkey to the tablet?
If the way it is implemented is wrong:
Does somebody have an idea why the passkey is available through the Authentication Callback on Windows? I guess there is something wrong with the configuration of the BlueMod module, but I haven't been able to change the behavior.

How to restrict access to dev/mem on a Raspberry Pi?

I am trying to write a program that controls the access to the GPIO pins of my raspberry pi. In other words, any process that needs to access a GPIO pin will have to go through the service I am writing. I know that in order to access and control a GPIO pin, a library/program needs to access the /dev/mem file.
Is there a way to protect this file or restrict the access to it by ANY other process?

Significance of context name in snmpv3

Snmpv3 is a secured protocol compared to Snmpv2 and Snmpv1. But I dont understand what is the use of context name.We already have an user name and also authentication and privacy passwords which provide a security level. Someone using a wireshark cannot identify it as it is sent through encrypted form. So what is the use of context name in Snmpv3?
The contextName and contextEngineID parameters allow multiple versions of the same MIB objects to be made available by a single SNMPv3 engine, as if you have multiple agents running on the same IP address and port. These are distinguished from one another by contextName and contextEngineID, where otherwise they would have had a different address and/or port. One reason for this could be that you have a master agent with multiple sub-agents and the sub-agents have some overlap. Another reason would be a proxy agent: for example, a manager that only speaks SNMPv3 and devices than only speak SNMPv1 could use a multi-lingual proxy at a single address/port and use the contextName and contextEngineID to identify devices. The proxy here would map the contextName and contextEngineID to device address/port and translate/forward requests to the devices and responses back to the manager.

Resources