Add Qt 5.12 and 5.13 support

Co-Authored-By: aaronjense <aaron@wolfssl.com>
Co-Authored-By: MJSPollard <mpollard@wolfssl.com>
Co-Authored-By: Quinn Miller <quinnmiller1997@users.noreply.github.com>
Co-Authored-By: Tim Parrish <timparrish@users.noreply.github.com>
This commit is contained in:
Carie Pointer
2019-12-06 14:27:01 -07:00
parent b4f67dabcf
commit ee13dfd878
42 changed files with 5991 additions and 561 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -29,7 +29,7 @@
#ifndef NO_DH
#if defined(HAVE_FIPS) && \
defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
/* set NO_WRAPPERS before headers, use direct internal f()s not wrappers */
#define FIPS_NO_WRAPPERS
@@ -930,7 +930,11 @@ int wc_InitDhKey_ex(DhKey* key, void* heap, int devId)
key->heap = heap; /* for XMALLOC/XFREE in future */
#if !defined(WOLFSSL_QT) && !defined(OPENSSL_ALL)
if (mp_init_multi(&key->p, &key->g, &key->q, NULL, NULL, NULL) != MP_OKAY)
#else
if (mp_init_multi(&key->p,&key->g,&key->q,&key->pub,&key->priv,NULL) != MP_OKAY)
#endif
return MEMORY_E;
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_DH)
@@ -2061,6 +2065,73 @@ int wc_DhAgree(DhKey* key, byte* agree, word32* agreeSz, const byte* priv,
return ret;
}
#if defined(WOLFSSL_QT) || defined(OPENSSL_ALL)
WOLFSSL_LOCAL int wc_DhSetFullKeys(DhKey* key,const byte* priv_key,word32 privSz,
const byte* pub_key, word32 pubSz)
{
byte havePriv = 0;
byte havePub = 0;
mp_int* keyPriv = NULL;
mp_int* keyPub = NULL;
if (key == NULL) {
return BAD_FUNC_ARG;
}
havePriv = ( (priv_key != NULL) && (privSz > 0) );
havePub = ( (pub_key != NULL) && (pubSz > 0) );
if (!havePub && !havePriv) {
WOLFSSL_MSG("No Public or Private Key to Set");
return BAD_FUNC_ARG;
}
/* Set Private Key */
if (havePriv == TRUE) {
/* may have leading 0 */
if (priv_key[0] == 0) {
privSz--; priv_key++;
}
if (mp_init(&key->priv) != MP_OKAY)
havePriv = FALSE;
}
if (havePriv == TRUE) {
if (mp_read_unsigned_bin(&key->priv, priv_key, privSz) != MP_OKAY) {
havePriv = FALSE;
} else {
keyPriv = &key->priv;
WOLFSSL_MSG("DH Private Key Set.");
}
}
/* Set Public Key */
if (havePub == TRUE) {
/* may have leading 0 */
if (pub_key[0] == 0) {
pubSz--; pub_key++;
}
if (mp_init(&key->pub) != MP_OKAY)
havePub = FALSE;
}
if (havePub == TRUE) {
if (mp_read_unsigned_bin(&key->pub, pub_key, pubSz) != MP_OKAY) {
havePub = FALSE;
} else {
keyPub = &key->pub;
WOLFSSL_MSG("DH Public Key Set.");
}
}
/* Free Memory if error occured */
if (havePriv == FALSE && keyPriv != NULL)
mp_clear(keyPriv);
if (havePub == FALSE && keyPub != NULL)
mp_clear(keyPub);
/* WOLFSSL_SUCCESS if private or public was set else WOLFSSL_FAILURE */
return havePriv || havePub;
}
#endif
static int _DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g,
word32 gSz, const byte* q, word32 qSz, int trusted,

View File

@@ -286,7 +286,7 @@ enum {
#ifdef HAVE_ECC_SECPR2
#ifdef HAVE_OID_ENCODING
#define CODED_SECP160R2 {1,3,132,0,30}
#define CODED_SECP160R1_SZ 5
#define CODED_SECP160R2_SZ 5
#else
#define CODED_SECP160R2 {0x2B,0x81,0x04,0x00,0x1E}
#define CODED_SECP160R2_SZ 5

View File

@@ -512,6 +512,9 @@ const char* wc_GetErrorString(int error)
case PSS_SALTLEN_RECOVER_E:
return "PSS - Salt length unable to be recovered";
case ASN_SELF_SIGNED_E:
return "ASN self-signed certificate error";
default:
return "unknown error number";

View File

@@ -372,7 +372,7 @@ int wc_BufferKeyEncrypt(EncryptedInfo* info, byte* der, word32 derSz,
*/
int wc_CryptKey(const char* password, int passwordSz, byte* salt,
int saltSz, int iterations, int id, byte* input,
int length, int version, byte* cbcIv, int enc)
int length, int version, byte* cbcIv, int enc, int shaOid)
{
int typeH;
int derivedLen;
@@ -404,9 +404,17 @@ int wc_CryptKey(const char* password, int passwordSz, byte* salt,
break;
case PBE_SHA1_DES3:
typeH = WC_SHA;
derivedLen = 32; /* may need iv for v1.5 */
break;
switch(shaOid) {
case HMAC_SHA256_OID:
typeH = WC_SHA256;
derivedLen = 32;
break;
default:
typeH = WC_SHA;
derivedLen = 32; /* may need iv for v1.5 */
break;
}
break;
#endif /* !NO_SHA */
#endif /* !NO_DES3 */
#if !defined(NO_SHA) && !defined(NO_RC4)
@@ -415,14 +423,37 @@ int wc_CryptKey(const char* password, int passwordSz, byte* salt,
derivedLen = 16;
break;
#endif
#ifdef WOLFSSL_AES_256
#if defined(WOLFSSL_AES_256) && !defined(NO_SHA)
case PBE_AES256_CBC:
typeH = WC_SHA256;
derivedLen = 32;
switch(shaOid) {
case HMAC_SHA256_OID:
typeH = WC_SHA256;
derivedLen = 32;
break;
default:
typeH = WC_SHA;
derivedLen = 32;
break;
}
break;
#endif
#endif /* WOLFSSL_AES_256 && !NO_SHA */
#if defined(WOLFSSL_AES_128) && !defined(NO_SHA)
case PBE_AES128_CBC:
switch(shaOid) {
case HMAC_SHA256_OID:
typeH = WC_SHA256;
derivedLen = 16;
break;
default:
typeH = WC_SHA;
derivedLen = 16;
break;
}
break;
#endif /* WOLFSSL_AES_128 && !NO_SHA */
default:
WOLFSSL_MSG("Unknown/Unsupported encrypt/decrypt id");
(void)shaOid;
return ALGO_ID_E;
}
@@ -574,6 +605,7 @@ int wc_CryptKey(const char* password, int passwordSz, byte* salt,
#if !defined(NO_AES) && defined(HAVE_AES_CBC)
#ifdef WOLFSSL_AES_256
case PBE_AES256_CBC:
case PBE_AES128_CBC:
{
Aes aes;
ret = wc_AesInit(&aes, NULL, INVALID_DEVID);