Merge pull request #959 from SparkiDev/tls_pss_fix

Fix check for PSS availability in peer
This commit is contained in:
toddouska
2017-06-12 11:20:29 -07:00
committed by GitHub
4 changed files with 36 additions and 7 deletions

View File

@@ -16272,6 +16272,11 @@ void PickHashSigAlgo(WOLFSSL* ssl, const byte* hashSigAlgo,
PickHashSigAlgo(ssl, input + *inOutIdx, len);
*inOutIdx += len;
#ifdef WC_RSA_PSS
ssl->pssAlgo = 0;
if (ssl->suites->sigAlgo == rsa_pss_sa_algo)
ssl->pssAlgo |= 1 << ssl->suites->hashAlgo;
#endif
}
/* authorities */
@@ -19037,7 +19042,7 @@ int SendCertificateVerify(WOLFSSL* ssl)
if (ssl->hsType == DYNAMIC_TYPE_RSA) {
#ifdef WC_RSA_PSS
if (IsAtLeastTLSv1_2(ssl) &&
(ssl->pssAlgo | (1 << ssl->suites->hashAlgo))) {
(ssl->pssAlgo & (1 << ssl->suites->hashAlgo))) {
args->sigAlgo = rsa_pss_sa_algo;
}
else

View File

@@ -2640,7 +2640,7 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs,
return CcmRet;
}
XMEMCPY(keys->aead_enc_imp_IV, keys->client_write_IV,
AESGCM_IMP_IV_SZ);
AEAD_MAX_IMP_SZ);
}
if (dec) {
CcmRet = wc_AesCcmSetKey(dec->aes, keys->server_write_key,
@@ -2649,7 +2649,7 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs,
return CcmRet;
}
XMEMCPY(keys->aead_dec_imp_IV, keys->server_write_IV,
AESGCM_IMP_IV_SZ);
AEAD_MAX_IMP_SZ);
}
}
else {
@@ -2660,7 +2660,7 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs,
return CcmRet;
}
XMEMCPY(keys->aead_enc_imp_IV, keys->server_write_IV,
AESGCM_IMP_IV_SZ);
AEAD_MAX_IMP_SZ);
}
if (dec) {
CcmRet = wc_AesCcmSetKey(dec->aes, keys->client_write_key,
@@ -2669,7 +2669,7 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs,
return CcmRet;
}
XMEMCPY(keys->aead_dec_imp_IV, keys->client_write_IV,
AESGCM_IMP_IV_SZ);
AEAD_MAX_IMP_SZ);
}
}
if (enc)

View File

@@ -1595,7 +1595,7 @@ static int TLSX_SNI_Parse(WOLFSSL* ssl, byte* input, word16 length,
/* Don't process the second ClientHello SNI extension if there
* was problems with the first.
*/
if (sni->status != 0)
if (!cacheOnly && sni->status != 0)
break;
#endif
byte matched = cacheOnly ||

View File

@@ -1616,6 +1616,10 @@ static int EncryptTls13(WOLFSSL* ssl, byte* output, const byte* input,
switch (ssl->specs.bulk_cipher_algorithm) {
#ifdef BUILD_AESGCM
case wolfssl_aes_gcm:
#ifdef WOLFSSL_DEBUG_TLS
WOLFSSL_MSG("Nonce");
WOLFSSL_BUFFER(nonce, AESGCM_NONCE_SZ);
#endif
ret = wc_AesGcmEncrypt(ssl->encrypt.aes, output, input, dataSz,
nonce, AESGCM_NONCE_SZ, output + dataSz, macSz, NULL, 0);
break;
@@ -1623,6 +1627,10 @@ static int EncryptTls13(WOLFSSL* ssl, byte* output, const byte* input,
#ifdef HAVE_AESCCM
case wolfssl_aes_ccm:
#ifdef WOLFSSL_DEBUG_TLS
WOLFSSL_MSG("Nonce");
WOLFSSL_BUFFER(nonce, AESCCM_NONCE_SZ);
#endif
ret = wc_AesCcmEncrypt(ssl->encrypt.aes, output, input, dataSz,
nonce, AESCCM_NONCE_SZ, output + dataSz, macSz, NULL, 0);
break;
@@ -1630,6 +1638,10 @@ static int EncryptTls13(WOLFSSL* ssl, byte* output, const byte* input,
#if defined(HAVE_CHACHA) && defined(HAVE_POLY1305)
case wolfssl_chacha:
#ifdef WOLFSSL_DEBUG_TLS
WOLFSSL_MSG("Nonce");
WOLFSSL_BUFFER(nonce, CHACHA_IV_BYTES);
#endif
ret = ChaCha20Poly1305_Encrypt(ssl, output, input, dataSz, nonce,
output + dataSz);
break;
@@ -1740,6 +1752,10 @@ int DecryptTls13(WOLFSSL* ssl, byte* output, const byte* input, word16 sz)
switch (ssl->specs.bulk_cipher_algorithm) {
#ifdef BUILD_AESGCM
case wolfssl_aes_gcm:
#ifdef WOLFSSL_DEBUG_TLS
WOLFSSL_MSG("Nonce");
WOLFSSL_BUFFER(nonce, AESGCM_NONCE_SZ);
#endif
ret = wc_AesGcmDecrypt(ssl->decrypt.aes, output, input, dataSz,
nonce, AESGCM_NONCE_SZ, input + dataSz, macSz, NULL, 0);
break;
@@ -1747,6 +1763,10 @@ int DecryptTls13(WOLFSSL* ssl, byte* output, const byte* input, word16 sz)
#ifdef HAVE_AESCCM
case wolfssl_aes_ccm:
#ifdef WOLFSSL_DEBUG_TLS
WOLFSSL_MSG("Nonce");
WOLFSSL_BUFFER(nonce, AESCCM_NONCE_SZ);
#endif
ret = wc_AesCcmDecrypt(ssl->decrypt.aes, output, input, dataSz,
nonce, AESCCM_NONCE_SZ, input + dataSz, macSz, NULL, 0);
break;
@@ -1754,6 +1774,10 @@ int DecryptTls13(WOLFSSL* ssl, byte* output, const byte* input, word16 sz)
#if defined(HAVE_CHACHA) && defined(HAVE_POLY1305)
case wolfssl_chacha:
#ifdef WOLFSSL_DEBUG_TLS
WOLFSSL_MSG("Nonce");
WOLFSSL_BUFFER(nonce, CHACHA_IV_BYTES);
#endif
ret = ChaCha20Poly1305_Decrypt(ssl, output, input, dataSz, nonce,
input + dataSz);
break;
@@ -3830,7 +3854,7 @@ int SendTls13CertificateVerify(WOLFSSL* ssl)
/* Add signature algorithm. */
if (ssl->hsType == DYNAMIC_TYPE_RSA) {
#ifdef WC_RSA_PSS
if (ssl->pssAlgo | (1 << ssl->suites->hashAlgo))
if (ssl->pssAlgo & (1 << ssl->suites->hashAlgo))
args->sigAlgo = rsa_pss_sa_algo;
else
#endif