From: Nikos Mavrogiannopoulos Date: Wed, 13 Aug 2003 10:25:46 +0000 (+0000) Subject: RC2 was made reentrant. The stddef.h is now included if found. X-Git-Tag: gnutls_0_9_7~13 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b45f15c3f856a581a66d052ee6743aae84fc8310;p=thirdparty%2Fgnutls.git RC2 was made reentrant. The stddef.h is now included if found. --- diff --git a/configure.in b/configure.in index 5ad3f1a938..7f7bf916d9 100644 --- a/configure.in +++ b/configure.in @@ -155,7 +155,7 @@ AC_MSG_RESULT([*** AC_HEADER_STDC AC_HEADER_TIME -AC_CHECK_HEADERS(unistd.h strings.h) +AC_CHECK_HEADERS(unistd.h strings.h stddef.h) AC_CHECK_HEADERS(sys/stat.h sys/types.h sys/socket.h) AC_CHECK_HEADERS(errno.h sys/time.h time.h) AC_CHECK_FUNCS(memset memmove strnstr memcmp memcpy mmap,,) diff --git a/lib/defines.h b/lib/defines.h index 4524ade3ca..171f7c1a32 100644 --- a/lib/defines.h +++ b/lib/defines.h @@ -61,6 +61,10 @@ typedef long ptrdiff_t; char *strnstr(const char *haystack, const char *needle, size_t haystacklen); #endif +#ifdef HAVE_STDDEF_H +# include +#endif + #ifdef HAVE_SYS_TYPES_H # include #endif diff --git a/lib/rc2.c b/lib/rc2.c index dcb7f09972..64d45931ee 100644 --- a/lib/rc2.c +++ b/lib/rc2.c @@ -183,33 +183,16 @@ static void rc2_decrypt(void *context, uint8 * outbuf, const uint8 * inbuf) do_rc2_decrypt(ctx, outbuf, inbuf); } - +static int disable_p2 = 0; static gpg_err_code_t do_rc2_setkey(void *context, const uint8 * key, unsigned int keylen) { - static int initialized, disable_p2; - static const char *selftest_failed; uint i; uint8 *S, x; RC2_context *ctx = (RC2_context *) context; int bits = keylen * 8, len; - /* Self test is for the plain cipher (with phase 2 stripped) - */ - - if (!initialized) { - initialized = 1; - disable_p2 = 1; /* strip phase 2 */ - selftest_failed = selftest(); - disable_p2 = 0; - } - if (selftest_failed) { - gnutls_assert(); - _gnutls_x509_log( selftest_failed); - return GPG_ERR_SELFTEST_FAILED; - } - if (keylen < 40 / 8) /* we want at least 40 bits */ return GPG_ERR_INV_KEYLEN; @@ -352,6 +335,22 @@ static gcry_module_t rc2_40_mod; int _gnutls_register_rc2_cipher(void) { +const char* selftest_failed; + + /* Self test is for the plain cipher (with phase 2 stripped) + */ + disable_p2 = 1; /* strip phase 2 */ + selftest_failed = selftest(); + disable_p2 = 0; + + if (selftest_failed) { + gnutls_assert(); + _gnutls_x509_log( selftest_failed); + return GNUTLS_E_INTERNAL_ERROR; + } + + /* If self test succeeded then register the cipher. + */ if (gcry_cipher_register(&cipher_spec_rc2, &_gcry_rc2_40_id, &rc2_40_mod)) { gnutls_assert();