fixes from scan-build output in test.c
This commit is contained in:
parent
ed80732957
commit
1ef9d7852c
@ -3179,30 +3179,49 @@ int rsa_test(void)
|
|||||||
wc_RsaInitCavium(&key, CAVIUM_DEV_ID);
|
wc_RsaInitCavium(&key, CAVIUM_DEV_ID);
|
||||||
#endif
|
#endif
|
||||||
ret = wc_InitRsaKey(&key, 0);
|
ret = wc_InitRsaKey(&key, 0);
|
||||||
if (ret != 0) return -39;
|
if (ret != 0) {
|
||||||
|
free(tmp);
|
||||||
|
return -39;
|
||||||
|
}
|
||||||
ret = wc_RsaPrivateKeyDecode(tmp, &idx, &key, (word32)bytes);
|
ret = wc_RsaPrivateKeyDecode(tmp, &idx, &key, (word32)bytes);
|
||||||
if (ret != 0) return -41;
|
if (ret != 0) {
|
||||||
|
free(tmp);
|
||||||
|
return -41;
|
||||||
|
}
|
||||||
ret = wc_InitRng(&rng);
|
ret = wc_InitRng(&rng);
|
||||||
if (ret != 0) return -42;
|
if (ret != 0) {
|
||||||
|
free(tmp);
|
||||||
|
return -42;
|
||||||
|
}
|
||||||
ret = wc_RsaPublicEncrypt(in, inLen, out, sizeof(out), &key, &rng);
|
ret = wc_RsaPublicEncrypt(in, inLen, out, sizeof(out), &key, &rng);
|
||||||
if (ret < 0) return -43;
|
if (ret < 0) {
|
||||||
|
free(tmp);
|
||||||
|
return -43;
|
||||||
|
}
|
||||||
ret = wc_RsaPrivateDecrypt(out, ret, plain, sizeof(plain), &key);
|
ret = wc_RsaPrivateDecrypt(out, ret, plain, sizeof(plain), &key);
|
||||||
if (ret < 0) return -44;
|
if (ret < 0) {
|
||||||
|
free(tmp);
|
||||||
if (memcmp(plain, in, inLen)) return -45;
|
return -44;
|
||||||
|
}
|
||||||
|
if (memcmp(plain, in, inLen)) {
|
||||||
|
free(tmp);
|
||||||
|
return -45;
|
||||||
|
}
|
||||||
ret = wc_RsaSSL_Sign(in, inLen, out, sizeof(out), &key, &rng);
|
ret = wc_RsaSSL_Sign(in, inLen, out, sizeof(out), &key, &rng);
|
||||||
if (ret < 0) return -46;
|
if (ret < 0) {
|
||||||
|
free(tmp);
|
||||||
|
return -46;
|
||||||
|
}
|
||||||
memset(plain, 0, sizeof(plain));
|
memset(plain, 0, sizeof(plain));
|
||||||
ret = wc_RsaSSL_Verify(out, ret, plain, sizeof(plain), &key);
|
ret = wc_RsaSSL_Verify(out, ret, plain, sizeof(plain), &key);
|
||||||
if (ret < 0) return -47;
|
if (ret < 0) {
|
||||||
|
free(tmp);
|
||||||
if (memcmp(plain, in, ret)) return -48;
|
return -47;
|
||||||
|
}
|
||||||
|
if (memcmp(plain, in, ret)) {
|
||||||
|
free(tmp);
|
||||||
|
return -48;
|
||||||
|
}
|
||||||
#if defined(WOLFSSL_MDK_ARM)
|
#if defined(WOLFSSL_MDK_ARM)
|
||||||
#define sizeof(s) strlen((char *)(s))
|
#define sizeof(s) strlen((char *)(s))
|
||||||
#endif
|
#endif
|
||||||
@ -3215,8 +3234,10 @@ int rsa_test(void)
|
|||||||
bytes = sizeof_client_cert_der_2048;
|
bytes = sizeof_client_cert_der_2048;
|
||||||
#else
|
#else
|
||||||
file2 = fopen(clientCert, "rb");
|
file2 = fopen(clientCert, "rb");
|
||||||
if (!file2)
|
if (!file2) {
|
||||||
|
free(tmp);
|
||||||
return -49;
|
return -49;
|
||||||
|
}
|
||||||
|
|
||||||
bytes = fread(tmp, 1, FOURK_BUF, file2);
|
bytes = fread(tmp, 1, FOURK_BUF, file2);
|
||||||
fclose(file2);
|
fclose(file2);
|
||||||
|
Loading…
Reference in New Issue
Block a user