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