aboutsummaryrefslogtreecommitdiffstats
path: root/sm/decrypt.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2023-07-13 04:18:05 +0000
committerNIIBE Yutaka <[email protected]>2023-07-13 04:18:05 +0000
commit3e1357789f24c4ddc7bb91fa14cfdaa91a43938e (patch)
tree1215365065e852cd781d682135e6f879e337a148 /sm/decrypt.c
parentsm: Use estream_t for DATA_FP for verify operation. (diff)
downloadgnupg-3e1357789f24c4ddc7bb91fa14cfdaa91a43938e.tar.gz
gnupg-3e1357789f24c4ddc7bb91fa14cfdaa91a43938e.zip
sm: Use estream_t for operations.
* sm/decrypt.c (gpgsm_decrypt): Use estream for the input. * sm/encrypt.c (gpgsm_encrypt): Likewise. * sm/gpgsm.c (open_read): Remove. (main): Use open_es_fread for gpgsm_import_files. Fix call of gpgsm_encrypt, gpgsm_sign, gpgsm_verify and gpgsm_decrypt. (open_es_fread): Use gnupg_check_special_filename and open_stream_nc. * sm/gpgsm.h: Fix function declarations. * sm/import.c (import_one): Use estream for the input. (reimport_one, gpgsm_import, gpgsm_import_files): Likewise. * sm/server.c (cmd_encrypt): Use open_stream_nc to get estream and call gpgsm_encrypt with it. (cmd_decrypt): Likewise for the call of gpgsm_decrypt. (cmd_verify): Likewise for the call of gpgsm_verify. (cmd_sign): Likewise for the call of gpgsm_sign. (cmd_import): Likewise for the call of gpgsm_import. * sm/sign.c (hash_data): Use estream for the input. (hash_and_copy_data): Likewise. (gpgsm_sign): Likewise. * sm/verify.c (gpgsm_verify): Use estream for the input. -- GnuPG-bug-id: 6592 Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'sm/decrypt.c')
-rw-r--r--sm/decrypt.c12
1 files changed, 1 insertions, 11 deletions
diff --git a/sm/decrypt.c b/sm/decrypt.c
index 62983fe9c..a30eafc55 100644
--- a/sm/decrypt.c
+++ b/sm/decrypt.c
@@ -1052,7 +1052,7 @@ decrypt_gcm_filter (void *arg,
/* Perform a decrypt operation. */
int
-gpgsm_decrypt (ctrl_t ctrl, int in_fd, estream_t out_fp)
+gpgsm_decrypt (ctrl_t ctrl, estream_t in_fp, estream_t out_fp)
{
int rc;
gnupg_ksba_io_t b64reader = NULL;
@@ -1063,7 +1063,6 @@ gpgsm_decrypt (ctrl_t ctrl, int in_fd, estream_t out_fp)
ksba_stop_reason_t stopreason;
KEYDB_HANDLE kh;
int recp;
- estream_t in_fp = NULL;
struct decrypt_filter_parm_s dfparm;
memset (&dfparm, 0, sizeof dfparm);
@@ -1078,14 +1077,6 @@ gpgsm_decrypt (ctrl_t ctrl, int in_fd, estream_t out_fp)
goto leave;
}
- in_fp = es_fdopen_nc (in_fd, "rb");
- if (!in_fp)
- {
- rc = gpg_error_from_syserror ();
- log_error ("fdopen() failed: %s\n", strerror (errno));
- goto leave;
- }
-
rc = gnupg_ksba_create_reader
(&b64reader, ((ctrl->is_pem? GNUPG_KSBA_IO_PEM : 0)
| (ctrl->is_base64? GNUPG_KSBA_IO_BASE64 : 0)
@@ -1516,7 +1507,6 @@ gpgsm_decrypt (ctrl_t ctrl, int in_fd, estream_t out_fp)
gnupg_ksba_destroy_reader (b64reader);
gnupg_ksba_destroy_writer (b64writer);
keydb_release (kh);
- es_fclose (in_fp);
if (dfparm.hd)
gcry_cipher_close (dfparm.hd);
return rc;