Merge pull request #1445 from SparkiDev/wpas_fix

Fixes for wpa_supplicant
pull/1457/head
toddouska 2018-03-21 15:11:43 -07:00 committed by GitHub
commit 2a356228be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 88 additions and 33 deletions

View File

@ -579,7 +579,7 @@ then
AM_CFLAGS="$AM_CFLAGS -DHAVE_EXT_CACHE"
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ALWAYS_VERIFY_CB"
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_AES_DIRECT -DWOLFSSL_DER_LOAD"
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_KEY_GEN"
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_KEY_GEN -DWOLFSSL_DES_ECB"
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_WPAS"
fi

View File

@ -1753,16 +1753,12 @@ void InitSuitesHashSigAlgo(Suites* suites, int haveECDSAsig, int haveRSAsig,
#ifdef WC_RSA_PSS
if (tls1_2) {
#ifdef WOLFSSL_SHA512
if (keySz >= MIN_RSA_SHA512_PSS_BITS) {
suites->hashSigAlgo[idx++] = rsa_pss_sa_algo;
suites->hashSigAlgo[idx++] = sha512_mac;
}
suites->hashSigAlgo[idx++] = rsa_pss_sa_algo;
suites->hashSigAlgo[idx++] = sha512_mac;
#endif
#ifdef WOLFSSL_SHA384
if (keySz >= MIN_RSA_SHA384_PSS_BITS) {
suites->hashSigAlgo[idx++] = rsa_pss_sa_algo;
suites->hashSigAlgo[idx++] = sha384_mac;
}
suites->hashSigAlgo[idx++] = rsa_pss_sa_algo;
suites->hashSigAlgo[idx++] = sha384_mac;
#endif
#ifndef NO_SHA256
suites->hashSigAlgo[idx++] = rsa_pss_sa_algo;
@ -8523,11 +8519,7 @@ int ProcessPeerCerts(WOLFSSL* ssl, byte* input, word32* inOutIdx,
XMEMSET(store, 0, sizeof(WOLFSSL_X509_STORE_CTX));
store->error = ret;
#ifdef WOLFSSL_WPAS
store->error_depth = 0;
#else
store->error_depth = args->certIdx;
#endif
store->discardSessionCerts = 0;
store->domain = args->domain;
store->userCtx = ssl->verifyCbCtx;
@ -14635,6 +14627,11 @@ const char* wolfSSL_ERR_reason_error_string(unsigned long e)
switch (error) {
#ifdef WOLFSSL_WPAS
case 0 :
return "ok";
#endif
case UNSUPPORTED_SUITE :
return "unsupported cipher suite";
@ -23013,6 +23010,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
XMEMSET(&cookieHmac, 0, sizeof(Hmac));
#endif /* WOLFSSL_DTLS */
#ifdef WOLFSSL_CALLBACKS
if (ssl->hsInfoOn) AddPacketName(ssl, "ClientHello");
if (ssl->toInfoOn) AddLateName("ClientHello", &ssl->timeoutInfo);

View File

@ -7005,6 +7005,19 @@ int wolfSSL_CTX_use_certificate_chain_file(WOLFSSL_CTX* ctx, const char* file)
}
int wolfSSL_CTX_use_certificate_chain_file_format(WOLFSSL_CTX* ctx,
const char* file, int format)
{
/* process up to MAX_CHAIN_DEPTH plus subject cert */
WOLFSSL_ENTER("wolfSSL_CTX_use_certificate_chain_file_format");
if (ProcessFile(ctx, file, format, CERT_TYPE, NULL, 1, NULL)
== WOLFSSL_SUCCESS)
return WOLFSSL_SUCCESS;
return WOLFSSL_FAILURE;
}
#ifndef NO_DH
/* server Diffie-Hellman parameters */
@ -7957,6 +7970,18 @@ int wolfSSL_use_certificate_chain_file(WOLFSSL* ssl, const char* file)
return WOLFSSL_FAILURE;
}
int wolfSSL_use_certificate_chain_file_format(WOLFSSL* ssl, const char* file,
int format)
{
/* process up to MAX_CHAIN_DEPTH plus subject cert */
WOLFSSL_ENTER("wolfSSL_use_certificate_chain_file_format");
if (ProcessFile(ssl->ctx, file, format, CERT_TYPE, ssl, 1,
NULL) == WOLFSSL_SUCCESS)
return WOLFSSL_SUCCESS;
return WOLFSSL_FAILURE;
}
#ifdef HAVE_ECC
@ -16102,7 +16127,7 @@ void wolfSSL_set_connect_state(WOLFSSL* ssl)
InitSuites(ssl->suites, ssl->version, ssl->buffers.keySz, haveRSA,
havePSK, ssl->options.haveDH, ssl->options.haveNTRU,
ssl->options.haveECDSAsig, ssl->options.haveECC,
ssl->options.haveStaticECC, ssl->options.side);
ssl->options.haveStaticECC, WOLFSSL_CLIENT_END);
}
ssl->options.side = WOLFSSL_CLIENT_END;
}
@ -21380,24 +21405,21 @@ int wolfSSL_ASN1_GENERALIZEDTIME_print(WOLFSSL_BIO* bio,
return 0;
}
#ifndef NO_WOLFSSL_STUB
int wolfSSL_sk_num(WOLFSSL_X509_REVOKED* rev)
int wolfSSL_sk_num(WOLF_STACK_OF(WOLFSSL_ASN1_OBJECT)* sk)
{
(void)rev;
WOLFSSL_STUB("OPENSSL_sk_num");
return 0;
if (sk == NULL)
return 0;
return (int)sk->num;
}
#endif
#ifndef NO_WOLFSSL_STUB
void* wolfSSL_sk_value(WOLFSSL_X509_REVOKED* rev, int i)
void* wolfSSL_sk_value(WOLF_STACK_OF(WOLFSSL_ASN1_OBJECT)* sk, int i)
{
(void)rev;
(void)i;
WOLFSSL_STUB("OPENSSL_sk_value");
return 0;
for (; sk != NULL && i > 0; i--)
sk = sk->next;
if (sk == NULL)
return NULL;
return (void*)sk->data.obj;
}
#endif
/* stunnel 4.28 needs */
void wolfSSL_CTX_sess_set_get_cb(WOLFSSL_CTX* ctx,

View File

@ -4301,6 +4301,10 @@ static int GetName(DecodedCert* cert, int nameType)
if (copy && !tooBig) {
XMEMCPY(&full[idx], copy, XSTRLEN(copy));
idx += (word32)XSTRLEN(copy);
#ifdef WOLFSSL_WPAS
full[idx] = '=';
idx++;
#endif
XMEMCPY(&full[idx], &cert->source[cert->srcIdx], strLen);
idx += strLen;
}
@ -6900,6 +6904,7 @@ int ParseCertRelative(DecodedCert* cert, int type, int verify, void* cm)
int badDate = 0;
int criticalExt = 0;
word32 confirmOID;
int selfSigned = 0;
if (cert == NULL) {
return BAD_FUNC_ARG;
@ -6990,18 +6995,25 @@ int ParseCertRelative(DecodedCert* cert, int type, int verify, void* cm)
#endif
#else
cert->ca = GetCA(cm, cert->issuerHash);
if (XMEMCMP(cert->issuerHash, cert->subjectHash, KEYID_SIZE) == 0)
selfSigned = 1;
#endif /* !NO_SKID */
WOLFSSL_MSG("About to verify certificate signature");
if (cert->ca) {
if (cert->isCA) {
if (cert->ca->pathLengthSet) {
if (cert->isCA && cert->ca->pathLengthSet) {
if (selfSigned) {
if (cert->ca->pathLength != 0) {
WOLFSSL_MSG("Root CA with path length > 0");
return ASN_PATHLEN_INV_E;
}
}
else {
if (cert->ca->pathLength == 0) {
WOLFSSL_MSG("CA with path length 0 signing a CA");
return ASN_PATHLEN_INV_E;
}
if (cert->pathLengthSet &&
cert->pathLength >= cert->ca->pathLength) {
else if (cert->pathLength >= cert->ca->pathLength) {
WOLFSSL_MSG("CA signing CA with longer path length");
return ASN_PATHLEN_INV_E;

View File

@ -966,6 +966,7 @@ int wc_DhCheckPubKey_ex(DhKey* key, const byte* pub, word32 pubSz,
}
#else
{
ret = WC_KEY_SIZE_E;
}
#endif

View File

@ -8069,6 +8069,23 @@ done:
*/
int mp_sqrtmod_prime(mp_int* n, mp_int* prime, mp_int* ret)
{
#ifdef SQRTMOD_USE_MOD_EXP
int res;
mp_int e;
res = mp_init(&e);
if (res == MP_OKAY)
res = mp_add_d(prime, 1, &e);
if (res == MP_OKAY)
res = mp_div_2d(&e, 2, &e, NULL);
if (res == MP_OKAY)
res = mp_exptmod(n, &e, prime, ret);
mp_clear(&e);
return res;
#else
int res, legendre, done = 0;
mp_int t1, C, Q, S, Z, M, T, R, two;
mp_digit i;
@ -8247,6 +8264,7 @@ int mp_sqrtmod_prime(mp_int* n, mp_int* prime, mp_int* ret)
mp_clear(&two);
return res;
#endif
}
#endif
#endif /* !WOLFSSL_ATECC508A */

View File

@ -490,6 +490,8 @@ WOLFSSL_API int wolfSSL_CTX_trust_peer_cert(WOLFSSL_CTX*, const char*, int);
#endif
WOLFSSL_API int wolfSSL_CTX_use_certificate_chain_file(WOLFSSL_CTX *,
const char *file);
WOLFSSL_API int wolfSSL_CTX_use_certificate_chain_file_format(WOLFSSL_CTX *,
const char *file, int format);
WOLFSSL_API int wolfSSL_CTX_use_RSAPrivateKey_file(WOLFSSL_CTX*, const char*, int);
WOLFSSL_API long wolfSSL_get_verify_depth(WOLFSSL* ssl);
@ -498,6 +500,8 @@ WOLFSSL_API void wolfSSL_CTX_set_verify_depth(WOLFSSL_CTX *ctx,int depth);
WOLFSSL_API int wolfSSL_use_certificate_file(WOLFSSL*, const char*, int);
WOLFSSL_API int wolfSSL_use_PrivateKey_file(WOLFSSL*, const char*, int);
WOLFSSL_API int wolfSSL_use_certificate_chain_file(WOLFSSL*, const char *file);
WOLFSSL_API int wolfSSL_use_certificate_chain_file_format(WOLFSSL*,
const char *file, int format);
WOLFSSL_API int wolfSSL_use_RSAPrivateKey_file(WOLFSSL*, const char*, int);
#ifdef WOLFSSL_DER_LOAD
@ -1413,8 +1417,8 @@ WOLFSSL_API int wolfSSL_ASN1_UTCTIME_print(WOLFSSL_BIO*,
const WOLFSSL_ASN1_UTCTIME*);
WOLFSSL_API int wolfSSL_ASN1_GENERALIZEDTIME_print(WOLFSSL_BIO*,
const WOLFSSL_ASN1_GENERALIZEDTIME*);
WOLFSSL_API int wolfSSL_sk_num(WOLFSSL_X509_REVOKED*);
WOLFSSL_API void* wolfSSL_sk_value(WOLFSSL_X509_REVOKED*, int);
WOLFSSL_API int wolfSSL_sk_num(WOLF_STACK_OF(WOLFSSL_ASN1_OBJECT)*);
WOLFSSL_API void* wolfSSL_sk_value(WOLF_STACK_OF(WOLFSSL_ASN1_OBJECT)*, int);
/* stunnel 4.28 needs */
WOLFSSL_API void* wolfSSL_CTX_get_ex_data(const WOLFSSL_CTX*, int);