mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
gpg: Add stub function for encrypting AEAD.
* g10/cipher.c (cipher_filter): Rename to cipher_filter_cfb. * g10/cipher-aead.c: New. Right now only with a stub function. * g10/Makefile.am (gpg_sources): Add file. * g10/encrypt.c (encrypt_simple): Push either cipher_filter_cfb or cipher_filter_aead. (encrypt_crypt): Ditto. (encrypt_filter): Ditto. * g10/sign.c (sign_symencrypt_file): Ditto. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
4e2ba546cd
commit
81d71818d0
@ -132,6 +132,7 @@ gpg_sources = server.c \
|
||||
decrypt.c \
|
||||
decrypt-data.c \
|
||||
cipher.c \
|
||||
cipher-aead.c \
|
||||
encrypt.c \
|
||||
sign.c \
|
||||
verify.c \
|
||||
|
67
g10/cipher-aead.c
Normal file
67
g10/cipher-aead.c
Normal file
@ -0,0 +1,67 @@
|
||||
/* cipher-aead.c - Enciphering filter for AEAD modes
|
||||
* Copyright (C) 2018 Werner koch
|
||||
*
|
||||
* This file is part of GnuPG.
|
||||
*
|
||||
* GnuPG is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GnuPG is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: GPL-3.0+
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "gpg.h"
|
||||
#include "../common/status.h"
|
||||
#include "../common/iobuf.h"
|
||||
#include "../common/util.h"
|
||||
#include "filter.h"
|
||||
#include "packet.h"
|
||||
#include "options.h"
|
||||
#include "main.h"
|
||||
|
||||
|
||||
/*
|
||||
* This filter is used to encipher data with an AEAD algorithm
|
||||
*/
|
||||
int
|
||||
cipher_filter_aead (void *opaque, int control,
|
||||
iobuf_t a, byte *buf, size_t *ret_len)
|
||||
{
|
||||
cipher_filter_context_t *cfx = opaque;
|
||||
size_t size = *ret_len;
|
||||
int rc = 0;
|
||||
|
||||
if (control == IOBUFCTRL_UNDERFLOW) /* decrypt */
|
||||
{
|
||||
rc = -1; /* not yet used */
|
||||
}
|
||||
else if (control == IOBUFCTRL_FLUSH) /* encrypt */
|
||||
{
|
||||
log_assert (a);
|
||||
rc = GPG_ERR_NOT_IMPLEMENTED;
|
||||
}
|
||||
else if (control == IOBUFCTRL_FREE)
|
||||
{
|
||||
gcry_cipher_close (cfx->cipher_hd);
|
||||
}
|
||||
else if (control == IOBUFCTRL_DESC)
|
||||
{
|
||||
mem2str (buf, "cipher_filter_aead", *ret_len);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
/* cipher.c - En-/De-ciphering filter
|
||||
/* cipher.c - Enciphering filter for the old CFB mode.
|
||||
* Copyright (C) 1998-2003, 2006, 2009 Free Software Foundation, Inc.
|
||||
* Copyright (C) 1998-2003, 2006, 2009, 2017 Werner koch
|
||||
*
|
||||
@ -117,7 +117,8 @@ write_header (cipher_filter_context_t *cfx, iobuf_t a)
|
||||
* This filter is used to en/de-cipher data with a symmetric algorithm
|
||||
*/
|
||||
int
|
||||
cipher_filter (void *opaque, int control, iobuf_t a, byte *buf, size_t *ret_len)
|
||||
cipher_filter_cfb (void *opaque, int control,
|
||||
iobuf_t a, byte *buf, size_t *ret_len)
|
||||
{
|
||||
cipher_filter_context_t *cfx = opaque;
|
||||
size_t size = *ret_len;
|
||||
@ -177,7 +178,7 @@ cipher_filter (void *opaque, int control, iobuf_t a, byte *buf, size_t *ret_len)
|
||||
}
|
||||
else if (control == IOBUFCTRL_DESC)
|
||||
{
|
||||
mem2str (buf, "cipher_filter", *ret_len);
|
||||
mem2str (buf, "cipher_filter_cfb", *ret_len);
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
@ -409,7 +409,10 @@ encrypt_simple (const char *filename, int mode, int use_seskey)
|
||||
|
||||
/* Register the cipher filter. */
|
||||
if (mode)
|
||||
iobuf_push_filter ( out, cipher_filter, &cfx );
|
||||
iobuf_push_filter (out,
|
||||
cfx.dek->use_aead? cipher_filter_aead
|
||||
/**/ : cipher_filter_cfb,
|
||||
&cfx );
|
||||
|
||||
/* Register the compress filter. */
|
||||
if ( do_compress )
|
||||
@ -800,7 +803,10 @@ encrypt_crypt (ctrl_t ctrl, int filefd, const char *filename,
|
||||
cfx.datalen = filesize && !do_compress ? filesize : 0;
|
||||
|
||||
/* Register the cipher filter. */
|
||||
iobuf_push_filter (out, cipher_filter, &cfx);
|
||||
iobuf_push_filter (out,
|
||||
cfx.dek->use_aead? cipher_filter_aead
|
||||
/**/ : cipher_filter_cfb,
|
||||
&cfx);
|
||||
|
||||
/* Register the compress filter. */
|
||||
if (do_compress)
|
||||
@ -959,7 +965,10 @@ encrypt_filter (void *opaque, int control,
|
||||
return rc;
|
||||
}
|
||||
|
||||
iobuf_push_filter (a, cipher_filter, &efx->cfx);
|
||||
iobuf_push_filter (a,
|
||||
efx->cfx.dek->use_aead? cipher_filter_aead
|
||||
/**/ : cipher_filter_cfb,
|
||||
&efx->cfx);
|
||||
|
||||
efx->header_okay = 1;
|
||||
}
|
||||
|
@ -145,7 +145,11 @@ void push_compress_filter2(iobuf_t out,compress_filter_context_t *zfx,
|
||||
int algo,int rel);
|
||||
|
||||
/*-- cipher.c --*/
|
||||
int cipher_filter( void *opaque, int control,
|
||||
int cipher_filter_cfb (void *opaque, int control,
|
||||
iobuf_t chain, byte *buf, size_t *ret_len);
|
||||
|
||||
/*-- cipher-aead.c --*/
|
||||
int cipher_filter_aead (void *opaque, int control,
|
||||
iobuf_t chain, byte *buf, size_t *ret_len);
|
||||
|
||||
/*-- textfilter.c --*/
|
||||
|
@ -2573,7 +2573,7 @@ encrypted (const char *option, int argc, char *argv[], void *cookie)
|
||||
|
||||
cfx->datalen = 0;
|
||||
|
||||
filter_push (out, cipher_filter, cfx, PKT_ENCRYPTED, cfx->datalen == 0);
|
||||
filter_push (out, cipher_filter_cfb, cfx, PKT_ENCRYPTED, cfx->datalen == 0);
|
||||
|
||||
debug ("Wrote encrypted packet:\n");
|
||||
|
||||
|
@ -1379,7 +1379,10 @@ sign_symencrypt_file (ctrl_t ctrl, const char *fname, strlist_t locusr)
|
||||
}
|
||||
|
||||
/* Push the encryption filter */
|
||||
iobuf_push_filter( out, cipher_filter, &cfx );
|
||||
iobuf_push_filter (out,
|
||||
cfx.dek->use_aead? cipher_filter_aead
|
||||
/**/ : cipher_filter_cfb,
|
||||
&cfx);
|
||||
|
||||
/* Push the compress filter */
|
||||
if (default_compress_algo())
|
||||
|
Loading…
x
Reference in New Issue
Block a user