summaryrefslogtreecommitdiff
path: root/lib/ssl/ssl3con.c
diff options
context:
space:
mode:
authorMartin Thomson <martin.thomson@gmail.com>2017-11-24 14:26:57 +1100
committerMartin Thomson <martin.thomson@gmail.com>2017-11-24 14:26:57 +1100
commit9be31fda8aaf8856e02befcaa1d64027a8eaf2ee (patch)
tree909f97d10771c6adeecbf7db020d33c0021863ac /lib/ssl/ssl3con.c
parentb05d7405b24ce950642d4c7dedffd4dc9ffe36ec (diff)
parent10888d7af3845441ddad47b4cba718876d6ca74d (diff)
downloadnss-hg-9be31fda8aaf8856e02befcaa1d64027a8eaf2ee.tar.gz
Merge NSS trunk to NSS_TLS13_DRAFT19_BRANCHNSS_TLS13_DRAFT19_BRANCH
Diffstat (limited to 'lib/ssl/ssl3con.c')
-rw-r--r--lib/ssl/ssl3con.c53
1 files changed, 24 insertions, 29 deletions
diff --git a/lib/ssl/ssl3con.c b/lib/ssl/ssl3con.c
index 9c9db093f..8513e7c1d 100644
--- a/lib/ssl/ssl3con.c
+++ b/lib/ssl/ssl3con.c
@@ -773,7 +773,7 @@ ssl_HasCert(const sslSocket *ss, SSLAuthType authType)
* regardless of policy or user preference.
* If this returns zero, the user cannot do SSL v3.
*/
-int
+unsigned int
ssl3_config_match_init(sslSocket *ss)
{
ssl3CipherSuiteCfg *suite;
@@ -782,9 +782,9 @@ ssl3_config_match_init(sslSocket *ss)
CK_MECHANISM_TYPE cipher_mech;
SSLAuthType authType;
SSLKEAType keaType;
- int i;
- int numPresent = 0;
- int numEnabled = 0;
+ unsigned int i;
+ unsigned int numPresent = 0;
+ unsigned int numEnabled = 0;
PORT_Assert(ss);
if (!ss) {
@@ -842,7 +842,7 @@ ssl3_config_match_init(sslSocket *ss)
}
}
PORT_Assert(numPresent > 0 || numEnabled == 0);
- if (numPresent <= 0) {
+ if (numPresent == 0) {
PORT_SetError(SSL_ERROR_NO_CIPHERS_SUPPORTED);
}
return numPresent;
@@ -887,10 +887,10 @@ config_match(const ssl3CipherSuiteCfg *suite, int policy,
/* Return the number of cipher suites that are usable. */
/* called from ssl3_SendClientHello */
-static int
+static unsigned int
count_cipher_suites(sslSocket *ss, int policy)
{
- int i, count = 0;
+ unsigned int i, count = 0;
if (SSL_ALL_VERSIONS_DISABLED(&ss->vrange)) {
return 0;
@@ -899,7 +899,7 @@ count_cipher_suites(sslSocket *ss, int policy)
if (config_match(&ss->cipherSuites[i], policy, &ss->vrange, ss))
count++;
}
- if (count <= 0) {
+ if (count == 0) {
PORT_SetError(SSL_ERROR_SSL_DISABLED);
}
return count;
@@ -4518,9 +4518,9 @@ ssl3_SendClientHello(sslSocket *ss, sslClientHelloType type)
sslSessionID *sid;
SECStatus rv;
unsigned int i;
- int length;
- int num_suites;
- int actual_count = 0;
+ unsigned int length;
+ unsigned int num_suites;
+ unsigned int actual_count = 0;
PRBool isTLS = PR_FALSE;
PRBool requestingResume = PR_FALSE, fallbackSCSV = PR_FALSE;
PRBool unlockNeeded = PR_FALSE;
@@ -4565,8 +4565,7 @@ ssl3_SendClientHello(sslSocket *ss, sslClientHelloType type)
ss->ssl3.hs.receivedNewSessionTicket = PR_FALSE;
/* How many suites does our PKCS11 support (regardless of policy)? */
- num_suites = ssl3_config_match_init(ss);
- if (!num_suites) {
+ if (ssl3_config_match_init(ss) == 0) {
return SECFailure; /* ssl3_config_match_init has set error code. */
}
@@ -6090,11 +6089,9 @@ SECStatus
ssl_ClientSetCipherSuite(sslSocket *ss, SSL3ProtocolVersion version,
ssl3CipherSuite suite, PRBool initHashes)
{
- int i;
-
- i = ssl3_config_match_init(ss);
- PORT_Assert(i > 0);
- if (i <= 0) {
+ unsigned int i;
+ if (ssl3_config_match_init(ss) == 0) {
+ PORT_Assert(PR_FALSE);
return SECFailure;
}
for (i = 0; i < ssl_V3_SUITES_IMPLEMENTED; i++) {
@@ -7722,7 +7719,6 @@ ssl3_ServerCallSNICallback(sslSocket *ss)
* and save the name. */
SECStatus rv;
SECItem *name = &ss->xtnData.sniNameArr[ret];
- int configedCiphers;
SECItem *pwsName;
/* get rid of the old name and save the newly picked. */
@@ -7751,8 +7747,7 @@ ssl3_ServerCallSNICallback(sslSocket *ss)
ret = SSL_SNI_SEND_ALERT;
break;
}
- configedCiphers = ssl3_config_match_init(ss);
- if (configedCiphers <= 0) {
+ if (ssl3_config_match_init(ss) == 0) {
/* no ciphers are working/supported */
errCode = PORT_GetError();
desc = handshake_failure;
@@ -8368,7 +8363,7 @@ ssl3_HandleClientHelloPart2(sslSocket *ss,
#ifndef PARANOID
/* Look for a matching cipher suite. */
- if (ssl3_config_match_init(ss) <= 0) {
+ if (ssl3_config_match_init(ss) == 0) {
desc = internal_error;
errCode = PORT_GetError(); /* error code is already set. */
goto alert_loser;
@@ -8625,11 +8620,11 @@ ssl3_HandleV2ClientHello(sslSocket *ss, unsigned char *buffer, int length,
unsigned char *random;
SSL3ProtocolVersion version;
SECStatus rv;
- int i;
- int j;
- int sid_length;
- int suite_length;
- int rand_length;
+ unsigned int i;
+ unsigned int j;
+ unsigned int sid_length;
+ unsigned int suite_length;
+ unsigned int rand_length;
int errCode = SSL_ERROR_RX_MALFORMED_CLIENT_HELLO;
SSL3AlertDescription desc = handshake_failure;
unsigned int total = SSL_HL_CLIENT_HELLO_HBYTES;
@@ -8709,8 +8704,8 @@ ssl3_HandleV2ClientHello(sslSocket *ss, unsigned char *buffer, int length,
PRINT_BUF(60, (ss, "client random:", ss->ssl3.hs.client_random,
SSL3_RANDOM_LENGTH));
- i = ssl3_config_match_init(ss);
- if (i <= 0) {
+
+ if (ssl3_config_match_init(ss) == 0) {
errCode = PORT_GetError(); /* error code is already set. */
goto alert_loser;
}