"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/basic.c" between
libgcrypt-1.9.1.tar.bz2 and libgcrypt-1.9.2.tar.bz2

About: Libgcrypt is a general purpose library of cryptographic building blocks (originally based on GnuPG code).

basic.c  (libgcrypt-1.9.1.tar.bz2):basic.c  (libgcrypt-1.9.2.tar.bz2)
skipping to change at line 38 skipping to change at line 38
#include <stdarg.h> #include <stdarg.h>
#include <assert.h> #include <assert.h>
#include "../src/gcrypt-int.h" #include "../src/gcrypt-int.h"
#define PGM "basic" #define PGM "basic"
#include "t-common.h" #include "t-common.h"
#if __GNUC__ >= 4 #if __GNUC__ >= 4
# define ALWAYS_INLINE __attribute__((always_inline)) # define ALWAYS_INLINE __attribute__((always_inline))
#else
# define ALWAYS_INLINE
#endif #endif
typedef struct test_spec_pubkey_key typedef struct test_spec_pubkey_key
{ {
const char *secret; const char *secret;
const char *public; const char *public;
const char *grip; const char *grip;
} }
test_spec_pubkey_key_t; test_spec_pubkey_key_t;
skipping to change at line 10426 skipping to change at line 10428
printf ("%02x ", expect[i] & 0xFF); printf ("%02x ", expect[i] & 0xFF);
printf ("\n"); printf ("\n");
fail ("check_one_md_multi: algo %d, digest mismatch\n", algo); fail ("check_one_md_multi: algo %d, digest mismatch\n", algo);
} }
} }
static void static void
check_one_md_final(int algo, const char *expect, unsigned int expectlen) check_one_md_final(int algo, const char *expect, unsigned int expectlen)
{ {
char inbuf[288 + 1]; const unsigned int max_inbuf_len = 288 + 1;
char *inbuf;
char xorbuf[64]; char xorbuf[64];
char digest[64]; char digest[64];
unsigned int mdlen; unsigned int mdlen;
int i, j; int i, j;
mdlen = gcry_md_get_algo_dlen (algo); mdlen = gcry_md_get_algo_dlen (algo);
if (mdlen < 1 || mdlen > 64) if (mdlen < 1 || mdlen > 64)
{ {
return; return;
} }
if (expectlen == 0) if (expectlen == 0)
expectlen = mdlen; expectlen = mdlen;
if (expectlen != mdlen) if (expectlen != mdlen)
{ {
fail ("check_one_md_final: algo %d, digest length mismatch\n", algo); fail ("check_one_md_final: algo %d, digest length mismatch\n", algo);
return; return;
} }
for (i = 0; i < sizeof(inbuf); i++)
inbuf[i] = i;
clutter_vector_registers(); clutter_vector_registers();
gcry_md_hash_buffer (algo, xorbuf, NULL, 0); gcry_md_hash_buffer (algo, xorbuf, NULL, 0);
for (i = 1; i < sizeof(inbuf); i++) for (i = 1; i < max_inbuf_len; i++)
{ {
inbuf = xmalloc(i);
if (!inbuf)
{
fail ("out-of-memory\n");
return;
}
for (j = 0; j < i; j++)
inbuf[j] = j;
gcry_md_hash_buffer (algo, digest, inbuf, i); gcry_md_hash_buffer (algo, digest, inbuf, i);
for (j = 0; j < expectlen; j++) for (j = 0; j < expectlen; j++)
xorbuf[j] ^= digest[j]; xorbuf[j] ^= digest[j];
xfree (inbuf);
} }
if (memcmp(expect, xorbuf, expectlen) != 0) if (memcmp(expect, xorbuf, expectlen) != 0)
{ {
printf ("computed: "); printf ("computed: ");
for (i = 0; i < expectlen; i++) for (i = 0; i < expectlen; i++)
printf ("%02x ", xorbuf[i] & 0xFF); printf ("%02x ", xorbuf[i] & 0xFF);
printf ("\nexpected: "); printf ("\nexpected: ");
for (i = 0; i < expectlen; i++) for (i = 0; i < expectlen; i++)
printf ("%02x ", expect[i] & 0xFF); printf ("%02x ", expect[i] & 0xFF);
 End of changes. 6 change blocks. 
5 lines changed or deleted 17 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)