some clients still send sslv2 client hello
| 521 | |
| 522 | // some clients still send sslv2 client hello |
| 523 | void ProcessOldClientHello(input_buffer& input, SSL& ssl) |
| 524 | { |
| 525 | if (input.get_error() || input.get_remaining() < 2) { |
| 526 | ssl.SetError(bad_input); |
| 527 | return; |
| 528 | } |
| 529 | byte b0 = input[AUTO]; |
| 530 | byte b1 = input[AUTO]; |
| 531 | |
| 532 | uint16 sz = ((b0 & 0x7f) << 8) | b1; |
| 533 | |
| 534 | if (sz > input.get_remaining()) { |
| 535 | ssl.SetError(bad_input); |
| 536 | return; |
| 537 | } |
| 538 | |
| 539 | // hashHandShake manually |
| 540 | const opaque* buffer = input.get_buffer() + input.get_current(); |
| 541 | ssl.useHashes().use_MD5().update(buffer, sz); |
| 542 | ssl.useHashes().use_SHA().update(buffer, sz); |
| 543 | |
| 544 | b1 = input[AUTO]; // does this value mean client_hello? |
| 545 | |
| 546 | ClientHello ch; |
| 547 | ch.client_version_.major_ = input[AUTO]; |
| 548 | ch.client_version_.minor_ = input[AUTO]; |
| 549 | |
| 550 | byte len[2]; |
| 551 | |
| 552 | len[0] = input[AUTO]; |
| 553 | len[1] = input[AUTO]; |
| 554 | ato16(len, ch.suite_len_); |
| 555 | |
| 556 | len[0] = input[AUTO]; |
| 557 | len[1] = input[AUTO]; |
| 558 | uint16 sessionLen; |
| 559 | ato16(len, sessionLen); |
| 560 | ch.id_len_ = sessionLen; |
| 561 | |
| 562 | len[0] = input[AUTO]; |
| 563 | len[1] = input[AUTO]; |
| 564 | uint16 randomLen; |
| 565 | ato16(len, randomLen); |
| 566 | |
| 567 | if (input.get_error() || ch.suite_len_ > MAX_SUITE_SZ || |
| 568 | ch.suite_len_ > input.get_remaining() || |
| 569 | sessionLen > ID_LEN || randomLen > RAN_LEN) { |
| 570 | ssl.SetError(bad_input); |
| 571 | return; |
| 572 | } |
| 573 | |
| 574 | int j = 0; |
| 575 | for (uint16 i = 0; i < ch.suite_len_; i += 3) { |
| 576 | byte first = input[AUTO]; |
| 577 | if (first) // sslv2 type |
| 578 | input.read(len, SUITE_LEN); // skip |
| 579 | else { |
| 580 | input.read(&ch.cipher_suites_[j], SUITE_LEN); |
no test coverage detected