Plan 9 from Bell Labs’s /usr/web/sources/contrib/mospak/tls-1.2/tls-min-version-tls12.diff

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


--- sys/src/libsec/port/tlshand.c
+++ sys/src/libsec/port/tlshand.c
@@ -180,7 +180,12 @@ enum {
 	TLS11Version = 0x0302,
 	TLS12Version = 0x0303,
 	ProtocolVersion = TLS12Version,	// maximum version we speak
-	MinProtoVersion = 0x0300,	// limits on version we accept
+	/*
+	 * RFC 8996 (BCP 195) Sections 4 and 5: TLS 1.0 and TLS 1.1 must
+	 * not be negotiated from any version.  SSL 3.0 is refused in
+	 * setVersion, so this floor is what rules out the other two.
+	 */
+	MinProtoVersion = 0x0303,	// limits on version we accept
 	MaxProtoVersion	= 0x03ff,
 };
 
@@ -663,7 +668,8 @@ tlsServer2(int ctl, int hand, TLSconn *conn)
 	if(trace)
 		trace("ClientHello version %x\n", c->clientVersion);
 	if(setVersion(c, m.u.clientHello.version) < 0) {
-		tlsError(c, EIllegalParameter, "incompatible version");
+		/* RFC 8996 Sections 4 and 5 name this alert specifically */
+		tlsError(c, EProtocolVersion, "incompatible version");
 		goto Err;
 	}
 
@@ -1071,7 +1077,7 @@ tlsClient2(int ctl, int hand, uchar *csid, int ncsid, 
 		goto Err;
 	}
 	if(setVersion(c, m.u.serverHello.version) < 0) {
-		tlsError(c, EIllegalParameter, "incompatible version %r");
+		tlsError(c, EProtocolVersion, "incompatible version %r");
 		goto Err;
 	}
 	memmove(c->srandom, m.u.serverHello.random, RandomSize);
@@ -2148,8 +2154,6 @@ setVersion(TlsConnection *c, int version)
 	case SSL3Version:
 		c->finished.n = SSL3FinishedLen;
 		return -1;
-	case TLS10Version:
-	case TLS11Version:
 	case TLS12Version:
 		c->finished.n = TLSFinishedLen;
 		break;
@@ -3858,12 +3862,6 @@ setVers(TlsSec *sec, int v)
 		sec->setFinished = sslSetFinished;
 		sec->nfin = SSL3FinishedLen;
 		sec->prf = sslPRF;
-		break;
-	case TLS10Version:
-	case TLS11Version:
-		sec->setFinished = tlsSetFinished;
-		sec->nfin = TLSFinishedLen;
-		sec->prf = tlsPRF;
 		break;
 	case TLS12Version:
 		sec->setFinished = tls12SetFinished;

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.