Send commitlog mailing list submissions to
        commitlog@lists.openmoko.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.openmoko.org/mailman/listinfo/commitlog
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of commitlog digest..."
Today's Topics:

   1. Holger's qtopia repo: Changes to 'master' ([EMAIL PROTECTED])
   2. r4699 - trunk/src/host/dfu-util/src ([EMAIL PROTECTED])
   3. r4700 - trunk/src/host/dfu-util/src ([EMAIL PROTECTED])
   4. r4701 - trunk/src/host/dfu-util/src ([EMAIL PROTECTED])
   5. development tree for U-Boot: Changes to 'stable'
      ([EMAIL PROTECTED])
   6. r4702 - in developers/werner: . wep wep/tests
      ([EMAIL PROTECTED])
   7. r4703 - in developers/werner/wep: . tests
      ([EMAIL PROTECTED])
--- Begin Message ---
 src/libraries/qtopiacomm/serial/qatutils.cpp       |   37 ++++++++++++++++++++
 src/libraries/qtopiacomm/serial/qatutils.h         |    1 +
 .../qmodemsupplementaryservices.cpp                |    8 +----
 3 files changed, 39 insertions(+), 7 deletions(-)

New commits:
commit 711e8236746e093f48869265a3a5baa470d52f18
Author: Holger Freyther <[EMAIL PROTECTED]>
Date:   Tue Oct 7 16:18:20 2008 +0200

    [gsm] Fixes from trolltech for CUSD handling that are in Qtopia4.3.3
        - In 4f7df94616ffac06cc3927fd1d8c2dbf6de724af CUSD parsing was fixed for
          a german default encoding case, a bug was filed at trolltech
        - Now include the mostly unverified fix from Trolltech that was put
          into Qtopia 4.3.3.
    
        Bug report at Trolltech:
        
http://trolltech.com/developer/task-tracker/index_html?method=entry&id=212600
    
        Bug report at Openmoko:
        https://docs.openmoko.org/trac/ticket/2029
    
        I wanted to take care of this when merging Qt4.3.3 (actually did in
        master-4.3.3) but it looks like we will go for Qt Extended 4.4.x 
directly
        so let us merge this patch and test it.




--- End Message ---
--- Begin Message ---
Author: laforge
Date: 2008-10-07 19:34:43 +0200 (Tue, 07 Oct 2008)
New Revision: 4699

Modified:
   trunk/src/host/dfu-util/src/main.c
Log:
cosmetic cleanup (long lines, copyright notice)


Modified: trunk/src/host/dfu-util/src/main.c
===================================================================
--- trunk/src/host/dfu-util/src/main.c  2008-10-07 15:07:33 UTC (rev 4698)
+++ trunk/src/host/dfu-util/src/main.c  2008-10-07 17:34:43 UTC (rev 4699)
@@ -1,7 +1,7 @@
 /*
  * dfu-util
  *
- * (C) 2007 by OpenMoko, Inc.
+ * (C) 2007-2008 by OpenMoko, Inc.
  * Written by Harald Welte <[EMAIL PROTECTED]>
  *
  * Based on existing code of dfu-programmer-0.4
@@ -162,15 +162,20 @@
        int if_name_str_idx;
        char name[MAX_STR_LEN+1] = "UNDEFINED";
 
-       if_name_str_idx = 
dev->config[dfu_if->configuration].interface[dfu_if->interface].altsetting[dfu_if->altsetting].iInterface;
+       if_name_str_idx = dev->config[dfu_if->configuration]
+                               .interface[dfu_if->interface]
+                               .altsetting[dfu_if->altsetting].iInterface;
        if (if_name_str_idx) {
                if (!dfu_if->dev_handle)
                        dfu_if->dev_handle = usb_open(dfu_if->dev);
                if (dfu_if->dev_handle)
-                       usb_get_string_simple(dfu_if->dev_handle, 
if_name_str_idx, name, MAX_STR_LEN);
+                       usb_get_string_simple(dfu_if->dev_handle,
+                                             if_name_str_idx, name,
+                                             MAX_STR_LEN);
        }
 
-       printf("Found %s: [0x%04x:0x%04x] devnum=%u, cfg=%u, intf=%u, alt=%u, 
name=\"%s\"\n", 
+       printf("Found %s: [0x%04x:0x%04x] devnum=%u, cfg=%u, intf=%u, "
+              "alt=%u, name=\"%s\"\n", 
               dfu_if->flags & DFU_IFF_DFU ? "DFU" : "Runtime",
               dev->descriptor.idVendor, dev->descriptor.idProduct,
               dev->devnum, dfu_if->configuration, dfu_if->interface,
@@ -428,7 +433,7 @@
        int page_size = getpagesize();
        int ret;
        
-       printf("dfu-util - (C) 2007 by OpenMoko Inc.\n"
+       printf("dfu-util - (C) 2007-2008 by OpenMoko Inc.\n"
               "This program is Free Software and has ABSOLUTELY NO 
WARRANTY\n\n");
 
        memset(dif, 0, sizeof(*dif));
@@ -440,7 +445,8 @@
 
        while (1) {
                int c, option_index = 0;
-               c = getopt_long(argc, argv, "hVvld:p:c:i:a:t:U:D:R", opts, 
&option_index);
+               c = getopt_long(argc, argv, "hVvld:p:c:i:a:t:U:D:R", opts,
+                               &option_index);
                if (c == -1)
                        break;
 
@@ -575,43 +581,53 @@
 
                printf("Claiming USB DFU Runtime Interface...\n");
                if (usb_claim_interface(_rt_dif.dev_handle, _rt_dif.interface) 
< 0) {
-                       fprintf(stderr, "Cannot claim interface: %s\n", 
usb_strerror());
+                       fprintf(stderr, "Cannot claim interface: %s\n",
+                               usb_strerror());
                        exit(1);
                }
 
                printf("Determining device status: ");
                if (dfu_get_status(_rt_dif.dev_handle, _rt_dif.interface, 
&status ) < 0) {
-                       fprintf(stderr, "error get_status: %s\n", 
usb_strerror());
+                       fprintf(stderr, "error get_status: %s\n",
+                               usb_strerror());
                        exit(1);
                }
-               printf("state = %s, status = %d\n", 
dfu_state_to_string(status.bState), status.bStatus);
+               printf("state = %s, status = %d\n", 
+                      dfu_state_to_string(status.bState), status.bStatus);
 
                switch (status.bState) {
                case DFU_STATE_appIDLE:
                case DFU_STATE_appDETACH:
-                       printf("Device really in Runtime Mode, send DFU detach 
request...\n");
-                       if (dfu_detach(_rt_dif.dev_handle, _rt_dif.interface, 
1000) < 0) {
-                               fprintf(stderr, "error detaching: %s\n", 
usb_strerror());
+                       printf("Device really in Runtime Mode, send DFU "
+                              "detach request...\n");
+                       if (dfu_detach(_rt_dif.dev_handle, 
+                                      _rt_dif.interface, 1000) < 0) {
+                               fprintf(stderr, "error detaching: %s\n",
+                                       usb_strerror());
                                exit(1);
                                break;
                        }
                        printf("Resetting USB...\n");
                        ret = usb_reset(_rt_dif.dev_handle);
                        if (ret < 0 && ret != -ENODEV)
-                               fprintf(stderr, "error resetting after detach: 
%s\n", 
+                               fprintf(stderr,
+                                       "error resetting after detach: %s\n", 
                                        usb_strerror());
                        sleep(2);
                        break;
                case DFU_STATE_dfuERROR:
                        printf("dfuERROR, clearing status\n");
-                       if (dfu_clear_status(_rt_dif.dev_handle, 
_rt_dif.interface) < 0) {
-                               fprintf(stderr, "error clear_status: %s\n", 
usb_strerror());
+                       if (dfu_clear_status(_rt_dif.dev_handle,
+                                            _rt_dif.interface) < 0) {
+                               fprintf(stderr, "error clear_status: %s\n",
+                                       usb_strerror());
                                exit(1);
                                break;
                        }
                        break;
                default:
-                       fprintf(stderr, "WARNING: Runtime device already in DFU 
state ?!?\n");
+                       fprintf(stderr, "WARNING: Runtime device already "
+                               "in DFU state ?!?\n");
                        goto dfustate;
                        break;
                }
@@ -640,9 +656,9 @@
                        fprintf(stderr, "Lost device after RESET?\n");
                        exit(1);
                } else if (num_devs > 1) {
-                       fprintf(stderr, "More than one DFU capable USB device 
found, "
-                              "you might try `--list' and then disconnect all 
but one "
-                              "device\n");
+                       fprintf(stderr, "More than one DFU capable USB "
+                               "device found, you might try `--list' and "
+                               "then disconnect all but one device\n");
                        exit(1);
                }
                if (!get_first_dfu_device(dif))
@@ -651,7 +667,8 @@
                printf("Opening USB Device...\n");
                dif->dev_handle = usb_open(dif->dev);
                if (!dif->dev_handle) {
-                       fprintf(stderr, "Cannot open device: %s\n", 
usb_strerror());
+                       fprintf(stderr, "Cannot open device: %s\n",
+                               usb_strerror());
                        exit(1);
                }
        } else {
@@ -684,7 +701,8 @@
                exit(1);
        } else if (num_ifs == 1) {
                if (!get_first_dfu_if(dif)) {
-                       fprintf(stderr, "Can't find the single available DFU 
IF\n");
+                       fprintf(stderr, "Can't find the single available "
+                               "DFU IF\n");
                        exit(1);
                }
        } else if (num_ifs > 1 && !dif->flags & (DFU_IFF_IFACE|DFU_IFF_ALT)) {
@@ -697,13 +715,15 @@
 #if 0
        printf("Setting Configuration %u...\n", dif->configuration);
        if (usb_set_configuration(dif->dev_handle, dif->configuration) < 0) {
-               fprintf(stderr, "Cannot set configuration: %s\n", 
usb_strerror());
+               fprintf(stderr, "Cannot set configuration: %s\n",
+                       usb_strerror());
                exit(1);
        }
 #endif
        printf("Claiming USB DFU Interface...\n");
        if (usb_claim_interface(dif->dev_handle, dif->interface) < 0) {
-               fprintf(stderr, "Cannot claim interface: %s\n", usb_strerror());
+               fprintf(stderr, "Cannot claim interface: %s\n",
+                       usb_strerror());
                exit(1);
        }
 
@@ -720,7 +740,8 @@
                fprintf(stderr, "error get_status: %s\n", usb_strerror());
                exit(1);
        }
-       printf("state = %s, status = %d\n", dfu_state_to_string(status.bState), 
status.bStatus);
+       printf("state = %s, status = %d\n",
+              dfu_state_to_string(status.bState), status.bStatus);
 
        switch (status.bState) {
        case DFU_STATE_appIDLE:
@@ -731,7 +752,8 @@
        case DFU_STATE_dfuERROR:
                printf("dfuERROR, clearing status\n");
                if (dfu_clear_status(dif->dev_handle, dif->interface) < 0) {
-                       fprintf(stderr, "error clear_status: %s\n", 
usb_strerror());
+                       fprintf(stderr, "error clear_status: %s\n",
+                               usb_strerror());
                        exit(1);
                }
                goto status_again;
@@ -740,7 +762,8 @@
        case DFU_STATE_dfuUPLOAD_IDLE:
                printf("aborting previous incomplete transfer\n");
                if (dfu_abort(dif->dev_handle, dif->interface) < 0) {
-                       fprintf(stderr, "can't send DFU_ABORT: %s\n", 
usb_strerror());
+                       fprintf(stderr, "can't send DFU_ABORT: %s\n",
+                               usb_strerror());
                        exit(1);
                }
                goto status_again;




--- End Message ---
--- Begin Message ---
Author: laforge
Date: 2008-10-07 19:37:05 +0200 (Tue, 07 Oct 2008)
New Revision: 4700

Modified:
   trunk/src/host/dfu-util/src/commands.c
Log:
fix copy+paste mistake.  When we upload, then no download can fail


Modified: trunk/src/host/dfu-util/src/commands.c
===================================================================
--- trunk/src/host/dfu-util/src/commands.c      2008-10-07 17:34:43 UTC (rev 
4699)
+++ trunk/src/host/dfu-util/src/commands.c      2008-10-07 17:37:05 UTC (rev 
4700)
@@ -340,7 +340,7 @@
     if ( 0 > sam7dfu_do_upload(device, interface, 256, /* FIXME */
                               args.com_flash_data.file) )
     {
-       fprintf( stderr, "Download failed.\n" );
+       fprintf( stderr, "Upload failed.\n" );
        return -1;
     }
 }




--- End Message ---
--- Begin Message ---
Author: laforge
Date: 2008-10-07 19:42:36 +0200 (Tue, 07 Oct 2008)
New Revision: 4701

Modified:
   trunk/src/host/dfu-util/src/sam7dfu.c
Log:
* add hashmark printing during DFU upload
* add copyright notice to code copied from sam7dfu project (OpenPCD)


Modified: trunk/src/host/dfu-util/src/sam7dfu.c
===================================================================
--- trunk/src/host/dfu-util/src/sam7dfu.c       2008-10-07 17:37:05 UTC (rev 
4700)
+++ trunk/src/host/dfu-util/src/sam7dfu.c       2008-10-07 17:42:36 UTC (rev 
4701)
@@ -1,5 +1,7 @@
 /* This is supposed to be a "real" DFU implementation, just as specified in the
  * USB DFU 1.0 Spec.  Not overloaded like the Atmel one...
+ *
+ * (C) 2007-2008 by Harald Welte <[EMAIL PROTECTED]>
  */
 
 #include <stdio.h>
@@ -36,6 +38,10 @@
                goto out_free;
        }
        
+       printf("bytes_per_hash=%u\n", xfer_size);
+       printf("Starting upload: [");
+       fflush(stdout);
+
        while (1) {
                int rc, write_rc;
                rc = dfu_upload(usb_handle, interface, xfer_size, buf);
@@ -45,7 +51,7 @@
                }
                write_rc = write(fd, buf, rc);
                if (write_rc < rc) {
-                       fprintf(stderr, "Short write: %s\n",
+                       fprintf(stderr, "Short file write: %s\n",
                                strerror(errno));
                        ret = total_bytes;
                        goto out_close;
@@ -56,9 +62,14 @@
                        ret = total_bytes;
                        goto out_close;
                }
+               putchar('#');
+               fflush(stdout);
        }
        ret = 0;
 
+       printf("] finished!\n");
+       fflush(stdout);
+
 out_close:
        close(fd);
 out_free:




--- End Message ---
--- Begin Message ---
 common/cmd_terminal.c        |   13 +++++++++++++
 common/serial.c              |    2 +-
 cpu/arm920t/s3c24x0/serial.c |    3 ++-
 drivers/usb/usbdfu.c         |   42 +++++++++++++++---------------------------
 include/serial.h             |    4 ++++
 5 files changed, 35 insertions(+), 29 deletions(-)

New commits:
commit 414367bf5b65942947dd5d569c27d2a8e8e5e562
Author: Harald Welte <[EMAIL PROTECTED]>
Date:   Tue Oct 7 18:49:49 2008 +0100

    u-boot: Fix DFU upload in u-boot
    
    Fix DFU upload in u-boot
    
    The existing USB DFU upload (read firmware from device to USB host) code
    was a big mess and probably only ever worked by accident.
    
    specifically, there were three bugs described in
    http://docs.openmoko.org/trac/ticket/1843 :
    
    * when it copies a new blockful of data, it copies it into the same buffer 
that
      urb->buffer was already pointing to, thus overwriting the beginning of the
      last buffer before it is sent back to the requestor
    
    * it then calls memcpy() to copy the beginning of the newly-read block to 
after
      the end of the buffer that urb->buffer is pointing to. If 
ds->nand->erasesize
      is the same as the _buf[] array, then this will write past the end of the
      _buf[] array and smash some other item in RAM.
    
    * if a requested buffer exactly reaches the end of the block that's been
      buffered in ds->buf, then handle_upload() will read a new NAND block into 
the
      buffer even though it is not needed. (The test for (len > remain) should
      probably go before the test for ds->ptr, not after?)
    
    So instead of fixing those issues individually, I rewored the logic
    for how to deal with DFU upload. Much simpler, and without those bugs.
    
    Signed-off-by: Harald Welte <[EMAIL PROTECTED]>

commit 1746c3657337018a3f14688ed4793be2ed609733
Author: Harald Welte <[EMAIL PROTECTED]>
Date:   Tue Oct 7 18:49:34 2008 +0100

    Enable hardware flow control for GSM/GPS
    
    GTA02 >= v3: Enable hardware flow control for GSM and GPS serial ports
    
    Without this patch, s3ser0 (GSM) and s3ser1 (GPS) will not properly
    work on GTA02 >= v3 hardware.
    
    Together with the previous patch, this fixes bug
    https://docs.openmoko.org/trac/ticket/1595
    
    Signed-off-by: Harald Welte <[EMAIL PROTECTED]>

commit 017271c84a1f5b8dc7a8869b2bf4d77347cce647
Author: Harald Welte <[EMAIL PROTECTED]>
Date:   Tue Oct 7 18:49:18 2008 +0100

    Fix init of non-console serial lines
    
    [serial]: Fix initialization of non-console serial lines
    
    When using a serial port for something that is not console operation
    (like the 'terminal' mode with GSM or GPS on Openmoko GTA02), then
    the serial port needs to be initialized properly.
    
    Signed-off-by: Harald Welte <[EMAIL PROTECTED]>




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2008-10-07 23:30:44 +0200 (Tue, 07 Oct 2008)
New Revision: 4702

Added:
   developers/werner/wep/
   developers/werner/wep/Makefile
   developers/werner/wep/tests/
   developers/werner/wep/tests/Makefile
   developers/werner/wep/tests/foobar
   developers/werner/wep/wep.c
   developers/werner/wep/wepkey.c
   developers/werner/wep/wepkey.h
Log:
WEP keyphrase hash.



Added: developers/werner/wep/Makefile
===================================================================
--- developers/werner/wep/Makefile                              (rev 0)
+++ developers/werner/wep/Makefile      2008-10-07 21:30:44 UTC (rev 4702)
@@ -0,0 +1,20 @@
+CFLAGS=-Wall
+LDFLAGS=-lssl
+
+OBJS=wep.o wepkey.o
+
+.PHONY:                all test tests clean spotless
+
+
+all:           wep
+
+wep:           $(OBJS)
+
+test tests:    wep
+               $(MAKE) -C tests
+
+clean:
+               rm -f $(WEPKEY)
+
+spotless:      clean
+               rm -f wep

Added: developers/werner/wep/tests/Makefile
===================================================================
--- developers/werner/wep/tests/Makefile                                (rev 0)
+++ developers/werner/wep/tests/Makefile        2008-10-07 21:30:44 UTC (rev 
4702)
@@ -0,0 +1,7 @@
+.PHONY:        tests clean
+
+all:
+       ./foobar
+
+clean:
+       rm -f _*

Added: developers/werner/wep/tests/foobar
===================================================================
--- developers/werner/wep/tests/foobar                          (rev 0)
+++ developers/werner/wep/tests/foobar  2008-10-07 21:30:44 UTC (rev 4702)
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+fail()
+{
+    echo TEST FAILED 1>&2
+    exit 1
+}
+
+
+../wep foobar >_out || fail
+diff -u - _out <<EOF || fail
+49d68437b1ffb0db3fdf2d4a93
+a4beb3b8ec
+b697e900c8
+b5d2bb755b
+197ea2abe7
+EOF
+
+echo PASSED
+exit 0


Property changes on: developers/werner/wep/tests/foobar
___________________________________________________________________
Name: svn:executable
   + *

Added: developers/werner/wep/wep.c
===================================================================
--- developers/werner/wep/wep.c                         (rev 0)
+++ developers/werner/wep/wep.c 2008-10-07 21:30:44 UTC (rev 4702)
@@ -0,0 +1,49 @@
+/*
+ * wep.c - Generate WEP keys from a passphrase
+ *
+ * Copyright (C) 2008 by OpenMoko, Inc.
+ * Written by Werner Almesberger <[EMAIL PROTECTED]>
+ * All Rights Reserved
+ *  
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "wepkey.h"
+
+
+static void dump(void *buf, size_t len)
+{
+       uint8_t *p;
+
+       for (p = buf; p != buf+len; p++)
+               printf("%02x", *p);
+       putchar('\n');
+}
+
+
+static void usage(const char *name)
+{
+       fprintf(stderr, "usage: %s key_phrase\n", name);
+       exit(1);
+}
+
+
+int main(int argc, char **argv)
+{
+       char buf[13];
+       int i;
+
+       if (argc != 2)
+               usage(*argv);
+       dump(buf, wepkey_128(buf, sizeof(buf), argv[1], 0));
+       for (i = 0; i != 4; i++)
+               dump(buf, wepkey_64(buf, sizeof(buf), argv[1], i));
+       return 0;
+}

Added: developers/werner/wep/wepkey.c
===================================================================
--- developers/werner/wep/wepkey.c                              (rev 0)
+++ developers/werner/wep/wepkey.c      2008-10-07 21:30:44 UTC (rev 4702)
@@ -0,0 +1,74 @@
+/*
+ * wepkey.c - Generate WEP keys from a passphrase
+ *
+ * Copyright (C) 2008 by OpenMoko, Inc.
+ * Written by Werner Almesberger <[EMAIL PROTECTED]>
+ * All Rights Reserved
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ */
+
+/*
+ * Thanks to dd-wrt.com for the algorithm !
+ *
+ * 
http://svn.dd-wrt.com:8000/dd-wrt/browser/src/router/httpd/modules/wepkey.c?rev=631
+ */
+
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <openssl/md5.h>
+
+#include "wepkey.h"
+
+
+ssize_t wepkey_128(void *out, size_t size, const char *in, int n)
+{
+       MD5_CTX ctx;
+       char buf[64];
+       unsigned char tmp[16];
+       int len, i;
+
+       if (n)
+               abort(); /* not yet implemented */
+       if (size < WEPKEY_128_BYTES)
+               return -1;
+       len = strlen(in);
+       for (i = 0; i != sizeof(buf); i++)
+               buf[i] = in[i % len];
+       MD5_Init(&ctx);
+       MD5_Update(&ctx, buf, sizeof(buf));
+       MD5_Final(tmp, &ctx);
+       memcpy(out, tmp, WEPKEY_128_BYTES);
+       return WEPKEY_128_BYTES;
+}
+
+
+ssize_t wepkey_64(void *out, size_t size, const char *in, int n)
+{
+       int len, i, j;
+       uint32_t prn;
+
+       if (size < WEPKEY_64_BYTES)
+               return -1;
+       prn = 0;
+       len = strlen(in);
+       for (i = 0; i != len; i++)
+               prn ^= ((uint8_t *) in)[i] << (8*(i & 3));
+       for (i = 0; i != n; i++)
+               for (j = 0; j != WEPKEY_64_BYTES; j++) {
+                       prn *= 0x343fd;
+                       prn += 0x269ec3;
+               }
+       for (i = 0; i != WEPKEY_64_BYTES; i++) {
+               prn *= 0x343fd;
+               prn += 0x269ec3;
+               ((uint8_t *) out)[i] = prn >> 16;
+       }
+       return WEPKEY_64_BYTES;
+}

Added: developers/werner/wep/wepkey.h
===================================================================
--- developers/werner/wep/wepkey.h                              (rev 0)
+++ developers/werner/wep/wepkey.h      2008-10-07 21:30:44 UTC (rev 4702)
@@ -0,0 +1,28 @@
+/*
+ * wepkey.h - Generate WEP keys from a passphrase
+ *
+ * Copyright (C) 2008 by OpenMoko, Inc.
+ * Written by Werner Almesberger <[EMAIL PROTECTED]>
+ * All Rights Reserved
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ */
+
+
+#ifndef WEPKEY_H
+#define WEPKEY_H
+
+#include <sys/types.h>
+
+
+#define WEPKEY_128_BYTES       13
+#define WEPKEY_64_BYTES                5
+
+
+ssize_t wepkey_128(void *out, size_t size, const char *in, int n);
+ssize_t wepkey_64(void *out, size_t size, const char *in, int n);
+
+#endif /* !WEPKEY_H */




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2008-10-07 23:48:14 +0200 (Tue, 07 Oct 2008)
New Revision: 4703

Modified:
   developers/werner/wep/tests/foobar
   developers/werner/wep/wep.c
   developers/werner/wep/wepkey.c
Log:
Added generation of 128-bit keys with index > 0.



Modified: developers/werner/wep/tests/foobar
===================================================================
--- developers/werner/wep/tests/foobar  2008-10-07 21:30:44 UTC (rev 4702)
+++ developers/werner/wep/tests/foobar  2008-10-07 21:48:14 UTC (rev 4703)
@@ -10,6 +10,9 @@
 ../wep foobar >_out || fail
 diff -u - _out <<EOF || fail
 49d68437b1ffb0db3fdf2d4a93
+a240f0feabe487bfcb2cfdb05b
+0c81b0bfab27187ea7b5467c63
+80b0656e46bc81e0627a046701
 a4beb3b8ec
 b697e900c8
 b5d2bb755b

Modified: developers/werner/wep/wep.c
===================================================================
--- developers/werner/wep/wep.c 2008-10-07 21:30:44 UTC (rev 4702)
+++ developers/werner/wep/wep.c 2008-10-07 21:48:14 UTC (rev 4703)
@@ -42,8 +42,9 @@
 
        if (argc != 2)
                usage(*argv);
-       dump(buf, wepkey_128(buf, sizeof(buf), argv[1], 0));
        for (i = 0; i != 4; i++)
+               dump(buf, wepkey_128(buf, sizeof(buf), argv[1], i));
+       for (i = 0; i != 4; i++)
                dump(buf, wepkey_64(buf, sizeof(buf), argv[1], i));
        return 0;
 }

Modified: developers/werner/wep/wepkey.c
===================================================================
--- developers/werner/wep/wepkey.c      2008-10-07 21:30:44 UTC (rev 4702)
+++ developers/werner/wep/wepkey.c      2008-10-07 21:48:14 UTC (rev 4703)
@@ -29,22 +29,23 @@
 
 ssize_t wepkey_128(void *out, size_t size, const char *in, int n)
 {
+       const char extra[] = "#$%" "[EMAIL PROTECTED]" "%&^";
        MD5_CTX ctx;
        char buf[64];
        unsigned char tmp[16];
-       int len, i;
+       int len, i, j;
 
-       if (n)
-               abort(); /* not yet implemented */
        if (size < WEPKEY_128_BYTES)
                return -1;
        len = strlen(in);
-       for (i = 0; i != sizeof(buf); i++)
-               buf[i] = in[i % len];
+       for (i = 0; i != sizeof(buf); i++) {
+               j = i % (len+n*3);
+               buf[i] = j < len ? in[j] : extra[j-len];
+       }
        MD5_Init(&ctx);
        MD5_Update(&ctx, buf, sizeof(buf));
        MD5_Final(tmp, &ctx);
-       memcpy(out, tmp, WEPKEY_128_BYTES);
+       memcpy(out, tmp+n, WEPKEY_128_BYTES);
        return WEPKEY_128_BYTES;
 }
 




--- End Message ---
_______________________________________________
commitlog mailing list
commitlog@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/commitlog

Reply via email to