Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
ssl3ecc.c File Reference
#include "nssrenam.h"
#include "nss.h"
#include "cert.h"
#include "ssl.h"
#include "cryptohi.h"
#include "keyhi.h"
#include "secder.h"
#include "secitem.h"
#include "sslimpl.h"
#include "sslproto.h"
#include "sslerr.h"
#include "prtime.h"
#include "prinrval.h"
#include "prerror.h"
#include "pratom.h"
#include "prthread.h"
#include "prinit.h"
#include "pk11func.h"
#include "secmod.h"
#include "nsslocks.h"
#include "ec.h"
#include "blapi.h"
#include <stdio.h>

Go to the source code of this file.

Functions

PRInt32 ssl3_SendServerNameIndicationExtension (sslSocket *ss, PRBool append, PRUint32 maxBytes)
SECStatus ssl3_HandleServerNameIndicationExtension (sslSocket *ss, PRUint16 ex_type, SECItem *data)
SECStatus ssl3_HandleClientHelloExtensions (sslSocket *ss, SSL3Opaque **b, PRUint32 *length)
SECStatus ssl3_RegisterServerHelloExtensionSender (sslSocket *ss, PRUint16 ex_type, ssl3HelloExtensionSenderFunc cb)
PRInt32 ssl3_CallHelloExtensionSenders (sslSocket *ss, PRBool append, PRUint32 maxBytes, const ssl3HelloExtensionSender *sender)

Variables

static const
ssl3HelloExtensionHandler 
handlers []
static const
ssl3HelloExtensionSender 
clientHelloSenders [MAX_EXTENSION_SENDERS]

Function Documentation

PRInt32 ssl3_CallHelloExtensionSenders ( sslSocket *  ss,
PRBool  append,
PRUint32  maxBytes,
const ssl3HelloExtensionSender sender 
)

Definition at line 1358 of file ssl3ecc.c.

{
    PRInt32 total_exten_len = 0;
    int i;

    if (!sender)
       sender = &clientHelloSenders[0];

    for (i = 0; i < MAX_EXTENSION_SENDERS; ++i, ++sender) {
       if (sender->ex_sender) {
           PRInt32 extLen = (*sender->ex_sender)(ss, append, maxBytes);
           if (extLen < 0)
              return -1;
           maxBytes        -= extLen;
           total_exten_len += extLen;
       }
    }
    return total_exten_len;
}
SECStatus ssl3_HandleClientHelloExtensions ( sslSocket *  ss,
SSL3Opaque **  b,
PRUint32 length 
)

Definition at line 1292 of file ssl3ecc.c.

{
    while (*length) {
       const ssl3HelloExtensionHandler * handler;
       SECStatus rv;
       PRInt32   extension_type;
       SECItem   extension_data;

       /* Get the extension's type field */
       extension_type = ssl3_ConsumeHandshakeNumber(ss, 2, b, length);
       if (extension_type < 0)  /* failure to decode extension_type */
           return SECFailure;   /* alert already sent */

       /* get the data for this extension, so we can pass it or skip it. */
       rv = ssl3_ConsumeHandshakeVariable(ss, &extension_data, 2, b, length);
       if (rv != SECSuccess)
           return rv;

       /* find extension_type in table of Client Hello Extension Handlers */
       for (handler = handlers; handler->ex_type >= 0; handler++) {
           if (handler->ex_type == extension_type)
               break;
       }

       /* if found,  Call this handler */
       if (handler->ex_type == extension_type) {
           rv = (*handler->ex_handler)(ss, (PRUint16)extension_type, 
                                                    &extension_data);
           /* Ignore this result */
           /* Essentially, treat all bad extensions as unrecognized types. */
       }
    }
    return SECSuccess;
}

Here is the call graph for this function:

SECStatus ssl3_HandleServerNameIndicationExtension ( sslSocket *  ss,
PRUint16  ex_type,
SECItem *  data 
)

Definition at line 1250 of file ssl3ecc.c.

{
    /* For now, we ignore this, as if we didn't understand it. :-)  */
    return SECSuccess;
}

Definition at line 1332 of file ssl3ecc.c.

{
    int i;
    ssl3HelloExtensionSender *sender = &ss->serverExtensionSenders[0];

    for (i = 0; i < MAX_EXTENSION_SENDERS; ++i, ++sender) {
        if (!sender->ex_sender) {
           sender->ex_type   = ex_type;
           sender->ex_sender = cb;
           return SECSuccess;
       }
       /* detect duplicate senders */
       PORT_Assert(sender->ex_type != ex_type);
       if (sender->ex_type == ex_type) {
           /* duplicate */
           break;
       }
    }
    PORT_Assert(i < MAX_EXTENSION_SENDERS); /* table needs to grow */
    PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
    return SECFailure;
}

Here is the call graph for this function:

PRInt32 ssl3_SendServerNameIndicationExtension ( sslSocket *  ss,
PRBool  append,
PRUint32  maxBytes 
)

Definition at line 1211 of file ssl3ecc.c.

{
    PRUint32 len, span;
    /* must have a hostname */
    if (!ss || !ss->url || !ss->url[0])
       return 0;
    /* must have at lest one character other than [0-9\.] */
    len  = PORT_Strlen(ss->url);
    span = strspn(ss->url, "0123456789.");
    if (len == span) {
       /* is a dotted decimal IP address */
       return 0;
    }
    if (append && maxBytes >= len + 9) {
       SECStatus rv;
       /* extension_type */
       rv = ssl3_AppendHandshakeNumber(ss,       0, 2); 
       if (rv != SECSuccess) return 0;
       /* length of extension_data */
       rv = ssl3_AppendHandshakeNumber(ss, len + 5, 2); 
       if (rv != SECSuccess) return 0;
       /* length of server_name_list */
       rv = ssl3_AppendHandshakeNumber(ss, len + 3, 2);
       if (rv != SECSuccess) return 0;
       /* Name Type (host_name) */
       rv = ssl3_AppendHandshake(ss,       "\0",    1);
       if (rv != SECSuccess) return 0;
       /* HostName (length and value) */
       rv = ssl3_AppendHandshakeVariable(ss, ss->url, len, 2);
       if (rv != SECSuccess) return 0;
    }
    return len + 9;
}

Here is the call graph for this function:


Variable Documentation

Initial value:

Definition at line 1276 of file ssl3ecc.c.

Initial value:

Definition at line 1261 of file ssl3ecc.c.