-/*
- * Given a protocol version sent by peer, determine if we accept that version
- * and downgrade if appropriate (which can not be done for the client side).
- */
-OSStatus sslVerifyProtVersion(
- SSLContext *ctx,
- SSLProtocolVersion peerVersion, // sent by peer
- SSLProtocolVersion *negVersion) // final negotiated version if return success
-{
- if ((ctx->isDTLS)
- ? peerVersion > ctx->minProtocolVersion
- : peerVersion < ctx->minProtocolVersion) {
- return errSSLNegotiation;
- }
- if ((ctx->isDTLS)
- ? peerVersion < ctx->maxProtocolVersion
- : peerVersion > ctx->maxProtocolVersion) {
- if (ctx->protocolSide == kSSLClientSide) {
- return errSSLNegotiation;
- }
- *negVersion = ctx->maxProtocolVersion;
- } else {
- *negVersion = peerVersion;
- }
-
- return noErr;
-}
-
-/*
- * Determine max enabled protocol, i.e., the one we try to negotiate for.
- * Only returns an error (paramErr) if NO protocols are enabled, which can
- * in fact happen by malicious or ignorant use of SSLSetProtocolVersionEnabled().
- */
-OSStatus sslGetMaxProtVersion(
- SSLContext *ctx,
- SSLProtocolVersion *version) // RETURNED
-{
- /* This check is here until SSLSetProtocolVersionEnabled() is gone .*/
- if (ctx->maxProtocolVersion == SSL_Version_Undetermined)
- return badReqErr;
-
- *version = ctx->maxProtocolVersion;
- return noErr;
-}