Beispiel #1
0
int dtls1_new(SSL *s) {
  DTLS1_STATE *d1;

  if (!ssl3_new(s)) {
    return 0;
  }
  d1 = OPENSSL_malloc(sizeof *d1);
  if (d1 == NULL) {
    ssl3_free(s);
    return 0;
  }
  memset(d1, 0, sizeof *d1);

  d1->buffered_messages = pqueue_new();
  d1->sent_messages = pqueue_new();

  if (!d1->buffered_messages || !d1->sent_messages) {
    pqueue_free(d1->buffered_messages);
    pqueue_free(d1->sent_messages);
    OPENSSL_free(d1);
    ssl3_free(s);
    return 0;
  }

  s->d1 = d1;

  /* Set the version to the highest version for DTLS. This controls the initial
   * state of |s->enc_method| and what the API reports as the version prior to
   * negotiation.
   *
   * TODO(davidben): This is fragile and confusing. */
  s->version = DTLS1_2_VERSION;
  return 1;
}
Beispiel #2
0
int dtls1_new(SSL *ssl) {
  DTLS1_STATE *d1;

  if (!ssl3_new(ssl)) {
    return 0;
  }
  d1 = OPENSSL_malloc(sizeof *d1);
  if (d1 == NULL) {
    ssl3_free(ssl);
    return 0;
  }
  memset(d1, 0, sizeof *d1);

  d1->buffered_messages = pqueue_new();
  d1->sent_messages = pqueue_new();

  if (!d1->buffered_messages || !d1->sent_messages) {
    pqueue_free(d1->buffered_messages);
    pqueue_free(d1->sent_messages);
    OPENSSL_free(d1);
    ssl3_free(ssl);
    return 0;
  }

  ssl->d1 = d1;

  /* Set the version to the highest supported version.
   *
   * TODO(davidben): Move this field into |s3|, have it store the normalized
   * protocol version, and implement this pre-negotiation quirk in |SSL_version|
   * at the API boundary rather than in internal state. */
  ssl->version = DTLS1_2_VERSION;
  return 1;
}
Beispiel #3
0
int
tls1_new(SSL *s)
{
	if (!ssl3_new(s))
		return (0);
	s->method->internal->ssl_clear(s);
	return (1);
}
Beispiel #4
0
int dtls1_new(SSL *s)
{
    DTLS1_STATE *d1;

    if (!ssl3_new(s))
        return (0);
    if ((d1 = OPENSSL_malloc(sizeof *d1)) == NULL)
        return (0);
    memset(d1, 0, sizeof *d1);

    /* d1->handshake_epoch=0; */
#if defined(OPENSSL_SYS_VMS) || defined(VMS_TEST)
    d1->bitmap.length = 64;
#else
    d1->bitmap.length = sizeof(d1->bitmap.map) * 8;
#endif
    pq_64bit_init(&(d1->bitmap.map));
    pq_64bit_init(&(d1->bitmap.max_seq_num));

    d1->next_bitmap.length = d1->bitmap.length;
    pq_64bit_init(&(d1->next_bitmap.map));
    pq_64bit_init(&(d1->next_bitmap.max_seq_num));

    d1->unprocessed_rcds.q = pqueue_new();
    d1->processed_rcds.q = pqueue_new();
    d1->buffered_messages = pqueue_new();
    d1->sent_messages = pqueue_new();
    d1->buffered_app_data.q = pqueue_new();

    if (s->server) {
        d1->cookie_len = sizeof(s->d1->cookie);
    }

    if (!d1->unprocessed_rcds.q || !d1->processed_rcds.q
        || !d1->buffered_messages || !d1->sent_messages
        || !d1->buffered_app_data.q) {
        if (d1->unprocessed_rcds.q)
            pqueue_free(d1->unprocessed_rcds.q);
        if (d1->processed_rcds.q)
            pqueue_free(d1->processed_rcds.q);
        if (d1->buffered_messages)
            pqueue_free(d1->buffered_messages);
        if (d1->sent_messages)
            pqueue_free(d1->sent_messages);
        if (d1->buffered_app_data.q)
            pqueue_free(d1->buffered_app_data.q);
        OPENSSL_free(d1);
        return (0);
    }

    s->d1 = d1;
    s->method->ssl_clear(s);
    return (1);
}
Beispiel #5
0
int dtls1_new (SSL * s)
{
    DTLS1_STATE *d1;

    if (!ssl3_new (s))
        return (0);
    if ((d1 = OPENSSL_malloc (sizeof *d1)) == NULL)
        return (0);
    memset (d1, 0, sizeof *d1);

    /* d1->handshake_epoch=0; */

    d1->unprocessed_rcds.q = pqueue_new ();
    d1->processed_rcds.q = pqueue_new ();
    d1->buffered_messages = pqueue_new ();
    d1->sent_messages = pqueue_new ();
    d1->buffered_app_data.q = pqueue_new ();

    if (s->server)
    {
        d1->cookie_len = sizeof (s->d1->cookie);
    }

    d1->link_mtu = 0;
    d1->mtu = 0;

    if (!d1->unprocessed_rcds.q || !d1->processed_rcds.q
        || !d1->buffered_messages || !d1->sent_messages || !d1->buffered_app_data.q)
    {
        if (d1->unprocessed_rcds.q)
            pqueue_free (d1->unprocessed_rcds.q);
        if (d1->processed_rcds.q)
            pqueue_free (d1->processed_rcds.q);
        if (d1->buffered_messages)
            pqueue_free (d1->buffered_messages);
        if (d1->sent_messages)
            pqueue_free (d1->sent_messages);
        if (d1->buffered_app_data.q)
            pqueue_free (d1->buffered_app_data.q);
        OPENSSL_free (d1);
        return (0);
    }

    s->d1 = d1;
    s->method->ssl_clear (s);
    return (1);
}
Beispiel #6
0
int
dtls1_new(SSL *s)
{
	DTLS1_STATE *d1;

	if (!ssl3_new(s))
		return (0);
	if ((d1 = calloc(1, sizeof *d1)) == NULL) {
		ssl3_free(s);
		return (0);
	}

	/* d1->handshake_epoch=0; */

	d1->unprocessed_rcds.q = pqueue_new();
	d1->processed_rcds.q = pqueue_new();
	d1->buffered_messages = pqueue_new();
	d1->sent_messages = pqueue_new();
	d1->buffered_app_data.q = pqueue_new();

	if (s->server) {
		d1->cookie_len = sizeof(s->d1->cookie);
	}

	if (!d1->unprocessed_rcds.q || !d1->processed_rcds.q ||
	    !d1->buffered_messages || !d1->sent_messages ||
	    !d1->buffered_app_data.q) {
		if (d1->unprocessed_rcds.q)
			pqueue_free(d1->unprocessed_rcds.q);
		if (d1->processed_rcds.q)
			pqueue_free(d1->processed_rcds.q);
		if (d1->buffered_messages)
			pqueue_free(d1->buffered_messages);
		if (d1->sent_messages)
			pqueue_free(d1->sent_messages);
		if (d1->buffered_app_data.q)
			pqueue_free(d1->buffered_app_data.q);
		free(d1);
		ssl3_free(s);
		return (0);
	}

	s->d1 = d1;
	s->method->ssl_clear(s);
	return (1);
}
Beispiel #7
0
int dtls1_new(SSL *s)
{
    DTLS1_STATE *d1;

    if (!DTLS_RECORD_LAYER_new(&s->rlayer)) {
        return 0;
    }

    if (!ssl3_new(s))
        return 0;
    if ((d1 = OPENSSL_zalloc(sizeof(*d1))) == NULL) {
        ssl3_free(s);
        return 0;
    }

    d1->buffered_messages = pqueue_new();
    d1->sent_messages = pqueue_new();

    if (s->server) {
        d1->cookie_len = sizeof(s->d1->cookie);
    }

    d1->link_mtu = 0;
    d1->mtu = 0;

    if (d1->buffered_messages == NULL || d1->sent_messages == NULL) {
        pqueue_free(d1->buffered_messages);
        pqueue_free(d1->sent_messages);
        OPENSSL_free(d1);
        ssl3_free(s);
        return 0;
    }

    s->d1 = d1;

    if (!s->method->ssl_clear(s))
        return 0;

    return 1;
}