Commit 12a7898e authored by Niels Möller's avatar Niels Möller
Browse files

*** empty log message ***

Rev: ChangeLog:1.191
Rev: src/.cvsignore:1.17
Rev: src/pkcs5-test.c:1.1
parent eb2853dc
2000-05-06 Niels Mller <nisse@cuckoo.localdomain>
* configure.in: Bumped version to 0.9.8.
* src/sexp.c (sexp_argp_parser): Renamed output-format option from
-o to -f.
* src/lsh_writekey.c (main_options): #if:ed out the -f alias.
* doc/lsh.texinfo (Getting started): Updated example on using
lsh_writekey.
* src/tcpforward_commands.c (do_remote_port_install_continuation):
Handle only the successful case here.
......
......@@ -24,6 +24,7 @@ lsh_proxy
lsh_writekey
lshd
packet_types.h
pkcs5-test
prime_table
prime_table.h
sexp_conv
......
......@@ -24,6 +24,7 @@
/lsh_writekey
/lshd
/packet_types.h
/pkcs5-test
/prime_table
/prime_table.h
/sexp_conv
......
/* pkcs5-test.c
*
*/
#include "crypto.h"
#include <getopt.h>
#include <stdio.h>
static void
usage(void)
{
fprintf(stderr, "pkcs5-test [-i iterations] [-s salt] [-l key length] password");
exit(1);
}
static void
print_hex(unsigned length, const char *data)
{
static const char digits[16] = "0123456789ABCDEF";
unsigned i;
for (i = 0; i<length; i++)
{
if (!(i%8))
putchar(' ');
putchar(digits[(data[i]/0x10) & 0xf]);
putchar(digits[data[i] & 0xf]);
}
}
int main(int argc, char **argv)
{
int iterations = 10;
char *salt = "pepper";
int length = 32;
char *password;
int c;
char *key;
while ((c = getopt(argc, argv, "i:s:l:")) != -1)
{
switch (c)
{
case 'i':
iterations = atoi(optarg);
if ( (iterations < 1) || (iterations > 10000000))
usage();
break;
case 's':
salt = optarg;
break;
case 'l':
length = atoi(optarg);
if ( (length < 1) || (length > 5000) )
usage();
break;
case '?':
usage();
default:
abort();
}
}
if (optind != (argc - 1))
usage();
password = argv[optind];
key = alloca(length);
pkcs5_derive_key(make_hmac_algorithm(&sha1_algorithm),
strlen(password), password,
strlen(salt), salt,
iterations,
length, key);
printf("Key:");
print_hex(length, key);
printf("\n");
return 0;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment