[git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-380-g47c6a1f
by Werner Koch
cvs at cvs.gnupg.org
Thu Apr 14 14:42:37 CEST 2016
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU crypto library".
The branch, master has been updated
via 47c6a1f88eb763e9baa394e34d873b761abcebbe (commit)
via 88c6b98350193abbdcfb227754979b0c097ee09c (commit)
from 8472b71812e71c69d66e2fcc02a6e21b66755f8b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 47c6a1f88eb763e9baa394e34d873b761abcebbe
Author: Werner Koch <wk at gnupg.org>
Date: Thu Apr 14 14:39:31 2016 +0200
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 at gnupg.org>
diff --git a/NEWS b/NEWS
index 9cb5e36..7b53c1a 100644
--- a/NEWS
+++ b/NEWS
@@ -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 a78c5fd..0171cd6 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
+ at 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 bd25d1b..96d742a 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 4940f6a..96fb4cb 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));
commit 88c6b98350193abbdcfb227754979b0c097ee09c
Author: Werner Koch <wk at gnupg.org>
Date: Thu Apr 14 13:26:55 2016 +0200
tests: Add a new test for S-expressions.
* tests/t-sexp.c (compare_to_canon): New.
(back_and_forth_one): Add another test.
--
Signed-off-by: Werner Koch <wk at gnupg.org>
diff --git a/tests/t-sexp.c b/tests/t-sexp.c
index 4785b17..33a58ff 100644
--- a/tests/t-sexp.c
+++ b/tests/t-sexp.c
@@ -387,11 +387,46 @@ canon_len (void)
}
+/* Compare SE to the canonical formatted expression in
+ * (CANON,CANONLEN). This is done by a converting SE to canonical
+ * format and doing a byte compare. Returns 0 if they match. */
+static int
+compare_to_canon (gcry_sexp_t se, const unsigned char *canon, size_t canonlen)
+{
+ size_t n, n1;
+ char *p1;
+
+ n1 = gcry_sexp_sprint (se, GCRYSEXP_FMT_CANON, NULL, 0);
+ if (!n1)
+ {
+ fail ("get required length in compare_to_canon failed\n");
+ return -1;
+ }
+ p1 = gcry_xmalloc (n1);
+ n = gcry_sexp_sprint (se, GCRYSEXP_FMT_CANON, p1, n1);
+ if (n1 != n+1)
+ {
+ fail ("length mismatch in compare_to_canon detected\n");
+ xfree (p1);
+ return -1;
+ }
+ if (n1 != canonlen || memcmp (p1, canon, canonlen))
+ {
+ xfree (p1);
+ return -1;
+ }
+ xfree (p1);
+ return 0;
+}
+
+
static void
back_and_forth_one (int testno, const char *buffer, size_t length)
{
gcry_error_t rc;
gcry_sexp_t se, se1;
+ unsigned char *canon;
+ size_t canonlen; /* Including the hidden nul suffix. */
size_t n, n1;
char *p1;
@@ -409,11 +444,14 @@ back_and_forth_one (int testno, const char *buffer, size_t length)
}
p1 = gcry_xmalloc (n1);
n = gcry_sexp_sprint (se, GCRYSEXP_FMT_CANON, p1, n1);
- if (n1 != n+1) /* sprints adds an extra 0 but dies not return it */
+ if (n1 != n+1) /* sprints adds an extra 0 but does not return it. */
{
fail ("baf %d: length mismatch for canon\n", testno);
return;
}
+ canonlen = n1;
+ canon = gcry_malloc (canonlen);
+ memcpy (canon, p1, canonlen);
rc = gcry_sexp_create (&se1, p1, n, 0, gcry_free);
if (rc)
{
@@ -449,9 +487,40 @@ back_and_forth_one (int testno, const char *buffer, size_t length)
fail ("baf %d: memory corrupted (3)\n", testno);
gcry_free (p1);
+ /* Check converting to advanced format. */
+ n1 = gcry_sexp_sprint (se, GCRYSEXP_FMT_ADVANCED, NULL, 0);
+ if (!n1)
+ {
+ fail ("baf %d: get required length for advanced failed\n", testno);
+ return;
+ }
+ p1 = gcry_xmalloc (n1);
+ n = gcry_sexp_sprint (se, GCRYSEXP_FMT_ADVANCED, p1, n1);
+ if (n1 != n+1) /* sprints adds an extra 0 but does not return it */
+ {
+ fail ("baf %d: length mismatch for advanced\n", testno);
+ return;
+ }
+ rc = gcry_sexp_create (&se1, p1, n, 0, gcry_free);
+ if (rc)
+ {
+ fail ("baf %d: gcry_sexp_create failed: %s\n",
+ testno, gpg_strerror (rc));
+ return;
+ }
+ if (compare_to_canon (se1, canon, canonlen))
+ {
+ fail ("baf %d: converting to advanced failed.\n",
+ testno, gpg_strerror (rc));
+ return;
+ }
+ gcry_sexp_release (se1);
+
+
/* FIXME: we need a lot more tests */
gcry_sexp_release (se);
+ xfree (canon);
}
@@ -474,6 +543,13 @@ back_and_forth (void)
" #F7B0B535F8F8E22F4F3DA031224070303F82F9207D42952F1ACF21A4AB1C50304EBB25527992C7B265A9E9FF702826FB88759BDD55E4759E9FCA6C879538C9D043A9C60A326CB6681090BAA731289BD880A7D5774D9999F026E5E7963BFC8C0BDC9F061393CB734B4F259725C0A0A0B15BA39C39146EF6A1B3DC4DF30A22EBE09FD05AE6CB0C8C6532951A925F354F4E26A51964F5BBA50081690C421C8385C4074E9BAB9297D081B857756607EAE652415275A741C89E815558A50AC638EDC5F5030210B4395E3E1A40FF38DCCCB333A19EA88EFE7E4D51B54128C6DF27395646836679AC21B1B25C1DA6F0A7CE9F9BE078EFC7934FA9AE202CBB0AA06C20DFAF9A66FAB7E9073FBE96B9A7F25C3BA45EC3EECA65796AEE313BA148DE5314F30345B452B50B17C4D841A7F27397126E8C10BD0CE3B50A82C0425AAEE7798031671407B681F52916256F78CAF92A477AC27BCBE26DAFD1BCE386A853E2A036F8314BB2E8E5BB1F196434232EFB0288331C2AB16DBC5457CC295EB966CAC5CE73D5DA5D566E469F0EFA82F9A12B8693E0#)\n"
" )\n"
" )\n", 0 },
+ { "((sha1 #8B98CBF4A9823CA7# \"2097\") #3B6FC9#)", 0 },
+ { "((4:sha18:\x8B\x98\xCB\xF4\xA9\x82\x3C\xA7""4:2097)3:\x3B\x6F\xC9)", 0},
+ { "((4:sha18:\x8B\x98\xCB\x22\xA9\x82\x3C\xA7""4:2097)3:\x3B\x6F\xC9)", 0},
+ { "((sha1 #64652267686970C9# \"2097\") #3B6FC9#)", 0 },
+ { "((4:sha18:\x64\x65\x22\x67\x68\xc3\xa4\x71""4:2097)3:\x3B\x6F\xC9)", 0},
+ { "((sha1 \"defghäq\" \"2097\") #3B6FC9#)", 0 },
+ { "((sha1 \"de\\\"ghäq\" \"2097\") #3B6FC9#)", 0 },
{ NULL, 0 }
};
int idx;
-----------------------------------------------------------------------
Summary of changes:
NEWS | 1 +
doc/gcrypt.texi | 7 ++++--
src/gcrypt.h.in | 3 ++-
tests/basic.c | 15 ++++++-----
tests/t-sexp.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
5 files changed, 94 insertions(+), 10 deletions(-)
hooks/post-receive
--
The GNU crypto library
http://git.gnupg.org
_______________________________________________
Gnupg-commits mailing list
Gnupg-commits at gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-commits
More information about the Gcrypt-devel
mailing list