allow selecting blocksize

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23640 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2008-08-19 02:20:01 +00:00
parent ae6d0372d5
commit 6fe6bf3eef

View File

@@ -38,6 +38,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <err.h> #include <err.h>
#include <assert.h>
/* key and initial vector */ /* key and initial vector */
static char key[16] = static char key[16] =
@@ -47,6 +48,9 @@ static char ivec[16] =
"\xaa\xbb\x45\xd4\xaa\xbb\x45\xd4" "\xaa\xbb\x45\xd4\xaa\xbb\x45\xd4"
"\xaa\xbb\x45\xd4\xaa\xbb\x45\xd4"; "\xaa\xbb\x45\xd4\xaa\xbb\x45\xd4";
static void
usage(int exit_code) __attribute__((noreturn));
static void static void
usage(int exit_code) usage(int exit_code)
{ {
@@ -77,22 +81,20 @@ main(int argc, char **argv)
} }
if (strcmp(argv[1], "--help") == 0) if (strcmp(argv[1], "--help") == 0)
usage(0); usage(0);
} else if (argc == 3) { usage(1);
ifn = argv[1]; } else if (argc == 4) {
ofn = argv[2]; block_size = atoi(argv[1]);
if (block_size == 0)
errx(1, "invalid blocksize %s", argv[1]);
ifn = argv[2];
ofn = argv[3];
} else } else
usage(1); usage(1);
/* in = fopen(ifn, "r");
* Size is prime to trigger mis-match between io block size and
* encryption block size.
*/
block_size = 1021;
in = fopen("in", "r");
if (in == NULL) if (in == NULL)
errx(1, "failed to open input file"); errx(1, "failed to open input file");
out = fopen("out", "w"); out = fopen(ofn, "w+");
if (out == NULL) if (out == NULL)
errx(1, "failed to open output file"); errx(1, "failed to open output file");