~ubuntu-branches/ubuntu/raring/nss/raring-security

« back to all changes in this revision

Viewing changes to mozilla/security/nss/lib/ssl/sslinfo.c

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson
  • Date: 2010-03-25 13:46:06 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20100325134606-bl6liuok2w9l7snv
Tags: 3.12.6-0ubuntu1
* New upstream release 3.12.6 RTM (NSS_3_12_6_RTM)
  - fixes CVE-2009-3555 aka US-CERT VU#120541
* Adjust patches to changed upstream code base
  - update debian/patches/38_kbsd.patch
  - update debian/patches/38_mips64_build.patch
  - update debian/patches/85_security_load.patch
* Remove patches that are merged upstream
  - delete debian/patches/91_nonexec_stack.patch
  - update debian/patches/series
* Bump nspr dependency to 4.8
  - update debian/control
* Add new symbols for 3.12.6
  - update debian/libnss3-1d.symbols

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 * the terms of any one of the MPL, the GPL or the LGPL.
35
35
 *
36
36
 * ***** END LICENSE BLOCK ***** */
37
 
/* $Id: sslinfo.c,v 1.18 2008/12/17 06:09:19 nelson%bolyard.com Exp $ */
 
37
/* $Id: sslinfo.c,v 1.23 2010/01/15 01:49:33 alexei.volkov.bugs%sun.com Exp $ */
38
38
#include "ssl.h"
39
39
#include "sslimpl.h"
40
40
#include "sslproto.h"
41
41
 
 
42
static const char *
 
43
ssl_GetCompressionMethodName(SSLCompressionMethod compression)
 
44
{
 
45
    switch (compression) {
 
46
    case ssl_compression_null:
 
47
        return "NULL";
 
48
#ifdef NSS_ENABLE_ZLIB
 
49
    case ssl_compression_deflate:
 
50
        return "DEFLATE";
 
51
#endif
 
52
    default:
 
53
        return "???";
 
54
    }
 
55
}
 
56
 
42
57
SECStatus 
43
58
SSL_GetChannelInfo(PRFileDesc *fd, SSLChannelInfo *info, PRUintn len)
44
59
{
67
82
        inf.authKeyBits      = ss->sec.authKeyBits;
68
83
        inf.keaKeyBits       = ss->sec.keaKeyBits;
69
84
        if (ss->version < SSL_LIBRARY_VERSION_3_0) { /* SSL2 */
70
 
            inf.cipherSuite      = ss->sec.cipherType | 0xff00;
 
85
            inf.cipherSuite           = ss->sec.cipherType | 0xff00;
 
86
            inf.compressionMethod     = ssl_compression_null;
 
87
            inf.compressionMethodName = "N/A";
71
88
        } else if (ss->ssl3.initialized) {      /* SSL3 and TLS */
72
 
 
73
 
            /* XXX  These should come from crSpec */
74
 
            inf.cipherSuite      = ss->ssl3.hs.cipher_suite;
 
89
            ssl_GetSpecReadLock(ss);
 
90
            /* XXX  The cipher suite should be in the specs and this
 
91
             * function should get it from crSpec rather than from the "hs".
 
92
             * See bug 275744 comment 69.
 
93
             */
 
94
            inf.cipherSuite           = ss->ssl3.hs.cipher_suite;
 
95
            inf.compressionMethod     = ss->ssl3.crSpec->compression_method;
 
96
            ssl_ReleaseSpecReadLock(ss);
 
97
            inf.compressionMethodName =
 
98
                ssl_GetCompressionMethodName(inf.compressionMethod);
75
99
        }
76
100
        if (sid) {
77
101
            inf.creationTime   = sid->creationTime;
283
307
    }
284
308
    return PR_FALSE;
285
309
}
 
310
 
 
311
SECItem*
 
312
SSL_GetNegotiatedHostInfo(PRFileDesc *fd)
 
313
{
 
314
    SECItem *sniName = NULL;
 
315
    sslSocket *ss;
 
316
    char *name = NULL;
 
317
 
 
318
    ss = ssl_FindSocket(fd);
 
319
    if (!ss) {
 
320
        SSL_DBG(("%d: SSL[%d]: bad socket in SSL_GetNegotiatedHostInfo",
 
321
                 SSL_GETPID(), fd));
 
322
        return NULL;
 
323
    }
 
324
 
 
325
    if (ss->sec.isServer) {
 
326
        if (ss->version > SSL_LIBRARY_VERSION_3_0 &&
 
327
            ss->ssl3.initialized) { /* TLS */
 
328
            SECItem *crsName;
 
329
            ssl_GetSpecReadLock(ss); /*********************************/
 
330
            crsName = &ss->ssl3.crSpec->srvVirtName;
 
331
            if (crsName->data) {
 
332
                sniName = SECITEM_DupItem(crsName);
 
333
            }
 
334
            ssl_ReleaseSpecReadLock(ss); /*----------------------------*/
 
335
        }
 
336
        return sniName;
 
337
    } 
 
338
    name = SSL_RevealURL(fd);
 
339
    if (name) {
 
340
        sniName = PORT_ZNew(SECItem);
 
341
        if (!sniName) {
 
342
            PORT_Free(name);
 
343
            return NULL;
 
344
        }
 
345
        sniName->data = (void*)name;
 
346
        sniName->len  = PORT_Strlen(name);
 
347
    }
 
348
    return sniName;
 
349
}