version 1.3, 2005/05/29 07:34:34 |
version 1.4, 2005/05/29 08:54:13 |
|
|
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
#include <unistd.h> |
#include <unistd.h> |
|
#include <err.h> |
|
|
#include "extern.h" |
#include "extern.h" |
#include "gzip.h" |
#include "gzip.h" |
#include "key.h" |
#include "key.h" |
#include "util.h" |
#include "util.h" |
|
|
static char *passphrase = NULL; |
static char *passphrase_file = NULL; |
|
|
static int |
static int |
embed_signature(struct key *key, FILE *fin, FILE *fout) |
embed_signature(struct key *key, FILE *fin, FILE *fout) |
|
|
sign_passwd_cb(char *buf, int size, int rwflag, void *u) |
sign_passwd_cb(char *buf, int size, int rwflag, void *u) |
{ |
{ |
char *p; |
char *p; |
|
FILE *f; |
|
|
if (passphrase != NULL) { |
if (passphrase_file != NULL) { |
if (strlcpy(buf, passphrase, size) >= size) |
if ((f = fopen(passphrase_file, "r")) == NULL) |
errx(1, "Passphrase too long"); |
err(1, "fopen(%.64s)", passphrase_file); |
|
if (fgets(buf, size, f) == NULL) |
|
err(1, "fgets(%.64s)", passphrase_file); |
|
fclose(f); |
|
if ((p = strchr(buf, '\n')) != NULL) |
|
*p = '\0'; |
} else { |
} else { |
p = getpass("Enter passphrase: "); |
p = getpass("Enter passphrase: "); |
if (strlcpy(buf, p, size) >= size) |
if (strlcpy(buf, p, size) >= size) |
|
|
|
|
qflag = 0; |
qflag = 0; |
|
|
while ((i = getopt(argc, argv, "qvh?p:")) != -1) { |
while ((i = getopt(argc, argv, "qvh?f:")) != -1) { |
switch (i) { |
switch (i) { |
case 'q': |
case 'q': |
qflag = 1; |
qflag = 1; |
|
|
case 'v': |
case 'v': |
qflag = 0; |
qflag = 0; |
break; |
break; |
case 'p': |
case 'f': |
passphrase = optarg; |
passphrase_file = optarg; |
break; |
break; |
default: |
default: |
sign_usage(); |
sign_usage(); |
|
|
} |
} |
} |
} |
key_free(key); |
key_free(key); |
|
|
if (passphrase != NULL) |
|
memset(passphrase, 0, strlen(passphrase)); |
|
} |
} |