Skip to content

Commit

Permalink
fix errors during pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kojo1 committed Oct 25, 2024
1 parent b668228 commit 3b2f805
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/genkey/clu_genkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ int wolfCLU_genKey_Dilithium(WC_RNG* rng, char* fName, int directive, int fmt,
#ifdef HAVE_DILITHIUM
int ret = WOLFCLU_SUCCESS;

XFILE file;
XFILE file = NULL;
int fNameSz = 0;
int fExtSz = 6; // size of ".priv\0" or ".pub\0\0"
char fExtPriv[6] = ".priv\0";
Expand Down Expand Up @@ -1236,7 +1236,8 @@ int wolfCLU_genKey_Dilithium(WC_RNG* rng, char* fName, int directive, int fmt,
}
}

XFCLOSE(file);
if (file != NULL)
XFCLOSE(file);

if (derBuf != NULL) {
wolfCLU_ForceZero(derBuf, (unsigned int)maxDerBufSz);
Expand Down
9 changes: 7 additions & 2 deletions src/sign-verify/clu_sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ int wolfCLU_KeyPemToDer(unsigned char** pkeyBuf, int pkeySz, int pubIn) {
int wolfCLU_sign_data(char* in, char* out, char* privKey, int keyType,
int inForm, int level)
{
#ifndef HAVE_DILITHIUM
(void)level;
#endif
int ret;
int fSz;
XFILE f;
Expand Down Expand Up @@ -126,9 +129,11 @@ int wolfCLU_sign_data(char* in, char* out, char* privKey, int keyType,
ret = wolfCLU_sign_data_ed25519(data, out, fSz, privKey, inForm);
break;

#ifdef HAVE_DILITHIUM
case DILITHIUM_SIG_VER:
ret = wolfCLU_sign_data_dilithium(data, out, fSz, privKey, level, inForm);
break;
#endif

default:
wolfCLU_LogError("No valid sign algorithm selected.");
Expand Down Expand Up @@ -719,8 +724,8 @@ int wolfCLU_sign_data_dilithium (byte* data, char* out, word32 dataSz, char* pri
#else
(void)data;
(void)out;
(void)fSz;
(void)privKey;
(void)dataSz;
(void) privKey;
(void)level;
(void)inForm;

Expand Down
10 changes: 7 additions & 3 deletions src/sign-verify/clu_verify.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,13 @@ int wolfCLU_verify_signature(char* sig, char* hashFile, char* out,
char* keyPath, int keyType, int pubIn,
int inForm, int level)
{
#ifndef HAVE_DILITHIUM
(void) level;
#endif

int hSz = 0;
int fSz;
int ret;
int ret = WOLFCLU_FATAL_ERROR;

byte* hash = NULL;
byte* data = NULL;
Expand Down Expand Up @@ -230,8 +234,8 @@ int wolfCLU_verify_signature(char* sig, char* hashFile, char* out,
#endif
break;

#ifdef HAVE_DILITHIUM
case DILITHIUM_SIG_VER:
#ifdef HAVE_DILITHIUM
/* hashFIle means msgFile */
h = XFOPEN(hashFile, "rb");
if (h == NULL) {
Expand Down Expand Up @@ -259,8 +263,8 @@ int wolfCLU_verify_signature(char* sig, char* hashFile, char* out,
XFCLOSE(h);

ret = wolfCLU_verify_signature_dilithium(data, fSz, hash, hSz, keyPath, level, inForm);
#endif
break;
#endif

default:
wolfCLU_LogError("No valid verify algorithm selected.");
Expand Down

0 comments on commit 3b2f805

Please sign in to comment.