diff options
author | Werner Koch <wk@gnupg.org> | 2016-04-14 14:39:31 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2016-04-14 14:39:31 +0200 |
commit | 47c6a1f88eb763e9baa394e34d873b761abcebbe (patch) | |
tree | 56d9c5ca4753225bf1e82dec51df0773317e1121 | |
parent | 88c6b98350193abbdcfb227754979b0c097ee09c (diff) | |
download | libgcrypt-47c6a1f88eb763e9baa394e34d873b761abcebbe.tar.gz |
cipher: Add constant for 8 bit CFB mode.
* src/gcrypt.h.in (GCRY_CIPHER_MODE_CFB8): New.
* tests/basic.c (check_cfb_cipher): Prepare for CFB-8 tests.
--
Note that there is no implementation for the 8 bit CFB mode yet. We
will add that as a bug fix after the release of 1.7.0.
Signed-off-by: Werner Koch <wk@gnupg.org>
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | doc/gcrypt.texi | 7 | ||||
-rw-r--r-- | src/gcrypt.h.in | 3 | ||||
-rw-r--r-- | tests/basic.c | 15 |
4 files changed, 17 insertions, 9 deletions
@@ -68,6 +68,7 @@ Noteworthy changes in version 1.7.0 (unreleased) gcry_mpi_ec_decode_point NEW. GCRY_CIPHER_MODE_POLY1305 NEW. GCRY_CIPHER_MODE_OCB NEW. + GCRY_CIPHER_MODE_CFB8 NEW constant. GCRYCTL_SET_TAGLEN NEW. GCRYCTL_GET_TAGLEN NEW. gcry_cipher_final NEW macro. diff --git a/doc/gcrypt.texi b/doc/gcrypt.texi index a78c5fd7..0171cd62 100644 --- a/doc/gcrypt.texi +++ b/doc/gcrypt.texi @@ -1598,9 +1598,12 @@ set, this mode may be used to bypass the actual encryption. Electronic Codebook mode. @item GCRY_CIPHER_MODE_CFB +@item GCRY_CIPHER_MODE_CFB8 @cindex CFB, Cipher Feedback mode -Cipher Feedback mode. The shift size equals the block size of the -cipher (e.g. for AES it is CFB-128). +Cipher Feedback mode. For GCRY_CIPHER_MODE_CFB the shift size equals +the block size of the cipher (e.g. for AES it is CFB-128). For +GCRY_CIPHER_MODE_CFB8 the shift size is 8 bit but that variant is not +yet available. @item GCRY_CIPHER_MODE_CBC @cindex CBC, Cipher Block Chaining mode diff --git a/src/gcrypt.h.in b/src/gcrypt.h.in index bd25d1b6..96d742a0 100644 --- a/src/gcrypt.h.in +++ b/src/gcrypt.h.in @@ -961,7 +961,8 @@ enum gcry_cipher_modes GCRY_CIPHER_MODE_CCM = 8, /* Counter with CBC-MAC. */ GCRY_CIPHER_MODE_GCM = 9, /* Galois Counter Mode. */ GCRY_CIPHER_MODE_POLY1305 = 10, /* Poly1305 based AEAD mode. */ - GCRY_CIPHER_MODE_OCB = 11 /* OCB3 mode. */ + GCRY_CIPHER_MODE_OCB = 11, /* OCB3 mode. */ + GCRY_CIPHER_MODE_CFB8 = 12 /* Cipher feedback (8 bit mode). */ }; /* Flags used with the open function. */ diff --git a/tests/basic.c b/tests/basic.c index 4940f6a2..96fb4cbd 100644 --- a/tests/basic.c +++ b/tests/basic.c @@ -873,6 +873,7 @@ check_cfb_cipher (void) static const struct tv { int algo; + int cfb8; char key[MAX_DATA_LEN]; char iv[MAX_DATA_LEN]; struct data @@ -885,7 +886,7 @@ check_cfb_cipher (void) } tv[] = { /* http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf */ - { GCRY_CIPHER_AES, + { GCRY_CIPHER_AES, 0, "\x2b\x7e\x15\x16\x28\xae\xd2\xa6\xab\xf7\x15\x88\x09\xcf\x4f\x3c", "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", { { "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a", @@ -902,7 +903,7 @@ check_cfb_cipher (void) "\xc0\x4b\x05\x35\x7c\x5d\x1c\x0e\xea\xc4\xc6\x6f\x9f\xf7\xf2\xe6" }, } }, - { GCRY_CIPHER_AES192, + { GCRY_CIPHER_AES192, 0, "\x8e\x73\xb0\xf7\xda\x0e\x64\x52\xc8\x10\xf3\x2b" "\x80\x90\x79\xe5\x62\xf8\xea\xd2\x52\x2c\x6b\x7b", "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", @@ -920,7 +921,7 @@ check_cfb_cipher (void) "\xc0\x5f\x9f\x9c\xa9\x83\x4f\xa0\x42\xae\x8f\xba\x58\x4b\x09\xff" }, } }, - { GCRY_CIPHER_AES256, + { GCRY_CIPHER_AES256, 0, "\x60\x3d\xeb\x10\x15\xca\x71\xbe\x2b\x73\xae\xf0\x85\x7d\x77\x81" "\x1f\x35\x2c\x07\x3b\x61\x08\xd7\x2d\x98\x10\xa3\x09\x14\xdf\xf4", "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", @@ -941,7 +942,7 @@ check_cfb_cipher (void) }; gcry_cipher_hd_t hde, hdd; unsigned char out[MAX_DATA_LEN]; - int i, j, keylen, blklen; + int i, j, keylen, blklen, mode; gcry_error_t err = 0; if (verbose) @@ -957,13 +958,15 @@ check_cfb_cipher (void) continue; } + mode = tv[i].cfb8? GCRY_CIPHER_MODE_CFB8 : GCRY_CIPHER_MODE_CFB; + if (verbose) fprintf (stderr, " checking CFB mode for %s [%i]\n", gcry_cipher_algo_name (tv[i].algo), tv[i].algo); - err = gcry_cipher_open (&hde, tv[i].algo, GCRY_CIPHER_MODE_CFB, 0); + err = gcry_cipher_open (&hde, tv[i].algo, mode, 0); if (!err) - err = gcry_cipher_open (&hdd, tv[i].algo, GCRY_CIPHER_MODE_CFB, 0); + err = gcry_cipher_open (&hdd, tv[i].algo, mode, 0); if (err) { fail ("aes-cfb, gcry_cipher_open failed: %s\n", gpg_strerror (err)); |