Skip to content

Commit

Permalink
Fix compiler warnings from mingw.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarske committed Dec 4, 2023
1 parent 8cabca7 commit 89c85a8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
35 changes: 17 additions & 18 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
#endif
#endif

#if defined(WC_RSA_BLINDING) && (!defined(HAVE_FIPS) || \
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION > 2)))
#define WOLFPKCS11_NEED_RSA_RNG
#endif

/* Size of hash calculated from PIN. */
#define PIN_HASH_SZ 32
/* Size of seed used when calculating hash from PIN. */
Expand Down Expand Up @@ -6503,26 +6508,23 @@ int WP11_RsaPkcs15_PrivateDecrypt(unsigned char* in, word32 inLen,
WP11_Object* priv, WP11_Slot* slot)
{
int ret = 0;
#if defined(WC_RSA_BLINDING) && (!defined(HAVE_FIPS) || \
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION > 2)))
#ifdef WOLFPKCS11_NEED_RSA_RNG
WC_RNG rng;
#endif
/* A random number generator is needed for blinding. */
if (priv->onToken)
WP11_Lock_LockRW(priv->lock);
#if defined(WC_RSA_BLINDING) && (!defined(HAVE_FIPS) || \
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION > 2)))
#ifdef WOLFPKCS11_NEED_RSA_RNG
ret = Rng_New(&slot->token.rng, &slot->token.rngLock, &rng);
if (ret == 0) {
priv->data.rsaKey.rng = &rng;
}
#endif
if (ret == 0) {
#ifdef WOLFPKCS11_NEED_RSA_RNG
priv->data.rsaKey.rng = &rng;
#endif
ret = wc_RsaPrivateDecrypt_ex(in, inLen, out, *outLen,
&priv->data.rsaKey, WC_RSA_PKCSV15_PAD,
WC_HASH_TYPE_NONE, WC_MGF1NONE, NULL, 0);
#if defined(WC_RSA_BLINDING) && (!defined(HAVE_FIPS) || \
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION > 2)))
#ifdef WOLFPKCS11_NEED_RSA_RNG
priv->data.rsaKey.rng = NULL;
Rng_Free(&rng);
#endif
Expand Down Expand Up @@ -6607,28 +6609,25 @@ int WP11_RsaOaep_PrivateDecrypt(unsigned char* in, word32 inLen,
int ret = 0;
WP11_OaepParams* oaep = &session->params.oaep;
WP11_Slot* slot = WP11_Session_GetSlot(session);
#if defined(WC_RSA_BLINDING) && (!defined(HAVE_FIPS) || \
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION > 2)))
#ifdef WOLFPKCS11_NEED_RSA_RNG
WC_RNG rng;
#endif

/* A random number generator is needed for blinding. */
if (priv->onToken)
WP11_Lock_LockRW(priv->lock);
#if defined(WC_RSA_BLINDING) && (!defined(HAVE_FIPS) || \
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION > 2)))
#ifdef WOLFPKCS11_NEED_RSA_RNG
ret = Rng_New(&slot->token.rng, &slot->token.rngLock, &rng);
if (ret == 0) {
priv->data.rsaKey.rng = &rng;
}
#endif
if (ret == 0) {
#ifdef WOLFPKCS11_NEED_RSA_RNG
priv->data.rsaKey.rng = &rng;
#endif
ret = wc_RsaPrivateDecrypt_ex(in, inLen, out, *outLen,
&priv->data.rsaKey, WC_RSA_OAEP_PAD,
oaep->hashType, oaep->mgf,
oaep->label, oaep->labelSz);
#if defined(WC_RSA_BLINDING) && (!defined(HAVE_FIPS) || \
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION > 2)))
#ifdef WOLFPKCS11_NEED_RSA_RNG
priv->data.rsaKey.rng = NULL;
Rng_Free(&rng);
#endif
Expand Down
2 changes: 2 additions & 0 deletions tests/pkcs11mtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
#include "unit.h"
#include "testdata.h"

#include <stdlib.h> /* setenv/getenv */

#define PKCS11MTT_CASE(func) \
TEST_CASE(func, 0, pkcs11_open_session, pkcs11_close_session, \
sizeof(CK_SESSION_HANDLE))
Expand Down
2 changes: 2 additions & 0 deletions tests/pkcs11str.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

#include "testdata.h"

#include <stdlib.h> /* setenv/getenv */

int verbose = 0;

#ifdef DEBUG_WOLFPKCS11
Expand Down
2 changes: 2 additions & 0 deletions tests/pkcs11test.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#include "unit.h"
#include "testdata.h"

#include <stdlib.h> /* setenv/getenv */


#define TEST_FLAG_INIT 0x01
#define TEST_FLAG_TOKEN 0x02
Expand Down

0 comments on commit 89c85a8

Please sign in to comment.