SECStatus SSL_HandshakeNegotiatedExtension(PRFileDesc * socket, SSLExtensionType extId, PRBool *pYes) { /* some decisions derived from SSL_GetChannelInfo */ sslSocket * sslsocket = NULL; PRBool enoughFirstHsDone = PR_FALSE; if (!pYes) { PORT_SetError(SEC_ERROR_INVALID_ARGS); return SECFailure; } sslsocket = ssl_FindSocket(socket); if (!sslsocket) { SSL_DBG(("%d: SSL[%d]: bad socket in HandshakeNegotiatedExtension", SSL_GETPID(), socket)); return SECFailure; } *pYes = PR_FALSE; if (sslsocket->firstHsDone) { enoughFirstHsDone = PR_TRUE; } else if (sslsocket->ssl3.initialized && ssl3_CanFalseStart(sslsocket)) { enoughFirstHsDone = PR_TRUE; } /* according to public API SSL_GetChannelInfo, this doesn't need a lock */ if (sslsocket->opt.useSecurity && enoughFirstHsDone) { if (sslsocket->ssl3.initialized) { /* SSL3 and TLS */ /* now we know this socket went through ssl3_InitState() and * ss->xtnData got initialized, which is the only member accessed by * ssl3_ExtensionNegotiated(); * Member xtnData appears to get accessed in functions that handle * the handshake (hello messages and extension sending), * therefore the handshake lock should be sufficient. */ ssl_GetSSL3HandshakeLock(sslsocket); *pYes = ssl3_ExtensionNegotiated(sslsocket, extId); ssl_ReleaseSSL3HandshakeLock(sslsocket); } } return SECSuccess; }
PRBool SSLInt_ExtensionNegotiated(PRFileDesc *fd, PRUint16 ext) { sslSocket *ss = ssl_FindSocket(fd); return (PRBool)(ss && ssl3_ExtensionNegotiated(ss, ext)); }