mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
gpg: First take on PKT_ENCRYPTED_AEAD.
* common/openpgpdefs.h (PKT_ENCRYPTED_AEAD): New const. * g10/dek.h (DEK): Increase size of use_aead to 4 bits. * g10/filter.h (cipher_filter_context_t): Add new fields for AEAD. * g10/packet.h (PKT_encrypted): Add fields aead_algo, cipher_algo, and chunkbyte. * g10/build-packet.c (do_encrypted_aead): New. (build_packet): Call it. * g10/parse-packet.c (dump_sig_subpkt): Handle SIGSUBPKT_PREF_AEAD. (parse_one_sig_subpkt, can_handle_critical): Ditto. (parse_encrypted): Clear new PKT_ENCRYPTED fields. (parse_encrypted_aead): New. (parse): Call it. * g10/gpg.c (main): Take care of --rfc4880bis option when checking compliance. * g10/cipher-aead.c: Replace the stub by real code. * g10/decrypt-data.c (decode_filter_ctx_t): Add fields for use with AEAD. (aead_set_nonce): New. (aead_set_ad): New. (decrypt_data): Support AEAD. (aead_underflow): New. (aead_decode_filter): New. * g10/encrypt.c (use_aead): Make that new fucntion work. (encrypt_simple): Use default_aead_algo() instead of EAX. * g10/mainproc.c (proc_encrypted): Support AEAD. (do_proc_packets): Support PKT_ENCRYPTED_AEAD. -- This code has seen only a very few manual tests. Encrypting always uses a 64k chunks and decryption has not been tested with larger chunks. Those small chunks make debugging much faster. Tests can be done using: gpg --rfc4880bis --pinentry-mode=loopback --passphrase abc \ --force-aead --aead-algo ocb --s2k-mode 0 --cipher AES \ -v -z 0 --status-fd 2 -c <INFILE >OUTFILE and gpg --rfc4880bis --pinentry-mode=loopback --passphrase=abc \ --status-fd 2 -v -d <INFILE >OUTFILE Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
81d71818d0
commit
3f4ca85cb0
12 changed files with 1235 additions and 138 deletions
55
g10/filter.h
55
g10/filter.h
|
@ -88,15 +88,52 @@ struct compress_filter_context_s {
|
|||
typedef struct compress_filter_context_s compress_filter_context_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
DEK *dek;
|
||||
u32 datalen;
|
||||
gcry_cipher_hd_t cipher_hd;
|
||||
unsigned int wrote_header : 1;
|
||||
unsigned int short_blklen_warn : 1;
|
||||
unsigned long short_blklen_count;
|
||||
gcry_md_hd_t mdc_hash;
|
||||
byte enchash[20];
|
||||
typedef struct
|
||||
{
|
||||
/* Object with the key and algo */
|
||||
DEK *dek;
|
||||
|
||||
/* Length of the data to encrypt if known - 32 bit because OpenPGP
|
||||
* requires partial encoding for a larger data size. */
|
||||
u32 datalen;
|
||||
|
||||
/* The current cipher handle. */
|
||||
gcry_cipher_hd_t cipher_hd;
|
||||
|
||||
/* Various processing flags. */
|
||||
unsigned int wrote_header : 1;
|
||||
unsigned int short_blklen_warn : 1;
|
||||
unsigned long short_blklen_count;
|
||||
|
||||
/* The encoded chunk byte for AEAD. */
|
||||
byte chunkbyte;
|
||||
|
||||
/* The decoded CHUNKBYTE. */
|
||||
uint64_t chunksize;
|
||||
|
||||
/* The chunk index for AEAD. */
|
||||
uint64_t chunkindex;
|
||||
|
||||
/* The number of bytes in the current chunk. */
|
||||
uint64_t chunklen;
|
||||
|
||||
/* The total count of encrypted plaintext octets. Note that we
|
||||
* don't care about encrypting more than 16 Exabyte. */
|
||||
uint64_t total;
|
||||
|
||||
/* The hash context and a buffer used for MDC. */
|
||||
gcry_md_hd_t mdc_hash;
|
||||
byte enchash[20];
|
||||
|
||||
/* The start IV for AEAD encryption. */
|
||||
byte startiv[16];
|
||||
|
||||
/* Using a large buffer for encryption makes processing easier and
|
||||
* also makes sure the data is well aligned. */
|
||||
char *buffer;
|
||||
size_t bufsize; /* Allocated length. */
|
||||
size_t buflen; /* Used length. */
|
||||
|
||||
} cipher_filter_context_t;
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue