])
AS_IF([test "x$want_crypto" = "xauto" -o "x$want_crypto" = "xcyassl"], [
PKG_CHECK_MODULES(WOLFSSL, [wolfssl >= $CYASSL_MINIMUM],
- [want_crypto="cyassl"; CRYPTO_PKG="cyassl"; CRYPTO_CFLAGS="$WOLFSSL_CFLAGS"; CRYPTO_LIBS="$WOLFSSL_LIBS"],
+ [want_crypto="cyassl"; CRYPTO_PKG="cyassl"; CRYPTO_CFLAGS="$WOLFSSL_CFLAGS"; CRYPTO_LIBS="$WOLFSSL_LIBS"; CYASSL_IS_WOLFSSL=yes],
[PKG_CHECK_MODULES(CYASSL, [cyassl >= $CYASSL_MINIMUM],
[want_crypto="cyassl"; CRYPTO_PKG="cyassl"; CRYPTO_CFLAGS="$CYASSL_CFLAGS"; CRYPTO_LIBS="$CYASSL_LIBS"],
[AS_IF([test "x$want_crypto" = "xcyassl"],
AM_CONDITIONAL([CRYPTO_USE_OPENSSL],[test "x$CRYPTO_PKG" = "xopenssl"])
AM_CONDITIONAL([CRYPTO_USE_CYASSL],[test "x$CRYPTO_PKG" = "xcyassl"])
+AM_CONDITIONAL([CYASSL_IS_WOLFSSL],[test "x$CYASSL_IS_WOLFSSL" = "xyes"])
AM_CONDITIONAL([CRYPTO_USE_POLARSSL],[test "x$CRYPTO_PKG" = "xpolarssl"])
AM_CONDITIONAL([POLARSSL_IS_MBEDTLS],[test "x$POLARSSL_IS_MBEDTLS" = "xyes"])
AC_SUBST(CRYPTO_PKG)
*
*/
+#if defined (CYASSL_IS_WOLFSSL)
+ #define API_HEADER(x) <wolfssl/x>
+ #define API_HEADER_CRYPT(x) API_HEADER (wolfcrypt/x)
+ #define API(x) wc_##x
+ #define API_VERSION_HEX LIBWOLFSSL_VERSION_HEX
+#else
+ #define API_HEADER(x) <cyassl/x>
+ #define API_HEADER_CRYPT(x) API_HEADER (ctaocrypt/x)
+ #define API(x) x
+ #define API_VERSION_HEX LIBCYASSL_VERSION_HEX
+#endif
+
#include <assert.h>
-#include <cyassl/ctaocrypt/arc4.h>
-#include <cyassl/ctaocrypt/dh.h>
-#include <cyassl/ctaocrypt/error-crypt.h>
-#include <cyassl/ctaocrypt/random.h>
-#include <cyassl/ctaocrypt/sha.h>
-#include <cyassl/version.h>
+#include API_HEADER_CRYPT (arc4.h)
+#include API_HEADER_CRYPT (dh.h)
+#include API_HEADER_CRYPT (error-crypt.h)
+#include API_HEADER_CRYPT (random.h)
+#include API_HEADER_CRYPT (sha.h)
+#include API_HEADER (version.h)
#include "transmission.h"
#include "crypto-utils.h"
{
if (tr_logLevelIsActive (TR_LOG_ERROR))
{
-#if LIBCYASSL_VERSION_HEX >= 0x03000002
+#if API_VERSION_HEX >= 0x03004000
+ const char * error_message = API (GetErrorString) (error_code);
+#elif API_VERSION_HEX >= 0x03000002
const char * error_message = CTaoCryptGetErrorString (error_code);
#else
char error_message[CYASSL_MAX_ERROR_SZ];
if (!rng_initialized)
{
- if (!check_result (InitRng (&rng)))
+ if (!check_result (API (InitRng) (&rng)))
return NULL;
rng_initialized = true;
}
{
Sha * handle = tr_new (Sha, 1);
- if (check_result (InitSha (handle)))
+ if (check_result (API (InitSha) (handle)))
return handle;
tr_free (handle);
assert (data != NULL);
- return check_result (ShaUpdate (handle, data, data_length));
+ return check_result (API (ShaUpdate) (handle, data, data_length));
}
bool
{
assert (handle != NULL);
- ret = check_result (ShaFinal (handle, hash));
+ ret = check_result (API (ShaFinal) (handle, hash));
}
tr_free (handle);
assert (handle != NULL);
assert (key != NULL);
- Arc4SetKey (handle, key, key_length);
+ API (Arc4SetKey) (handle, key, key_length);
}
void
assert (input != NULL);
assert (output != NULL);
- Arc4Process (handle, output, input, length);
+ API (Arc4Process) (handle, output, input, length);
}
/***
assert (prime_num != NULL);
assert (generator_num != NULL);
- InitDhKey (&handle->dh);
- if (!check_result (DhSetKey (&handle->dh,
- prime_num, prime_num_length,
- generator_num, generator_num_length)))
+ API (InitDhKey) (&handle->dh);
+ if (!check_result (API (DhSetKey) (&handle->dh,
+ prime_num, prime_num_length,
+ generator_num, generator_num_length)))
{
tr_free (handle);
return NULL;
if (handle == NULL)
return;
- FreeDhKey (&handle->dh);
+ API (FreeDhKey) (&handle->dh);
tr_free (handle->private_key);
tr_free (handle);
}
tr_lockLock (rng_lock);
- if (!check_result (DhGenerateKeyPair (&handle->dh, get_rng (),
- handle->private_key, &my_private_key_length,
- public_key, &my_public_key_length)))
+ if (!check_result (API (DhGenerateKeyPair) (&handle->dh, get_rng (),
+ handle->private_key, &my_private_key_length,
+ public_key, &my_public_key_length)))
{
tr_lockUnlock (rng_lock);
return false;
ret = tr_dh_secret_new (handle->key_length);
- if (check_result (DhAgree (&handle->dh,
- ret->key, &my_secret_key_length,
- handle->private_key, handle->private_key_length,
- other_public_key, other_public_key_length)))
+ if (check_result (API (DhAgree) (&handle->dh,
+ ret->key, &my_secret_key_length,
+ handle->private_key, handle->private_key_length,
+ other_public_key, other_public_key_length)))
{
tr_dh_secret_align (ret, my_secret_key_length);
}
assert (buffer != NULL);
tr_lockLock (rng_lock);
- ret = check_result (RNG_GenerateBlock (get_rng (), buffer, length));
+ ret = check_result (API (RNG_GenerateBlock) (get_rng (), buffer, length));
tr_lockUnlock (rng_lock);
return ret;