summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoHyun Pyun <dh79.pyun@samsung.com>2016-09-07 09:45:27 +0900
committerPyun DoHyun <dh79.pyun@samsung.com>2016-09-12 03:12:46 -0700
commit34acee328c26242685691848fc6c0d1f72ef128c (patch)
tree89193af57a1467ee2abb469b15aac4f29480273a
parent27edb2803529562f56f3d4b8d14f21e88a23b1c9 (diff)
downloadbluetooth-34acee328c26242685691848fc6c0d1f72ef128c.tar.gz
bluetooth-34acee328c26242685691848fc6c0d1f72ef128c.tar.bz2
bluetooth-34acee328c26242685691848fc6c0d1f72ef128c.zip
Add oob extended APIs in public native API
Change-Id: I28b08740dbee527bf0475fe7c7ed52ff233927fc Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
-rw-r--r--include/mobile/bluetooth.h70
-rw-r--r--include/tv/bluetooth.h70
-rw-r--r--include/wearable/bluetooth.h70
-rw-r--r--test/bt_unit_test.c109
-rw-r--r--test/bt_unit_test.h4
5 files changed, 320 insertions, 3 deletions
diff --git a/include/mobile/bluetooth.h b/include/mobile/bluetooth.h
index 2d10b81..7fcc974 100644
--- a/include/mobile/bluetooth.h
+++ b/include/mobile/bluetooth.h
@@ -646,6 +646,76 @@ int bt_adapter_get_local_oob_data(unsigned char **hash, unsigned char **randomiz
int bt_adapter_set_remote_oob_data(const char *remote_address,
unsigned char *hash, unsigned char *randomizer,
int hash_len, int randomizer_len);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
+ * @brief Gets the Hash and Randmoizer value, synchronously.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/bluetooth
+ *
+ * @remarks The @a hash192, randomizer192, hash256 and randomizer256 must be released using free()
+ *
+ * @param[out] hash192 The hash value derived from the P-192 public key
+ * @param[out] randomizer192 The randomizer value associated with the P-192 public key
+ * @param[out] hash192_len The length of @a hash192
+ * @param[out] randomizer192_len The length of @a randomizer192
+ * @param[out] hash256 The hash value derived from the P-256 public key
+ * @param[out] randomizer256 The randomizer value associated with the P-256 public key
+ * @param[out] hash256_len The length of @a hash256
+ * @param[out] randomizer256_len The length of @a randomizer256
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE Successful
+ * @retval #BT_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #BT_ERROR_NOT_ENABLED Not enabled
+ * @retval #BT_ERROR_OPERATION_FAILED Operation failed
+ * @retval #BT_ERROR_NOT_SUPPORTED Not supported
+ *
+ * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED.
+ * @pre The Bluetooth service must be initialized with bt_initialize().
+ * @see bt_initialize()
+ */
+int bt_adapter_get_local_oob_ext_data(unsigned char **hash192, unsigned char **randomizer192,
+ int *hash192_len, int *randomizer192_len,
+ unsigned char **hash256, unsigned char **randomizer256,
+ int *hash256_len, int *randomizer256_len);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
+ * @brief Sets the Hash and Randmoizer value, synchronously.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/bluetooth
+ *
+ * @param[in] remote_address Remote device address
+ * @param[in] hash192 The P-192 hash value received via OOB from remote device
+ * @param[in] randomizer192 The P-192 randomizer value received via OOB from remote device
+ * @param[in] hash192_len The length of @a hash192
+ * @param[in] randomizer192_len The length of @a randomizer192
+ * @param[in] hash256 The P-256 hash value received via OOB from remote device
+ * @param[in] randomizer256 The P-256 randomizer value received via OOB from remote device
+ * @param[in] hash256_len The length of @a hash256
+ * @param[in] randomizer256_len The length of @a randomizer256
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE Successful
+ * @retval #BT_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #BT_ERROR_NOT_ENABLED Not enabled
+ * @retval #BT_ERROR_OPERATION_FAILED Operation failed
+ * @retval #BT_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #BT_ERROR_NOT_SUPPORTED Not supported
+ *
+ * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED.
+ * @pre The Bluetooth service must be initialized with bt_initialize().
+ * @see bt_initialize()
+ */
+int bt_adapter_set_remote_oob_ext_data(const char *remote_address,
+ const unsigned char *hash192, const unsigned char *randomizer192,
+ int hash192_len, int randomizer192_len,
+ const unsigned char *hash256, const unsigned char *randomizer256,
+ int hash256_len, int randomizer256_len);
+
/**
* @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
* @brief Deletes the Hash and Randomizer value, synchronously.
diff --git a/include/tv/bluetooth.h b/include/tv/bluetooth.h
index ef9bce7..e5f4108 100644
--- a/include/tv/bluetooth.h
+++ b/include/tv/bluetooth.h
@@ -646,6 +646,76 @@ int bt_adapter_get_local_oob_data(unsigned char **hash, unsigned char **randomiz
int bt_adapter_set_remote_oob_data(const char *remote_address,
unsigned char *hash, unsigned char *randomizer,
int hash_len, int randomizer_len);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
+ * @brief Gets the Hash and Randmoizer value, synchronously.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/bluetooth
+ *
+ * @remarks The @a hash192, randomizer192, hash256 and randomizer256 must be released using free()
+ *
+ * @param[out] hash192 The hash value derived from the P-192 public key
+ * @param[out] randomizer192 The randomizer value associated with the P-192 public key
+ * @param[out] hash192_len The length of @a hash192
+ * @param[out] randomizer192_len The length of @a randomizer192
+ * @param[out] hash256 The hash value derived from the P-256 public key
+ * @param[out] randomizer256 The randomizer value associated with the P-256 public key
+ * @param[out] hash256_len The length of @a hash256
+ * @param[out] randomizer256_len The length of @a randomizer256
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE Successful
+ * @retval #BT_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #BT_ERROR_NOT_ENABLED Not enabled
+ * @retval #BT_ERROR_OPERATION_FAILED Operation failed
+ * @retval #BT_ERROR_NOT_SUPPORTED Not supported
+ *
+ * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED.
+ * @pre The Bluetooth service must be initialized with bt_initialize().
+ * @see bt_initialize()
+ */
+int bt_adapter_get_local_oob_ext_data(unsigned char **hash192, unsigned char **randomizer192,
+ int *hash192_len, int *randomizer192_len,
+ unsigned char **hash256, unsigned char **randomizer256,
+ int *hash256_len, int *randomizer256_len);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
+ * @brief Sets the Hash and Randmoizer value, synchronously.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/bluetooth
+ *
+ * @param[in] remote_address Remote device address
+ * @param[in] hash192 The P-192 hash value received via OOB from remote device
+ * @param[in] randomizer192 The P-192 randomizer value received via OOB from remote device
+ * @param[in] hash192_len The length of @a hash192
+ * @param[in] randomizer192_len The length of @a randomizer192
+ * @param[in] hash256 The P-256 hash value received via OOB from remote device
+ * @param[in] randomizer256 The P-256 randomizer value received via OOB from remote device
+ * @param[in] hash256_len The length of @a hash256
+ * @param[in] randomizer256_len The length of @a randomizer256
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE Successful
+ * @retval #BT_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #BT_ERROR_NOT_ENABLED Not enabled
+ * @retval #BT_ERROR_OPERATION_FAILED Operation failed
+ * @retval #BT_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #BT_ERROR_NOT_SUPPORTED Not supported
+ *
+ * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED.
+ * @pre The Bluetooth service must be initialized with bt_initialize().
+ * @see bt_initialize()
+ */
+int bt_adapter_set_remote_oob_ext_data(const char *remote_address,
+ const unsigned char *hash192, const unsigned char *randomizer192,
+ int hash192_len, int randomizer192_len,
+ const unsigned char *hash256, const unsigned char *randomizer256,
+ int hash256_len, int randomizer256_len);
+
/**
* @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
* @brief Deletes the Hash and Randomizer value, synchronously.
diff --git a/include/wearable/bluetooth.h b/include/wearable/bluetooth.h
index 2c5efc6..77ccb32 100644
--- a/include/wearable/bluetooth.h
+++ b/include/wearable/bluetooth.h
@@ -646,6 +646,76 @@ int bt_adapter_get_local_oob_data(unsigned char **hash, unsigned char **randomiz
int bt_adapter_set_remote_oob_data(const char *remote_address,
unsigned char *hash, unsigned char *randomizer,
int hash_len, int randomizer_len);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
+ * @brief Gets the Hash and Randmoizer value, synchronously.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/bluetooth
+ *
+ * @remarks The @a hash192, randomizer192, hash256 and randomizer256 must be released using free()
+ *
+ * @param[out] hash192 The hash value derived from the P-192 public key
+ * @param[out] randomizer192 The randomizer value associated with the P-192 public key
+ * @param[out] hash192_len The length of @a hash192
+ * @param[out] randomizer192_len The length of @a randomizer192
+ * @param[out] hash256 The hash value derived from the P-256 public key
+ * @param[out] randomizer256 The randomizer value associated with the P-256 public key
+ * @param[out] hash256_len The length of @a hash256
+ * @param[out] randomizer256_len The length of @a randomizer256
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE Successful
+ * @retval #BT_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #BT_ERROR_NOT_ENABLED Not enabled
+ * @retval #BT_ERROR_OPERATION_FAILED Operation failed
+ * @retval #BT_ERROR_NOT_SUPPORTED Not supported
+ *
+ * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED.
+ * @pre The Bluetooth service must be initialized with bt_initialize().
+ * @see bt_initialize()
+ */
+int bt_adapter_get_local_oob_ext_data(unsigned char **hash192, unsigned char **randomizer192,
+ int *hash192_len, int *randomizer192_len,
+ unsigned char **hash256, unsigned char **randomizer256,
+ int *hash256_len, int *randomizer256_len);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
+ * @brief Sets the Hash and Randmoizer value, synchronously.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/bluetooth
+ *
+ * @param[in] remote_address Remote device address
+ * @param[in] hash192 The P-192 hash value received via OOB from remote device
+ * @param[in] randomizer192 The P-192 randomizer value received via OOB from remote device
+ * @param[in] hash192_len The length of @a hash192
+ * @param[in] randomizer192_len The length of @a randomizer192
+ * @param[in] hash256 The P-256 hash value received via OOB from remote device
+ * @param[in] randomizer256 The P-256 randomizer value received via OOB from remote device
+ * @param[in] hash256_len The length of @a hash256
+ * @param[in] randomizer256_len The length of @a randomizer256
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE Successful
+ * @retval #BT_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #BT_ERROR_NOT_ENABLED Not enabled
+ * @retval #BT_ERROR_OPERATION_FAILED Operation failed
+ * @retval #BT_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #BT_ERROR_NOT_SUPPORTED Not supported
+ *
+ * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED.
+ * @pre The Bluetooth service must be initialized with bt_initialize().
+ * @see bt_initialize()
+ */
+int bt_adapter_set_remote_oob_ext_data(const char *remote_address,
+ const unsigned char *hash192, const unsigned char *randomizer192,
+ int hash192_len, int randomizer192_len,
+ const unsigned char *hash256, const unsigned char *randomizer256,
+ int hash256_len, int randomizer256_len);
+
/**
* @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
* @brief Deletes the Hash and Randomizer value, synchronously.
diff --git a/test/bt_unit_test.c b/test/bt_unit_test.c
index 72f4104..2514c40 100644
--- a/test/bt_unit_test.c
+++ b/test/bt_unit_test.c
@@ -217,9 +217,13 @@ tc_table_t tc_adapter[] = {
{"bt_adapter_get_local_oob_data"
, BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_OOB_DATA},
{"bt_adapter_set_remote_oob_data"
- , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_LOCAL_OOB_DATA},
+ , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_REMOTE_OOB_DATA},
{"bt_adapter_remove_remote_oob_data"
, BT_UNIT_TEST_FUNCTION_ADAPTER_REMOVE_REMOTE_OOB_DATA},
+ {"bt_adapter_get_local_oob_ext_data"
+ , BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_OOB_EXT_DATA},
+ {"bt_adapter_set_remote_oob_ext_data"
+ , BT_UNIT_TEST_FUNCTION_ADAPTER_SET_REMOTE_OOB_EXT_DATA},
{"bt_adapter_set_visibility_mode_changed_cb"
, BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY_MODE_CHANGED_CB},
{"bt_adapter_unset_visibility_mode_changed_cb"
@@ -2990,7 +2994,37 @@ int test_set_params(int test_id, char *param)
break;
}
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_REMOTE_OOB_EXT_DATA: {
+ if (param_index == 0) {
+ g_test_param.param_count = 5;
+ g_test_param.params = g_malloc0(sizeof(char*) * g_test_param.param_count);
+ param_type = BT_UNIT_TEST_PARAM_TYPE_STRING;
+ }
+ if (param_index > 0) {
+ int len = strlen(param);
+ g_test_param.params[param_index - 1] = g_malloc0(len);
+ param[len - 1] = '\0';
+ strcpy(g_test_param.params[param_index - 1], param);
+ }
+
+ if (param_index == g_test_param.param_count) {
+ need_to_set_params = false;
+#ifdef ARCH64
+ test_input_callback((void *)(uintptr_t)test_id);
+#else
+ test_input_callback((void *)test_id);
+#endif
+ param_index = 0;
+ return 0;
+ }
+
+ TC_PRT("Input param(%d) type:%s", param_index + 1, param_type);
+ param_index++;
+
+ break;
+
+ }
default:
TC_PRT("There is no param to set\n");
need_to_set_params = false;
@@ -4297,12 +4331,83 @@ int test_input_callback(void *data)
break;
}
- case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_LOCAL_OOB_DATA: {
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_REMOTE_OOB_DATA: {
ret = bt_adapter_set_remote_oob_data(remote_addr, hash,
randomizer, hash_len, rand_len);
TC_PRT("returns %s\n", __bt_get_error_message(ret));
break;
}
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_OOB_EXT_DATA: {
+ unsigned char *data[4];
+ int len[4];
+ int i;
+
+ ret = bt_adapter_get_local_oob_ext_data(
+ &data[0], &data[1], &len[0], &len[1],
+ &data[2], &data[3], &len[2], &len[3]);
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ } else {
+ for (i = 0; i < 4; i++) {
+ int j;
+
+ printf("Data[%d] : ", i);
+ for (j = 0; j < len[i]; j++) {
+ printf("%02x", data[i][j]);
+ }
+ printf("\n");
+
+ g_free(data[i]);
+ }
+ }
+ break;
+ }
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_REMOTE_OOB_EXT_DATA: {
+ char remote_addr[18];
+ unsigned char *data[4];
+ int len[4];
+ int i;
+ char tmp[3];
+ long val;
+
+ if (g_test_param.param_count != 5) {
+ TC_PRT("Input parameter first!");
+ break;
+ }
+
+ g_strlcpy(remote_addr, g_test_param.params[0],
+ sizeof(remote_addr));
+
+ for (i = 0; i < 4; i++) {
+ len[i] = strlen(g_test_param.params[i + 1]) / 2;
+ data[i] = g_malloc0(len[i]);
+ }
+
+ for (i = 0; i < 4; i++) {
+ int j;
+
+ printf("Data[%d] : ", i);
+ for (j = 0; j < len[i]; j++) {
+ g_strlcpy(tmp, g_test_param.params[i + 1] + 2 * j, sizeof(tmp));
+ val = strtol(tmp, NULL, 16);
+ data[i][j] = val;
+ printf("%02x", data[i][j]);
+ }
+ printf("\n");
+ }
+
+ ret = bt_adapter_set_remote_oob_ext_data(remote_addr,
+ data[0], data[1], len[0], len[1],
+ data[2], data[3], len[2], len[3]);
+
+ __bt_free_test_param(&g_test_param);
+
+ for (i = 0; i < 4; i++)
+ g_free(data[i]);
+
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
case BT_UNIT_TEST_FUNCTION_ADAPTER_REMOVE_REMOTE_OOB_DATA: {
ret = bt_adapter_remove_remote_oob_data(remote_addr);
diff --git a/test/bt_unit_test.h b/test/bt_unit_test.h
index 9c6069b..328a260 100644
--- a/test/bt_unit_test.h
+++ b/test/bt_unit_test.h
@@ -74,7 +74,9 @@ typedef enum {
BT_UNIT_TEST_FUNCTION_ADAPTER_SET_DEVICE_DISCOVERY_STATE_CHANGED_CB,
BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_DEVICE_DISCOVERY_STATE_CHANGED_CB,
BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_OOB_DATA,
- BT_UNIT_TEST_FUNCTION_ADAPTER_SET_LOCAL_OOB_DATA,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_SET_REMOTE_OOB_DATA,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_GET_LOCAL_OOB_EXT_DATA,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_SET_REMOTE_OOB_EXT_DATA,
BT_UNIT_TEST_FUNCTION_ADAPTER_REMOVE_REMOTE_OOB_DATA,
BT_UNIT_TEST_FUNCTION_ADAPTER_SET_VISIBILITY_MODE_CHANGED_CB,
BT_UNIT_TEST_FUNCTION_ADAPTER_UNSET_VISIBILITY_MODE_CHANGED_CB,