List Info

Thread: Enabling authentication and encryption in C




Enabling authentication and encryption in C
user name
2006-07-27 11:09:35
Hi,

I'm working on my master thesis about Bluetooth security,
and are going 
to test the security and possibly implement some
improvements. I program 
in C, and am currently trying to enable authentication and
encryption 
through some function calls in hci_lib.h, namly
hci_authenticate_link 
and hci_encrypt_link respectively. Below is a part of my
code.

int main(void) {
    struct hci_conn_info_req *cr;
    struct sockaddr_rc resciever = ;
    struct sockaddr_rc local = ;
    uint16_t handle;
    int s, status, dd;

    char destination[17] = "00:09D:60:02:
45";

    resciever.rc_family = AF_BLUETOOTH;
    resciever.rc_channel = (uint8_t) 1;
    str2ba( destination, &resciever.rc_bdaddr );

    local.rc_family = AF_BLUETOOTH;
    local.rc_channel = (uint8_t) 1;
    //lokal_addr.rc_bdaddr = *BDADDR_ANY;
    str2ba("00:14:A44:0F:A1
", &local.rc_bdaddr);
   
    dd = hci_open_dev(hci_get_route(&local.rc_bdaddr));
    cr = (struct hci_conn_info_req*) malloc(sizeof(struct 
hci_conn_info_req));
    ioctl(dd, HCIGETCONNINFO, (unsigned long) cr);
    handle = cr->conn_info->handle;

    status = hci_authenticate_link(dd, handle, 0);
    printf("status: %d\n", status);
    status = hci_encrypt_link(dd, handle, (uint8_t)1, 0);
    printf("status: %d\n", status);
    ....
    .... }

Both calls always return -1, and things obviously aren't
going as 
expected. I've managed to digg down through several
function calls:
hci_authenticate_link -> hci_send_req -> hci_send_cmd
-> writev.
writev returns -1 as well and sets the error code variable
'errno' to 77 
(EBADFD, defined in asm/errno.h and means 'File descriptor
in bad state').
I'm not sure what this means.
Thoughts?
Any help will be appreciated!

Regards

Ståle



------------------------------------------------------------
-------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the
chance to share your
opinions on IT & business topics through brief surveys
-- and earn cash
http://www.techsay.com/default.
php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-users mailing list
Bluez-userslists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users

Enabling authentication and encryption in C
user name
2006-07-28 19:25:05
Hi Stale,

> I'm working on my master thesis about Bluetooth
security, and are going 
> to test the security and possibly implement some
improvements. I program 
> in C, and am currently trying to enable authentication
and encryption 
> through some function calls in hci_lib.h, namly
hci_authenticate_link 
> and hci_encrypt_link respectively. Below is a part of
my code.
> 
> int main(void) {
>     struct hci_conn_info_req *cr;
>     struct sockaddr_rc resciever = ;
>     struct sockaddr_rc local = ;
>     uint16_t handle;
>     int s, status, dd;
> 
>     char destination[17] = "00:09D:60:02:
45";
> 
>     resciever.rc_family = AF_BLUETOOTH;
>     resciever.rc_channel = (uint8_t) 1;
>     str2ba( destination, &resciever.rc_bdaddr );
> 
>     local.rc_family = AF_BLUETOOTH;
>     local.rc_channel = (uint8_t) 1;
>     //lokal_addr.rc_bdaddr = *BDADDR_ANY;
>     str2ba("00:14:A44:0F:A1
", &local.rc_bdaddr);
>    
>     dd =
hci_open_dev(hci_get_route(&local.rc_bdaddr));
>     cr = (struct hci_conn_info_req*)
malloc(sizeof(struct 
> hci_conn_info_req));
>     ioctl(dd, HCIGETCONNINFO, (unsigned long) cr);
>     handle = cr->conn_info->handle;
> 
>     status = hci_authenticate_link(dd, handle, 0);
>     printf("status: %d\n", status);
>     status = hci_encrypt_link(dd, handle, (uint8_t)1,
0);
>     printf("status: %d\n", status);
>     ....
>     .... }
> 
> Both calls always return -1, and things obviously
aren't going as 
> expected. I've managed to digg down through several
function calls:
> hci_authenticate_link -> hci_send_req ->
hci_send_cmd -> writev.
> writev returns -1 as well and sets the error code
variable 'errno' to 77 
> (EBADFD, defined in asm/errno.h and means 'File
descriptor in bad state').
> I'm not sure what this means.

run "hcidump -X -V" and see if they really got
sent. And take a look at
hidd, because this daemon already implements this.

Regards

Marcel



------------------------------------------------------------
-------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the
chance to share your
opinions on IT & business topics through brief surveys
-- and earn cash
http://www.techsay.com/default.
php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-users mailing list
Bluez-userslists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )