~ubuntu-branches/ubuntu/karmic/openssl/karmic-proposed

« back to all changes in this revision

Viewing changes to ssl/ssl_lib.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-12-05 00:13:39 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20071205001339-tazlol313zs8u6ec
Tags: 0.9.8g-3ubuntu1
* Merge with Debian; remaining changes:
  - Configure: Add support for lpia.
  - Replace duplicate files in the doc directory with symlinks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
125
125
#include <openssl/objects.h>
126
126
#include <openssl/lhash.h>
127
127
#include <openssl/x509v3.h>
 
128
#include <openssl/rand.h>
128
129
#ifndef OPENSSL_NO_DH
129
130
#include <openssl/dh.h>
130
131
#endif
306
307
 
307
308
        CRYPTO_add(&ctx->references,1,CRYPTO_LOCK_SSL_CTX);
308
309
        s->ctx=ctx;
309
 
 
 
310
#ifndef OPENSSL_NO_TLSEXT
 
311
        s->tlsext_debug_cb = 0;
 
312
        s->tlsext_debug_arg = NULL;
 
313
        s->tlsext_ticket_expected = 0;
 
314
        CRYPTO_add(&ctx->references,1,CRYPTO_LOCK_SSL_CTX);
 
315
        s->initial_ctx=ctx;
 
316
#endif
310
317
        s->verify_result=X509_V_OK;
311
318
 
312
319
        s->method=ctx->method;
492
499
        /* Free up if allocated */
493
500
 
494
501
        if (s->ctx) SSL_CTX_free(s->ctx);
495
 
 
 
502
#ifndef OPENSSL_NO_TLSEXT
 
503
        if (s->initial_ctx) SSL_CTX_free(s->initial_ctx);
 
504
#endif
496
505
        if (s->client_CA != NULL)
497
506
                sk_X509_NAME_pop_free(s->client_CA,X509_NAME_free);
498
507
 
1304
1313
        return(NULL);
1305
1314
        }
1306
1315
 
 
1316
#ifndef OPENSSL_NO_TLSEXT
 
1317
/** return a servername extension value if provided in Client Hello, or NULL.
 
1318
 * So far, only host_name types are defined (RFC 3546).
 
1319
 */
 
1320
 
 
1321
const char *SSL_get_servername(const SSL *s, const int type)
 
1322
        {
 
1323
        if (type != TLSEXT_NAMETYPE_host_name)
 
1324
                return NULL;
 
1325
 
 
1326
        return s->session && !s->tlsext_hostname ?
 
1327
                s->session->tlsext_hostname :
 
1328
                s->tlsext_hostname;
 
1329
        }
 
1330
 
 
1331
int SSL_get_servername_type(const SSL *s)
 
1332
        {
 
1333
        if (s->session && (!s->tlsext_hostname ? s->session->tlsext_hostname : s->tlsext_hostname))
 
1334
                return TLSEXT_NAMETYPE_host_name;
 
1335
        return -1;
 
1336
        }
 
1337
#endif
 
1338
 
1307
1339
unsigned long SSL_SESSION_hash(const SSL_SESSION *a)
1308
1340
        {
1309
1341
        unsigned long l;
1453
1485
        ret->extra_certs=NULL;
1454
1486
        ret->comp_methods=SSL_COMP_get_compression_methods();
1455
1487
 
 
1488
#ifndef OPENSSL_NO_TLSEXT
 
1489
        ret->tlsext_servername_callback = 0;
 
1490
        ret->tlsext_servername_arg = NULL;
 
1491
        /* Setup RFC4507 ticket keys */
 
1492
        if ((RAND_pseudo_bytes(ret->tlsext_tick_key_name, 16) <= 0)
 
1493
                || (RAND_bytes(ret->tlsext_tick_hmac_key, 16) <= 0)
 
1494
                || (RAND_bytes(ret->tlsext_tick_aes_key, 16) <= 0))
 
1495
                ret->options |= SSL_OP_NO_TICKET;
 
1496
 
 
1497
#endif
 
1498
 
1456
1499
        return(ret);
1457
1500
err:
1458
1501
        SSLerr(SSL_F_SSL_CTX_NEW,ERR_R_MALLOC_FAILURE);
2402
2445
        return(ssl->ctx);
2403
2446
        }
2404
2447
 
 
2448
SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX* ctx)
 
2449
        {
 
2450
        if (ssl->ctx == ctx)
 
2451
                return ssl->ctx;
 
2452
#ifndef OPENSSL_NO_TLSEXT
 
2453
        if (ctx == NULL)
 
2454
                ctx = ssl->initial_ctx;
 
2455
#endif
 
2456
        if (ssl->cert != NULL)
 
2457
                ssl_cert_free(ssl->cert);
 
2458
        ssl->cert = ssl_cert_dup(ctx->cert);
 
2459
        CRYPTO_add(&ctx->references,1,CRYPTO_LOCK_SSL_CTX);
 
2460
        if (ssl->ctx != NULL)
 
2461
                SSL_CTX_free(ssl->ctx); /* decrement reference count */
 
2462
        ssl->ctx = ctx;
 
2463
        return(ssl->ctx);
 
2464
        }
 
2465
 
2405
2466
#ifndef OPENSSL_NO_STDIO
2406
2467
int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx)
2407
2468
        {