mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
Made decryption work in --server mode, allow output of plain base64,
allow --armor and --base64 arguments for INPUT and OUTPUT, new global option --base64, cleaned up the help page.
This commit is contained in:
parent
717bc63ad2
commit
9e241878a6
@ -530,6 +530,7 @@ gpgsm_create_writer (Base64Context *ctx,
|
||||
if (ctrl->create_pem || ctrl->create_base64)
|
||||
{
|
||||
(*ctx)->u.wparm.fp = fp;
|
||||
if (ctrl->create_pem)
|
||||
(*ctx)->u.wparm.pem_name = "CMS OBJECT"; /* fixme */
|
||||
rc = ksba_writer_set_cb (w, base64_writer_cb, &(*ctx)->u.wparm);
|
||||
}
|
||||
|
10
sm/decrypt.c
10
sm/decrypt.c
@ -279,7 +279,7 @@ gpgsm_decrypt (CTRL ctrl, int in_fd, FILE *out_fp)
|
||||
goto leave;
|
||||
}
|
||||
|
||||
rc = gpgsm_create_writer (&b64reader, ctrl, out_fp, &writer);
|
||||
rc = gpgsm_create_writer (&b64writer, ctrl, out_fp, &writer);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("can't create writer: %s\n", gnupg_strerror (rc));
|
||||
@ -447,6 +447,14 @@ gpgsm_decrypt (CTRL ctrl, int in_fd, FILE *out_fp)
|
||||
}
|
||||
while (stopreason != KSBA_SR_READY);
|
||||
|
||||
rc = gpgsm_finish_writer (b64writer);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("write failed: %s\n", gnupg_strerror (rc));
|
||||
goto leave;
|
||||
}
|
||||
|
||||
|
||||
leave:
|
||||
ksba_cms_release (cms);
|
||||
gpgsm_destroy_reader (b64reader);
|
||||
|
75
sm/gpgsm.c
75
sm/gpgsm.c
@ -83,6 +83,10 @@ enum cmd_and_opt_values {
|
||||
oAssumeBase64,
|
||||
oAssumeBinary,
|
||||
|
||||
oBase64,
|
||||
oNoArmor,
|
||||
|
||||
|
||||
oTextmode,
|
||||
oFingerprint,
|
||||
oWithFingerprint,
|
||||
@ -115,7 +119,6 @@ enum cmd_and_opt_values {
|
||||
oNoVerbose,
|
||||
oTrustDBName,
|
||||
oNoSecmemWarn,
|
||||
oNoArmor,
|
||||
oNoDefKeyring,
|
||||
oNoGreeting,
|
||||
oNoTTY,
|
||||
@ -169,7 +172,7 @@ enum cmd_and_opt_values {
|
||||
oTryAllSecrets,
|
||||
oTrustedKey,
|
||||
oEmuMDEncodeBug,
|
||||
aTest
|
||||
aDummy
|
||||
};
|
||||
|
||||
|
||||
@ -187,8 +190,8 @@ static ARGPARSE_OPTS opts[] = {
|
||||
{ aVerifyFiles, "verify-files" , 256, "@" },
|
||||
{ aListKeys, "list-keys", 256, N_("list keys")},
|
||||
{ aListKeys, "list-public-keys", 256, "@" },
|
||||
{ aListSigs, "list-sigs", 256, N_("list keys and signatures")},
|
||||
{ aCheckKeys, "check-sigs",256, N_("check key signatures")},
|
||||
{ aDummy, "list-sigs", 256, "@"},
|
||||
{ aDummy, "check-sigs",256, "@"},
|
||||
{ oFingerprint, "fingerprint", 256, N_("list keys and fingerprints")},
|
||||
{ aListSecretKeys, "list-secret-keys", 256, N_("list secret keys")},
|
||||
{ aKeygen, "gen-key", 256, N_("generate a new key pair")},
|
||||
@ -204,6 +207,7 @@ static ARGPARSE_OPTS opts[] = {
|
||||
|
||||
{ oArmor, "armor", 0, N_("create ascii armored output")},
|
||||
{ oArmor, "armour", 0, "@" },
|
||||
{ oBase64, "base64", 0, N_("create base-64 encoded output")},
|
||||
|
||||
{ oAssumeArmor, "assume-armor", 0, N_("assume input is in PEM format")},
|
||||
{ oAssumeBase64, "assume-base64", 0,
|
||||
@ -211,11 +215,9 @@ static ARGPARSE_OPTS opts[] = {
|
||||
{ oAssumeBase64, "assume-binary", 0,
|
||||
N_("assume input is in binary format")},
|
||||
|
||||
|
||||
{ oRecipient, "recipient", 2, N_("|NAME|encrypt for NAME")},
|
||||
|
||||
#if 0
|
||||
{ oRecipient, "remote-user", 2, "@"}, /* old option name */
|
||||
{ oDefRecipient, "default-recipient" ,2,
|
||||
N_("|NAME|use NAME as default recipient")},
|
||||
{ oDefRecipientSelf, "default-recipient-self" ,0,
|
||||
@ -226,11 +228,13 @@ static ARGPARSE_OPTS opts[] = {
|
||||
|
||||
#endif
|
||||
{ oUser, "local-user",2, N_("use this user-id to sign or decrypt")},
|
||||
{ oCompress, NULL, 1, N_("|N|set compress level N (0 disables)") },
|
||||
|
||||
#if 0
|
||||
{ oCompress, NULL, 1, N_("|N|set compress level N (0 disables)") },
|
||||
{ oTextmodeShort, NULL, 0, "@"},
|
||||
{ oTextmode, "textmode", 0, N_("use canonical text mode")},
|
||||
#endif
|
||||
|
||||
{ oOutput, "output", 2, N_("use as output file")},
|
||||
{ oVerbose, "verbose", 0, N_("verbose") },
|
||||
{ oQuiet, "quiet", 0, N_("be somewhat more quiet") },
|
||||
@ -245,6 +249,7 @@ static ARGPARSE_OPTS opts[] = {
|
||||
{ oBatch, "batch", 0, N_("batch mode: never ask")},
|
||||
{ oAnswerYes, "yes", 0, N_("assume yes on most questions")},
|
||||
{ oAnswerNo, "no", 0, N_("assume no on most questions")},
|
||||
|
||||
{ oKeyring, "keyring" ,2, N_("add this keyring to the list of keyrings")},
|
||||
{ oSecretKeyring, "secret-keyring" ,2, N_("add this secret keyring to the list")},
|
||||
{ oDefaultKey, "default-key" ,2, N_("|NAME|use NAME as default secret key")},
|
||||
@ -255,24 +260,26 @@ static ARGPARSE_OPTS opts[] = {
|
||||
{ oDebug, "debug" ,4|16, "@"},
|
||||
{ oDebugAll, "debug-all" ,0, "@"},
|
||||
{ oStatusFD, "status-fd" ,1, N_("|FD|write status info to this FD") },
|
||||
{ oNoComment, "no-comment", 0, "@"},
|
||||
{ oCompletesNeeded, "completes-needed", 1, "@"},
|
||||
{ oMarginalsNeeded, "marginals-needed", 1, "@"},
|
||||
{ aDummy, "no-comment", 0, "@"},
|
||||
{ aDummy, "completes-needed", 1, "@"},
|
||||
{ aDummy, "marginals-needed", 1, "@"},
|
||||
{ oMaxCertDepth, "max-cert-depth", 1, "@" },
|
||||
{ oTrustedKey, "trusted-key", 2, N_("|KEYID|ulimately trust this key")},
|
||||
{ oLoadExtension, "load-extension" ,2, N_("|FILE|load extension module FILE")},
|
||||
{ oRFC1991, "rfc1991", 0, N_("emulate the mode described in RFC1991")},
|
||||
{ oOpenPGP, "openpgp", 0, N_("set all packet, cipher and digest options to OpenPGP behavior")},
|
||||
{ oS2KMode, "s2k-mode", 1, N_("|N|use passphrase mode N")},
|
||||
{ oS2KDigest, "s2k-digest-algo",2,
|
||||
N_("|NAME|use message digest algorithm NAME for passphrases")},
|
||||
{ oS2KCipher, "s2k-cipher-algo",2,
|
||||
N_("|NAME|use cipher algorithm NAME for passphrases")},
|
||||
{ aDummy, "trusted-key", 2, "@"},
|
||||
{ oLoadExtension, "load-extension" ,2,
|
||||
N_("|FILE|load extension module FILE")},
|
||||
{ aDummy, "rfc1991", 0, "@"},
|
||||
{ aDummy, "openpgp", 0, "@"},
|
||||
{ aDummy, "s2k-mode", 1, "@"},
|
||||
{ aDummy, "s2k-digest-algo",2, "@"},
|
||||
{ aDummy, "s2k-cipher-algo",2, "@"},
|
||||
{ oCipherAlgo, "cipher-algo", 2 , N_("|NAME|use cipher algorithm NAME")},
|
||||
{ oDigestAlgo, "digest-algo", 2 , N_("|NAME|use message digest algorithm NAME")},
|
||||
{ oDigestAlgo, "digest-algo", 2 ,
|
||||
N_("|NAME|use message digest algorithm NAME")},
|
||||
#if 0
|
||||
{ oCompressAlgo, "compress-algo", 1 , N_("|N|use compress algorithm N")},
|
||||
{ oThrowKeyid, "throw-keyid", 0, N_("throw keyid field of encrypted packets")},
|
||||
{ oNotation, "notation-data", 2, N_("|NAME=VALUE|use this notation data")},
|
||||
#endif
|
||||
{ aDummy, "throw-keyid", 0, "@"},
|
||||
{ aDummy, "notation-data", 2, "@"},
|
||||
|
||||
{ 302, NULL, 0, N_(
|
||||
"@\n(See the man page for a complete listing of all commands and options)\n"
|
||||
@ -292,7 +299,7 @@ static ARGPARSE_OPTS opts[] = {
|
||||
|
||||
|
||||
{ oTrustDBName, "trustdb-name", 2, "@" },
|
||||
{ oNoSecmemWarn, "no-secmem-warning", 0, "@" }, /* used only by regression tests */
|
||||
{ oNoSecmemWarn, "no-secmem-warning", 0, "@" },
|
||||
{ oNoArmor, "no-armor", 0, "@"},
|
||||
{ oNoArmor, "no-armour", 0, "@"},
|
||||
{ oNoDefKeyring, "no-default-keyring", 0, "@" },
|
||||
@ -682,13 +689,20 @@ main ( int argc, char **argv)
|
||||
case aClearsign: set_cmd (&cmd, aClearsign); break;
|
||||
case aVerify: set_cmd (&cmd, aVerify); break;
|
||||
|
||||
case oArmor: opt.armor = 1; opt.no_armor=0; break;
|
||||
/* output encoding selection */
|
||||
case oArmor:
|
||||
ctrl.create_pem = 1;
|
||||
break;
|
||||
case oBase64:
|
||||
ctrl.create_pem = 0;
|
||||
ctrl.create_base64 = 1;
|
||||
break;
|
||||
case oNoArmor:
|
||||
/* use of no-armor for setting the input encoding is deprecated*/
|
||||
ctrl.autodetect_encoding = 0;
|
||||
opt.no_armor=1; opt.armor=0;
|
||||
ctrl.create_pem = 0;
|
||||
ctrl.create_base64 = 0;
|
||||
break;
|
||||
|
||||
/* Input encoding selection */
|
||||
case oAssumeArmor:
|
||||
ctrl.autodetect_encoding = 0;
|
||||
ctrl.is_pem = 1;
|
||||
@ -707,6 +721,8 @@ main ( int argc, char **argv)
|
||||
|
||||
|
||||
case oOutput: opt.outfile = pargs.r.ret_str; break;
|
||||
|
||||
|
||||
case oQuiet: opt.quiet = 1; break;
|
||||
case oNoTTY: /* fixme:tty_no_terminal(1);*/ break;
|
||||
case oDryRun: opt.dry_run = 1; break;
|
||||
@ -825,7 +841,8 @@ main ( int argc, char **argv)
|
||||
case oEnableSpecialFilenames: allow_special_filenames =1; break;
|
||||
|
||||
|
||||
|
||||
case aDummy:
|
||||
break;
|
||||
default:
|
||||
pargs.err = configfp? 1:2;
|
||||
break;
|
||||
@ -906,8 +923,6 @@ main ( int argc, char **argv)
|
||||
xfree(p);
|
||||
}
|
||||
|
||||
if (opt.armor)
|
||||
ctrl.create_pem = 1;
|
||||
|
||||
if (!cmd && opt.fingerprint && !with_fpr)
|
||||
set_cmd (&cmd, aListKeys);
|
||||
|
19
sm/server.c
19
sm/server.c
@ -203,9 +203,25 @@ cmd_encrypt (ASSUAN_CONTEXT ctx, char *line)
|
||||
static int
|
||||
cmd_decrypt (ASSUAN_CONTEXT ctx, char *line)
|
||||
{
|
||||
CTRL ctrl = assuan_get_pointer (ctx);
|
||||
int inp_fd, out_fd;
|
||||
FILE *out_fp;
|
||||
int rc;
|
||||
|
||||
inp_fd = assuan_get_input_fd (ctx);
|
||||
if (inp_fd == -1)
|
||||
return set_error (No_Input, NULL);
|
||||
out_fd = assuan_get_output_fd (ctx);
|
||||
if (out_fd == -1)
|
||||
return set_error (No_Output, NULL);
|
||||
|
||||
return set_error (Not_Implemented, "fixme");
|
||||
out_fp = fdopen ( dup(out_fd), "w");
|
||||
if (!out_fp)
|
||||
return set_error (General_Error, "fdopen() failed");
|
||||
rc = gpgsm_decrypt (ctrl, inp_fd, out_fp);
|
||||
fclose (out_fp);
|
||||
|
||||
return rc_to_assuan_status (rc);
|
||||
}
|
||||
|
||||
|
||||
@ -395,6 +411,7 @@ gpgsm_server (void)
|
||||
assuan_strerror(rc));
|
||||
gpgsm_exit (2);
|
||||
}
|
||||
assuan_set_hello_line (ctx, "GNU Privacy Guard's S/M server ready");
|
||||
|
||||
assuan_register_reset_notify (ctx, reset_notify);
|
||||
assuan_register_input_notify (ctx, input_notify);
|
||||
|
Loading…
x
Reference in New Issue
Block a user