time_t t;
srand((unsigned) time(&t));
mac = (char*)calloc(128, sizeof(char));
- snprintf(mac, 128 - 1, "%d", (AsmCrypto::genRandomInt()%1000 + 1));
-
- char *macClone = _SAFE_DUP(mac);
- if(macClone)
- _INFO("%s", macClone);
- std::string macStr(macClone);
- _INFO("%s", macStr.c_str());
- asmTok = strdup(macClone);
- SAFE_DELETE(macClone);
- SAFE_DELETE(mac);
- bt_deinitialize();
- return macStr;
+ if(mac != NULL ) {
+ snprintf(mac, 128 - 1, "%d", (AsmCrypto::genRandomInt()%1000 + 1));
+
+ char *macClone = _SAFE_DUP(mac);
+ std::string macStr(macClone);
+
+ _INFO("%s", macClone);
+ _INFO("%s", macStr.c_str());
+ asmTok = strdup(macClone);
+ SAFE_DELETE(macClone);
+ SAFE_DELETE(mac);
+ bt_deinitialize();
+ return macStr;
+ }
}
char *realpath_res = NULL;
if (1 != EVP_EncryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, key, iv))
{
_ERR("EVP_EncryptInit_ex() failed");
+ EVP_CIPHER_CTX_free(ctx);
return -1;
}
if (1 != EVP_EncryptUpdate(ctx, ciphertext, &len, plaintext, plaintext_len))
{
_ERR("EVP_EncryptUpdate() failed");
+ EVP_CIPHER_CTX_free(ctx);
return -1;
}
if (1 != EVP_EncryptFinal_ex(ctx, ciphertext + len, &len))
{
_ERR("EVP_EncryptFinal_ex() failed");
+ EVP_CIPHER_CTX_free(ctx);
return -1;
}
if (1 != EVP_DecryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, key, iv))
{
_ERR("EVP_DecryptInit_ex() failed");
+ EVP_CIPHER_CTX_free(ctx);
return -1;
}
if (1 != EVP_DecryptUpdate(ctx, plaintext, &len, ciphertext, ciphertext_len))
{
_ERR("EVP_DecryptUpdate() failed");
+ EVP_CIPHER_CTX_free(ctx);
return -1;
}
if (1 != EVP_DecryptFinal_ex(ctx, plaintext + len, &len))
{
_ERR("EVP_DecryptFinal_ex() failed");
+ EVP_CIPHER_CTX_free(ctx);
return -1;
}
RET_IF_FAIL(input != NULL, NULL);
RET_IF_FAIL(ip_len > 0, NULL);
- unsigned char *output = (unsigned char*)calloc(ip_len * 1.5, sizeof(char));
-
+ unsigned char *output = NULL;
BIO *bmem = NULL;
BIO *b64 = NULL;
BUF_MEM *bptr = NULL;
+
+ output = (unsigned char*)calloc(ip_len * 1.5, sizeof(char));
+ if(output == NULL) {
+ _ERR("memory allocation failed");
+ return NULL;
+ }
b64 = BIO_new(BIO_f_base64());
if (b64 == NULL) {
_ERR("BIO_new failed \n");
AcUiAdaptor::genNonce(void)
{
struct timeval t1;
+ char *nonce = NULL;
gettimeofday(&t1, NULL);
srand(t1.tv_usec * t1.tv_sec);
- char *nonce = NALLOC(NONCE_LEN + 1, char);
+ nonce = NALLOC(NONCE_LEN + 1, char);
+ if(nonce == NULL) {
+ _ERR("memory allocation failed");
+ return NULL;
+ }
for (int i = 0; i < NONCE_LEN; i++) {
int randNum = AsmCrypto::genRandomInt() % ('z' - '0');
nonce[i] = '0' + randNum;
PinAuthUiAdaptor::genNonce(void)
{
struct timeval t1;
+ char *nonce = NULL;
gettimeofday(&t1, NULL);
srand(t1.tv_usec * t1.tv_sec);
- char *nonce = NALLOC(NONCE_LEN + 1, char);
+ nonce = NALLOC(NONCE_LEN + 1, char);
+ if(nonce == NULL) {
+ _ERR("memory allocation failed");
+ return NULL;
+ }
for (int i = 0; i < NONCE_LEN; i++) {
int randNum = AsmCrypto::genRandomInt() % ('z' - '0');
nonce[i] = '0' + randNum;
TcUiAdaptor::genNonce(void)
{
struct timeval t1;
+ char * nonce = NULL;
gettimeofday(&t1, NULL);
srand(t1.tv_usec * t1.tv_sec);
- char *nonce = NALLOC(NONCE_LEN + 1, char);
+ nonce = NALLOC(NONCE_LEN + 1, char);
+ if(nonce == NULL) {
+ _ERR("memory allocation failed");
+ return NULL;
+ }
for (int i = 0; i < NONCE_LEN; i++) {
int randNum = AsmCrypto::genRandomInt() % ('z' - '0');
nonce[i] = '0' + randNum;
_INFO("AuthenrStub::hash::digest generated is [%s]", digest);
Buffer *hashInfo = ALLOC(Buffer);
+ if(hashInfo == NULL) {
+ _ERR("memory allocation failed");
+ return NULL;
+ }
hashInfo->len = SHA256_DIGEST_LENGTH;
hashInfo->data = NALLOC(BIG_SIZE, uint8_t);
memcpy(hashInfo->data, digest, SHA256_DIGEST_LENGTH);
+ if(hashInfo->data == NULL) {
+ _ERR("memory allocation failed");
+ SAFE_DELETE(hashInfo);
+ return NULL;
+ }
//std::string digestStr((char*)digest, 5000);
_END;
return hashInfo;
//std::string digestStr(digest, strlen(digest));
Buffer *hashInfo = ALLOC(Buffer);
+ if(hashInfo == NULL) {
+ _ERR("memory allocation failed");
+ return NULL;
+ }
hashInfo->len = SHA256_DIGEST_LENGTH;
hashInfo->data = NALLOC(BIG_SIZE, uint8_t);
+ if(hashInfo->data == NULL) {
+ _ERR("memory allocation failed");
+ SAFE_DELETE(hashInfo);
+ return NULL;
+ }
memcpy(hashInfo->data, digest, SHA256_DIGEST_LENGTH);
_END;
_INFO("AuthenrStub::hash::digest generated is [%s]", digest);
Buffer *hashInfo = ALLOC(Buffer);
+ if(hashInfo == NULL) {
+ _ERR("memory allocation failed");
+ return NULL;
+ }
hashInfo->len = SHA256_DIGEST_LENGTH;
hashInfo->data = NALLOC(BIG_SIZE, uint8_t);
+ if(hashInfo->data == NULL) {
+ _ERR("memory allocation failed");
+ SAFE_DELETE(hashInfo);
+ return NULL;
+ }
memcpy(hashInfo->data, digest, SHA256_DIGEST_LENGTH);
//std::string digestStr((char*)digest, 5000);
_END;
RET_IF_FAIL(input != NULL, NULL);
RET_IF_FAIL(ip_len > 0, NULL);
- unsigned char *output = (unsigned char*)calloc(ip_len * 1.5, sizeof(char));
-
+ unsigned char *output = NULL;
BIO *bmem = NULL;
BIO *b64 = NULL;
BUF_MEM *bptr = NULL;
+
+ output = (unsigned char*)calloc(ip_len * 1.5, sizeof(char));
+ if(output == NULL) {
+ _ERR(" calloc failed \n");
+ return NULL;
+ }
b64 = BIO_new(BIO_f_base64());
if (b64 == NULL) {
_ERR("BIO_new failed \n");
ret = sqlite3_exec(dbH, query, NULL, 0, &errMsg);
if (errMsg != NULL) {
_INFO("createtable error = [%s]", errMsg);
+ sqlite3_free(errMsg);
sqlite3_close(dbH);
SAFE_DELETE(dbPath);