pike.git / lib / modules / SSL.pmod / Connection.pike

version» Context lines:

pike.git/lib/modules/SSL.pmod/Connection.pike:1193:    SSL3_DEBUG_MSG("tried change_cipher: %d\n", err);    if (err)    return err;    }    break;    }    case PACKET_handshake:    {    SSL3_DEBUG_MSG("SSL.Connection: HANDSHAKE\n");    +  if (dtls) { +  // FIXME: Defragment and serialize packets. +  got_dtls_handshake_fragment(packet->fragment); +  string(8bit) new_fragment = get_dtls_handshake_data(); +  if (new_fragment) { +  packet->fragment = new_fragment; +  } else { +  packet = 0; +  } +  } +  +  while(packet) {    COND_FATAL(!sizeof(packet->fragment), ALERT_unexpected_message,    "Zero length Handshake fragments not allowed.\n");       // Don't allow renegotiation in unsecure mode, to address    // http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2009-3555.    // For details see: http://www.g-sec.lu/practicaltls.pdf and    // RFC 5746.    COND_FATAL(!(state & CONNECTION_handshaking) &&    !secure_renegotiation, ALERT_no_renegotiation,    "Renegotiation not supported in unsecure mode.\n");
pike.git/lib/modules/SSL.pmod/Connection.pike:1237:    int type = handshake_buffer->read_int8();    Buffer input = Buffer(handshake_buffer->read_hbuffer(3));    if(!input)    {    // Not enough data.    key->rewind();    break;    }       int len = 1+3+sizeof(input); +  if (dtls) len += 2 + 3 + 3; // Fragmentation info.    key->rewind();    Stdio.Buffer raw = handshake_buffer->read_buffer(len);    -  +  SSL3_DEBUG_MSG("Connection: %s(%O)...\n", +  fmt_constant(type, "HANDSHAKE"), +  input); +  +  if (dtls) { +  // Strip fragmentation info. +  input->read(2 + 3 + 3); +  } +     mixed exception = catch {    err = handle_handshake(type, input, raw);    COND_FATAL(err>=0 && sizeof(input), ALERT_record_overflow,    sprintf("Extraneous handshake packet data (%O).\n",    type));    };    if( exception )    {    if( objectp(exception) && ([object]exception)->buffer_error )    {
pike.git/lib/modules/SSL.pmod/Connection.pike:1269:    if ((version >= PROTOCOL_TLS_1_3) || expect_change_cipher) {    // NB: Renegotiation is available in TLS 1.2 and earlier.    COND_FATAL(sizeof(handshake_buffer), ALERT_unexpected_message,    "Extraneous handshake packets.\n");    }    COND_FATAL(sizeof(handshake_buffer) && !secure_renegotiation,    ALERT_no_renegotiation,    "Renegotiation not supported in unsecure mode.\n");    }    } +  +  if (dtls) { +  string(8bit) new_fragment = get_dtls_handshake_data(); +  if (new_fragment) { +  packet->fragment = new_fragment; +  } else { +  packet = 0; +  } +  } else {    break;    } -  +  } +  break; +  }    case PACKET_application_data:    SSL3_DEBUG_MSG("SSL.Connection: APPLICATION_DATA\n");       COND_FATAL(state & CONNECTION_handshaking,    ALERT_unexpected_message,    "Handshake not finished yet!\n");       res += packet->fragment;    break;    case PACKET_heartbeat:
pike.git/lib/modules/SSL.pmod/Connection.pike:1330:       // RFC 4346 6:    // If a TLS implementation receives a record type it does not    // understand, it SHOULD just ignore it.    SSL3_DEBUG_MSG("SSL.Connection: Ignoring packet of type %s\n",    fmt_constant(packet->content_type, "PACKET"));    break;    }    }    +  if (dtls) { +  // This should normally be a no-op, but better safe than sorry. +  read_buffer->clear(); +  } +     if (sizeof(res)) return res;    if (state & CONNECTION_peer_closed) return 1;    return "";   }