Branch Coverage

inc/matrixssl-3-9-3-open/matrixssl/matrixsslApi.c
Criterion Covered Total %
branch 190 440 43.1


line true false branch
88 0 11156 if (!ssl)
92 0 11156 if (cipherSpecLen > 0 && (cipherSpec == NULL || cipherSpec[0] == 0))
0 0 if (cipherSpecLen > 0 && (cipherSpec == NULL || cipherSpec[0] == 0))
0 0 if (cipherSpecLen > 0 && (cipherSpec == NULL || cipherSpec[0] == 0))
96 0 11156 if (options == NULL)
117 11156 0 if (cipherSpec != NULL && cipherSpec[0] != 0 && sid != NULL &&
11139 17 if (cipherSpec != NULL && cipherSpec[0] != 0 && sid != NULL &&
10520 619 if (cipherSpec != NULL && cipherSpec[0] != 0 && sid != NULL &&
509 10011 if (cipherSpec != NULL && cipherSpec[0] != 0 && sid != NULL &&
121 0 509 for (i = 0; i < cipherSpecLen; i++)
123 0 0 if (cipherSpec[i] == sid->cipherId)
128 509 0 if (rc)
137 0 11156 if ((rc = matrixSslNewSession(&lssl, keys, sid, options)) < 0)
143 0 11156 if (options->clientRejectVersionDowngrade)
149 0 11156 if (expectedName)
151 0 0 if (psX509ValidateGeneralName((char *) expectedName) < 0)
163 10127 1029 if (certCb)
168 0 11156 if (extCb)
185 0 11156 if ((rc = matrixSslEncodeClientHello(lssl, &tmp, cipherSpec, cipherSpecLen,
188 0 0 if (rc == SSL_FULL)
190 0 0 if ((tmp.buf = psRealloc(lssl->outbuf, len, lssl->bufferPool))
206 0 11156 psAssert(tmp.start == tmp.buf);
242 0 110023 if ((ses = psMalloc(pool, sizeof(sslSessionId_t))) == NULL)
264 0 110023 if (sess == NULL)
269 0 110023 if (sess->sessionTicket)
511 0 0 if ((rc = matrixSslNewServerSession(ssl, NULL, certCb, options)) < 0)
529 0 11158 if (!ssl)
533 0 11158 if (options == NULL)
544 0 11158 if (certCb)
547 0 0 if (matrixSslNewSession(&lssl, keys, NULL, options) < 0)
553 0 11158 else if (matrixSslNewSession(&lssl, keys, NULL, options) < 0)
574 0 11158 if (options->maxFragLen < 0)
581 0 11158 if (options->truncHmac < 0)
588 0 11158 if (options->extendedMasterSecret > 0)
597 0 0 if (lssl)
635 9678 0 if (!ssl || !buf)
0 9678 if (!ssl || !buf)
639 9678 0 psAssert(ssl && ssl->insize > 0 && ssl->inbuf != NULL);
9678 0 psAssert(ssl && ssl->insize > 0 && ssl->inbuf != NULL);
9678 0 psAssert(ssl && ssl->insize > 0 && ssl->inbuf != NULL);
655 0 0 if (!ssl || !buf)
0 0 if (!ssl || !buf)
659 0 0 psAssert(ssl && ssl->insize > 0 && ssl->inbuf != NULL);
0 0 psAssert(ssl && ssl->insize > 0 && ssl->inbuf != NULL);
0 0 psAssert(ssl && ssl->insize > 0 && ssl->inbuf != NULL);
661 0 0 if ((ssl->insize - ssl->inlen) >= size)
668 0 0 if (ssl->inlen == 0)
674 0 0 if ((ssl->inbuf = psMalloc(ssl->bufferPool, size)) == NULL)
686 0 0 if ((p = psRealloc(ssl->inbuf, ssl->inlen + size, ssl->bufferPool))
713 0 11841 if (!ssl)
717 11841 0 psAssert(ssl->outsize > 0 && ssl->outbuf != NULL);
11841 0 psAssert(ssl->outsize > 0 && ssl->outbuf != NULL);
718 11841 0 if (buf)
752 4125 0 if (!ssl || !buf)
0 4125 if (!ssl || !buf)
756 4125 0 psAssert(ssl->outsize > 0 && ssl->outbuf != NULL);
4125 0 psAssert(ssl->outsize > 0 && ssl->outbuf != NULL);
760 4123 2 if (!(ssl->flags & SSL_FLAGS_SERVER))
764 4123 0 if ((ssl->majVer == SSL3_MAJ_VER) && (ssl->minVer <= TLS_MIN_VER)
0 4123 if ((ssl->majVer == SSL3_MAJ_VER) && (ssl->minVer <= TLS_MIN_VER)
765 0 0 && (ssl->enBlockSize > 1) && (requestedLen > 1) &&
0 0 && (ssl->enBlockSize > 1) && (requestedLen > 1) &&
0 0 && (ssl->enBlockSize > 1) && (requestedLen > 1) &&
779 0 4125 if (requestedLen > (uint32) ssl->maxPtFrag)
796 0 4125 psAssert(requiredLen >= requestedLen);
814 0 4125 if (ssl->outsize < ssl->outlen)
823 2063 2062 if (sz < requiredLen)
825 0 2063 if ((p = psRealloc(ssl->outbuf, ssl->outsize +
835 0 2063 if (ssl->outsize < ssl->outlen)
846 4125 0 if (requestedLen <= (uint32) ssl->maxPtFrag)
849 0 4125 if (requestedLen > (uint32) ssl->maxPtFrag)
865 4125 0 if ((ssl->flags & SSL_FLAGS_WRITE_SECURE) &&
4125 0 if ((ssl->flags & SSL_FLAGS_WRITE_SECURE) &&
866 1 4124 (ssl->flags & SSL_FLAGS_TLS_1_1) && (ssl->enBlockSize > 1))
872 4124 0 if (ssl->flags & SSL_FLAGS_AEAD_W)
874 4124 0 *buf = ssl->outbuf + ssl->outlen + ssl->recordHeadLen +
881 0 0 if (ssl->bFlags & BFLAG_STOP_BEAST)
886 0 0 overhead = ((ssl->enMacSize + 1) % ssl->enBlockSize) ?
916 0 0 if (rc > 0)
940 0 0 if (!ssl || ((int32) len < 0))
0 0 if (!ssl || ((int32) len < 0))
944 0 0 if (ssl->bFlags & BFLAG_CLOSE_AFTER_SENT)
948 0 0 psAssert(ssl->outsize > 0 && ssl->outbuf != NULL);
0 0 psAssert(ssl->outsize > 0 && ssl->outbuf != NULL);
951 0 0 if (ssl->outbuf == NULL || (ssl->outsize - ssl->outlen) < (int32) len)
0 0 if (ssl->outbuf == NULL || (ssl->outsize - ssl->outlen) < (int32) len)
958 0 0 if (ssl->bFlags & BFLAG_STOP_BEAST)
960 0 0 rc = ((ssl->enMacSize + 1) % ssl->enBlockSize) ? ssl->enBlockSize : 0;
973 0 0 if ((ssl->flags & SSL_FLAGS_WRITE_SECURE) &&
0 0 if ((ssl->flags & SSL_FLAGS_WRITE_SECURE) &&
974 0 0 (ssl->flags & SSL_FLAGS_TLS_1_1) && (ssl->enBlockSize > 1))
978 0 0 if (ssl->flags & SSL_FLAGS_AEAD_W)
980 0 0 reserved += AEAD_NONCE_LEN(ssl);
986 0 0 if (rc < 0)
988 0 0 psAssert(rc != SSL_FULL); /* should not happen */
1016 4126 0 if (!ssl || !ptBuf)
0 4126 if (!ssl || !ptBuf)
1020 1 4125 if (ssl->bFlags & BFLAG_CLOSE_AFTER_SENT)
1038 4125 4124 while (len > 0)
1041 0 4125 if ((rc = matrixSslGetWritebuf(ssl, &internalBuf, len)) < 0)
1048 4125 0 psAssert(ssl->outsize > 0 && ssl->outbuf != NULL);
4125 0 psAssert(ssl->outsize > 0 && ssl->outbuf != NULL);
1050 4125 0 if (ssl->outbuf == NULL ||
0 4125 if (ssl->outbuf == NULL ||
1059 1 4124 if (rc < 0)
1061 0 1 psAssert(rc != SSL_FULL); /* should not happen */
1087 8540 6477 if (inOrOut == SSL_INBUF)
1101 2064 6476 if (ssl->insize > defaultSize && ssl->inlen < defaultSize)
2064 0 if (ssl->insize > defaultSize && ssl->inlen < defaultSize)
1104 2064 0 if ((p = psRealloc(ssl->inbuf, defaultSize, ssl->bufferPool))
1126 1025 5452 if (ssl->outsize > defaultSize && ssl->outlen < defaultSize)
1025 0 if (ssl->outsize > defaultSize && ssl->outlen < defaultSize)
1129 1025 0 if ((p = psRealloc(ssl->outbuf, defaultSize, ssl->bufferPool))
1153 10699 0 if (!ssl || !ptbuf || !ptlen)
10699 0 if (!ssl || !ptbuf || !ptlen)
0 10699 if (!ssl || !ptbuf || !ptlen)
1158 10699 0 psAssert(ssl->outsize > 0 && ssl->outbuf != NULL);
10699 0 psAssert(ssl->outsize > 0 && ssl->outbuf != NULL);
1159 10699 0 psAssert(ssl->insize > 0 && ssl->inbuf != NULL);
10699 0 psAssert(ssl->insize > 0 && ssl->inbuf != NULL);
1163 0 10699 if (ssl->inlen == 0)
1171 6194 10949 if (matrixSslHandshakeIsComplete(ssl))
1181 0 17143 if (sanity-- < 0)
1203 6440 1061 if (ssl->inlen > 0)
1205 0 6440 psAssert(buf > ssl->inbuf);
1219 1061 0 if (!(ssl->bFlags & BFLAG_HS_COMPLETE))
1221 1060 1 if (matrixSslHandshakeIsComplete(ssl))
1278 0 3356 if ((ssl->flags & SSL_FLAGS_FALSE_START) && buf != prevBuf)
0 0 if ((ssl->flags & SSL_FLAGS_FALSE_START) && buf != prevBuf)
1281 0 0 psAssert(ssl->inlen > 0);
1282 0 0 psAssert((uint32) ssl->inlen == start);
1283 0 0 psAssert(buf > ssl->inbuf);
1298 90 3266 if (alertDesc != SSL_ALERT_NONE)
1302 0 3356 psAssert(prevBuf == buf);
1303 0 3356 psAssert(ssl->insize >= (int32) len);
1304 0 3356 psAssert(start == 0);
1305 0 3356 psAssert(buf == ssl->inbuf);
1306 0 3356 if (ssl->outlen > 0)
1313 0 0 if (ssl->outlen + (int32) len > ssl->outsize)
1315 0 0 if ((p = psRealloc(ssl->outbuf, ssl->outlen + len,
1345 1 90 if (alertLevel == SSL_ALERT_LEVEL_FATAL)
1364 1 90 if ((ssl->flags & SSL_FLAGS_READ_SECURE) &&
1 0 if ((ssl->flags & SSL_FLAGS_READ_SECURE) &&
1365 0 1 (ssl->flags & SSL_FLAGS_TLS_1_1) && (ssl->enBlockSize > 1))
1370 0 91 psAssert(len == 2);
1377 0 2068 if (reqLen > SSL_MAX_BUF_SIZE)
1381 2064 4 if (reqLen > (uint32) ssl->insize)
1383 0 2064 if ((p = psRealloc(ssl->inbuf, reqLen, ssl->bufferPool)) == NULL)
1398 0 4 if (reqLen > SSL_MAX_BUF_SIZE)
1406 0 0 if (reqLen > SSL_MAX_PLAINTEXT_LEN)
1418 4 0 if (reqLen > (uint32) ssl->insize)
1421 0 4 if ((p = psRealloc(ssl->inbuf, reqLen, ssl->bufferPool)) == NULL)
1459 0 4123 psAssert((uint32) ssl->inlen == start);
1467 0 4123 psAssert(ssl->enBlockSize == ssl->deBlockSize);
1468 4123 0 if ((ssl->flags & SSL_FLAGS_READ_SECURE) &&
4123 0 if ((ssl->flags & SSL_FLAGS_READ_SECURE) &&
1469 1 4122 (ssl->flags & SSL_FLAGS_TLS_1_1) && (ssl->deBlockSize > 1))
1500 2068 4417 if (ssl->inlen > 0 && (buf != ssl->inbuf))
0 2068 if (ssl->inlen > 0 && (buf != ssl->inbuf))
1509 4417 2068 if (decodeRet != SSL_PARTIAL)
1535 4123 0 if (!ssl || !ptbuf || !ptlen)
4123 0 if (!ssl || !ptbuf || !ptlen)
0 4123 if (!ssl || !ptbuf || !ptlen)
1542 4123 0 psAssert(ssl->insize > 0 && ssl->inbuf != NULL);
4123 0 psAssert(ssl->insize > 0 && ssl->inbuf != NULL);
1544 1021 3102 if (ssl->inlen > 0)
1547 1021 0 if (ssl->flags & SSL_FLAGS_AEAD_R)
1551 0 1021 ctlen += AEAD_TAG_LEN(ssl) + AEAD_NONCE_LEN(ssl);
1021 0 ctlen += AEAD_TAG_LEN(ssl) + AEAD_NONCE_LEN(ssl);
1559 1021 3102 if (ssl->inlen > 0)
1580 0 1 if (!ssl)
1584 1 0 psAssert(ssl->outsize > 0 && ssl->outbuf != NULL);
1 0 psAssert(ssl->outsize > 0 && ssl->outbuf != NULL);
1590 1 0 if (!(ssl->bFlags & BFLAG_CLOSE_AFTER_SENT))
1597 0 1 if (rc == SSL_FULL && newLen == 0)
0 0 if (rc == SSL_FULL && newLen == 0)
1600 0 0 if ((p = psRealloc(ssl->outbuf, newLen, ssl->bufferPool)) == NULL)
1608 0 1 else if (rc != PS_SUCCESS)
1646 0 8 if (!ssl)
1650 2 6 if (cipherSpecLen > 0 && (cipherSpec == NULL || cipherSpec[0] == 0))
2 0 if (cipherSpecLen > 0 && (cipherSpec == NULL || cipherSpec[0] == 0))
0 2 if (cipherSpecLen > 0 && (cipherSpec == NULL || cipherSpec[0] == 0))
1654 0 8 if (ssl->bFlags & BFLAG_CLOSE_AFTER_SENT)
1658 8 0 psAssert(ssl->outsize > 0 && ssl->outbuf != NULL);
8 0 psAssert(ssl->outsize > 0 && ssl->outbuf != NULL);
1675 3 5 if (sessionOption == SSL_OPTION_FULL_HANDSHAKE)
1684 2 6 if (keys != NULL)
1691 2 6 if (certCb != NULL)
1702 0 2 if (ssl->flags & SSL_FLAGS_SERVER)
1713 8 0 if (!(ssl->flags & SSL_FLAGS_SERVER))
1716 2 6 if (cipherSpecLen > 0)
1719 2 2 for (i = 0; i < cipherSpecLen; i++)
1721 0 2 if (cipherSpec[i] == ssl->cipher->ident)
1727 2 6 if (rc)
1747 0 8 if (ssl->flags & SSL_FLAGS_SERVER)
1751 0 0 if ((rc = matrixSslEncodeHelloRequest(ssl, &sbuf, &reqLen)) < 0)
1753 0 0 if (rc == SSL_FULL && newLen == 0)
0 0 if (rc == SSL_FULL && newLen == 0)
1756 0 0 if (newLen < SSL_MAX_BUF_SIZE)
1758 0 0 if ((p = psRealloc(ssl->outbuf, newLen, ssl->bufferPool))
1780 8 0 if (ssl->extFlags.extended_master_secret == 1)
1790 1 7 if ((rc = matrixSslEncodeClientHello(ssl, &sbuf, cipherSpec,
1793 0 1 if (rc == SSL_FULL && newLen == 0)
0 0 if (rc == SSL_FULL && newLen == 0)
1796 0 0 if (newLen < SSL_MAX_BUF_SIZE)
1798 0 0 if ((p = psRealloc(ssl->outbuf, newLen, ssl->bufferPool))
1820 0 0 if (ssl == NULL)
1830 0 0 if (ssl == NULL)
1841 0 0 if (ssl)
1850 0 0 if (ssl)
1853 0 0 if (ssl->rehandshakeCount >= 0)
1855 0 0 if ((ssl->rehandshakeCount + credits) < 0x8000)
1893 0 6568 if (!ssl)
1897 0 6568 if (bytes == 0)
1899 0 0 if (ssl->outlen > 0)
1908 6568 0 psAssert(ssl->outsize > 0 && ssl->outbuf != NULL);
6568 0 psAssert(ssl->outsize > 0 && ssl->outbuf != NULL);
1912 0 6568 if (ssl->outlen > 0)
1941 6568 0 if ((ssl->outlen == 0) && (ssl->bFlags & BFLAG_CLOSE_AFTER_SENT))
91 6477 if ((ssl->outlen == 0) && (ssl->bFlags & BFLAG_CLOSE_AFTER_SENT))