* [Bluez-devel] [PATCH] randomizer for passkey-agent
@ 2007-10-23 13:07 eGore
2007-10-23 14:30 ` eGore
2007-10-25 22:52 ` Marcel Holtmann
0 siblings, 2 replies; 6+ messages in thread
From: eGore @ 2007-10-23 13:07 UTC (permalink / raw)
To: BlueZ development
[-- Attachment #1: Type: text/plain, Size: 361 bytes --]
Hi list,
I wanted a passkey-agent that does not always use the same passkey so it can run in daemon mode and provide passkeys. This is an attempt to implement this functionality.
Please review and commit.
Thanks in advance,
Christoph Brill
--
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kanns mit allen: http://www.gmx.net/de/go/multimessenger
[-- Attachment #2: bluez-passkey-random.patch --]
[-- Type: text/x-patch, Size: 4190 bytes --]
--- daemon/passkey-agent.c.org 2007-01-25 16:09:25.000000000 +0100
+++ daemon/passkey-agent.c 2007-10-23 15:02:48.000000000 +0200
@@ -32,6 +32,7 @@
#include <signal.h>
#include <getopt.h>
#include <string.h>
+#include <time.h>
#include <dbus/dbus.h>
@@ -39,6 +40,9 @@
static char *passkey = NULL;
static char *address = NULL;
+int use_random = 0;
+int use_default = 0;
+int key_length = 4;
static volatile sig_atomic_t __io_canceled = 0;
static volatile sig_atomic_t __io_terminated = 0;
@@ -48,6 +52,16 @@
__io_canceled = 1;
}
+static char * next_key() {
+ int i;
+ char * key = malloc((key_length + 1) * sizeof(char));
+ for (i = 0; i < key_length; i++) {
+ key[i] = 48+(rand() %10);
+ }
+ key[key_length] = '\0';
+ return key;
+}
+
static DBusHandlerResult agent_filter(DBusConnection *conn,
DBusMessage *msg, void *data)
{
@@ -78,6 +92,12 @@
const char *path, *address;
dbus_bool_t numeric;
+ if (use_random) {
+ if (passkey)
+ free(passkey);
+ passkey = next_key();
+ }
+
if (!passkey)
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
@@ -150,7 +170,7 @@
if (!dbus_message_get_args(msg, NULL,
DBUS_TYPE_STRING, &path, DBUS_TYPE_STRING, &address,
DBUS_TYPE_INVALID)) {
- fprintf(stderr, "Invalid arguments for passkey Confirm method");
+ fprintf(stderr, "Invalid arguments for passkey Cancel method");
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
@@ -224,7 +244,7 @@
};
static int register_agent(DBusConnection *conn, const char *agent_path,
- const char *remote_address, int use_default)
+ const char *remote_address)
{
DBusMessage *msg, *reply;
DBusError err;
@@ -280,7 +300,7 @@
}
static int unregister_agent(DBusConnection *conn, const char *agent_path,
- const char *remote_address, int use_default)
+ const char *remote_address)
{
DBusMessage *msg, *reply;
DBusError err;
@@ -334,17 +354,23 @@
static void usage(void)
{
+#ifdef HAVE_CONFIG_H
printf("Bluetooth passkey agent ver %s\n\n", VERSION);
+#else
+ printf("Bluetooth passkey agent\n\n");
+#endif
printf("Usage:\n"
- "\tpasskey-agent [--default] [--path agent-path] <passkey> [address]\n"
+ "\tpasskey-agent [--default] [--path agent-path] [--random] [--length keylength] <passkey> [address]\n"
"\n");
}
static struct option main_options[] = {
- { "default", 0, 0, 'd' },
- { "path", 1, 0, 'p' },
- { "help", 0, 0, 'h' },
+ { "default", no_argument, &use_default, 1 },
+ { "path", required_argument, 0, 'p' },
+ { "help", no_argument, 0, 'h' },
+ { "random", no_argument, &use_random, 1 },
+ { "length", required_argument, 0, 'l' },
{ 0, 0, 0, 0 }
};
@@ -353,12 +379,14 @@
struct sigaction sa;
DBusConnection *conn;
char match_string[128], default_path[128], *agent_path = NULL;
- int opt, use_default = 0;
+ int opt = 0;
+
+ srand(time(NULL));
snprintf(default_path, sizeof(default_path),
"/org/bluez/passkey_agent_%d", getpid());
- while ((opt = getopt_long(argc, argv, "+dp:h", main_options, NULL)) != EOF) {
+ while ((opt = getopt_long(argc, argv, "+dp:hrl:", main_options, NULL)) != EOF) {
switch(opt) {
case 'd':
use_default = 1;
@@ -373,8 +401,15 @@
case 'h':
usage();
exit(0);
+ case 'r':
+ use_random = 1;
+ break;
+ case 'l':
+ key_length = atoi(optarg);
+ use_random = 1;
+ break;
default:
- exit(1);
+ abort ();
}
}
@@ -382,12 +417,17 @@
argv += optind;
optind = 0;
- if (argc < 1) {
+ if (argc < 1 && !use_random) {
usage();
exit(1);
}
- passkey = strdup(argv[0]);
+ if (!use_random) {
+ passkey = strdup(argv[0]);
+ } else {
+ passkey = next_key();
+ }
+
address = (argc > 1) ? strdup(argv[1]) : NULL;
if (!use_default && !address) {
@@ -404,7 +444,7 @@
exit(1);
}
- if (register_agent(conn, agent_path, address, use_default) < 0) {
+ if (register_agent(conn, agent_path, address) < 0) {
dbus_connection_unref(conn);
exit(1);
}
@@ -430,7 +470,7 @@
}
if (!__io_terminated)
- unregister_agent(conn, agent_path, address, use_default);
+ unregister_agent(conn, agent_path, address);
if (passkey)
free(passkey);
[-- Attachment #3: Type: text/plain, Size: 314 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
[-- Attachment #4: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Bluez-devel] [PATCH] randomizer for passkey-agent
2007-10-23 13:07 [Bluez-devel] [PATCH] randomizer for passkey-agent eGore
@ 2007-10-23 14:30 ` eGore
2007-10-25 22:52 ` Marcel Holtmann
1 sibling, 0 replies; 6+ messages in thread
From: eGore @ 2007-10-23 14:30 UTC (permalink / raw)
To: BlueZ development, bluez-devel
Hi again,
forgot to mention my "issue" with this patch. Is it possible to find out th=
e passkey over dbus that is used for a handshake?
-------- Original-Nachricht --------
> Datum: Tue, 23 Oct 2007 15:07:38 +0200
> Von: "eGore" <eGore@gmx.de>
> An: "BlueZ development" <bluez-devel@lists.sourceforge.net>
> Betreff: [Bluez-devel] [PATCH] randomizer for passkey-agent
> Hi list,
> =
> I wanted a passkey-agent that does not always use the same passkey so it
> can run in daemon mode and provide passkeys. This is an attempt to implem=
ent
> this functionality.
> =
> Please review and commit.
> =
> Thanks in advance,
> Christoph Brill
> -- =
> Psssst! Schon vom neuen GMX MultiMessenger geh=F6rt?
> Der kanns mit allen: http://www.gmx.net/de/go/multimessenger
-- =
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! =
Ideal f=FCr Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Bluez-devel] [PATCH] randomizer for passkey-agent
2007-10-23 13:07 [Bluez-devel] [PATCH] randomizer for passkey-agent eGore
2007-10-23 14:30 ` eGore
@ 2007-10-25 22:52 ` Marcel Holtmann
2007-10-26 18:07 ` Christoph Brill
1 sibling, 1 reply; 6+ messages in thread
From: Marcel Holtmann @ 2007-10-25 22:52 UTC (permalink / raw)
To: BlueZ development
Hi,
> I wanted a passkey-agent that does not always use the same passkey so it can run in daemon mode and provide passkeys. This is an attempt to implement this functionality.
you have to explain the use case for this one. The passkey-agent.c is
only an example on how to write a passkey agent. The GNOME and KDE
desktops provide their own ones that open input dialogs.
Regards
Marcel
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Bluez-devel] [PATCH] randomizer for passkey-agent
2007-10-25 22:52 ` Marcel Holtmann
@ 2007-10-26 18:07 ` Christoph Brill
2007-10-26 19:14 ` Brad Midgley
2007-10-27 10:31 ` Marcel Holtmann
0 siblings, 2 replies; 6+ messages in thread
From: Christoph Brill @ 2007-10-26 18:07 UTC (permalink / raw)
To: BlueZ development
Hi
the use case is quite simple. Imagin a headless system that is doing
bonding via a deamon. The idea is to show a random passkey on a display
and enable the mobile user to authenitcate using this passkey. I know
that the passkey-agent is more a "proof of concept" version, but if it
would generate random keys and if there was a dbus interface to the last
generated key it would be pretty helpful. At least for me :-)
If you dislike the idea I will split of a bugfix patch of the original
one patch I sent that should be applied.
Am Freitag, den 26.10.2007, 00:52 +0200 schrieb Marcel Holtmann:
> Hi,
>
> > I wanted a passkey-agent that does not always use the same passkey so it can run in daemon mode and provide passkeys. This is an attempt to implement this functionality.
>
> you have to explain the use case for this one. The passkey-agent.c is
> only an example on how to write a passkey agent. The GNOME and KDE
> desktops provide their own ones that open input dialogs.
>
> Regards
>
> Marcel
>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Bluez-devel mailing list
> Bluez-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/bluez-devel
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Bluez-devel] [PATCH] randomizer for passkey-agent
2007-10-26 18:07 ` Christoph Brill
@ 2007-10-26 19:14 ` Brad Midgley
2007-10-27 10:31 ` Marcel Holtmann
1 sibling, 0 replies; 6+ messages in thread
From: Brad Midgley @ 2007-10-26 19:14 UTC (permalink / raw)
To: BlueZ development
Christoph
Your passkey agent could also send its key over dbus by itself. This
goes beyond the original purpose of the bluez example agent, so
instead of posting a diff, I suggest you post the whole thing as a
separate example.
Brad
On 10/26/07, Christoph Brill <egore@gmx.de> wrote:
> Hi
>
> the use case is quite simple. Imagin a headless system that is doing
> bonding via a deamon. The idea is to show a random passkey on a display
> and enable the mobile user to authenitcate using this passkey. I know
> that the passkey-agent is more a "proof of concept" version, but if it
> would generate random keys and if there was a dbus interface to the last
> generated key it would be pretty helpful. At least for me :-)
>
> If you dislike the idea I will split of a bugfix patch of the original
> one patch I sent that should be applied.
>
>
> Am Freitag, den 26.10.2007, 00:52 +0200 schrieb Marcel Holtmann:
> > Hi,
> >
> > > I wanted a passkey-agent that does not always use the same passkey so it can run in daemon mode and provide passkeys. This is an attempt to implement this functionality.
> >
> > you have to explain the use case for this one. The passkey-agent.c is
> > only an example on how to write a passkey agent. The GNOME and KDE
> > desktops provide their own ones that open input dialogs.
> >
> > Regards
> >
> > Marcel
> >
> >
> >
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by: Splunk Inc.
> > Still grepping through log files to find problems? Stop.
> > Now Search log events and configuration files using AJAX and a browser.
> > Download your FREE copy of Splunk now >> http://get.splunk.com/
> > _______________________________________________
> > Bluez-devel mailing list
> > Bluez-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/bluez-devel
> >
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Bluez-devel mailing list
> Bluez-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/bluez-devel
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Bluez-devel] [PATCH] randomizer for passkey-agent
2007-10-26 18:07 ` Christoph Brill
2007-10-26 19:14 ` Brad Midgley
@ 2007-10-27 10:31 ` Marcel Holtmann
1 sibling, 0 replies; 6+ messages in thread
From: Marcel Holtmann @ 2007-10-27 10:31 UTC (permalink / raw)
To: BlueZ development
Hi Christoph,
> the use case is quite simple. Imagin a headless system that is doing
> bonding via a deamon. The idea is to show a random passkey on a display
> and enable the mobile user to authenitcate using this passkey. I know
> that the passkey-agent is more a "proof of concept" version, but if it
> would generate random keys and if there was a dbus interface to the last
> generated key it would be pretty helpful. At least for me :-)
that is the whole idea, why we have the full blown passkey interface.
You can do whatever you want with it. However since that system will
interact with a specific display (which I know nothing about), I don't
even know where to put this agent. It is flexible to cover these use
cases, but they are so specific that this kind of code makes no sense in
the example passkey agent.
Regards
Marcel
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-10-27 10:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-23 13:07 [Bluez-devel] [PATCH] randomizer for passkey-agent eGore
2007-10-23 14:30 ` eGore
2007-10-25 22:52 ` Marcel Holtmann
2007-10-26 18:07 ` Christoph Brill
2007-10-26 19:14 ` Brad Midgley
2007-10-27 10:31 ` Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox