From 2f4cd9104d075ac470603f544989f31c5a08570e Mon Sep 17 00:00:00 2001 From: Todd A Ouska Date: Thu, 28 Apr 2011 15:40:31 -0700 Subject: [PATCH] more warning fixes --- ctaocrypt/include/integer.h | 4 +++- ctaocrypt/include/tfm.h | 2 +- ctaocrypt/src/asn.c | 10 ++++++---- ctaocrypt/src/dh.c | 2 ++ ctaocrypt/src/integer.c | 12 +++++------- ctaocrypt/src/rsa.c | 2 ++ ctaocrypt/src/tfm.c | 9 +++++---- include/openssl/ssl.h | 2 -- 8 files changed, 24 insertions(+), 19 deletions(-) diff --git a/ctaocrypt/include/integer.h b/ctaocrypt/include/integer.h index 6840dea0c..c73bc4390 100644 --- a/ctaocrypt/include/integer.h +++ b/ctaocrypt/include/integer.h @@ -302,8 +302,10 @@ int mp_add_d (mp_int* a, mp_digit b, mp_int* c); int mp_init_multi(mp_int* a, mp_int* b, mp_int* c, mp_int* d, mp_int* e, mp_int* f); -#ifdef HAVE_ECC +#if defined(HAVE_ECC) || defined(CYASSL_KEY_GEN) int mp_sqrmod(mp_int* a, mp_int* b, mp_int* c); +#endif +#ifdef HAVE_ECC int mp_read_radix(mp_int* a, const char* str, int radix); #endif diff --git a/ctaocrypt/include/tfm.h b/ctaocrypt/include/tfm.h index 7cc052228..d8cac93da 100644 --- a/ctaocrypt/include/tfm.h +++ b/ctaocrypt/include/tfm.h @@ -427,7 +427,7 @@ void fp_mul_d(fp_int *a, fp_digit b, fp_int *c); int fp_mulmod(fp_int *a, fp_int *b, fp_int *c, fp_int *d); /* c = a * a (mod b) */ -/*int fp_sqrmod(fp_int *a, fp_int *b, fp_int *c);*/ +int fp_sqrmod(fp_int *a, fp_int *b, fp_int *c); /* c = 1/a (mod b) */ int fp_invmod(fp_int *a, fp_int *b, fp_int *c); diff --git a/ctaocrypt/src/asn.c b/ctaocrypt/src/asn.c index 54d1f35cb..19fcbb9d1 100644 --- a/ctaocrypt/src/asn.c +++ b/ctaocrypt/src/asn.c @@ -2296,7 +2296,7 @@ int DerToPem(const byte* der, word32 derSz, byte* output, word32 outSz, /* body */ outLen = outSz; /* input to Base64Encode */ if ( (err = Base64Encode(der, derSz, output + i, (word32*)&outLen)) < 0) - return ret; + return err; i += outLen; /* footer */ @@ -2506,7 +2506,7 @@ static int SetPublicKey(byte* output, RsaKey* key) n[0] = ASN_INTEGER; nSz = SetLength(rawLen, n + 1) + 1; /* int tag */ - if ( (nSz + rawLen) < sizeof(n)) { + if ( (nSz + rawLen) < (int)sizeof(n)) { int err = mp_to_unsigned_bin(&key->n, n + nSz); if (err == MP_OKAY) nSz += rawLen; @@ -2521,7 +2521,7 @@ static int SetPublicKey(byte* output, RsaKey* key) e[0] = ASN_INTEGER; eSz = SetLength(rawLen, e + 1) + 1; /* int tag */ - if ( (eSz + rawLen) < sizeof(e)) { + if ( (eSz + rawLen) < (int)sizeof(e)) { int err = mp_to_unsigned_bin(&key->e, e + eSz); if (err == MP_OKAY) eSz += rawLen; @@ -2780,7 +2780,7 @@ static int SetName(byte* output, CertName* name) setSz = SetSet(thisLen, set); thisLen += setSz; - if (thisLen > sizeof(names[i].encoded)) + if (thisLen > (int)sizeof(names[i].encoded)) return BUFFER_E; /* store it */ @@ -2847,6 +2847,8 @@ static int SetName(byte* output, CertName* name) static int EncodeCert(Cert* cert, DerCert* der, RsaKey* rsaKey, RNG* rng, const byte* ntruKey, word16 ntruSz) { + (void)ntruKey; + (void)ntruSz; /* version */ der->versionSz = SetMyVersion(cert->version, der->version, TRUE); diff --git a/ctaocrypt/src/dh.c b/ctaocrypt/src/dh.c index 8b3d94b41..db0910e32 100644 --- a/ctaocrypt/src/dh.c +++ b/ctaocrypt/src/dh.c @@ -47,6 +47,7 @@ void InitDhKey(DhKey* key) { + (void)key; /* TomsFastMath doesn't use memory allocation */ #ifndef USE_FAST_MATH key->p.dp = 0; @@ -57,6 +58,7 @@ void InitDhKey(DhKey* key) void FreeDhKey(DhKey* key) { + (void)key; /* TomsFastMath doesn't use memory allocation */ #ifndef USE_FAST_MATH mp_clear(&key->p); diff --git a/ctaocrypt/src/integer.c b/ctaocrypt/src/integer.c index ff95cfb39..35ab188a3 100644 --- a/ctaocrypt/src/integer.c +++ b/ctaocrypt/src/integer.c @@ -3591,7 +3591,7 @@ int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs) } -#if defined(HAVE_ECC) +#if defined(CYASSL_KEY_GEN) || defined(HAVE_ECC) /* c = a * a (mod b) */ int mp_sqrmod (mp_int * a, mp_int * b, mp_int * c) @@ -3617,8 +3617,6 @@ int mp_sqrmod (mp_int * a, mp_int * b, mp_int * c) #if defined(CYASSL_KEY_GEN) || defined(HAVE_ECC) || !defined(NO_PWDBASED) -int mp_sub_d (mp_int* a, mp_digit b, mp_int* c); - /* single digit addition */ int mp_add_d (mp_int* a, mp_digit b, mp_int* c) { @@ -3805,7 +3803,7 @@ static int s_is_power_of_two(mp_digit b, int *p) } /* single digit division (based on routine from MPI) */ -int mp_div_d (mp_int * a, mp_digit b, mp_int * c, mp_digit * d) +static int mp_div_d (mp_int * a, mp_digit b, mp_int * c, mp_digit * d) { mp_int q; mp_word w; @@ -3880,7 +3878,7 @@ int mp_div_d (mp_int * a, mp_digit b, mp_int * c, mp_digit * d) } -int mp_mod_d (mp_int * a, mp_digit b, mp_digit * c) +static int mp_mod_d (mp_int * a, mp_digit b, mp_digit * c) { return mp_div_d(a, b, NULL, c); } @@ -3935,7 +3933,7 @@ const mp_digit ltm_prime_tab[] = { * Randomly the chance of error is no more than 1/4 and often * very much lower. */ -int mp_prime_miller_rabin (mp_int * a, mp_int * b, int *result) +static int mp_prime_miller_rabin (mp_int * a, mp_int * b, int *result) { mp_int n1, y, r; int s, j, err; @@ -4016,7 +4014,7 @@ LBL_N1:mp_clear (&n1); * * sets result to 0 if not, 1 if yes */ -int mp_prime_is_divisible (mp_int * a, int *result) +static int mp_prime_is_divisible (mp_int * a, int *result) { int err, ix; mp_digit res; diff --git a/ctaocrypt/src/rsa.c b/ctaocrypt/src/rsa.c index 97804cb8f..e72c8ba0f 100644 --- a/ctaocrypt/src/rsa.c +++ b/ctaocrypt/src/rsa.c @@ -65,6 +65,7 @@ void InitRsaKey(RsaKey* key, void* heap) void FreeRsaKey(RsaKey* key) { + (void)key; /* TomsFastMath doesn't use memory allocation */ #ifndef USE_FAST_MATH if (key->type == RSA_PRIVATE) { @@ -379,6 +380,7 @@ static int rand_prime(mp_int* N, int len, RNG* rng, void* heap) int err, res, type; byte* buf; + (void)heap; if (N == NULL || rng == NULL) return BAD_FUNC_ARG; diff --git a/ctaocrypt/src/tfm.c b/ctaocrypt/src/tfm.c index 873b6e03a..a3a812ae2 100644 --- a/ctaocrypt/src/tfm.c +++ b/ctaocrypt/src/tfm.c @@ -1972,6 +1972,7 @@ int mp_sub_d(fp_int *a, fp_digit b, fp_int *c) int mp_prime_is_prime(mp_int* a, int t, int* result) { + (void)t; *result = fp_isprime(a); return MP_OKAY; } @@ -2006,7 +2007,7 @@ static int s_is_power_of_two(fp_digit b, int *p) } /* a/b => cb + d == a */ -int fp_div_d(fp_int *a, fp_digit b, fp_int *c, fp_digit *d) +static int fp_div_d(fp_int *a, fp_digit b, fp_int *c, fp_digit *d) { fp_int q; fp_word w; @@ -2072,7 +2073,7 @@ int fp_div_d(fp_int *a, fp_digit b, fp_int *c, fp_digit *d) /* c = a mod b, 0 <= c < b */ -int fp_mod_d(fp_int *a, fp_digit b, fp_digit *c) +static int fp_mod_d(fp_int *a, fp_digit b, fp_digit *c) { return fp_div_d(a, b, NULL, c); } @@ -2085,7 +2086,7 @@ int fp_mod_d(fp_int *a, fp_digit b, fp_digit *c) * Randomly the chance of error is no more than 1/4 and often * very much lower. */ -void fp_prime_miller_rabin (fp_int * a, fp_int * b, int *result) +static void fp_prime_miller_rabin (fp_int * a, fp_int * b, int *result) { fp_int n1, y, r; int s, j; @@ -2326,7 +2327,7 @@ int mp_add_d(fp_int *a, fp_digit b, fp_int *c) /* chars used in radix conversions */ const char *fp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/"; -int fp_read_radix(fp_int *a, const char *str, int radix) +static int fp_read_radix(fp_int *a, const char *str, int radix) { int y, neg; char ch; diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h index 885fed84b..7f6b8f532 100644 --- a/include/openssl/ssl.h +++ b/include/openssl/ssl.h @@ -636,8 +636,6 @@ CYASSL_API int CyaSSL_negotiate(SSL* ssl); /* turn on CyaSSL data compression */ CYASSL_API int CyaSSL_set_compression(SSL* ssl); -/* load NTRU private key blob */ -CYASSL_API int CyaSSL_CTX_use_NTRUPrivateKey_file(SSL_CTX*, const char*); /* get CyaSSL peer X509_CHAIN */ CYASSL_API X509_CHAIN* CyaSSL_get_peer_chain(SSL* ssl); /* peer chain count */