diff options
author | Werner Koch <wk@gnupg.org> | 2018-01-21 16:24:43 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2018-01-21 16:30:53 +0100 |
commit | 3f4ca85cb0cf58006417f4f7faafaa9a1f1bdf22 (patch) | |
tree | d77273b89c38dda139c8e204c6d60673e46a5e36 /g10/encrypt.c | |
parent | gpg: Add stub function for encrypting AEAD. (diff) | |
download | gnupg2-3f4ca85cb0cf58006417f4f7faafaa9a1f1bdf22.tar.xz gnupg2-3f4ca85cb0cf58006417f4f7faafaa9a1f1bdf22.zip |
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>
Diffstat (limited to 'g10/encrypt.c')
-rw-r--r-- | g10/encrypt.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/g10/encrypt.c b/g10/encrypt.c index 01feb4a7d..856849799 100644 --- a/g10/encrypt.c +++ b/g10/encrypt.c @@ -123,7 +123,7 @@ use_aead (pk_list_t pk_list, int algo) return 0; } - can_use = openpgp_cipher_get_algo_blklen (algo) != 16; + can_use = openpgp_cipher_get_algo_blklen (algo) == 16; /* With --force-mdc we clearly do not want AEAD. */ if (opt.force_mdc) @@ -133,12 +133,15 @@ use_aead (pk_list_t pk_list, int algo) if (opt.force_aead) { if (!can_use) - log_info ("Warning: request to use AEAD ignored for cipher '%s'\n", - openpgp_cipher_algo_name (algo)); + { + log_info ("Warning: request to use AEAD ignored for cipher '%s'\n", + openpgp_cipher_algo_name (algo)); + return 0; + } return 1; } - /* AEAD does noly work with 128 bit cipher blocklength. */ + /* AEAD does only work with 128 bit cipher blocklength. */ if (!can_use) return 0; @@ -307,7 +310,7 @@ encrypt_simple (const char *filename, int mode, int use_seskey) openpgp_cipher_algo_name (cfx.dek->algo)); if (use_aead (NULL, cfx.dek->algo)) - cfx.dek->use_aead = 1; + cfx.dek->use_aead = default_aead_algo (); else cfx.dek->use_mdc = !!use_mdc (NULL, cfx.dek->algo); } |