diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-18 18:56:34 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-18 18:56:34 +0000 |
commit | 5285d9763b1680e6344425ec29e3c92e8bfc9b3d (patch) | |
tree | fa0d67ea7578fb6c7ee34e644222b5d2cf768e55 /net/third_party/nss/ssl/ssl.h | |
parent | c6e6617d80159e7c1dbf00ebf44f82b52f89f4ff (diff) | |
download | chromium_src-5285d9763b1680e6344425ec29e3c92e8bfc9b3d.zip chromium_src-5285d9763b1680e6344425ec29e3c92e8bfc9b3d.tar.gz chromium_src-5285d9763b1680e6344425ec29e3c92e8bfc9b3d.tar.bz2 |
net: rework the NPN patch.
This change moves the protocol selection logic out of NSS and into Chromium
code. This allows some things to be a little cleaner (no more wire-encoded NPN
strings) and also allows for some tricks that we have been considering for
SPDY+WebSockets.
As a consequence of this change, next protocols are now a
std::vector<std::string> rather than an encoded char*
BUG=none
TEST=SPDY still works with Google sites.
Review URL: http://codereview.chromium.org/8156001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106093 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/third_party/nss/ssl/ssl.h')
-rw-r--r-- | net/third_party/nss/ssl/ssl.h | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/net/third_party/nss/ssl/ssl.h b/net/third_party/nss/ssl/ssl.h index 03535f3..debfbfb 100644 --- a/net/third_party/nss/ssl/ssl.h +++ b/net/third_party/nss/ssl/ssl.h @@ -157,14 +157,53 @@ SSL_IMPORT SECStatus SSL_OptionSetDefault(PRInt32 option, PRBool on); SSL_IMPORT SECStatus SSL_OptionGetDefault(PRInt32 option, PRBool *on); SSL_IMPORT SECStatus SSL_CertDBHandleSet(PRFileDesc *fd, CERTCertDBHandle *dbHandle); +/* SSLNextProtoCallback is called, during the handshake, when the server has + * sent a Next Protocol Negotiation extension. |protos| and |protosLen| define + * a buffer which contains the server's advertisement. This data is guaranteed + * to be well formed per the NPN spec. |protoOut| is a buffer provided by the + * caller, of length 255 (the maximum allowed by the protocol). + * On successful return, the protocol to be announced to the server will be in + * |protoOut| and its length in |protoOutLen|. */ +typedef SECStatus (PR_CALLBACK *SSLNextProtoCallback)( + void *arg, + PRFileDesc *fd, + const unsigned char* protos, + unsigned int protosLen, + unsigned char* protoOut, + unsigned int* protoOutLen); + +/* SSL_SetNextProtoCallback sets a callback function to handle Next Protocol + * Negotiation. It causes a client to advertise NPN. */ +SSL_IMPORT SECStatus SSL_SetNextProtoCallback(PRFileDesc *fd, + SSLNextProtoCallback callback, + void *arg); + +/* SSL_SetNextProtoNego can be used as an alternative to + * SSL_SetNextProtoCallback. It also causes a client to advertise NPN and + * installs a default callback function which selects the first supported + * protocol in server-preference order. If no matching protocol is found it + * selects the first supported protocol. + * + * The supported protocols are specified in |data| in wire-format (8-bit + * length-prefixed). For example: "\010http/1.1\006spdy/2". */ SSL_IMPORT SECStatus SSL_SetNextProtoNego(PRFileDesc *fd, const unsigned char *data, - unsigned short length); + unsigned int length); +/* SSL_GetNextProto can be used after a handshake on a socket where + * SSL_SetNextProtoNego was called to retrieve the result of the Next Protocol + * negotiation. + * + * state is set to one of the SSL_NEXT_PROTO_* constants. The negotiated + * protocol, if any, is written into buf, which must be at least buf_len bytes + * long. If the negotiated protocol is longer than this, it is truncated. The + * number of bytes copied is written into *length. */ SSL_IMPORT SECStatus SSL_GetNextProto(PRFileDesc *fd, int *state, unsigned char *buf, - unsigned *length, - unsigned buf_len); + unsigned int *length, + unsigned int buf_len); + +// TODO(wtc): it may be a good idea to define these as an enum type. #define SSL_NEXT_PROTO_NO_SUPPORT 0 /* No peer support */ #define SSL_NEXT_PROTO_NEGOTIATED 1 /* Mutual agreement */ #define SSL_NEXT_PROTO_NO_OVERLAP 2 /* No protocol overlap found */ |