summaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorroot <root@lamia.panaceas.james.local>2016-08-20 14:04:59 +0100
committerroot <root@lamia.panaceas.james.local>2016-08-20 14:04:59 +0100
commitb063a2da3024a2e3175e1ba9b0a87cb6c7470765 (patch)
treef5c90c4119b091876a3f53acf4e581316eec4926 /host
parentbc832d6d342922a828aebb997d1d9c6626898487 (diff)
downloadcandlestick-b063a2da3024a2e3175e1ba9b0a87cb6c7470765.tar.gz
candlestick-b063a2da3024a2e3175e1ba9b0a87cb6c7470765.tar.bz2
candlestick-b063a2da3024a2e3175e1ba9b0a87cb6c7470765.zip
candlestick
Diffstat (limited to 'host')
-rw-r--r--host/Makefile23
-rw-r--r--host/cryptopad.c122
-rw-r--r--host/hexdump.c60
-rw-r--r--host/project.h39
4 files changed, 0 insertions, 244 deletions
diff --git a/host/Makefile b/host/Makefile
deleted file mode 100644
index 2013f89..0000000
--- a/host/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-INCLUDES=$(shell pkg-config --cflags libusb-1.0)
-LIBS=-Bstatic $(shell pkg-config --libs libusb-1.0) -lpthread -Bdynamic -ludev
-
-LDFLAGS=-s
-PROG=cryptopad
-SRCS=hexdump.c cryptopad.c
-
-OBJS=${SRCS:%.c=%.o}
-
-CFLAGS=${OPT}
-CPPFLAGS=${INCLUDES} ${DEFINES}
-
-default:${PROG}
-
-
-${PROG}:${OBJS}
- ${CC} ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
-
-install: ${PROG}
- install -c -m 755 ${PROG} /sbin/${PROG}
-clean:
- /bin/rm -f *~ *.d ${PROG} ${OBJS}
-
diff --git a/host/cryptopad.c b/host/cryptopad.c
deleted file mode 100644
index 42b1d36..0000000
--- a/host/cryptopad.c
+++ /dev/null
@@ -1,122 +0,0 @@
-#include "project.h"
-#include "../common/vendor_req.h"
-
-#define TIMEOUT 4000
-
-struct libusb_device * find_device(libusb_context *ctx)
-{
- libusb_device **list;
- ssize_t num_devs;
- ssize_t i;
-
- num_devs = libusb_get_device_list(ctx, &list);
- for (i = 0; i < num_devs; ++i) {
- struct libusb_device_descriptor desc;
- struct libusb_device *dev = list[i];
-
- if (libusb_get_device_descriptor(dev, &desc))
- continue;
-
-
- if (desc.idVendor!=0x1d6b) continue;
- if (desc.idProduct!=0x1932) continue;
-
- return dev;
-
- }
- libusb_free_device_list(list, 0);
-
- return NULL;
-}
-
-
-static void usage(char *n)
-{
-fprintf(stderr,"Usage:\n"
- "%s [-g [-n secs]] [-s [-p pwd]] [-h]\n"
- " -h display this message\n"
- " -g ask cryptopad to type password\n"
- " -n secs wait secs before typing password\n"
- " -s set password in cryptopad\n"
- " -p pwd password to set, prompts otherwise\n"
- " -w wipe password from cryptopad\n",
- n);
-
-exit(1);
-}
-
-
-
-
-int main(int argc,char *argv[])
-{
- libusb_context *ctx;
- libusb_device *dev;
- libusb_device_handle *devh;
- int wflag=0,gflag=0,sflag=0;
- char *pass=NULL;
- int c,ret;
- int delay=0;
-
-
- while((c=getopt(argc,argv,"hwgsp:n:"))!=-1) {
- switch(c) {
- case 'n':
- if (optarg) delay=atoi(optarg);
- break;
- case 'g':
- gflag++;
- break;
- case 's':
- sflag++;
- break;
- case 'w':
- wflag++;
- break;
- case 'p':
- pass=optarg;
- break;
- default:
- usage(argv[0]);
- }
- }
-
- if ((ret=libusb_init(&ctx)))
- errx(EX_IOERR, "unable to initialize libusb: %i", ret);
-
- dev=find_device(ctx);
-
- if (!dev) err(1,"no cryptopad found");
-
- if ((ret=libusb_open(dev, &devh))) err(1,"unable to open usb device: %i",ret);
-
-
- if (sflag) {
- char *pwd;
- if (!pass) pass=getpass("Enter password:");
-
- pwd=malloc(strlen(pass)+2);
- strcpy(pwd,pass);
- strcat(pwd,"\n");
-
- libusb_control_transfer( devh, LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE, VENDOR_REQ_SET_KEY, 0, 0, pwd, strlen(pwd), TIMEOUT );
- }
-
-
- if (gflag)
- libusb_control_transfer( devh, LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE, VENDOR_REQ_SEND_KEY, delay, 0, NULL, 0, TIMEOUT );
-
- if (wflag)
- libusb_control_transfer( devh, LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE, VENDOR_REQ_CLEAR_KEY, 0, 0, NULL, 0, TIMEOUT );
-
-
- libusb_close(devh);
-
- return 0;
-}
-
-
-
-
-
-
diff --git a/host/hexdump.c b/host/hexdump.c
deleted file mode 100644
index 127faab..0000000
--- a/host/hexdump.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * hexdump.c
- *
- * Copyright (c) 2011 Citrix Sysmtes Inc.,
- * All rights reserved.
- *
- */
-
-#include "project.h"
-
-void
-hexdump (char *prefix, void *_d, int len)
-{
- uint8_t *d = (uint8_t *) _d;
- int i, j, k;
- int e;
-
- printf ("%s %d bytes from %p\n", prefix, len, d);
-
- if (!d || len < 0)
- return;
-
- e = len + 15;
- e &= ~15;
-
- for (i = 0; i < e; i += 16)
- {
- printf ("%s %05x:", prefix, i);
- for (j = 0; j < 16; ++j)
- {
- k = i + j;
-
- if (k < len)
- printf (" %02x", d[k]);
- else
- printf (" ");
-
- if (j == 7)
- printf (" ");
- }
-
- printf (" ");
- for (j = 0; j < 16; ++j)
- {
- k = i + j;
- if (k < len)
- {
- uint8_t c = d[k];
- if (c < 33)
- c = '.';
- if (c > 126)
- c = '.';
- printf ("%c", c);
- }
- if (j == 7)
- printf (" ");
- }
- printf ("\n");
- }
-}
diff --git a/host/project.h b/host/project.h
deleted file mode 100644
index cf932b6..0000000
--- a/host/project.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#include <libusb.h>
-#include <stdio.h>
-#include <malloc.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <libusb.h>
-#include <stdarg.h>
-
-#ifdef HAVE_ERR
-# include <err.h>
-#else
-# include <errno.h>
-# include <string.h>
-# define warnx(...) do {\
- fprintf(stderr, __VA_ARGS__);\
- fprintf(stderr, "\n"); } while (0)
-# define errx(eval, ...) do {\
- warnx(__VA_ARGS__);\
- exit(eval); } while (0)
-# define warn(...) do {\
- fprintf(stderr, "%s: ", strerror(errno));\
- warnx(__VA_ARGS__); } while (0)
-# define err(eval, ...) do {\
- warn(__VA_ARGS__);\
- exit(eval); } while (0)
-#endif /* HAVE_ERR */
-
-
-#ifdef HAVE_SYSEXITS_H
-# include <sysexits.h>
-#else
-# define EX_OK 0 /* successful termination */
-# define EX_USAGE 64 /* command line usage error */
-# define EX_SOFTWARE 70 /* internal software error */
-# define EX_IOERR 74 /* input/output error */
-#endif /* HAVE_SYSEXITS_H */
-
-