Fix warnings about signed/unsigned mismatch and global
shadowing (random, index) in hw_4758_cca.c
This commit is contained in:
parent
e0a6cdcf30
commit
c8cd7d9e0f
@ -97,9 +97,9 @@ static EVP_PKEY *ibm_4758_load_privkey(ENGINE*, const char*,
|
|||||||
static EVP_PKEY *ibm_4758_load_pubkey(ENGINE*, const char*,
|
static EVP_PKEY *ibm_4758_load_pubkey(ENGINE*, const char*,
|
||||||
UI_METHOD *ui_method, void *callback_data);
|
UI_METHOD *ui_method, void *callback_data);
|
||||||
|
|
||||||
static int getModulusAndExponent(const char *token, long *exponentLength,
|
static int getModulusAndExponent(const unsigned char *token, long *exponentLength,
|
||||||
char *exponent, long *modulusLength,
|
unsigned char *exponent, long *modulusLength,
|
||||||
long *modulusFieldLength, char *modulus);
|
long *modulusFieldLength, unsigned char *modulus);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* RAND number functions */
|
/* RAND number functions */
|
||||||
@ -108,7 +108,7 @@ static int cca_get_random_bytes(unsigned char*, int );
|
|||||||
static int cca_random_status(void);
|
static int cca_random_status(void);
|
||||||
|
|
||||||
static void cca_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad,
|
static void cca_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad,
|
||||||
int index,long argl, void *argp);
|
int idx,long argl, void *argp);
|
||||||
|
|
||||||
/* Function pointers for CCA verbs */
|
/* Function pointers for CCA verbs */
|
||||||
/*---------------------------------*/
|
/*---------------------------------*/
|
||||||
@ -359,8 +359,8 @@ static EVP_PKEY *ibm_4758_load_privkey(ENGINE* e, const char* key_id,
|
|||||||
{
|
{
|
||||||
RSA *rtmp = NULL;
|
RSA *rtmp = NULL;
|
||||||
EVP_PKEY *res = NULL;
|
EVP_PKEY *res = NULL;
|
||||||
char* keyToken = NULL;
|
unsigned char* keyToken = NULL;
|
||||||
char pubKeyToken[MAX_CCA_PKA_TOKEN_SIZE];
|
unsigned char pubKeyToken[MAX_CCA_PKA_TOKEN_SIZE];
|
||||||
long pubKeyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;
|
long pubKeyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;
|
||||||
long keyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;
|
long keyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;
|
||||||
long returnCode;
|
long returnCode;
|
||||||
@ -369,12 +369,12 @@ static EVP_PKEY *ibm_4758_load_privkey(ENGINE* e, const char* key_id,
|
|||||||
long ruleArrayLength = 0;
|
long ruleArrayLength = 0;
|
||||||
unsigned char exitData[8];
|
unsigned char exitData[8];
|
||||||
unsigned char ruleArray[8];
|
unsigned char ruleArray[8];
|
||||||
char keyLabel[64];
|
unsigned char keyLabel[64];
|
||||||
long keyLabelLength = strlen(key_id);
|
long keyLabelLength = strlen(key_id);
|
||||||
char modulus[256];
|
unsigned char modulus[256];
|
||||||
long modulusFieldLength = sizeof(modulus);
|
long modulusFieldLength = sizeof(modulus);
|
||||||
long modulusLength = 0;
|
long modulusLength = 0;
|
||||||
char exponent[256];
|
unsigned char exponent[256];
|
||||||
long exponentLength = sizeof(exponent);
|
long exponentLength = sizeof(exponent);
|
||||||
|
|
||||||
if (keyLabelLength > sizeof(keyLabel))
|
if (keyLabelLength > sizeof(keyLabel))
|
||||||
@ -453,7 +453,7 @@ static EVP_PKEY *ibm_4758_load_pubkey(ENGINE* e, const char* key_id,
|
|||||||
{
|
{
|
||||||
RSA *rtmp = NULL;
|
RSA *rtmp = NULL;
|
||||||
EVP_PKEY *res = NULL;
|
EVP_PKEY *res = NULL;
|
||||||
char* keyToken = NULL;
|
unsigned char* keyToken = NULL;
|
||||||
long keyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;
|
long keyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;
|
||||||
long returnCode;
|
long returnCode;
|
||||||
long reasonCode;
|
long reasonCode;
|
||||||
@ -461,12 +461,12 @@ static EVP_PKEY *ibm_4758_load_pubkey(ENGINE* e, const char* key_id,
|
|||||||
long ruleArrayLength = 0;
|
long ruleArrayLength = 0;
|
||||||
unsigned char exitData[8];
|
unsigned char exitData[8];
|
||||||
unsigned char ruleArray[8];
|
unsigned char ruleArray[8];
|
||||||
char keyLabel[64];
|
unsigned char keyLabel[64];
|
||||||
long keyLabelLength = strlen(key_id);
|
long keyLabelLength = strlen(key_id);
|
||||||
char modulus[512];
|
unsigned char modulus[512];
|
||||||
long modulusFieldLength = sizeof(modulus);
|
long modulusFieldLength = sizeof(modulus);
|
||||||
long modulusLength = 0;
|
long modulusLength = 0;
|
||||||
char exponent[512];
|
unsigned char exponent[512];
|
||||||
long exponentLength = sizeof(exponent);
|
long exponentLength = sizeof(exponent);
|
||||||
|
|
||||||
if (keyLabelLength > sizeof(keyLabel))
|
if (keyLabelLength > sizeof(keyLabel))
|
||||||
@ -598,7 +598,7 @@ static int cca_rsa_verify(int type, const unsigned char *m, unsigned int m_len,
|
|||||||
unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);
|
unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);
|
||||||
long length = SSL_SIG_LEN;
|
long length = SSL_SIG_LEN;
|
||||||
long keyLength ;
|
long keyLength ;
|
||||||
char *hashBuffer = NULL;
|
unsigned char *hashBuffer = NULL;
|
||||||
X509_SIG sig;
|
X509_SIG sig;
|
||||||
ASN1_TYPE parameter;
|
ASN1_TYPE parameter;
|
||||||
X509_ALGOR algorithm;
|
X509_ALGOR algorithm;
|
||||||
@ -656,7 +656,7 @@ static int cca_rsa_verify(int type, const unsigned char *m, unsigned int m_len,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
hashBuffer = (char*)m;
|
hashBuffer = (unsigned char *)m;
|
||||||
length = m_len;
|
length = m_len;
|
||||||
break;
|
break;
|
||||||
case NID_md5 :
|
case NID_md5 :
|
||||||
@ -719,7 +719,7 @@ static int cca_rsa_sign(int type, const unsigned char *m, unsigned int m_len,
|
|||||||
long outputLength=256;
|
long outputLength=256;
|
||||||
long outputBitLength;
|
long outputBitLength;
|
||||||
long keyTokenLength;
|
long keyTokenLength;
|
||||||
char *hashBuffer = NULL;
|
unsigned char *hashBuffer = NULL;
|
||||||
unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);
|
unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);
|
||||||
long length = SSL_SIG_LEN;
|
long length = SSL_SIG_LEN;
|
||||||
long keyLength ;
|
long keyLength ;
|
||||||
@ -779,7 +779,7 @@ static int cca_rsa_sign(int type, const unsigned char *m, unsigned int m_len,
|
|||||||
CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
|
CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
hashBuffer = (char*)m;
|
hashBuffer = (unsigned char*)m;
|
||||||
length = m_len;
|
length = m_len;
|
||||||
break;
|
break;
|
||||||
case NID_md5 :
|
case NID_md5 :
|
||||||
@ -830,9 +830,9 @@ static int cca_rsa_sign(int type, const unsigned char *m, unsigned int m_len,
|
|||||||
return ((returnCode || reasonCode) ? 0 : 1);
|
return ((returnCode || reasonCode) ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getModulusAndExponent(const char*token, long *exponentLength,
|
static int getModulusAndExponent(const unsigned char*token, long *exponentLength,
|
||||||
char *exponent, long *modulusLength, long *modulusFieldLength,
|
unsigned char *exponent, long *modulusLength, long *modulusFieldLength,
|
||||||
char *modulus)
|
unsigned char *modulus)
|
||||||
{
|
{
|
||||||
unsigned long len;
|
unsigned long len;
|
||||||
|
|
||||||
@ -898,34 +898,34 @@ static int cca_get_random_bytes(unsigned char* buf, int num)
|
|||||||
long ret_code;
|
long ret_code;
|
||||||
long reason_code;
|
long reason_code;
|
||||||
long exit_data_length;
|
long exit_data_length;
|
||||||
char exit_data[4];
|
unsigned char exit_data[4];
|
||||||
char form[] = "RANDOM ";
|
unsigned char form[] = "RANDOM ";
|
||||||
char random[8];
|
unsigned char rand_buf[8];
|
||||||
|
|
||||||
while(num >= sizeof(random))
|
while(num >= sizeof(rand_buf))
|
||||||
{
|
{
|
||||||
randomNumberGenerate(&ret_code, &reason_code, &exit_data_length,
|
randomNumberGenerate(&ret_code, &reason_code, &exit_data_length,
|
||||||
exit_data, form, random);
|
exit_data, form, rand_buf);
|
||||||
if (ret_code)
|
if (ret_code)
|
||||||
return 0;
|
return 0;
|
||||||
num -= sizeof(random);
|
num -= sizeof(rand_buf);
|
||||||
memcpy(buf, random, sizeof(random));
|
memcpy(buf, rand_buf, sizeof(rand_buf));
|
||||||
buf += sizeof(random);
|
buf += sizeof(rand_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num)
|
if (num)
|
||||||
{
|
{
|
||||||
randomNumberGenerate(&ret_code, &reason_code, NULL, NULL,
|
randomNumberGenerate(&ret_code, &reason_code, NULL, NULL,
|
||||||
form, random);
|
form, rand_buf);
|
||||||
if (ret_code)
|
if (ret_code)
|
||||||
return 0;
|
return 0;
|
||||||
memcpy(buf, random, num);
|
memcpy(buf, rand_buf, num);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cca_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad, int index,
|
static void cca_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad, int idx,
|
||||||
long argl, void *argp)
|
long argl, void *argp)
|
||||||
{
|
{
|
||||||
if (item)
|
if (item)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user