OSDN Git Service

PySecurity: Add create_bond_out_of_band
authorMartin Brabham <optedoblivion@google.com>
Tue, 17 Nov 2020 02:01:18 +0000 (18:01 -0800)
committerMyles Watson <mylesgw@google.com>
Fri, 20 Nov 2020 01:18:59 +0000 (17:18 -0800)
Bug: 162984360
Tag: #gd-refactor
Test: cert/run --host SecurityTest
Change-Id: I41ac53a3b29e2409a1eb2da60abe8f37db84a9f4

gd/cert/py_security.py

index 7d5c7b2..3e023fb 100644 (file)
@@ -78,6 +78,27 @@ class PySecurity(Closable):
         self._device.security.CreateBond(
             common.BluetoothAddressWithType(address=common.BluetoothAddress(address=address), type=type))
 
+    def create_bond_out_of_band(self, address, type, p192_oob_data, p256_oob_data):
+        """
+            Triggers stack under test to create bond using Out of Band method
+        """
+
+        logging.debug("DUT: Creating OOB bond to '%s' from '%s'" % (str(address), str(self._device.address)))
+
+        self._device.security.CreateBondOutOfBand(
+            OobDataBondMessage(
+                address=common.BluetoothAddressWithType(address=common.BluetoothAddress(address=address), type=type),
+                p192_data=OobDataMessage(
+                    address=common.BluetoothAddressWithType(
+                        address=common.BluetoothAddress(address=address), type=type),
+                    le_sc_confirmation_value=bytes(bytearray(p192_oob_data[0])),
+                    le_sc_random_value=bytes(bytearray(p192_oob_data[1]))),
+                p256_data=OobDataMessage(
+                    address=common.BluetoothAddressWithType(
+                        address=common.BluetoothAddress(address=address), type=type),
+                    le_sc_confirmation_value=bytes(bytearray(p256_oob_data[0])),
+                    le_sc_random_value=bytes(bytearray(p256_oob_data[1])))))
+
     def remove_bond(self, address, type):
         """
             Removes bond from stack under test
@@ -134,6 +155,14 @@ class PySecurity(Closable):
         """
         pass
 
+    def accept_oob_pairing(self, cert_address, reply_boolean, p192_data, p256_data):
+        """
+            Here we pass, but in cert we perform pairing flow tasks.
+            This was added here in order to be more dynamic, but the stack
+            under test will handle the pairing flow.
+        """
+        pass
+
     def on_user_input(self, cert_address, reply_boolean, expected_ui_event):
         """
             Respond to the UI event